Hello experts,
I have a program (dialog program - scr 400) screen and button on the screen. It's calling another program (+ transaction) having selection screen and after execution ALV grid displayed. After performing work it should back to original calling screen having dialog program screen (400).
ZPROGRAM1 (Screen 400) -> Call Transaction - ZPROGRAM2 (+selection screen) -> ALV screen and then back with same sequence.
We have tried with, AT SELECTION SCREEN EXIT-COMMAND and leave 0 or set screen 0 but somehow it is not working. CALL SCREEN will not work since it back button is in another program which is called.
How to call previous screens which are in call stack.
Regards,
PD
Request clarification before answering.
Your issue is because you leave ZPROGRAM2 (which you call using Call Transaction) by using LEAVE TO CURRENT TRANSACTION. You don't return to ZPROGRAM1. It happens like if you had started only ZPROGRAM2 without using ZPROGRAM1.
So, in short, this is what happens after you call ZPROGRAM1 from the SAP menu (via a transaction code):
ZPROGRAM1
ZPROGRAM2
The ABAP documentation of LEAVE TO CURRENT TRANSACTION says:
If CURRENT TRANSACTION is specified, the current transaction is called using the transaction code that was used to call the transaction using CALL TRANSACTION [...] When the transaction is called, the ABAP program associated with the transaction code is loaded in a new internal session. All previous internal sessions are deleted from the stack.
If you read the chapter about internal sessions, you can see that there's a new internal session each time there is a Call Transaction or Submit And Return, so it means that both programs ZPROGRAM1 and ZPROGRAM2 are terminated, and then the transaction of ZPROGRAM2 is restarted.
Solution: instead of LEAVE TO CURRENT TRANSACTION, you have a parameter RS_SELFIELD in the subroutine of the ALV event USER_COMMAND, which you can change, it contains several possible actions like EXIT to exit the screen and go back to after REUSE_ALV_GRID_DISPLAY instead of restarting the whole program.
Your current code:
FORM user_command
USING
R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE r_ucomm.
WHEN 'EXIT'.
LEAVE TO CURRENT TRANSACTION. " <====== Very bad idea
ENDCASE.
ENDFORM.Instead of LEAVE TO CURRENT TRANSACTION, just do:
CASE r_ucomm.
WHEN 'EXIT'.
rs_selfield-exit = 'X'. " or use = abap_true
ENDCASE.You will see that you stop at the breakpoint after CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'.
PS: to better understand what was happening, you can see the effect of LEAVE TO CURRENT TRANSACTION on the call stack by activating the debug option "cross roll area stack". You will see in the call stack the numbers of the internal sessions, that the first time ZPROGRAM2 is at the level 2 (and ZPROGRAM1 is at the level 1), and after LEAVE TO CURRENT TRANSACTION you only see ZPROGRAM2 at the level 1. ZPROGRAM1 has vanished.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Sandra_Rossi I tried this change. However, Getting back from ALV to Selection is not a problem. From Selection screen of (ZSOUPLOAD) program to back to calling program is main issue. From selection screen (ZSOUPLOAD -1000 screen no) back to calling program (screen 400) is not working.
Yes you are right. I did check that and I have to add some code to come back to calling screen 400. Can you provide some tips/ help to go back to the screen? I have sequences of screens where output of the screen is based on selection of previous screen. So, It's challenging to jump directly on the screen. I do not want user to traverse again through screens 100, 200, 300 and again 400. I directly want user to land at screen 400 where he left off before.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.