Application Development 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: 

saving variants in ALV

Former Member
0 Kudos

Hi I created a ALV report which is supposed to save variants.

But in my program the save button is missing.

all we can do is display/ hide some selected fileds.

How can i enable the save button?

4 REPLIES 4

former_member156446
Active Contributor
0 Kudos

in ur reuse_alv_grid/ list

pass i_default = 'X'

i_save = 'X'.

award points if useful

Former Member
0 Kudos

I_SAVE - the options available to the user for saving a layout:• 'X': global saving only

• 'U': user-specific saving only

• 'A': corresponds to 'X' and 'U'

• SPACE: no saving

i_save = 'U'

Check this link for details.

http://help.sap.com/saphelp_nw04/helpdata/en/2b/c670f702cf11d3b497006094192fe3/frameset.htm

Regards,

Maha

kesavadas_thekkillath
Active Contributor
0 Kudos

Just apply this in your Code....first execute the report and save it in a name...next time u can choose the same layout in the selection screen itself.

data:

wk_variant like disvariant,

wx_variant like disvariant,

wk_variant_save(1) type c,

wk_exit(1) type c,

wk_repid like sy-repid.

selection-screen skip 1.

*SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-016.

parameters: p_vari like disvariant-variant . "Variant

initialization.

perform f_init_variant.

perform f_variant_default using p_vari.

at selection-screen on value-request for p_vari.

perform f_variant_f4 using p_vari.

start-of-selection.

when calling alv pass the parameters as below.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

is_layout = wk_layout

it_fieldcat = alvfld[]

i_default = 'X' <------

i_save = 'A' <-----

is_variant = wk_variant <-------

it_events = v_events[]

tables

t_outtab = it_stpo.

&----


*& Form f_init_variant

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form f_init_variant .

clear: wk_variant.

wk_repid = sy-repid.

wk_variant-report = wk_repid.

wk_variant-username = sy-uname.

wk_variant_save = text-032. "All types

endform. " f_init_variant

&----


*& Form f_variant_default

&----


  • text

----


  • -->P_P_VARI text

----


form f_variant_default using p_variant.

wx_variant = wk_variant.

if not p_variant is initial.

wx_variant-variant = p_variant.

endif.

call function 'LVC_VARIANT_DEFAULT_GET'

exporting

i_save = wk_variant_save

changing

cs_variant = wx_variant

exceptions

wrong_input = 1

not_found = 2

program_error = 3

others = 4.

case sy-subrc.

when 0.

p_variant = wx_variant-variant.

when 2.

clear: p_variant.

endcase.

endform. " f_variant_default

0 Kudos

One more form

&----


*& Form f_variant_f4

&----


  • text

----


  • -->P_P_VARI text

----


form f_variant_f4 using p_variant .

call function 'LVC_VARIANT_F4'

exporting

is_variant = wk_variant

i_save = wk_variant_save

importing

e_exit = wk_exit

es_variant = wx_variant

exceptions

not_found = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message i122(zpp).

endif.

if wk_exit is initial.

wk_variant-variant = wx_variant-variant.

p_variant = wx_variant-variant.

endif.

endform. " f_variant_f4