Skip to Content
-1

How i can go back to the correct screen

Mar 05 at 10:42 AM

89

avatar image

Hello All,

I have a transaction that uses several screens, these screens contains a button to exit , when you press it , it just returns to the previous screen, I tried to implement a solution to return to the initial screen, but the problem is that the initial transaction can be one of two (ZTEST1 or ZTEST2), how to distinguish cases using a single button?
WHEN 'EXIT'

Call transaction 'ZTEST1'
OR

Call transaction 'ZTEST2'
I am looking for a place where SAP stores the calling transaction, so that I call it.
ZTEST1 -> ZMytransaction -> screen 1 -> screen 2 -> .. -> screnn N
ZTEST2 -> ZMytransaction -> screen 1 -> screen 2 -> .. -> screnn N

when i exit from N screen, how can i know where to come back? ZTEST1 OR ZTEST2?

NB: I already thought to put two different buttons for the two transactions but it is not optimal

Thanks in advance ,

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Raymond Giuseppi
Mar 05 at 12:45 PM
0

If every PAI user command module look like

WHEN 'NEXTSCREEN'.
  CALL SCREEN nnnn.
  LEAVE TO SCREEN 0.
WHEN 'BACK'. " Not on initial dynpro of transaction
  LEAVE TO SCREEN 0.

or even

WHEN 'NEXTSCREEN'.
  LEAVE TO SCREEN nnnn.
WHEN 'BACK'. " Not on initial dynpro of transaction
 LEAVE TO SCREEN 0.

Your problem should be solved. (sequence of LEAVE SCREEN til initial one)

Show 4 Share
10 |10000 characters needed characters left characters exceeded

In my case i have

WHEN 'NEXTSCREEN'.
LEAVE TO SCREEN nnnn.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
But it returns just in previous screen not the initial one.
I think the problem is that initial transaction is called from a different program.

0

Put some data in memory to set that transaction was called from another transaction and not from menu, in this case, the first dynpro of called transaction should trigger a LEAVE PROGRAM when back from called screen.

0
Raymond Giuseppi

I Used a IMPORT from memory or a GET PARAMETER in the INITIALIZATION block, and an EXPORT or SET PARAMETER in the calling program.)
But the import parameter is empty !

0
Raymond Giuseppi

Could you convert this comment into an answer, because it's a different answer, not related to screens, and I'd like to vote for it :)

0
Aris van Mazijk Mar 05 at 10:57 AM
0

Maybe check variable SY-TCODE for current transaction?

IF sy-tcode = 'ZTEST1'.
CALL SCREEN....
ELSEIF sy-tcode = 'ZTEST2'.
CALL SCREEN...
ENDIF.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hey Aris
In the current sy-tcode it will return 'ZMytransaction' .

0

What happens if you use statement EXIT TO SCREEN 0? Does it return to your initial screen?

0

it returns to the previous screen not the initial one
for example ,

ZTEST2 -> ZMytransaction -> screen 1 -> screen 2 -> .. -> screnn N

if you use LEAVE TO SCREEN 0 in screen 2 , it returns to screen 1

0
Raymond Giuseppi
Mar 06 at 12:35 PM
0

If SET PARAMETERs weren't passed to called transaction, many many developpers and SAP would get into trouble, check your code.

Share
10 |10000 characters needed characters left characters exceeded