Today I do it for free. send me an email for the rest of the code
FUNCTION ztest_j_fm.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(Z_FIRST) TYPE CHAR255
*" REFERENCE(Z_SECOND) TYPE CHAR255
*" REFERENCE(Z_THIRD) TYPE CHAR255
*"----------------------------------------------------------------------
TYPES: BEGIN OF lty_sflight,
carrid TYPE sflight-carrid,
END OF lty_sflight,
BEGIN OF lty_count,
carrid TYPE sflight-carrid,
count(10) TYPE n,
END OF lty_count.
DATA: lv_count TYPE i.
DATA: lwa_count TYPE lty_count,
lwa_sflight type lty_sflight,
lt_count TYPE STANDARD TABLE OF lty_count,
lt_sflight type STANDARD TABLE OF lty_sflight.
CLEAR: lv_count, lt_count[], lt_sflight[].
SELECT carrid "column to be selected
FROM sflight "table to be selected from
INTO table lt_sflight.
IF sy-subrc = 0.
SORT lt_sflight ASCENDING BY carrid.
LOOP AT lt_sflight INTO lwa_sflight.
lv_count = lv_count + 1. " number of entries for that specific field
AT END OF carrid.
lwa_count-count = lv_count.
lwa_count-carrid = lwa_sflight-carrid.
APPEND lwa_count TO lt_count.
CLEAR: lv_count,lwa_count.
ENDAT.
ENDLOOP.
ENDIF.
IF lt_count IS NOT INITIAL.
SORT lt_count DESCENDING BY count.
LOOP AT lt_count INTO lwa_count TO