Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

layout variant for cl_salv_table.

Former Member
0 Likes
24,107

hi ji's,

I need to know what to do to get the "alv_layout"  parameter in my selection screen. actually now am using "reuse_alv_list_display" for this i got the

alv layout variant in my selection screen I can select the desire layout option which i saved before. its all working fine..

but now i need to know how to do for "cl_salv_table" . I am going to use "cl_salv_table" instead of "reuse_alv_list_display". I know  am unable to use

"'REUSE_ALV_VARIANT_F4'.

please help me to do this friends.

thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
11,897

Hi,

Please implement the below code.

REPORT ZLAYOUT_VARIET.

data:BEGIN OF wa_kna1,

      kunnr type kunnr,

      name1 type name1,

      ort01 type ort01,

      end  of wa_kna1.

data:it_kna1 like TABLE OF wa_kna1,

      set_key type SALV_S_LAYOUT_KEY,

      G_EXIT  TYPE C,

      G_VARIANT   TYPE DISVARIANT,

      SET_LAY TYPE SLIS_VARI.

data:r_alv type REF TO cl_salv_table,

      r_lay type REF TO CL_SALV_LAYOUT.

PARAMETERS:p_var type DISVARIANT-VARIANT.

INITIALIZATION.

G_varIANT-report = sy-repid.

at SELECTION-SCREEN on VALUE-REQUEST FOR p_var.

   CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

     EXPORTING

       IS_VARIANT                = G_VARIANT

*     I_TABNAME_HEADER          =

*     I_TABNAME_ITEM            =

*     IT_DEFAULT_FIELDCAT       =

      I_SAVE                    = 'A'

*     I_DISPLAY_VIA_GRID        = ' '

    IMPORTING

      E_EXIT                    = G_EXIT

      ES_VARIANT                = G_VARIANT

    EXCEPTIONS

      NOT_FOUND                 = 1

      PROGRAM_ERROR             = 2

      OTHERS                    = 3

             .

   IF SY-SUBRC = 0.

  P_VAR = G_VARIANT-VARIANT.

  SET_LAY = G_VARIANT-VARIANT.

   ENDIF.

START-OF-SELECTION.

   select kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1 where kunnr BETWEEN '1000' and '1500'.

set_key-REPORT = sy-repid.

   TRY.

       CALL METHOD CL_SALV_TABLE=>FACTORY

         EXPORTING

           LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE

*         R_CONTAINER    =

*         CONTAINER_NAME =

         IMPORTING

           R_SALV_TABLE   = r_alv

         CHANGING

           T_TABLE        = it_kna1.

     CATCH CX_SALV_MSG .

   ENDTRY.

   CALL METHOD R_ALV->GET_LAYOUT

     RECEIVING

       VALUE = r_lay.

   CALL METHOD R_LAY->SET_KEY

     EXPORTING

       VALUE = Set_key.

CALL METHOD R_LAY->SET_SAVE_RESTRICTION

   EXPORTING

     VALUE  = IF_SALV_C_LAYOUT=>RESTRICT_NONE

     .

CALL METHOD R_LAY->SET_INITIAL_LAYOUT

   EXPORTING

     VALUE  = SET_LAY

     .

   CALL METHOD R_ALV->DISPLAY

     .

Regards,

Quddus.

hi ji's,

I need to know what to do to get the "alv_layout"  parameter in my selection screen. actually now am using "reuse_alv_list_display" for this i got the

alv layout variant in my selection screen I can select the desire layout option which i saved before. its all working fine..

but now i need to know how to do for "cl_salv_table" . I am going to use "cl_salv_table" instead of "reuse_alv_list_display". I know  am unable to use

"'REUSE_ALV_VARIANT_F4'.

please help me to do this friends.

thanks in advance.

5 REPLIES 5
Read only

alisson_fragozo
Explorer
0 Likes
11,897

Hello Sazees,

See the program: SALV_TEST_TABLE_LAYOUT

Read only

0 Likes
11,897

hi Ali Fragozo ,

thanks for your reply, already I have seen this program I have doubts and lot of confusions.

just can I take the "perform f4_layouts" part or I should nee to declare class and implement it. bcoz inside that perform there is no need of class .

please correct me if am wrong.

Read only

Former Member
11,898

Hi,

Please implement the below code.

REPORT ZLAYOUT_VARIET.

data:BEGIN OF wa_kna1,

      kunnr type kunnr,

      name1 type name1,

      ort01 type ort01,

      end  of wa_kna1.

data:it_kna1 like TABLE OF wa_kna1,

      set_key type SALV_S_LAYOUT_KEY,

      G_EXIT  TYPE C,

      G_VARIANT   TYPE DISVARIANT,

      SET_LAY TYPE SLIS_VARI.

data:r_alv type REF TO cl_salv_table,

      r_lay type REF TO CL_SALV_LAYOUT.

PARAMETERS:p_var type DISVARIANT-VARIANT.

INITIALIZATION.

G_varIANT-report = sy-repid.

at SELECTION-SCREEN on VALUE-REQUEST FOR p_var.

   CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

     EXPORTING

       IS_VARIANT                = G_VARIANT

*     I_TABNAME_HEADER          =

*     I_TABNAME_ITEM            =

*     IT_DEFAULT_FIELDCAT       =

      I_SAVE                    = 'A'

*     I_DISPLAY_VIA_GRID        = ' '

    IMPORTING

      E_EXIT                    = G_EXIT

      ES_VARIANT                = G_VARIANT

    EXCEPTIONS

      NOT_FOUND                 = 1

      PROGRAM_ERROR             = 2

      OTHERS                    = 3

             .

   IF SY-SUBRC = 0.

  P_VAR = G_VARIANT-VARIANT.

  SET_LAY = G_VARIANT-VARIANT.

   ENDIF.

START-OF-SELECTION.

   select kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1 where kunnr BETWEEN '1000' and '1500'.

set_key-REPORT = sy-repid.

   TRY.

       CALL METHOD CL_SALV_TABLE=>FACTORY

         EXPORTING

           LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE

*         R_CONTAINER    =

*         CONTAINER_NAME =

         IMPORTING

           R_SALV_TABLE   = r_alv

         CHANGING

           T_TABLE        = it_kna1.

     CATCH CX_SALV_MSG .

   ENDTRY.

   CALL METHOD R_ALV->GET_LAYOUT

     RECEIVING

       VALUE = r_lay.

   CALL METHOD R_LAY->SET_KEY

     EXPORTING

       VALUE = Set_key.

CALL METHOD R_LAY->SET_SAVE_RESTRICTION

   EXPORTING

     VALUE  = IF_SALV_C_LAYOUT=>RESTRICT_NONE

     .

CALL METHOD R_LAY->SET_INITIAL_LAYOUT

   EXPORTING

     VALUE  = SET_LAY

     .

   CALL METHOD R_ALV->DISPLAY

     .

Regards,

Quddus.

Read only

0 Likes
11,897

hi Mohammed Quddus,

thanks for your reply. your code helped me out partially but the issue am facing is i can able to save my layout but the alv output is always showing the default layout. its not showing the output by the selected layout.

actually the same problem i face when i did with resue_alv_grid_display but time i declared variant inside the from so i faced this. now i declared all  as global.

still I am facing the issue.

Read only

0 Likes
11,897

hi Mohammed Quddus,


problem solved thanks for your help.