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: 

alv layout problem ?

Former Member
0 Kudos

Hi everyone,

I generating 2 alv reports within a program.In the selection screen there are 2 radio buttons for different alv reports. First i selected the 1st radio button and executed the prog to get a alv report.Then i went to change layout and selected the required columns from the columns set and then saved the layout as the default layout.

Then I came back to the selection screen again.In the selection screen, in the parameter p_var there is default variant,so i cleared the parameter with no layout variant selected.then i selected the 2nd radio button and executed the program.Here the program is again taking the default layout (even though i cleared it in the selection screen )and generating the alv report according to that.But i don't want to use the default layout when i select the 2nd radio button,unless i select it from the variant list.How can i do that?

Any suggestions please?

7 REPLIES 7

hymavathi_oruganti
Active Contributor
0 Kudos

the layout may be seleted thru the fucntion module reuse_alv_grid_display. in which there will be aparameter is_layout.

0 Kudos

Hi Hymavathi,

Actually i m call alv 2 times in the program.When I use the 2nd radio button it should not use any default layout.The report should be displayed with the columns what we are using in the fieldcatalogue.What value should i have to pass to the parameter is_layout in my 2nd alv.

Thanks,

dp.

0 Kudos

chenge the value in the layout and pass , change accodingly how u want.

u post ur code, we can suggest.

0 Kudos

Hi Hymavathi,

Thanks for the reply.Below is my code for the layout.If u can see any problem in the code please tell me the changes.Thank you.

PARAMETERS: P_VAR LIKE DISVARIANT-VARIANT.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.

PERFORM GET_VARIANT CHANGING P_VAR. " ALV Layout

FORM GET_VARIANT CHANGING X_VAR.

PERFORM F4_ALV_LAYOUT(PPIO_ENTRY) USING I_GRID-PROGRAM

CHANGING X_VAR.

ENDFORM.

perform alv_display.

FORM ALV_DISPLAY.

DATA: I_GRID-LAYOUT TYPE SLIS_LAYOUT_ALV.

SORT I_HEADER BY PLNBEZ AUFNR.

  • Define layout.

CLEAR I_GRID-LAYOUT.

I_GRID-LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

  • Set up Variant

I_GRID-VARIANT-VARIANT = P_VAR. " Variant

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = I_GRID-PROGRAM

IS_LAYOUT = I_GRID-LAYOUT

IT_FIELDCAT = I_GRID-FIELDCAT

I_SAVE = 'A'

IS_VARIANT = I_GRID-VARIANT

TABLES

T_OUTTAB = I_HEADER

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

  • ALV Failed.

IF SY-SUBRC <> 0.

WRITE: / 'Failed with',SY-SUBRC.

ENDIF.

ENDFORM.

PERFORM ALV_DISPLAY_2.

FORM ALV_DISPLAY_2.

DATA: I_GRID-LAYOUT TYPE SLIS_LAYOUT_ALV.

SORT I_HEADER BY PLNBEZ AUFNR.

  • Define layout.

CLEAR I_GRID-LAYOUT.

I_GRID-LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

  • Set up Variant

  • I_GRID-VARIANT-VARIANT = P_VAR. " Variant

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = I_GRID-PROGRAM

I_CALLBACK_PF_STATUS_SET = I_GRID-PF_STATUS_SET

I_CALLBACK_USER_COMMAND = I_GRID-USER_COMMAND

IS_LAYOUT = i_grid-layout

IT_FIELDCAT = I_GRID-FIELDCAT

  • I_SAVE = 'A'

  • IS_VARIANT = I_GRID-VARIANT

TABLES

T_OUTTAB = I_HEADER

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

  • ALV Failed.

IF SY-SUBRC <> 0.

WRITE: / 'Failed with',SY-SUBRC.

ENDIF.

ENDFORM. " ALV_DISPLAY_2

0 Kudos

if u dont want column optimize for the second alv,

I_GRID-LAYOUT-COLWIDTH_OPTIMIZE = ' '. give space instead of X, or

u can just comment the layout

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = I_GRID-PROGRAM

I_CALLBACK_PF_STATUS_SET = I_GRID-PF_STATUS_SET

I_CALLBACK_USER_COMMAND = I_GRID-USER_COMMAND

<b>*IS_LAYOUT = i_grid-layout</b>

IT_FIELDCAT = I_GRID-FIELDCAT

  • I_SAVE = 'A'

  • IS_VARIANT = I_GRID-VARIANT

TABLES

T_OUTTAB = I_HEADER

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

  • ALV Failed.

IF SY-SUBRC <> 0.

WRITE: / 'Failed with',SY-SUBRC.

ENDIF.

0 Kudos

Hi Hymavathi,

I commented the paramter is_layout as u said but it is still taking the default layout.Even though i cleared the parameter p_var in the selection screen still it is taking the default layout.Any more suggestions please?

Thank you.

Former Member
0 Kudos

hi,

for any thing related to layout .. go to reuse_alv_grid_display function module and there two parameters is_layout and it_varient which are related to layout ... you can go to function module documentation and can get several option related to is_layout... one of them will fulfill your problem...

reach out to me any issues

reward if i have helped u

regards

Nikesh kumar