Displaying ALV in a Container using CL_SALV_TABLE Class
- In the Previous part, we understand how can we use CL_SALV_TABLE class for our purpose and can achieve various requirements easily.
- Also we had discussed how to display ALV in a container using method SET_TABLE_FOR_FIRST_DISPLAY of CL_GUI_ALV_GRID class.
- Now, we will display ALV in a container using CL_SALV_TABLE class.
Requirement :-
- User wants that he would be giving input as a Sales document number.
- And the output should be details of that Sales document from VBAK table in form ALV in a container.
Solution :-
-
Step 1 :- Create a executable program in ABAP Editor ( SE38 ).
-
Step 2 :- Create a type structure for VBAK table and a corresponding internal table for it.
-
Step 3 :- Define a select option for user input.
-
Step 4 :- In start of selection write the logic to fetch data from header table.
-
Step 5 :- We need to create a object of CL_GUI_CUSTOM_CONTAINER class which we will pass into the factory method.
-
Step 6 :- Call the factory method of CL_SALV_TABLE and pass this container into it.
-
Step 7 :- We have got the object for CL_SALV_TABLE class and now we need to call the display method.
-
Step 8 :- Call a screen and create a container with name ‘CONT1’ on it.
Code :-
*&---------------------------------------------------------------------*
*& Report ZAR_SALV_CONTAINER
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zar_salv_container.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbeln_va,
erdat TYPE erdat,
erzet TYPE erzet,
ernam TYPE ernam,
vbtyp TYPE vbtypl,
END OF ty_vbak.
DATA : lt_header TYPE TABLE OF ty_vbak.
DATA : lv_vbeln TYPE vbeln_va.
SELECT-OPTIONS : s_vbeln FOR lv_vbeln.
START-OF-SELECTION.
SELECT vbeln
erdat
erzet
ernam
vbtyp
FROM vbak INTO
TABLE lt_header
WHERE vbeln IN s_vbeln.
IF lt_header IS NOT INITIAL.
DATA(lo_container) = new CL_GUI_CONTAINER(
CLSID = '1'
CONTAINER_NAME = 'CONT1' ).
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = IF_SALV_C_BOOL_SAP=>FALSE
r_container = lo_container
* container_name =
IMPORTING
r_salv_table = data(lo_salv)
CHANGING
t_table = lt_header
.
CATCH cx_salv_msg.
ENDTRY.
lo_salv->display( ).
call screen '0100'.
ENDIF.
*&------------------------------------------------------------------
*&End of Program
*&------------------------------------------------------------------
Execute the code :-
- Press F8 to execute the code.
Comments
Post a Comment