ABAP Tips for Dynamic ABAP programming
A very simple program to select data from database table dynamically.
FIELD-SYMBOLS: '
' TYPE STANDARD TABLE.
DATA: TABREF TYPE REF TO DATA.
*Selection Screen for Table Name entry
PARAMETERS: L_TABLE TYPE DD02L-TABNAME DEFAULT 'MARA'.
*Create data reference and assignment to field symbol.
CREATE DATA TABREF TYPE STANDARD TABLE OF (L_TABLE).
ASSIGN TABREF->* TO .
*Data Selection
SELECT * FROM (L_TABLE) INTO TABLE
'
'.
*Display Output Data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = L_TABLE
TABLES
T_OUTTAB =.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
A very simple program to select data from database table dynamically.
FIELD-SYMBOLS:
DATA: TABREF TYPE REF TO DATA.
*Selection Screen for Table Name entry
PARAMETERS: L_TABLE TYPE DD02L-TABNAME DEFAULT 'MARA'.
*Create data reference and assignment to field symbol.
CREATE DATA TABREF TYPE STANDARD TABLE OF (L_TABLE).
ASSIGN TABREF->* TO
*Data Selection
SELECT * FROM (L_TABLE) INTO TABLE
*Display Output Data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = L_TABLE
TABLES
T_OUTTAB =
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
No comments:
Post a Comment