ALV By CL_SALV_TABLE Class
- CL_SALV_TABLE class is a part of ALV object model.
- ALV object model is an encapsulation of the pre-existing ALV tools
- In simple terms CL_SALV_TABLE actually combines both the CL_GUI_ALV_GRID class for container implementation, as well as the REUSE_ALV_GRID_DISPLAY and REUSE_ALV_LIST_DISPLAY function modules for full screen display.
Advantage :-
- It provides a collection of interface for ALV tools.
Disadvantage :-
- We can not go for editable ALV using ALV object model.
Steps to Create ALV by CL_SALV_TABLE
- Step 1 :- Call the factory method of CL_SALV_TABLE to get the instance of ALV table of object.
- Step 2 :- Call the display method of CL_SALV_TABLE to display the ALV.
let’s take a requirement.
Requirement :-
- User will provide a range of input for Sales Document Number.
- And we will show him the details of Sales Document number from VBAK table in ALV form.
Solution :-
-
Step 1 :- Create a executable program in ABAP Editor.
-
Step 2 :- Create a type structure from VBAK table and a corresponding internal table.
-
Step 3 :- Define a select option from Sales Document Number.
-
Step 4 :- In start of selection write the select query to fetch data into the internal table.
-
Step 5 :- Get object for CL_SALV_TABLE using its factory method.
-
Step 6 :- Call the display method from the above object.
-
Code :-
*&---------------------------------------------------------------------*
*& Report ZAR_SALV
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zar_salv.
TYPES : BEGIN OF ty_vbak,
vbeln TYPE vbeln,
erdat TYPE erdat,
erzet TYPE erzet,
ernam TYPE ernam,
vbtyp TYPE vbtypl,
END OF ty_vbak.
DATA : lt_vbak 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_vbak
WHERE vbeln IN s_vbeln.
IF lt_vbak IS NOT INITIAL.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = DATA(lo_object)
CHANGING
t_table = lt_vbak.
CATCH cx_salv_msg.
ENDTRY.
lo_object->display( ).
ENDIF.
*&------------------------------------------------------------
*&End of Program
*&------------------------------------------------------------
Execute the Program :-
- Press F8.
Comments
Post a Comment