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

Change Layout in Selection Screen for OO ALV-Grid

Former Member
0 Likes
4,042

Hello everyone,

I got a problem regarding layouts for objectoriented ALV Grid. I want to make it possible that user can take the layout for ALV he wants to on the selection screen. So far thats no problem and it works. But there are some little problems which I do not know how to fix them. But first the facts:

(1) I got my parameter for layout


PARAMETER: p_vari  TYPE disvariant-variant.

(2) I fill my global layout structure in initialization


************************************************************************
INITIALIZATION.
************************************************************************
* Variante vorbelegen
   gs_variant-username = sy-uname.
   gs_variant-report   = sy-repid.


* Layout holen
   CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'
     EXPORTING
       i_save        = 'A'
     CHANGING
       cs_variant    = gs_variant
     EXCEPTIONS
       wrong_input   = 1
       not_found     = 2
       program_error = 3
       OTHERS        = 4.

   IF sy-subrc = 0.
     p_vari = gs_variant-variant.
   ENDIF.

(3) I got my handling for F4-value help on variant parameter


************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
************************************************************************
   CALL FUNCTION 'LVC_VARIANT_F4'
     EXPORTING
       is_variant    = gs_variant
       i_save        = 'A'
     IMPORTING
       es_variant    = gs_variant
     EXCEPTIONS
       not_found     = 1
       program_error = 2
       OTHERS        = 3.

   IF sy-subrc <> 0.
     MESSAGE text-m01 TYPE 'S'.
   ELSE.
     p_vari = gs_variant-variant.
   ENDIF.

(4) I give back my parameters content into the variant structure at start of selection


************************************************************************
START-OF-SELECTION.
************************************************************************
   gs_variant-username = sy-uname.
   gs_variant-report   = sy-repid.
   gs_variant-variant  = p_vari.

This works all fine but I got some problems when using default variants/layouts. For example I got a default variant only for me. When starting the selection screen it works fine that the default layout was written. It is displayed automatically in the variant parameter. But I want that if i I empty the content (blank it out) from my variant parameter, that report should start with "normal" layout how it was written in the report and NOT with default layout.

When I clear the gs_variant it works like I want it, but then the alv layout button looks like (without functions for layout), because I do not have the reference to my report.

So what to do? 🙂

Regards

Michael

Hello everyone,

I got a problem regarding layouts for objectoriented ALV Grid. I want to make it possible that user can take the layout for ALV he wants to on the selection screen. So far thats no problem and it works. But there are some little problems which I do not know how to fix them. But first the facts:

(1) I got my parameter for layout


PARAMETER: p_vari  TYPE disvariant-variant.

(2) I fill my global layout structure in initialization


************************************************************************
INITIALIZATION.
************************************************************************
* Variante vorbelegen
   gs_variant-username = sy-uname.
   gs_variant-report   = sy-repid.


* Layout holen
   CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'
     EXPORTING
       i_save        = 'A'
     CHANGING
       cs_variant    = gs_variant
     EXCEPTIONS
       wrong_input   = 1
       not_found     = 2
       program_error = 3
       OTHERS        = 4.

   IF sy-subrc = 0.
     p_vari = gs_variant-variant.
   ENDIF.

(3) I got my handling for F4-value help on variant parameter


************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
************************************************************************
   CALL FUNCTION 'LVC_VARIANT_F4'
     EXPORTING
       is_variant    = gs_variant
       i_save        = 'A'
     IMPORTING
       es_variant    = gs_variant
     EXCEPTIONS
       not_found     = 1
       program_error = 2
       OTHERS        = 3.

   IF sy-subrc <> 0.
     MESSAGE text-m01 TYPE 'S'.
   ELSE.
     p_vari = gs_variant-variant.
   ENDIF.

(4) I give back my parameters content into the variant structure at start of selection


************************************************************************
START-OF-SELECTION.
************************************************************************
   gs_variant-username = sy-uname.
   gs_variant-report   = sy-repid.
   gs_variant-variant  = p_vari.

This works all fine but I got some problems when using default variants/layouts. For example I got a default variant only for me. When starting the selection screen it works fine that the default layout was written. It is displayed automatically in the variant parameter. But I want that if i I empty the content (blank it out) from my variant parameter, that report should start with "normal" layout how it was written in the report and NOT with default layout.

When I clear the gs_variant it works like I want it, but then the alv layout button looks like (without functions for layout), because I do not have the reference to my report.

So what to do? 🙂

Regards

Michael

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,683

Then deactivate the usage of default variant when calling the ALV (clear I_DEFAULT parameter of FM REUSE_ALV_GRID_DISPLAY_LVC or method CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY or method CL_SALV_LAYOUT->SET_DEFAULT( space ) for CL_SALV_TABLE)

Regards,

Raymond

Read only

0 Likes
1,683

Wow that was fast, works great, thanks 🙂

I did not use this parameter in set table method but now I fill it dynamically.

Ok next problem, one step harder 😉

Now I have one selection screen for one ALV-Grid, but four radio buttons which control with which data the ALV gets filled (four different fieldcats, data tables and so on). Each Grid got an own HANDLE so that the layouts can be separated in four categories.

Now I want that by changing the radio button the individual standard layout for the chosen alv grid is getting filled.

This works fine when using it in selection screen output.


************************************************************************
AT SELECTION-SCREEN OUTPUT.
************************************************************************


   CLEAR gs_variant.
* Layout-Handles individuell für Klausel-Radiobuttons setzen
   IF     p_py IS NOT INITIAL.
     gs_variant-username = sy-uname.
     gs_variant-report   = sy-repid.
     gs_variant-handle   = 'KLPY'.
   ELSEIF p_rh IS NOT INITIAL.
     gs_variant-username = sy-uname.
     gs_variant-report   = sy-repid.
     gs_variant-handle   = 'KLRH'.
   ELSEIF p_aj IS NOT INITIAL.
     gs_variant-username = sy-uname.
     gs_variant-report   = sy-repid.
     gs_variant-handle   = 'KLAJ'.
   ELSEIF p_sr IS NOT INITIAL.
     gs_variant-username = sy-uname.
     gs_variant-report   = sy-repid.
     gs_variant-handle   = 'KLSR'.
   ENDIF.

* Layout holen
   CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'
     EXPORTING
       i_save        = 'A'
     CHANGING
       cs_variant    = gs_variant
     EXCEPTIONS
       wrong_input   = 1
       not_found     = 2
       program_error = 3
       OTHERS        = 4.

   IF sy-subrc = 0.
     p_vari = gs_variant-variant.
   ELSE.
     CLEAR p_vari.
   ENDIF.

But unfortunately selection screen output is getting passed by EACH changing in the selection screen. This means when I try to clear the default layout in my parameter field, it gets refilled automatically with default layout. If I do a condition around the filling (only if not initial) the default value filling does not work fine in every case, e.g. when clearing the parameters field and then change the radiobutton -> then it does not get filled automatically.

Read only

0 Likes
1,683

Any idea? 😉