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

Adding layout variant to selection screen

Former Member
0 Likes
3,415

Hi all,

Currently I am working on report program, where I have to allow user to select his own output pattern. i.e layout variant is to be added to selection screen. The report uses object oriented ALV for display purpose. [set_table_for_first_display]

I made following steps,

1. Declared one parameter of type disvariant.

2. At selection-screen on value-request I called function REUSE_ALV_VARIANT_F4.

3. Passed internal table to method set_table_for_first_display.

Now I am able to create save new variant, on selection screen I can select the variant that I have created, but output shows the all the fields though

Only few are selected. Please tell me any modification so as to reflect the changes in output.

I am searching for a function which maintains fieldcat according to user defined variant.

Regards,

Nilesh kulkarni.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,466

U have to use REUSE_ALV_VARIANT_EXISTENCE inorder to use the layout u have selected

After ur code of REUSE_ALV_VARIANT_F4.

try this way

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

G_REPID = SY-REPID.

G_SAVE = 'A'.

FORM PAI_OF_SELECTION_SCREEN .

IF NOT P_LAYOUT IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_LAYOUT TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM VARIANT_INIT.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

FORM variant_init .

CLEAR G_VARIANT.

G_VARIANT-REPORT = G_REPID.

ENDFORM. " variant_init

Then when u call ALV for display, pass ur display variant, in this case = g_variant

Reward if useful

Cheers

~Arun

Message was edited by:

Arun Shekhar

3 REPLIES 3
Read only

Former Member
0 Likes
1,466

how u are passing this variant which is selected at selectioon screen to Output ?

means are u passing these variants to methods which display ALV or not ?

Regards

Peram

Read only

0 Likes
1,466

Yes I have defined a internal table of type disvariant and confirmed that it contains value before passing to display method, while debugging i could read the values in internal table, but the changing parameter c_layout remains blank.

Read only

Former Member
0 Likes
1,467

U have to use REUSE_ALV_VARIANT_EXISTENCE inorder to use the layout u have selected

After ur code of REUSE_ALV_VARIANT_F4.

try this way

AT SELECTION-SCREEN.

PERFORM PAI_OF_SELECTION_SCREEN.

G_REPID = SY-REPID.

G_SAVE = 'A'.

FORM PAI_OF_SELECTION_SCREEN .

IF NOT P_LAYOUT IS INITIAL.

MOVE G_VARIANT TO GX_VARIANT.

MOVE P_LAYOUT TO GX_VARIANT-VARIANT.

CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

EXPORTING

I_SAVE = G_SAVE

CHANGING

CS_VARIANT = GX_VARIANT.

G_VARIANT = GX_VARIANT.

ELSE.

PERFORM VARIANT_INIT.

ENDIF.

ENDFORM. " PAI_OF_SELECTION_SCREEN

FORM variant_init .

CLEAR G_VARIANT.

G_VARIANT-REPORT = G_REPID.

ENDFORM. " variant_init

Then when u call ALV for display, pass ur display variant, in this case = g_variant

Reward if useful

Cheers

~Arun

Message was edited by:

Arun Shekhar