cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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

View Entire Topic
Sandra_Rossi
Active Contributor
0 Likes

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

  1. ZPROGRAM1 (Screen 400)
  2. In PAI, a normal button does Call Transaction (which calls ZPROGRAM2). A breakpoint is defined after Call Transaction, you don't stop at it when leaving ZPROGRAM2 and your question is why?

ZPROGRAM2

  1. Selection screen. You press the standard Execute.
  2. In START-OF-SELECTION (or AT SELECTION-SCREEN?) there is a CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' which displays a screen with ALV.
  3. You press Back in the ALV Grid screen, it calls the subroutine defined for the USER_COMMAND event of the ALV Grid, you execute LEAVE TO CURRENT TRANSACTION, which makes you go back to the selection screen.
  4. NB: there is no stop at the breakpoint after REUSE_ALV_GRID_DISPLAY. LEAVE TO CURRENT TRANSACTION restarts the program ZPROGRAM2.
  5. You then press back in the selection screen, and you go back to the SAP menu instead of ZPROGRAM1.
  6. Why?

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.

saurabh_shukla4
Explorer
0 Likes

@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.

Sandra_Rossi
Active Contributor
0 Likes
You didn't understand. You have to fix the code when leaving the ALV (LEAVE TO CURRENT TRANSACTION), to solve the problem when you're leaving the selection screen. Please try the code and debug as I explained, you will understand.
saurabh_shukla4
Explorer
0 Likes

@ulrich_mhrke

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.

Sandra_Rossi
Active Contributor
0 Likes
You didn't give any debug details, did you? As I said, you can see by debug that after leaving the selection screen, you go back to ZPROGRAM1 directly after CALL TRANSACTION 'ZUPLOADRPA' in the PAI of the screen 400, and after the PAI of the screen 400 it goes to the PBO of the screen 400 and displays it. If not, please explain what you see during your debug.