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

alv variant

Former Member
0 Likes
1,397

Hi!

i Have a problem with the selected layout (p_vari) . When i execute the alv (for first time ) everything is OK, but if the user clicks the back button or f3 and re-executes the program the displayed layout isn't the one i selected even if in the selection screen the p_vari is not inital.

i Use this part of code

INITIALIZATION.
VAR-REPORT = SY-REPID.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
perform choose_layout.

*&---------------------------------------------------------------------*
*&      Form  CHOOSE_LAYOUT
*&---------------------------------------------------------------------*

FORM CHOOSE_LAYOUT .


  DATA nof4 TYPE c.

  CLEAR nof4.
  LOOP AT SCREEN.
    IF screen-name = 'P_VARI'.
      IF screen-input = 0.
        nof4 = 'X'.
      ENDIF.
    ENDIF.
  ENDLOOP.


CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = VAR
  i_save     = 'A'
IMPORTING
ES_VARIANT = VAR.

P_VARI = VAR-VARIANT.

ENDFORM.                    " CHOOSE_LAYOUT

ANY IDEAS??

Hi!

i Have a problem with the selected layout (p_vari) . When i execute the alv (for first time ) everything is OK, but if the user clicks the back button or f3 and re-executes the program the displayed layout isn't the one i selected even if in the selection screen the p_vari is not inital.

i Use this part of code

INITIALIZATION.
VAR-REPORT = SY-REPID.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
perform choose_layout.

*&---------------------------------------------------------------------*
*&      Form  CHOOSE_LAYOUT
*&---------------------------------------------------------------------*

FORM CHOOSE_LAYOUT .


  DATA nof4 TYPE c.

  CLEAR nof4.
  LOOP AT SCREEN.
    IF screen-name = 'P_VARI'.
      IF screen-input = 0.
        nof4 = 'X'.
      ENDIF.
    ENDIF.
  ENDLOOP.


CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = VAR
  i_save     = 'A'
IMPORTING
ES_VARIANT = VAR.

P_VARI = VAR-VARIANT.

ENDFORM.                    " CHOOSE_LAYOUT

ANY IDEAS??

8 REPLIES 8
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,332

If there is any default layout marked inlayout management, uncheck it.

Read only

0 Likes
1,332

there is no default layout

Read only

Former Member
0 Likes
1,332

Hi,

PARAMETER : P_LAYOU TYPE DISVARIANT-VARIANT.

*Add the above in declaration part

*Add the below logic.

INITIALIZATION.

P_LAYOU = '/DEFAULT'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LAYOU.

WA_VARIANT-REPORT = SY-REPID.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

IS_VARIANT = WA_VARIANT

I_SAVE = 'A'

IMPORTING

ES_VARIANT = WA_VARIANT

NOT_FOUND = 2.

IF SY-SUBRC = 2.

MESSAGE I001(ZID) WITH 'Layout not found'.

ELSE.

P_LAYOU = WA_VARIANT-VARIANT.

ENDIF.

Hope it helps you.

Edited by: Syed Maheboob on Feb 2, 2011 12:22 PM

Read only

0 Likes
1,332

hey this is almost the same code. i used this just in case i forgot something but the problem remains.

Read only

0 Likes
1,332

if the ALV is OO

free the ALV data before create a new instance.

Read only

0 Likes
1,332

Pass this P_LAYOU into alv grid display FM in Is_variant parameter.

hope it works.

Read only

madhu_vadlamani
Active Contributor
0 Likes
1,332

Dear Antonio,

I did this a long back .

PARAMETERS S(12) TYPE C.

Data Is_var type disvariant.

call function 'REUSE_ALV_VARIANT_F4'.

EXPORTING

Is_variant = IS_VAR

Is_display_via_grid = 'X'

IMPORTING

Es_variant = IS_VAR

S = IS_VAR_VARIANT.

Check in this way . it will work.

In the fm 'Reuse_alv_grid_display'.

i_save = 'x'

is_variant = is_var

Regards,

Madhu.

Edited by: madhurao123 on Feb 2, 2011 2:33 PM

Read only

Former Member
0 Likes
1,332

Hi,

Create a new input parameter p_disvar like disvariant-variant.

In selection screen output set the default variant using

REUSE_ALV_VARIANT_DEFAULT_GET

Provide value request help using REUSE_ALV_VARIANT_F4

Set the display variant before calling ALV display using

REUSE_ALV_VARIANT_SELECT

Now the user can select the ALV variant on the selection screen. They can create new variants and save it. Next time they use

the report, the can select the variant before executing the report, or in the report variant for background execution