SAP List Viewer (ALV) is another way to create reports in ABAP. This chapter explains how to develop reports using both procedural and object-oriented ALV libraries.
15 ALV Reports
Reports are a common development in ABAP. A typical report extracts data from the database and processes it per a user’s requirements. The processed data is then presented to the user as a report output. Such report output typically shows data in rows and columns and also provides some basic functionality, such as sorting the output, filtering the data, summarizing the values, and so on.
As discussed in Chapter 13, developing a classical report requires a developer to spend too much time making the report output presentable and provides only basic functions, such as sorting or filtering data.
To this end, SAP provides the SAP List Viewer (ALV) library, which automatically manages report output and provides additional functionalities without developers having to sweat. All the developer needs to do is supply the output data to the library. The ALV library is available for both procedural and object-oriented programming techniques. The object-oriented ALV library is available in two variants: the CL_GUI_ALV_GRID ABAP class and the ALV object model, the latter of which is an object-oriented encapsulation of the existing ALV tool.
In this chapter, we’ll discuss how to work with the ALV library using function modules, the CL_GUI_ALV_GRID ABAP class, and the ALV object model. In Section 15.1, we begin by discussing the standard ALV reports in the reuse library. We’ll look at the four primary report displays: list, grid, block, and hierarchical.
From there, in Section 15.2, we provide an overview of the interactive features that can be used in ALV reports. Section 15.3 teaches how to use the Control Framework to create a custom ALV grid control. Finally, in Section 15.4, we offer details on using the different displays of the ALV object model, including the table, hierarchical, and tree object displays.
15.1 Standard ALV Reports Using the Reuse Library
SAP provides various function modules in the reuse library that can be used to display report output. These function modules take care of formatting the output and automatically provide various additional functionalities, such as sorting, filtering, and so on. All the function module names in the reuse library start with REUSE_ALV*. The function modules in the reuse library require you to pass certain components to prepare the output; the basic components that you need to pass to the ALV function module include the following:
-
Output table
Prepare an internal table with the output data that should be displayed as an ALV output and pass it to the ALV function module. The ALV function module reads this output table to display it as an ALV output. -
Field catalog
Prepare another internal table to define specifications for how the output data supplied to the ALV function module should be displayed. These specifications about the output data are called the field catalog. The field catalog consists of different specifications for the output fields, such as column name, length, data format, and so on. An ABAP Data Dictionary structure can also be passed to ALV instead of an internal table to describe the structure of the output data.
With the reuse library, you can create simple reports, block reports, and hierarchical reports.
The following are the different types of report output that can be displayed using the function modules from the reuse library:
-
List display
The REUSE_ALV_LIST_DISPLAY function module is used to display a simple report as list output. The list display looks similar to the output generated using a WRITE statement. You’ll learn how to use a list display in Section 15.1.1. -
Grid display
The REUSE_ALV_GRID_DISPLAY function module is used to display a simple report as a two-dimensional grid output. The grid output is displayed using the control technology for the screen display and is part of the ALV grid control. Controls are software components that are installed on a local PC. You’ll learn more about the Control Framework in Section 15.3. -
Block display
List and grid displays allow you to show data from one internal table in the output, but a block display allows you to show data from multiple internal tables in the output. With a block display, you can show multiple report outputs on a single screen. The function modules used for block displays are REUSE_ALV_BLOCK_LIST_INIT, REUSE_ALV_BLOCK_LIST_APPEND, and REUSE_ALV_BLOCK_LIST_DISPLAY. You’ll learn about block displays in Section 15.1.2. -
Hierarchical display
This display is useful when you want to show header and line items in the output, such as a sales order header and its item details. The REUSE_ALV_HIERSEQ_LIST_DISPLAY function module is used for this purpose, which allows you to pass the header and item tables. The header and item tables should have a common key. You’ll learn how to create a hierarchical display in Section 15.1.3.
In the following subsections, we’ll discuss each of these report outputs in detail.
15.1.1 List and Grid Display: Simple Reports
A simple report shows data from a single internal table as a report output; data from various database tables can be consolidated into a single internal table and passed to the ALV function module as report output. The reuse library provides two function modules—REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY—that can be used to show a simple report either as a list or as a grid, respectively.
The parameter interfaces of these two function modules are similar. The function module help documentation in Function Builder (Transaction SE37) for each function module contains detailed information about each parameter.
Listing 15.1 shows sample code using a list display; it generates the output shown in Figure 15.1.
REPORT ZDEMO_SIMPLE_REPORT.
DATA it_sflight TYPE STANDARD TABLE OF sflight.
PARAMETERS p_carrid TYPE s_carr_id.
SELECT * FROM sflight INTO TABLE it_sflight WHERE carrid EQ p_carrid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
t_outtab = it_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
In Listing 15.1, we’re selecting the data from table SFLIGHT for a given airline code and displaying it as report output using the list display ALV. We pass the structure name from ABAP Data Dictionary to the I_STRUCTURE_NAME formal parameter of the REUSE_ALV_LIST_DISPLAY function module, which uses this structure name to create the output layout.
The data that should be displayed in the output is selected into the internal table IT_SFLIGHT and passed to the T_OUTTAB formal parameter. The ALV function module takes care of printing all the data in internal table IT_SFLIGHT without us having to spend any additional effort on formatting the output.
The function module also loads a default SAP GUI status, which provides many buttons in the application toolbar for additional functionality, such as sorting the output, printing the output, exporting the report output, and so on, as shown in Figure 15.1.
Table 15.1 lists some of the significant parameters of the ALV function module, not all of which are used in the example. Please refer to the function module documentation in Function Builder for each ALV function module for a more exhaustive explanation.
The grid display ALV is similar to the list display ALV for all practical purposes, but the grid display is part of the Control Framework. The Control Framework uses JavaBeans or ActiveX controls in the presentation layer and provides certain additional features, such as grid title, TOP-OF-PAGE, removing vertical and horizontal lines, making the ALV editable, and so on.
JavaBeans and ActiveX are competing technologies that facilitate communication among components within a framework container (such as SAP GUI or a web browser). The grid display can also be used within the Control Framework, allowing multiple grid displays to be shown on a single screen, which isn’t possible with a list display.
Listing 15.2 shows the grid display ALV being called, which is similar to calling the list display ALV. Here, we’re also passing the optional grid title, which is displayed in the report output, as shown in Figure 15.2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
I_GRID_TITLE = text-001
TABLES
t_outtab = it_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
The ALV function module has many parameters (see Table 15.1) that can be passed to control the report output. At a bare minimum, the ALV function module requires you to supply the output layout information, such as the column positions, column names, and so on, and the actual data that should be displayed in the output.
If you wish to display all the fields of an ABAP Data Dictionary table or structure, then the table/structure name can be passed to the I_STRUCTURE_NAME formal parameter of the ALV function module.
In Listing 15.1 and Listing 15.2, we passed SFLIGHT as the structure name to the I_STRUCTURE_NAME formal parameter, because we wanted to print all the fields of table SFLIGHT in the output. However, you may often be printing only certain fields of a table or fields from different tables in the output. In such scenarios, you can create a field catalog and pass it to the function module using the IT_FIELDCAT formal parameter.
You can also create a structure in ABAP Data Dictionary consisting of the output fields and pass it to the I_STRUCTURE_NAME formal parameter. Using a structure name as opposed to defining a field catalog in the program helps you to maintain the output fields centrally if multiple reports are using a similar layout.
Using the field catalog has the advantage that additional attributes can be supplied for each field. The field catalog should be an internal table in which information about each output field is maintained. This internal table should be of type SLIS_T_FIELDCAT_ALV, which belongs to the type group SLIS. The function module documentation provides information about each of the components of the SLIS_T_FIELDCAT_ALV structure and the valid values that can be passed.
Figure 15.3 shows some of the components of the field catalog structure. At a minimum, you should fill the COL_POS, TABNAME, FIELDNAME, and SELTEXT (long, medium, or short) components.
Listing 15.3 shows the code for a simple report using a field catalog.
REPORT ZDEMO_SIMPLE_REPORT.
TYPES: BEGIN OF ty_sflight,
CARRID TYPE S_CARR_ID,
CONNID TYPE S_CONN_ID,
FLDATE TYPE S_DATE,
PRICE TYPE S_PRICE,
CURRENCY TYPE S_CURRCODE,
END OF ty_sflight.
DATA : it_sflight TYPE STANDARD TABLE OF ty_sflight,
it_fieldcat TYPE SLIS_T_FIELDCAT_ALV.
PARAMETERS p_carrid TYPE s_carr_id.
START-OF-SELECTION.
PERFORM get_data USING p_carrid CHANGING it_sflight.
END-OF-SELECTION.
PERFORM field_catalog CHANGING it_fieldcat.
PERFORM show_output.
*&--------------------------------------------------------------*
*& Form GET_DATA
*&--------------------------------------------------------------*
FORM get_data USING p_p_carrid CHANGING pt_sflight LIKE it_sflight.
SELECT carrid connid fldate price currency FROM sflight INTO TABLE
pt_sflight WHERE carrid EQ p_p_carrid.
ENDFORM.
*&--------------------------------------------------------------*
*& Form FIELD_CATALOG
*&--------------------------------------------------------------*
FORM field_catalog CHANGING pt_fieldcat LIKE it_fieldcat.
DATA lw_fieldcat LIKE LINE OF pt_fieldcat.
lw_fieldcat-col_pos = 1.
lw_fieldcat-fieldname = 'CARRID'.
lw_fieldcat-tabname = 'IT_SFLIGHT'.
lw_fieldcat-seltext_m = 'Airline Code'.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-col_pos = 2.
lw_fieldcat-fieldname = 'CONNID'.
lw_fieldcat-tabname = 'IT_SFLIGHT'.
lw_fieldcat-seltext_l = 'Flight Connection Number'.
lw_fieldcat-outputlen = 25.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-col_pos = 3.
lw_fieldcat-fieldname = 'FLDATE'.
lw_fieldcat-tabname = 'IT_SFLIGHT'.
lw_fieldcat-seltext_m = 'Flight Date'.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-col_pos = 4.
lw_fieldcat-fieldname = 'PRICE'.
lw_fieldcat-tabname = 'IT_SFLIGHT'.
lw_fieldcat-seltext_m = 'Airfare'.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
lw_fieldcat-col_pos = 5.
lw_fieldcat-fieldname = 'CURRENCY'.
lw_fieldcat-tabname = 'IT_SFLIGHT'.
lw_fieldcat-seltext_m = 'Airline Currency'.
APPEND lw_fieldcat TO pt_fieldcat.
CLEAR lw_fieldcat.
ENDFORM.
*&--------------------------------------------------------------*
*& Form SHOW_OUTPUT
*&--------------------------------------------------------------*
FORM show_output.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = 'ALV Grid Display'
IT_FIELDCAT = it_fieldcat
TABLES
t_outtab = it_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
In Listing 15.3, we are printing certain fields from table SFLIGHT (see Figure 15.4), as defined in the TY_SFLIGHT structure. We defined a field catalog internal table IT_FIELDCAT of type SLIS_T_FIELDCAT_ALV.SLIS_T_FIELDCAT_ALV as a table type, which belongs to the type group SLIS and has a line type of SLIS_FIELDCAT_ALV. The SLIS_FIELDCAT_ALV structure has various field catalog components.
In our program, we’re passing various information about the output fields by filling the components of structure SLIS_FIELDCAT_ALV. For example, we’re passing the name of the internal table that holds the output data to the TABNAME component, the field name to the FIELDNAME component, the column position to the COL_POS component, and the column name to the relevant SELTEXT component.
In Listing 15.3, the field catalog is filled inside the FIELD_CATALOG subroutine. The function module documentation should help you explore other components of the field catalog that can be used for formatting the output.
We can also use the REUSE_ALV_FIELDCATALOG_MERGE function module to fill the field catalog internal table.
The layout can be handled by passing a structure of type SLIS_LAYOUT_ALV to the IS_LAYOUT formal parameter. Using the IS_LAYOUT parameter, we can control the output layout, such as making the fields editable, using a stripped pattern for cells, removing horizontal or vertical lines, and so on. The function module documentation explains the significance of each component of the SLIS_LAYOUT_ALV structure.
Listing 15.4 shows how the IS_LAYOUT parameter can be used to make the cells editable, as shown in Figure 15.5.
Note
The cells can be made editable only in a grid display; this feature is not supported in a list display.
FORM show_output.
DATA layout TYPE SLIS_LAYOUT_ALV.
layout-edit = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = 'ALV Grid Display'
IS_LAYOUT = layout
IT_FIELDCAT = it_fieldcat
TABLES
t_outtab = it_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
15.1.2 Block Display
Using a block display, we can print data from multiple internal tables in the output, with each internal table’s data printed in a block. For a block display, we use three function modules:
-
REUSE_ALV_BLOCK_LIST_INIT
This function module is used to initialize the block list and set the SAP GUI status. -
REUSE_ALV_BLOCK_LIST_APPEND
This function module is used to append the simple list in block mode; it’s called each time the data from an internal table need to be appended to the output. -
REUSE_ALV_BLOCK_LIST_APPEND
This function module is used to display the block list. All the parameters of this function module are optional.
Listing 15.5 shows the sample code to work with a block display.
REPORT ZDEMO_BLOCK_REPORT.
DATA : it_sflight TYPE STANDARD TABLE OF sflight,
it_spfli TYPE STANDARD TABLE OF spfli,
it_fcat_sflight TYPE SLIS_T_FIELDCAT_ALV,
it_fcat_spfli TYPE slis_t_fieldcat_alv,
it_events TYPE SLIS_T_EVENT.
PARAMETERS p_carrid TYPE s_carr_id.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM field_catalog.
PERFORM show_output.
*&--------------------------------------------------------------*
*& Form GET_DATA
*&--------------------------------------------------------------*
FORM get_data .
SELECT * FROM sflight INTO TABLE it_sflight WHERE carrid EQ p_carrid.
SELECT * FROM spfli INTO TABLE it_spfli WHERE carrid EQ p_carrid.
ENDFORM.
*&--------------------------------------------------------------*
*& Form FIELD_CATALOG
*&--------------------------------------------------------------*
FORM field_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SPFLI'
CHANGING
ct_fieldcat = it_fcat_spfli
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
ct_fieldcat = it_fcat_sflight
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
*&--------------------------------------------------------------*
*& Form SHOW_OUTPUT
*&--------------------------------------------------------------*
FORM show_output .
DATA layout TYPE SLIS_LAYOUT_ALV.
layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = 'ZDEMO_BLOCK_REPORT'
.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = layout
it_fieldcat = it_fcat_spfli
i_tabname = 'IT_SPFLI'
it_events = it_events
TABLES
t_outtab = it_spfli
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = layout
it_fieldcat = it_fcat_sflight
i_tabname = 'IT_SFLIGHT'
it_events = it_events
TABLES
t_outtab = it_sflight
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
In Listing 15.5, we’re selecting data from tables SFLIGHT and SPFLI and displaying that data as blocks in the output, as shown in Figure 15.6.
15.1.3 Hierarchical Sequential Display
A hierarchical sequential display is used when displaying related data, such as the header and item data of a document. We use the REUSE_ALV_HIERSEQ_LIST_DISPLAY function module to generate the hierarchical sequential display. This function module requires you to pass the header and item tables along with the key information of the tables.
The key information is used to identify the related records in the header and item tables. A field catalog is prepared with all the fields of the header and item tables and is passed to the function module.
Listing 15.6 shows the sequential report for a billing document, with certain data about the header and item details of the billing document printed in the output (see Figure 15.7).
REPORT ZDEMO_HIERARCHICAL_REPORT.
TYPES : BEGIN OF ty_vbrk,
vbeln TYPE vbeln_vf, "Document Number
kunrg TYPE kunrg, "Payer
fkdat TYPE fkdat, "Billing date
netwr TYPE netwr, "Net Value
END OF ty_vbrk.
TYPES : BEGIN OF ty_vbrp,
vbeln TYPE vbeln_vf, " Document Number
posnr TYPE posnr_vf, "Billing item
arktx TYPE arktx, "Description of Item
fkimg TYPE fkimg, "Billed quantity
vrkme TYPE vrkme, "Sales Unit
netwr TYPE netwr_fp, "Net Value
matnr TYPE matnr, "Material Number
END OF ty_vbrp.
DATA : it_vbrk TYPE STANDARD TABLE OF ty_vbrk,
it_vbrp TYPE STANDARD TABLE OF ty_vbrp,
it_fieldcat TYPE SLIS_T_FIELDCAT_ALV,
wa_fieldcat TYPE SLIS_FIELDCAT_ALV,
v_vbeln TYPE vbeln_vf.
SELECT-OPTIONS s_vbeln FOR v_vbeln.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM field_catalog.
PERFORM show_output.
*&--------------------------------------------------------------*
*& Form GET_DATA
*&--------------------------------------------------------------*
FORM get_data .
SELECT vbeln kunrg fkdat netwr FROM vbrk INTO TABLE it_vbrk WHERE vbeln IN s_vbeln.
SELECT vbeln posnr arktx fkimg vrkme netwr matnr FROM vbrp INTO TABLE
it_vbrp WHERE vbeln IN s_vbeln.
ENDFORM.
*&--------------------------------------------------------------*
*& Form FIELD_CATALOG
*&--------------------------------------------------------------*
FORM field_catalog .
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-tabname = 'IT_VBRK'.
wa_fieldcat-seltext_m = 'Document No.'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'KUNRG'.
wa_fieldcat-tabname = 'IT_VBRK'.
wa_fieldcat-seltext_m = 'Customer'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'FKDAT'.
wa_fieldcat-tabname = 'IT_VBRK'.
wa_fieldcat-seltext_m = 'Billing Date'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-tabname = 'IT_VBRK'.
wa_fieldcat-seltext_m = 'Net Value'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'POSNR'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'Item No'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 6.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'Document No.'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 7.
wa_fieldcat-fieldname = 'ARKTX'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'Description'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 8.
wa_fieldcat-fieldname = 'FKIMG'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'Quantity'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 9.
wa_fieldcat-fieldname = 'VRKME'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'UoM'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = 10.
wa_fieldcat-fieldname = 'NETWR'.
wa_fieldcat-tabname = 'IT_VBRP'.
wa_fieldcat-seltext_m = 'Net Value'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM.
*&--------------------------------------------------------------*
*& Form SHOW_OUTPUT
*&--------------------------------------------------------------*
FORM show_output .
DATA layout TYPE SLIS_LAYOUT_ALV.
DATA key_info TYPE SLIS_KEYINFO_ALV.
key_info-header01 = 'VBELN'.
key_info-item01 = 'VBELN'.
layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
IS_LAYOUT = layout
IT_FIELDCAT = it_fieldcat
i_tabname_header = 'IT_VBRK'
i_tabname_item = 'IT_VBRP'
is_keyinfo = key_info
TABLES
t_outtab_header = it_vbrk
t_outtab_item = it_vbrp
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
In Listing 15.6, data from the billing document header table VBRK is fetched into the internal table IT_VBRK, and the item data from the database table VBRP is fetched into the internal table IT_VBRP.
A field catalog is built manually with all the fields of the header and item tables. The REUSE_ALV_HIERSEQ_LIST_DISPLAY function module is called in the program to which the field catalog is passed, along with the internal tables that contain the header and item table. A KEY_INFO structure of type SLIS_KEYINFO_ALV is used to pass the common key fields of the header and item tables.
In this section, we discussed the different standard ALV report types available from the reuse library. In the next section, we’ll transition into a discussion of interactive reports.