SAP Tutorials Blog

 

 


 


REPORT  ysap_alv_hierseq_list.


TYPE-POOLS: slis, icon.


*table details

TYPES : BEGIN OF tdet,

        icon TYPE icon_d,

        tabname TYPE tabname,

        tabclass TYPE tabclass,

        contflag TYPE contflag,

        actflag TYPE actflag,

        mainflag TYPE maintflag,

        buffered TYPE buffered,

        as4user TYPE as4user,

        as4date TYPE as4date,

        as4time TYPE as4time,

        expand,

        END OF tdet.


DATA : t_tdet TYPE STANDARD TABLE OF tdet,

            w_tdet TYPE tdet.


*field details


TYPES : BEGIN OF fdet,

        tabname TYPE tabname,

        fieldname TYPE fieldname,

        keyflag TYPE keyflag,

        mandatory TYPE mandatory,

        checktable TYPE checktable,

        rollname TYPE rollname,

        END OF fdet.


DATA: t_fdet TYPE STANDARD TABLE OF fdet,

           w_fdet TYPE fdet.


DATA : it_fcat TYPE slis_t_fieldcat_alv,

            wa_fcat TYPE slis_fieldcat_alv,

            it_layout TYPE slis_layout_alv,

            key TYPE slis_keyinfo_alv.



SELECT-OPTIONS : table FOR w_tdet-tabname NO INTERVALS.


START-OF-SELECTION.



  SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE t_tdet WHERE tabname IN table.


  IF t_tdet[] IS NOT INITIAL.

    SELECT * FROM dd03l INTO CORRESPONDING FIELDS OF TABLE t_fdet FOR ALL ENTRIES IN t_tdet

          WHERE tabname EQ t_tdet-tabname.

  ENDIF.


  LOOP AT t_tdet INTO w_tdet.

    AT NEW tabname.

      w_tdet-icon = '@3M@'.


      MODIFY t_tdet FROM w_tdet TRANSPORTING icon WHERE tabname EQ w_tdet-tabname.

      CLEAR :  w_tdet.


    ENDAT.

  ENDLOOP.


  CLEAR wa_fcat.


  wa_fcat-col_pos = 1.

  wa_fcat-fieldname = 'TABNAME'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'Tablename'.

  wa_fcat-key = 'X'.

  wa_fcat-emphasize = 'C610'.

  APPEND wa_fcat TO it_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 2.

  wa_fcat-fieldname = 'TABCLASS'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'Tablecategory'.

  wa_fcat-emphasize = 'C600'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.



  CLEAR wa_fcat.

  wa_fcat-col_pos = 3.

  wa_fcat-fieldname = 'CONTFLAG'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'DeliveryClass'.

  wa_fcat-emphasize = 'C510'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 4.

  wa_fcat-fieldname = 'ACTFLAG'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'Activationstatus'.

  wa_fcat-emphasize = 'C500'.


  APPEND wa_fcat TO it_fcat.


  CLEAR wa_fcat.


  wa_fcat-col_pos = 5.

  wa_fcat-fieldname = 'MAINFLAG'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'MaintainenceFlag'.

  wa_fcat-emphasize = 'C410'.


  APPEND wa_fcat TO it_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 6.

  wa_fcat-fieldname = 'BUFFERED'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'BufferFlag'.

  wa_fcat-emphasize = 'C400'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 7.

  wa_fcat-fieldname = 'AS4USER'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'User'.

  wa_fcat-emphasize = 'C310'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 8.

  wa_fcat-fieldname = 'AS4DATE'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'Date'.

  wa_fcat-emphasize = 'C300'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.


  CLEAR wa_fcat.

  wa_fcat-col_pos = 9.

  wa_fcat-fieldname = 'AS4TIME'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'Time'.

  wa_fcat-emphasize = 'C210'.


  APPEND wa_fcat TO it_fcat.

  CLEAR wa_fcat.


  CLEAR wa_fcat.


  wa_fcat-col_pos = 10.

  wa_fcat-fieldname = 'ICON'.

  wa_fcat-tabname = 'T_TDET'.

  wa_fcat-seltext_m = 'ICON'.

  wa_fcat-icon = 'X'.

  APPEND wa_fcat TO it_fcat.


  CLEAR wa_fcat.


  wa_fcat-col_pos = 11.

  wa_fcat-fieldname = 'FIELDNAME'.

  wa_fcat-tabname = 'T_FDET'.

  wa_fcat-key = 'X'.

  wa_fcat-seltext_m = 'Field'.

  wa_fcat-emphasize = 'C600'.


  APPEND wa_fcat TO it_fcat.



  CLEAR wa_fcat.


  wa_fcat-col_pos = 12.

  wa_fcat-fieldname = 'KEYFLAG'.

  wa_fcat-tabname = 'T_FDET'.

  wa_fcat-seltext_m = 'Key'.

  wa_fcat-emphasize = 'C500'.


  APPEND wa_fcat TO it_fcat.




  CLEAR wa_fcat.


  wa_fcat-col_pos = 13.

  wa_fcat-fieldname = 'CHECKTABLE'.

  wa_fcat-tabname = 'T_FDET'.

  wa_fcat-seltext_m = 'Checktable'.

  wa_fcat-emphasize = 'C400'.


  APPEND wa_fcat TO it_fcat.



  CLEAR wa_fcat.


  wa_fcat-col_pos = 14.

  wa_fcat-fieldname = 'MANDATORY'.

  wa_fcat-tabname = 'T_FDET'.

  wa_fcat-seltext_m = 'Mandatory'.

  wa_fcat-emphasize = 'C300'.


  APPEND wa_fcat TO it_fcat.


  CLEAR wa_fcat.


  wa_fcat-col_pos = 15.

  wa_fcat-fieldname = 'ROLLNAME'.

  wa_fcat-tabname = 'T_FDET'.

  wa_fcat-seltext_m = 'Dataelement'.

  wa_fcat-emphasize = 'C200'.


  APPEND wa_fcat TO it_fcat.


  it_layout-expand_fieldname = 'EXPAND'.


  it_layout-window_titlebar = 'Hierarchical ALV list display'.

  it_layout-lights_tabname = 'T_FDET'.

  it_layout-colwidth_optimize = 'X'.



  key-header01 = 'TABNAME'.

  key-item01 = 'TABNAME'.


  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

