Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Submit and Return program executes Leave to Transaction

jdub67
Explorer
0 Likes
2,619

We are trying to submit RLINV050 (transaction LX26) via a custom Z program in a background job via Submit Exporting List to Memory and Return.  All works great unless RLINV050 doesn't have any results.  In that case rather than displaying an empty ALV report, it outputs a message L4-S136 and performs "LEAVE TO TRANSACTION SY-TCODE" which ends the processing of the calling Z program. 

Anyone have an ideas on how to have the Z program keep control of the process.  We are calling RLINV050 multiple times in a loop and consolidating the results, but can't do this properly when it hits the LEAVE statement.

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
1,456

I don't think we have anything on SUBMIT statement to avoid this situation.

From help on LEAVE TO TRANSACTION, :


When using LEAVE TO TRANSACTION, the current call sequence is exited completely. Upon completion of the called transaction, the runtime environment returns to the position where the first program in the call sequence was called. The current SAP LUW is thereby ended.

Probably you can write an implicit enhancement at the end of subroutine  AUSGABE to set the variable FLG_OUT = CON_TRUE when program is called in SUBMIT.

Thanks,
Naimesh Patel

We are trying to submit RLINV050 (transaction LX26) via a custom Z program in a background job via Submit Exporting List to Memory and Return.  All works great unless RLINV050 doesn't have any results.  In that case rather than displaying an empty ALV report, it outputs a message L4-S136 and performs "LEAVE TO TRANSACTION SY-TCODE" which ends the processing of the calling Z program. 

Anyone have an ideas on how to have the Z program keep control of the process.  We are calling RLINV050 multiple times in a loop and consolidating the results, but can't do this properly when it hits the LEAVE statement.

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
1,457

I don't think we have anything on SUBMIT statement to avoid this situation.

From help on LEAVE TO TRANSACTION, :


When using LEAVE TO TRANSACTION, the current call sequence is exited completely. Upon completion of the called transaction, the runtime environment returns to the position where the first program in the call sequence was called. The current SAP LUW is thereby ended.

Probably you can write an implicit enhancement at the end of subroutine  AUSGABE to set the variable FLG_OUT = CON_TRUE when program is called in SUBMIT.

Thanks,
Naimesh Patel

Read only

0 Likes
1,456

Thanks Naimesh.  I came to the same conclusion, no way to control this from our Z program without doing an enhancement.  What we ended up doing was to create 3 Z programs to do what I was hoping could be done in 1.  I didn't want to mess around with enhancement points in RLINV050 as it uses the old GET Logical Database stuff that I'm not very familiar with and the approach below is now working for us.

1st Z program

   delete all data from custom Z table

   Loop through LX26 Variants

     submit 2nd Z program via Job Open/Job Close for each unique LX26 Variant

   endloop

2nd Z Program

    Submit RLINV050 exporting list to memory and return

          (when no results this won't return because of LEAVE TO TRANSACTION,

           but that is OK because it is just for this one variant so nothing to add to Z table anyway)

    Get List

    Update Z table with consolidated data from LX26

3rd Program

    Report against Z table to show outstanding Cycle Count data across the entire company