10-29-2009 7:38 AM
In a report, I call FM REUSE_ALV_LIST_DISPLAY multiple times to output the data. This logic is include in a form FRM_OUTPUT.
After I run the program, result1 will be displayd. Now I want to change layout, I have added a button to select the fields that we want to display. After selected, I call the form FRM_OUTPUT again with changed field catalog. Then result2 will be displayed.
Now I have a problem when we click the BACK botton, the result1 will be showed up. What's we expected is the selection screen of the program.
Can any one help me? Thanks in advance!
10-29-2009 8:24 AM
I suppose you call the FORM in the USER_COMMAND form of the ALV, so after some clicks you get a stack like
- main
- form FRM_OUTPUT
- ALV
- form FRM_OUTPUT
- ALV
- etc.
so when you press back you get back to previous ALV
Don't call the form in the USER_COMMAND, but exit from ALV filling rs_selfield-exit and passing the r_ucomm ok code (and otgher informations required) to variable(s) of the main program, there execute again a FRM_OUTPUT when ALV memory is freed. (if you only set exit but call FRM_OUTPUT from inside ALV, that will work, but you will get every ALV stacked in memory, so less performances)
Regards,
Raymond
10-29-2009 8:07 AM
Hi,
Define the screen number of your selection screen as 100 (or any number between 0 and 999).
SELECTION-SCREEN BEGIN OF SCREEN 100.
<code>
SELECTION-SCREEN END OF SCREEN 100.
Now when BACK is clicked, code the following.
CALL SCREEN 100.
Hope this helps.
Thanks,
Harini
10-29-2009 8:24 AM
I suppose you call the FORM in the USER_COMMAND form of the ALV, so after some clicks you get a stack like
- main
- form FRM_OUTPUT
- ALV
- form FRM_OUTPUT
- ALV
- etc.
so when you press back you get back to previous ALV
Don't call the form in the USER_COMMAND, but exit from ALV filling rs_selfield-exit and passing the r_ucomm ok code (and otgher informations required) to variable(s) of the main program, there execute again a FRM_OUTPUT when ALV memory is freed. (if you only set exit but call FRM_OUTPUT from inside ALV, that will work, but you will get every ALV stacked in memory, so less performances)
Regards,
Raymond
10-29-2009 8:39 AM
Thanks for your reply.
Should I fill rs_selfield-exit every time I call FM REUSE_ALV_LIST_DISPLAY?
Where should I execute again a FRM_OUTPUT ?
10-29-2009 8:47 AM
I suggested something like
main
DO
perform FRM_OUTPUT
if g_ucomm NE yourcode. EXIT. ENDIF.
ENDDO
form FRM_OUTPUT
execute selection
CALL ALV
form USER_COMMAND
if r_ucomm EQ yourcode
move r_ucomm to g_ucomm.
rs_selfield-exit = 'X'.
else.
clear g_ucomm.
endif.
Regards,
Raymond
10-29-2009 9:39 AM
Thank you very very much.
Would you please explain me the following code?
form USER_COMMAND
if r_ucomm EQ yourcode
move r_ucomm to g_ucomm.
rs_selfield-exit = 'X'.
else.
clear g_ucomm.
endif.
10-29-2009 9:46 AM
if r_ucomm EQ yourcode. " when user click a "refresh" or "change selection" icon
move r_ucomm to g_ucomm. " store the volatile code to a global variable of main program
rs_selfield-exit = 'X'. " inform ALV to end, program will continue after CALL FUNCTION or equivalent
else. " else
clear g_ucomm. " clear the global code, so main program wont react when standard exit (F3, F12)
endif.
Regards,
Raymond