*     I_INTERFACE_CHECK                             = ' '

       I_CALLBACK_PROGRAM                       = sy-repid

*     I_CALLBACK_PF_STATUS_SET              = ' '

*     I_CALLBACK_USER_COMMAND\         = ' '

     IS_LAYOUT                                                   = it_layout

     IT_FIELDCAT                                                = it_fcat

*     IT_EXCLUDING                                         =

*     IT_SPECIAL_GROUPS                              =

*     IT_SORT                                                      =

*     IT_FILTER                                                    =

*     IS_SEL_HIDE                                               =

*     I_SCREEN_START_COLUMN                   = 0

*     I_SCREEN_START_LINE                           = 0

*     I_SCREEN_END_COLUMN                     = 0

*     I_SCREEN_END_LINE                             = 0

*     I_DEFAULT                                                = 'X'

*     I_SAVE                                                        = ' '

*     IS_VARIANT                                              =

*     IT_EVENTS                                                =

*     IT_EVENT_EXIT                                        =

      i_tabname_header                                          = 'T_TDET'

      i_tabname_item                                              = 'T_FDET'

*     I_STRUCTURE_NAME_HEADER             =

*     I_STRUCTURE_NAME_ITEM                   =

      is_keyinfo                                                       = key

*     IS_PRINT                                                    =

*     IS_REPREP_ID                                           =

*     I_BYPASSING_BUFFER                           =

*     I_BUFFER_ACTIVE                                  =

*     IR_SALV_HIERSEQ_ADAPTER               =

*     IT_EXCEPT_QINFO                                  =

*     I_SUPPRESS_EMPTY_DATA                    = ABAP_FALSE

*   IMPORTING

*     E_EXIT_CAUSED_BY_CALLER               =

*     ES_EXIT_CAUSED_BY_USER                  =

    tables

      t_outtab_header                                              = t_tdet

      t_outtab_item                                                  = t_fdet

*   EXCEPTIONS

*     PROGRAM_ERROR                                    = 1

*     OTHERS                                                       = 2

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.



Serkan AKKAVAK
Computer Engineer BSc
SAP Department Manager
Contact : serkurumsal@yandex.com