‎2006 Nov 22 8:44 AM
Hi Experts,
I have a requirement like,
I need to change the column width and save it as variant in my ALV Report,
I am usning FMs for grid display.
for ex, If I shrink the column width and save it with save variant button in standard ALV toolbar it should save and remains same. When I execute with that variant, it should show the same width which I changed last time.
Can you please me....
I am very mcuh thankful for your quick responses......
‎2006 Nov 22 8:51 AM
That's exactly is the purpose of the LAYOUT's. Set the width of the columns and save that setting as a layout (and also default). The next time you execute that you should be able to see the same output.
You should enable saving of the layout using I_SAVE parameter.
Regards,
Ravi
Note - Please mark all the helpful answers
‎2006 Nov 22 8:51 AM
Hi Alekhya,
In the call to the FM REUSE_ALV_GRID_DISPLAY
set the parameter I_SAVE = 'A'
and pass IS_VARIANT = v_var
v_var of type DISVARIANT.
This will allow you to save the layout in the ALV display. When you display the ALV Grid you can choose one of the saved layout.
Regards
Wenceslaus
‎2006 Nov 22 9:11 AM
hi alekhya,
declare the selection screen parameter first.
SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-053.
PARAMETERS: p_varia TYPE slis_vari.
SELECTION-SCREEN END OF BLOCK e.
then use the following function module for get the default varient.
at selection screen check
----
A T S E L E C T I O N - S C R E E N *
----
AT SELECTION-SCREEN.
IF NOT p_varia IS INITIAL.
MOVE st_variant TO st_var_usr.
MOVE p_varia TO st_var_usr-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = c_save
CHANGING
cs_variant = st_var_usr.
st_variant = st_var_usr.
ELSE.
PERFORM z_variant_init.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varia.
PERFORM z_f4_varia CHANGING p_varia.
&----
*& Form z_variant_init
&----
text
----
FORM z_variant_init .
CLEAR st_variant.
st_variant-report = sy-repid.
ENDFORM. " z_variant_init
&----
*& Form z_f4_varia
&----
text
----
<--P_P_VARIA text
----
FORM z_f4_varia CHANGING pc_varia TYPE slis_vari.
DATA: l_exit TYPE char1.
PERFORM z_variant_init.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = st_variant
i_save = c_save
IMPORTING
e_exit = l_exit
es_variant = st_var_usr
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF l_exit = space.
pc_varia = st_var_usr-variant.
ENDIF.
ENDIF.
ENDFORM. " z_f4_varia
Use the above code u will get some idea.
thanks
Sekhar
‎2006 Nov 22 9:51 AM
Alekhya,
You can do that with the help of layout, variant, save options of the ALV FM.
then you get a chance to save the layout variant. save the variant as you wish, next time if you choose that it will display the out with same properties.
DATA: LS_VARI TYPE DISVARIANT.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = 'TESTUSER'.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
pass the variant to is_variant, and i_save = 'X'. and layout parameter. then you will see option to save the layout variant.
Regards
Vijay