10-10-2007 9:44 AM
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?
10-10-2007 9:49 AM
the layout may be seleted thru the fucntion module reuse_alv_grid_display. in which there will be aparameter is_layout.
10-10-2007 10:00 AM
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.
10-10-2007 10:03 AM
chenge the value in the layout and pass , change accodingly how u want.
u post ur code, we can suggest.
10-10-2007 10:16 AM
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
10-10-2007 10:24 AM
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.
10-10-2007 10:31 AM
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.
10-10-2007 9:56 AM
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