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

Changing default Alv-layout !

Former Member
0 Likes
3,609

Hi all,

Have a query please help.

When i execute a report, it displays an ALV, and when i double click on any of the columns, it displays another ALV.

Now the default layout is the same for both ALVs. So, is there any means wherein I can change that and make two

different default layouts for the 2 ALVs.

Also when i change the layout at the O/P screen for 1, automatically the same one is set for the other ALV also.

Thanks in advance.

Yats.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,030

Hi,

For the second ALV, First modify the layout and save with some name.

When you are clicking on the first ALV, when it is about display the second ALV, lets say if you are using the USER COMMAND to display the same in your custom program, then using the standard REUSE* function modules, call the second ALV with the required layout.

Also check the function module FM_ALV_LAYOUT, for which need to pass the layout name.

Regards,

Santhosh.

6 REPLIES 6
Read only

Former Member
0 Likes
2,031

Hi,

For the second ALV, First modify the layout and save with some name.

When you are clicking on the first ALV, when it is about display the second ALV, lets say if you are using the USER COMMAND to display the same in your custom program, then using the standard REUSE* function modules, call the second ALV with the required layout.

Also check the function module FM_ALV_LAYOUT, for which need to pass the layout name.

Regards,

Santhosh.

Read only

Former Member
0 Likes
2,030

Yess, you can!

But for that, u'll need to call the REUSE_ALV_GRID_DISPLAY function again with , and all the rest of the functions (for populating field catalog, events etc) must be written twice.

Make sure you use this command:

rs_selfield-refresh = 'X'.

This should allow you to retain the parent ALV template.

Hope this helps! Provide feedback if helpful, and revert back if you want any further details!

Cheers,

shailesh.

Read only

Former Member
0 Likes
2,030

Hi,

Yes you can have 2 diff layouts you just need to define that when you use CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

DATA : AK_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
      AK_REPID LIKE SY-REPID,
      AK_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : AK_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
      AK_REPID1 LIKE SY-REPID,
    AK_LAYOUT1 TYPE SLIS_LAYOUT_ALV.

While displaying the first ALV Use:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM                = AK_REPID
   I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
     I_CALLBACK_TOP_OF_PAGE            = 'TOP-OF-PAGE'
   I_BACKGROUND_ID                   = 'ENJOY'
   I_GRID_TITLE                      = 'CUSTOMER DETAILS'
   IS_LAYOUT                         = AK_LAYOUT
        IT_FIELDCAT                       = AK_FIELDCAT[]
     IT_SORT                           = IT_SORTCAT
    TABLES
      T_OUTTAB                          = ITAB
  IF SY-SUBRC <> 0.
  ENDIF.

and 2nd time use AK_LAYOUT1 You will get different layout

Rgrds,

Nikhil.

Read only

Former Member
0 Likes
2,030

Hi Nikhil,

Thanks for the reply.

I am using two layouts in my program.

How can I make them as default layouts from my code.

Note : I have to make 2 different layouts default for the two alvs [1 for each].

I only intend to make them default nothing else.

Currently on make 1 layout default for 1 alv from the O/P screen, the layout becomes default for the other alv as well.

Thsnks.

Yats.

Read only

0 Likes
2,030

Hi Yats,

Good morning.

I also have encountered the same problem. Have you found a solution to your problem? If yes, Congrats! Pls share the solution with the rest of us. Thanks again.

Dodie Plata

Read only

0 Likes
2,030

Looks like 2 ALVs with 2 Default Layout is not possible. I have a work-around solution that might be helpful to others;

The 1st ALV call using fm REUSE_ALV_GRID_DISPLAY

i_default = ' '

i_save = ' '

Users cannot change or save Layout (user-specific or system). Users are stuck with the Layout specified in the program.

The 2nd ALV call

i_save = 'U'

Users can change and Save their own Layout but User-specific only (box is greyed-out). Default-option box can be set accordingly.

Preparation + Practice + a Little bit of Luck = GREAT SUCCESS. So Good Luck!

Hope this helps.