SALV Table 4 : Setting up Layout

By | September 21, 2008 | SALV Table, SALV Tutorial, Tutorials | 25,436 | 6

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.
*
    DATAlo_functions TYPE REF TO cl_salv_functions_list.
*
    lo_functions co_alv->get_functions).
    lo_functions->set_defaultabap_true ).
*
  ENDMETHOD.                    "set_pf_status
*
  METHOD set_layout.
*
    DATAlo_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_keyls_key ).
*   2. Remove Save layout the restriction.
    lo_layout->set_save_restrictionif_salv_c_layout=>restrict_none ).
*
*   set initial Layout
    lf_variant 'DEFAULT'.
    lo_layout->set_initial_layoutlf_variant ).
*
  ENDMETHOD.                    "set_layout
*$*$*.....CODE_ADD_3 - End....................................3..*$*$*

This code snippet will generate an output like this:

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{272 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 272 articles.

Load comments

6 Comments

  • Anonymous

    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

  • Anonymous

    Really helpful..keep up the good work.

  • Anonymous

    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 .

  • Avinash Palavai

    Good one…

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.