How to display a hierarchical sequential list ALV in SAP ABAP.
expand,
carrid TYPE s_carr_id,
carrname TYPE s_carrname,
END OF ty_swa.
carrid TYPE s_carr_id,
carrname TYPE s_carrname,
END OF ty_swa.
TYPES:
BEGIN OF ty_swad,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
countryfr TYPE land1,
countryto TYPE land1,
END OF ty_swad.
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
countryfr TYPE land1,
countryto TYPE land1,
END OF ty_swad.
DATA:
lt_swa TYPE TABLE OF ty_swa.
DATA: lt_swad TYPE TABLE OF ty_swad.
DATA: ls_layt TYPE slis_layout_alv.
DATA: lt_fcat TYPE slis_t_fieldcat_alv.
DATA: ls_fcat TYPE LINE OF slis_t_fieldcat_alv.
DATA: ls_key TYPE slis_keyinfo_alv.
DATA: lt_swad TYPE TABLE OF ty_swad.
DATA: ls_layt TYPE slis_layout_alv.
DATA: lt_fcat TYPE slis_t_fieldcat_alv.
DATA: ls_fcat TYPE LINE OF slis_t_fieldcat_alv.
DATA: ls_key TYPE slis_keyinfo_alv.
START-OF-SELECTION.
SELECT carrid carrname
FROM
scarr
INTO
CORRESPONDING FIELDS OF TABLE lt_swa.
CHECK lt_swa[] IS NOT INITIAL.
SELECT carrid connidcountryfr countryto FROM spfli
INTO CORRESPONDING
FIELDS OF TABLE lt_swad
FOR ALL ENTRIES IN lt_swa
FOR ALL ENTRIES IN lt_swa
WHERE carrid = lt_swa-carrid.
”Layout
ls_layt-expand_fieldname = ‘EXPAND’.
ls_layt-colwidth_optimize = ‘X’.
”Keyinfo
ls_key-header01 = ‘CARRID’.
ls_key-item01 = ‘CARRID’.
“Build Fieldcat
ls_fcat-col_pos = ‘1’.
ls_fcat-fieldname = ‘CARRID’.
ls_fcat-tabname = ‘LT_SWA’.
ls_fcat-key = ‘X’.
ls_fcat-seltext_m = ‘Flight ID’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_key-header01 = ‘CARRID’.
ls_key-item01 = ‘CARRID’.
“Build Fieldcat
ls_fcat-col_pos = ‘1’.
ls_fcat-fieldname = ‘CARRID’.
ls_fcat-tabname = ‘LT_SWA’.
ls_fcat-key = ‘X’.
ls_fcat-seltext_m = ‘Flight ID’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-col_pos
= ‘2’.
ls_fcat-fieldname = ‘CARRNAME’.
ls_fcat-tabname = ‘LT_SWA’.
ls_fcat-seltext_m = ‘Flight Conn’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = ‘CARRNAME’.
ls_fcat-tabname = ‘LT_SWA’.
ls_fcat-seltext_m = ‘Flight Conn’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-col_pos
= ‘3’.
ls_fcat-fieldname = ‘CONNID’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘Conn Number’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = ‘CONNID’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘Conn Number’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-col_pos
= ‘4’.
ls_fcat-fieldname = ‘COUNTRYFR’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘From Country’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = ‘COUNTRYFR’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘From Country’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-col_pos
= ‘5’.
ls_fcat-fieldname = ‘COUNTRYTO’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘To Country’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = ‘COUNTRYTO’.
ls_fcat-tabname = ‘LT_SWAD’.
ls_fcat-seltext_m = ‘To Country’.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
CALL
FUNCTION ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
EXPORTING
i_callback_program = sy-repid
is_layout = ls_layt
it_fieldcat = lt_fcat
i_tabname_header = ‘LT_SWA’
i_tabname_item = ‘LT_SWAD’
is_keyinfo = ls_key
TABLES
t_outtab_header = lt_SWA
t_outtab_item = lt_SWAD
EXCEPTIONS
program_error = 1
OTHERS = 2.
EXPORTING
i_callback_program = sy-repid
is_layout = ls_layt
it_fieldcat = lt_fcat
i_tabname_header = ‘LT_SWA’
i_tabname_item = ‘LT_SWAD’
is_keyinfo = ls_key
TABLES
t_outtab_header = lt_SWA
t_outtab_item = lt_SWAD
EXCEPTIONS
program_error = 1
OTHERS = 2.
No comments:
Post a Comment