Today we will see how easy it is to set up the Layout for the ALV which was created using the reference of the CL_SALV_TABLE calss.
All these discussions can be found under Tutorials > SALV Table Display .
Layouts provides greate flexibility to users for saving their own layouts which contains settings like – sum, subtotal, filter, sort etc. This provides a great degree of advantages to the ALV reports. We can add much more in this if we can provide the option from which user can select the Layout and generate his/her report.
We will request our ALV instance for the instance of the CL_SALV_LAYOUT. This class contains all the necessary methods which can be helpful for the Layout settings.
Here is the code snippet to which provides the ADD-ON code to our Base program. The base program can be found in the SALV Model 1: Normal ALV Table Display .
UML diagram for the test program will be like:
*$*$*.....CODE_ADD_1 - Begin..................................1..*$*$*
*
* In this section we will define the private methods which can
* be implemented to set the properties of the ALV and can be
* called in the
*
PRIVATE SECTION.
METHODS:
set_pf_status
CHANGING
co_alv TYPE REF TO cl_salv_table.
*
METHODS:
set_layout
CHANGING
co_alv TYPE REF TO cl_salv_table.
*$*$*.....CODE_ADD_1 - End....................................1..*$*$*
*
*$*$*.....CODE_ADD_2 - Begin..................................2..*$*$*
*
* In this area we will call the methods which will set the
* different properties to the ALV
*
* Setting up the PF-Status
CALL METHOD set_pf_status
CHANGING
co_alv = o_alv.
*
* Setting up the Layout
CALL METHOD set_layout
CHANGING
co_alv = o_alv.
*$*$*.....CODE_ADD_2 - End....................................2..*$*$*
*
*
*$*$*.....CODE_ADD_3 - Begin..................................3..*$*$*
*
* In this area we will implement the methods which are defined in
* the class definition
*
*
METHOD set_pf_status.
*
DATA: lo_functions TYPE REF TO cl_salv_functions_list.
*
lo_functions = co_alv->get_functions( ).
lo_functions->set_default( abap_true ).
*
ENDMETHOD. "set_pf_status
*
METHOD set_layout.
*
DATA: lo_layout TYPE REF TO cl_salv_layout,
lf_variant TYPE slis_vari,
ls_key TYPE salv_s_layout_key.
*
* get layout object
lo_layout = co_alv->get_layout( ).
*
* set Layout save restriction
* 1. Set Layout Key .. Unique key identifies the Differenet ALVs
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
* 2. Remove Save layout the restriction.
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
*
* set initial Layout
lf_variant = 'DEFAULT'.
lo_layout->set_initial_layout( lf_variant ).
*
ENDMETHOD. "set_layout
*$*$*.....CODE_ADD_3 - End....................................3..*$*$*
hi cam you give an example of how to set up the
SUM row at the end of the alv.
thanks
Blogs are so informative where we get lots of information on any topic. Nice job keep it up!!
_____________________________
BSC Dissertation
Really helpful..keep up the good work.
thank you – this was so helpful
Very good , and the diagram on top is really helping me to understand POO , you are really good man .
Good one…