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

Former Member
0 Likes
729

Hi Folks,

I want to create an ALV report, whose output should vary with the users basing upon some condition. can anybody tell me how to do it?

regards,

santosh

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
693

Hi,

What you can do is use the concept of variants.

Create variants as per our layout requirements and take a parameter for variant on selection screen with a F4 help.

When user selects a variant, validate it and then display appropriate data.

Kindly refer this wiki code by me and refer to the use of variant in ALV:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

Hope this helps you.

Regards,

Tarun

6 REPLIES 6
Read only

Former Member
0 Likes
693

Hi,

Can you give us more information on this...

If you want to have the different layout sets then save the layouts initially,

and then pass the same layout set name depending on the user.

Regards,

Venkatesh

Read only

0 Likes
693

Hi Venkatesh,

I tried doing that what you said but it didn't work. If you don't mind could you please supply me the code ?

Regards,

Santosh

Read only

Former Member
0 Likes
693

Hi,

You can use the different layout sets.

First display the ALV with all the fields and then depending on the user, select fields and then save this layout.

Now in the selection, use a field called Layout -

PARAMETERS: p_var07 TYPE disvariant-variant .

now use a f4 help for this.

DATA: l_exit TYPE char1 .

DATA: gs_vari TYPE disvariant .

gs_vari-report = sy-repid.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = gs_vari

i_save = 'A'

  • IT_DEFAULT_FIELDCAT =

IMPORTING

e_exit = l_exit

es_variant = gs_vari

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 EQ space .

p_p_var07 = gs_vari-variant .

ENDIF

Now pass this to grid functionmodule

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = gs_layout............................................................

Regards,

Venkatesh

Read only

0 Likes
693

Initially create a universal field catalog, then according the user inputs , delete the output fields from field catalog.

so in alv output are derived on the basis of field catalog.

a®

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
694

Hi,

What you can do is use the concept of variants.

Create variants as per our layout requirements and take a parameter for variant on selection screen with a F4 help.

When user selects a variant, validate it and then display appropriate data.

Kindly refer this wiki code by me and refer to the use of variant in ALV:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
693

Answered