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 Layout Variant error

Former Member
0 Likes
2,097

Hello,

When I display an ALV using REUSE_ALV_GRID_DISPLAY , Then create new Layout for it using button in ALV toolbar. It's OK with the.

But When I use the FM :

REUSE_ALV_VARIANT_F4

with the name of the report ( sy-repid) in s)variant :

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = s_variant

i_save = s_save

IMPORTING

e_exit = l_exit

es_variant = s_def_variant

EXCEPTIONS

not_found = 2.

The FM rerun nothing althought in the ALV list I can see and get them.

I do not know why , Could you please help

Thanks

1 ACCEPTED SOLUTION
Read only

deepak_dhamat
Active Contributor
0 Likes
1,535

hi,

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.

PERFORM get_alv_variant.

w_variant_selected = 'X'.

DATA : ls_variant TYPE disvariant.

ws_variant-username = sy-uname.

ws_variant-report = sy-repid.

ws_variant-handle = '0001'.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = ws_variant

i_save = 'A'

IMPORTING

es_variant = ws_variant.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

pa_vari = ws_variant-variant.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = ls_pfstatus

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = lt_fieldcat

i_default = 'X'

i_save = 'X'

is_variant = ws_variant

is_layout = ws_layout

it_events = lt_eventtab[]

TABLES

t_outtab = it_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

See that you pass proper parameter for ls_layout

Regards

Deepak.

7 REPLIES 7
Read only

Former Member
0 Likes
1,535

Hi,

Please check the demo program BALVHD01. In the at selection-screen on value-request for the variant, they have provided the FM.

If sy-subrc ne 2.

If l_exit = space.

p_vari ( parameter in the selection screen ) = s_def_variant-variant.

endif.

endif.

Hope it helps.

Sujay

Read only

Former Member
0 Likes
1,535

Hi,

Pass SY-REPID into structure field IS_VARIANT-REPORT while calling the FM. Test the FM in SE37 while passing only this value, You will get the popup with list of variants.

Regards

Vinod

Read only

deepak_dhamat
Active Contributor
0 Likes
1,536

hi,

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.

PERFORM get_alv_variant.

w_variant_selected = 'X'.

DATA : ls_variant TYPE disvariant.

ws_variant-username = sy-uname.

ws_variant-report = sy-repid.

ws_variant-handle = '0001'.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = ws_variant

i_save = 'A'

IMPORTING

es_variant = ws_variant.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

pa_vari = ws_variant-variant.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = ls_pfstatus

i_callback_user_command = 'USER_COMMAND'

it_fieldcat = lt_fieldcat

i_default = 'X'

i_save = 'X'

is_variant = ws_variant

is_layout = ws_layout

it_events = lt_eventtab[]

TABLES

t_outtab = it_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

See that you pass proper parameter for ls_layout

Regards

Deepak.

Read only

0 Likes
1,535

Hello,

Thank you for your annwer.

I'm still in block, In fact I've tried many ways as well as apply the sample code but it does not work. I've done this for several time .

Thanks once again

Read only

Former Member
0 Likes
1,535

Hi Joehan,

Please give the exact problem? are you getting an error or you are unable to do F4 using this FM?

PFB the sample code for F4 help on layout.

*-- data declaration

DATA: wa_variant LIKE disvariant, "I-RD6K907785

w_save(1) TYPE c. "I-RD6K907785

----


  • SELECTION SCREEN *

----


*--Layout Selection - Block

SELECTION-SCREEN BEGIN OF BLOCK b1

PARAMETERS : p_layt LIKE disvariant-variant. "Layout

SELECTION-SCREEN END OF BLOCK b1.

----


  • Initialization *

----


INITIALIZATION.

*--Variant Initialization

w_save = 'A'.

CLEAR wa_variant.

wa_variant-report = sy-repid.

CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

EXPORTING

i_save = w_save

CHANGING

cs_variant = wa_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc EQ 0.

p_layt = wa_variant-variant.

ENDIF.

----


  • AT SELECTION SCREEN ON VALUE REQUEST *

----


*--F4 For Variant.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layt.

DATA : l_exit(1) TYPE c.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = wa_variant

i_save = w_save

IMPORTING

e_exit = l_exit

es_variant = wa_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 0.

IF l_exit = space.

p_layt = wa_variant-variant.

ENDIF.

ENDIF.

Regards,

Pranjali

Read only

0 Likes
1,535

Hello,

in my case, I copied the program RVAUFSTA and add the field layout as the template you provide .

And Upto now I can not use the variant too .

Because I used variant like this many times, This error is strange to me, We can see and manage variant in the LIST ALV, But when I chec with FM ( F4) , We can see nothing .( No layout found) .

Please help me.

Thanks,

JoeHan

Read only

0 Likes
1,535

I used the following code:

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

PERFORM alv_reuse_variant_f4.

FORM alv_reuse_variant_f4.

DATA : l_exit(1) TYPE c.

CLEAR : l_exit, s_def_variant.

s_variant-report = sy-repid.

s_save = 'A'.

  • Call the ALV variant on F4 push button

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = s_variant

i_save = s_save

IMPORTING

e_exit = l_exit

es_variant = s_def_variant

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.

p_vari = s_def_variant-variant.

ENDIF.

ENDIF.

ENDFORM.