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

Read saved sort alv layout

Former Member
0 Likes
3,399

Hi all

How to get the sorted column field from alv grid outside from program?

As you can see above, I have a program a and I set a layout variant.

Now I want to read in program b the layout variant from a and all the sorted column. 

How can I do that? 

Thanks

Hi all

How to get the sorted column field from alv grid outside from program?

As you can see above, I have a program a and I set a layout variant.

Now I want to read in program b the layout variant from a and all the sorted column. 

How can I do that? 

Thanks

7 REPLIES 7
Read only

Former Member
0 Likes
2,152

Have a look at the function modules that start with LT_VAR* - there might be one there to help.

Rich

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,152

try FM  LVC_VARIANT_SELECT.


      call function 'LVC_VARIANT_SELECT'

        exporting

          i_dialog          = ' '

          i_user_specific    = 'X'

          it_default_fieldcat = gt_fields

        importing

          et_fieldcat        = gt_fields

          et_sort            = gt_sort

        tables

          it_data            = it_items

        changing

          cs_variant        = ls_vari

        exceptions

          others            = 0.

Regards,

Raymond

Read only

0 Likes
2,152

I've tried with the function module as you mentioned above, but it does not work at all.

Read only

0 Likes
2,152

Youd didn't pass the variant name (but system provided the default one) and you didn't fill the default field catalog, also clear the display flag.

Hint: Look at sample BCALV_GRID_11 for usage of this FM (or read documentation)

Regards,

Raymond

Read only

former_member241258
Active Participant
0 Likes
2,152

USE this FM : REUSE_ALV_VARIANT_F4

here just pass program name in structure DISVARIANT

Read only

asim_isik
Active Participant
0 Likes
2,152

Hi Anujit ,

variant-report = program A. when you set variant to is_variant it should come.


call method g_alvgrid->set_table_for_first_display

    exporting

      is_layout                     = gs_layout

      it_toolbar_excluding          = gt_exclude

     is_variant                    = variant

      i_save                        = 'A'

    changing

      it_outtab                     = gt_obj[]

      it_fieldcatalog               = gt_fieldcat

    exceptions

      invalid_parameter_combination = 1

      program_error                 = 2

      too_many_lines                = 3

      others                        = 4.

Read only

kabil_g
Active Participant
0 Likes
2,152

Hi Anujit,

Pls try the below .

DATA: rs_variant LIKE disvariant


.

SELECTION-SCREEN BEGIN OF BLOCK block WITH FRAME TITLE text-003.

PARAMETERS: p_vari  TYPE slis_vari.

SELECTION-SCREEN END OF BLOCK block.





AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

   rs_variant-report   = sy-repid.

   rs_variant-username = sy-uname.

   CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

     EXPORTING

       is_variant = rs_variant

       i_save     = 'A'

     IMPORTING

       es_variant = rs_variant

     EXCEPTIONS

       OTHERS     = 1.

   IF sy-subrc = 0.

     p_vari = rs_variant-variant.

   ENDIF.



Regards,

Kabil.G