Method GET_TABLE_FOR_ALV_GRID
Use
In the BRF you can display multiple BRF objects of the same class in an overview. This overview is provided by an ALV grid (transaction BRF_OVERVIEW).
To be able to display this overview, the implementing maintenance class must return a table with a structure description.
Sample source text:
Only the main parts of the source text are mentioned below.
METHOD if_maintenance_brf~get_table_for_alv_grid .
FIELD-SYMBOLS <lt_sbrf150_alv> TYPE sbrf150_alv_t.
DATA lr_sbrf150_alv TYPE REF TO DATA.
DATA ls_sbrf150_alv TYPE sbrf150_alv.
*--- get the common expression data from the super-class ---------------
CALL METHOD super->if_maintenance_brf~get_table_for_alv_grid
EXPORTING
iv_applclass = iv_applclass
iv_class_id = iv_class_id
iv_import_status = iv_import_status
iv_version = iv_version
IMPORTING
et_table = lr_sbrf150_alv.
ASSIGN lr_sbrf150_alv->* TO <lt_sbrf150_alv>.
CHECK <lt_sbrf150_alv> IS ASSIGNED.
*--- select data from the db-table TBRF142 ----------------------------
IF NOT <lt_sbrf150_alv>[] IS INITIAL.
SELECT * FROM tbrf142 INTO TABLE lt_tbrf142
FOR ALL ENTRIES IN <lt_sbrf150_alv> WHERE
ENDIF.
*--- merge all the fields into one table ------------------------------
LOOP AT <lt_sbrf150_alv> INTO ls_sbrf150_alv.
CLEAR ls_sbrf142_alv.
MOVE-CORRESPONDING ls_sbrf150_alv TO ls_sbrf142_alv.
READ TABLE lt_tbrf142 INTO ls_tbrf142 WITH KEY
MOVE-CORRESPONDING ls_tbrf142 TO ls_sbrf142_alv.
APPEND ls_sbrf142_alv TO mt_sbrf142_alv.
ENDLOOP.
* --------- get a data reference for the exporting parameter -----------
GET REFERENCE OF mt_sbrf142_alv INTO et_table.
ENDMETHOD.
Description:
The GET_TABLE_FOR_ALV_GRID method sets up an internal member table (MT_SBRF142_ALV). This member table consists of information from the following tables:
-
Expression table TBRF150 and TBRF150T (method of the superclass)
-
Table TBRF142
It is important that the internal table MT_SBRF142_ALV continues to exist even after the method is exited. Otherwise, the reference created in the last line would become invalid.
In the implementation you should also note the following:
-
Define your ALV structure in the DDIC.
The naming convention for existing ALV structures is SBRFxxx_ALV (xxx stands for the number of the relevant specialization table).
-
Include the ALV structure of the basis table in your ALV structure.
-
With expressions, the ALV structure of the basis table is SBRF150_ALV
-
With concrete actions, the ALV structure of the basis table is SBRF171_ALV
-