Show TOC

Program Statements to Leave a Called ProgramLocate this document in the navigation structure

Usually, the user exits a program you called using SUBMIT... AND RETURN by choosing F3 or F15 on list level 0 of the called program.

However, if you need to execute further statements before returning to the called program (for example, to place data in ABAP memory using the EXPORT statement), you need to modify the user interface of the called program. For example, you can define your own function code for the Back function and process it in the AT USER-COMMAND event. After you have written your additional statements, you can leave the called program using the LEAVE statement.

LEAVE.

statement. Control then returns to the point from which the program was called.

Tip

REPORT demo_programm_leave NO STANDARD PAGE HEADING.

DATA: itab TYPE TABLE OF i,      num TYPE i.

SUBMIT demo_program_rep3 AND RETURN.

IMPORT itab FROM MEMORY ID 'HK'.

LOOP AT itab INTO num.  WRITE / num.ENDLOOP.

TOP-OF-PAGE.  WRITE 'Report 1'.  ULINE.

This program calls the following executable program (report):

REPORT  demo_program_rep3 NO STANDARD PAGE HEADING.

DATA: number TYPE i,      itab TYPE TABLE OF i.

SET PF-STATUS 'MYBACK'.

DO 5 TIMES.  number = sy-index.  APPEND number TO itab.  WRITE / number.ENDDO.

TOP-OF-PAGE.  WRITE 'Report 2'.  ULINE.

AT USER-COMMAND.  CASE sy-ucomm.    WHEN 'MBCK'.      EXPORT itab TO MEMORY ID 'HK'.      LEAVE.  ENDCASE.

In the self-defined status MYBACK, the function code MBCK is assigned to the function keys F3and F15:

If the user chooses Backon the interface MYBACK, the system transfers Table itabinto the ABAP memory and then leaves demo_program_rep3. In demo_programm_leave, it reads Table itabagain.