&---- *& Report ZDEMO_ALVGRID * *& * &---- *& * *& Example of a simple ALV Grid Report with grand total * *&... * *& * *& The basic requirement for this demo is to display a number of * *& fields from the EKKO table. * &---- REPORT zdemo_alvgrid. TABLES: ekko. Type-pools: slis. ![]() 'ALV Declarations *Data Declaration *---- TYPES: BEGIN OF t_ekko, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp, netpr TYPE ekpo-netpr, END OF t_ekko. DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko. ![]() An ALV report is created using the standard function modules provided by SAP. An ALV report can be created using the following steps. Include SLIS type pool – SLIS type pool contains all the data types required by ALV function modules. Data retrieval – Code the logic to fetch the data from database table into an Internal Table. CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'. *ALV data declarations data: fieldcatalog type slis_t_fieldcat_alv with header line, gd_repid like sy-repid, gd_layout type slis_layout_alv, it_sort TYPE slis_t_sortinfo_alv, t_sort TYPE slis_sortinfo_alv. ************************************************************************ *Start-of-selection. Perform data_retrieval. Perform build_fieldcatalog. PERFORM sort_fields. Perform display_alv_report. PERFORM TOP-OF-PAGE. &---- *& Form BUILD_FIELDCATALOG &---- • Build Fieldcatalog for ALV Report ---- form build_fieldcatalog. Fieldcatalog-fieldname = 'EBELN'. Fieldcatalog-seltext_m = 'Purchase Order'. Fieldcatalog-col_pos = 0. Fieldcatalog-outputlen = 10. Fieldcatalog-emphasize = 'X'. Fieldcatalog-key = 'X'. • fieldcatalog-do_sum = 'X'. • fieldcatalog-no_zero = 'X'. Append fieldcatalog to fieldcatalog. Clear fieldcatalog. Fieldcatalog-fieldname = 'EBELP'. Fieldcatalog-seltext_m = 'PO Item'. Fieldcatalog-col_pos = 1. Append fieldcatalog to fieldcatalog. Clear fieldcatalog. Fieldcatalog-fieldname = 'NETPR'. Fieldcatalog-seltext_m = 'Net Price'. Fieldcatalog-col_pos = 7. Fieldcatalog-outputlen = 15. Fieldcatalog-do_sum = 'X'. 'Display column total fieldcatalog-datatype = 'CURR'. Append fieldcatalog to fieldcatalog. Clear fieldcatalog. ' BUILD_FIELDCATALOG &---- *& Form DISPLAY_ALV_REPORT &---- • Display report using ALV grid ---- form display_alv_report. Gd_repid = sy-repid. Call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = gd_repid i_callback_top_of_page = 'TOP-OF-PAGE' 'see FORM is_layout = gd_layout it_fieldcat = fieldcatalog[] it_sort = it_sort[] i_save = 'X' tables t_outtab = it_ekko 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. ' DISPLAY_ALV_REPORT &---- *& Form DATA_RETRIEVAL &---- • Retrieve data form EKPO table and populate itab it_ekko ---- form data_retrieval. Select ebeln ebelp netpr up to 10 rows from ekpo into table it_ekko. Revit 2019 download. ' DATA_RETRIEVAL &---- *& Form TOP-OF-PAGE &---- • text ---- • --> p1 text • p1 text •. Field Catalog Field catalog is an internal table which is used to pass a list of fields to display in ALV report, we can set different properties to fields which are going to display in ALV. Type Group It is a data dictionary object which contains all the reusable user-defined types.Example for a type group is SLIS, which contains all the user-defined types for developing ALV reports. TYPE-POOLS is a keyword which is used to assign the type-group to a ALV report. Syntax: TYPE-POOLS SLIS. 'TO USE FIELD CATALOG WE HAVE TO INCLUDE SLIS TYPE-POOLS DATA: TYPE SLIS_T_FIELDCAT_ALV. 'INTERNAL TABLE FOR FIELD CATALOG DATA: TYPE SLIS_FIELDCAT_ALV. ' WORK AREA FOR FIELD CATLOG Options/properties of field catalog. WA_FCAT-COL_POS = '1'. 'Specify position of a field WA_FCAT-FIELDNAME = 'MATNR'. 'Specify field name WA_FCAT-TABNAME = 'IT_MARA'. 'Specify internal table name WA_FCAT-SELTEXT_M = 'MATERIALNO'. 'Specify text to display column header WA_FCAT-KEY = 'X'. 'Specify if it is a key field APPEND WA_FCAT TO IT_FCAT. 'Append to field catalog internal table Useful resource and also Requirement: Develop an ALV report to display Material no (MATNR), Material type (MTART), Industry Sector (MBRSH) and Basic Unit Of measure (MEINS) for a range of material input (Select-Options). To develop above report, we have to use field catalog (because we have to display four fields only from MARA) and we have to pass field catalog parameter to Function Module REUSE_ALV_GIRD_DISPLAY. REPORT ZSAPN_ALV_FCAT.
0 Comments
Leave a Reply. |