ALV is very an useful tools in reporting. Just pass the data to ALV, than it will display interactive report easy to sort, filter, calculate total, etc.
There are two ALV model, list report (function REUSE_ALV_LIST_DISPLAY) and grid report (function REUSE_ALV_GRID_DISPLAY). Please read the function module documentation for complete guidance.
There are two main part of simple ALV report. 1. Create field catalog. Field catalog containing descriptions of the list output fields. 2. Pass data and field catalog to ALV function (function REUSE_ALV_LIST_DISPLAY or REUSE_ALV_GRID_DISPLAY).
You can also playing with ALV format, find it in "Change Format in ALV".
* Data output DATA: BEGIN OF t_report OCCURS 3, matnr LIKE mara-matnr, mtart LIKE mara-mtart, maktx LIKE makt-maktx, END OF t_report.
* Field desciption / field catalog TYPE-POOLS: SLIS. data t_fcat type SLIS_T_FIELDCAT_ALV.
*- DATA: d_repid LIKE sy-repid.
*----------------------------------------- *--Selection Screen SELECT-OPTIONS: s_matnr FOR mara-matnr, s_mtart FOR mara-mtart.
*----------------------------------------- START-OF-SELECTION. *-Read data SELECT * FROM mara WHERE matnr IN s_matnr AND mtart IN s_mtart. CLEAR makt. SELECT SINGLE * FROM makt WHERE matnr = mara-matnr AND spras = sy-langu. MOVE: mara-matnr TO t_report-matnr, mara-mtart TO t_report-mtart, makt-maktx TO t_report-maktx. APPEND t_report. ENDSELECT.
IF sy-subrc NE 0. WRITE 'No data found'. EXIT. ENDIF.
*----------------------------------------- *-Create Field Catalog
* Store report name d_repid = sy-repid.
* Create Fieldcatalogue from internal table * Use capital letter for I_INTERNAL_TABNAME CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = d_repid I_INTERNAL_TABNAME = 'T_REPORT' I_INCLNAME = d_repid CHANGING CT_FIELDCAT = t_fcat EXCEPTIONS INCONSISTENT_INTERFACE = 1 PROGRAM_ERROR = 2 OTHERS = 3.
IF SY-SUBRC <> 0. write: / 'Error:',sy-subrc, 'when Create Field Catalog'. EXIT. ENDIF.
Social Plugin