creating dynamic internal table to display alv

Solutions on MaxInterview for creating dynamic internal table to display alv by the best coders in the world

showing results for - "creating dynamic internal table to display alv"
Michela
06 May 2018
1REPORT ZSAN_RFCTEST.
2DATA : IT_FCAT TYPE LVC_T_FCAT.
3PARAMETERS: P_TABLE TYPE DD02L-TABNAME.
4DATA : WA_TABLE TYPE DD02L.
5
6AT SELECTION-SCREEN.
7  IF P_TABLE IS NOT INITIAL.
8    SELECT SINGLE * FROM DD02L INTO WA_TABLE WHERE TABNAME = P_TABLE AND TABCLASS = 'TRANSP'.
9  ELSE.
10    MESSAGE 'Please enter a table' TYPE 'E'.
11    STOP.
12  ENDIF.
13  IF WA_TABLE IS INITIAL.
14    MESSAGE 'Table Dosent exit or is not transparent table' TYPE 'E'.
15    STOP.
16  ENDIF.
17
18START-OF-SELECTION.
19  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
20    EXPORTING
21      I_STRUCTURE_NAME = P_TABLE
22    CHANGING
23      CT_FIELDCAT      = IT_FCAT.
24
25  DATA : FS_TAB TYPE REF TO DATA.
26  CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
27    EXPORTING
28*     I_STYLE_TABLE   =
29      IT_FIELDCATALOG = IT_FCAT
30*     I_LENGTH_IN_BYTE          =
31    IMPORTING
32      EP_TABLE        = FS_TAB.
33
34  FIELD-SYMBOLS: <FS_TAB> TYPE STANDARD TABLE.
35  ASSIGN FS_TAB->* TO <FS_TAB>.
36*data : it_tab type TABLE OF p_table.
37  SELECT * FROM (P_TABLE) INTO CORRESPONDING FIELDS OF TABLE <FS_TAB> UP TO 50 ROWS.
38  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
39    EXPORTING
40      I_STRUCTURE_NAME = P_TABLE
41    TABLES
42      T_OUTTAB         = <FS_TAB>.
43  IF SY-SUBRC <> 0.
44* Implement suitable error handling here
45  ENDIF.
46
similar questions