2011 Feb 02 10:57 AM
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??
if the ALV is OO
free the ALV data before create a new instance.
2011 Feb 02 11:15 AM
If there is any default layout marked inlayout management, uncheck it.
2011 Feb 02 11:18 AM
2011 Feb 02 11:18 AM
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
2011 Feb 02 11:29 AM
hey this is almost the same code. i used this just in case i forgot something but the problem remains.
2011 Feb 02 11:58 AM
if the ALV is OO
free the ALV data before create a new instance.
2011 Feb 02 1:24 PM
Pass this P_LAYOU into alv grid display FM in Is_variant parameter.
hope it works.
2011 Feb 02 1:33 PM
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
2011 Feb 04 10:00 AM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |