Sample ALV Program using OOPS but not using Container

TYPE-POOLS: slis.

TABLES ydb_emp. ,"ydb_emp is custom table

DATA:
BEGIN OF tp_emp OCCURS 0,
empid LIKE ydb_emp-emdid
fname LIKE ydb_emp-efname,
lname LIKE ydb_emp-elname,
sal LIKE ydb_emp-esal,
END OF tp_emp.

DATA int_fcat TYPE slis_t_fieldcat_alv.

DATA i_repid LIKE sy-repid.

START-OF-SELECTION.

SELECT emdid efname elname esal FROM ydb_emp INTO TABLE tp_emp.
IF sy-subrc 0.
WRITE / 'No rows selected'.
ENDIF.
i_repid = sy-repid.

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'TP_EMP'
i_inclname = i_repid
CHANGING
ct_fieldcat = int_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

IF sy-subrc 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = i_repid
it_fieldcat = int_fcat

  • I_SAVE = 'A'
TABLES
t_outtab = tp_emp
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.

RELATED POST

ALV BLOCK LIST APPEND SAMPLE REPORT FOR SAP ABAP

SAP ABAP BAPI 1
SAP ABAP BAPI 2
SAP ABAP BAPI 3
SAP ABAP BAPI 4

No comments:

Post a Comment