Start of Content Area

Procedures  Locate the document in its SAP Library structure

Called procedures (subroutines, function modules, and methods) always run in the same internal session as the calling program.

This graphic is explained in the accompanying text‑{}‑This graphic is explained in the accompanying text

Subroutines

You call a subroutine using the

PERFORM subrc[(prog)] ...

Without the (prog) addition, the call is internal. The subroutine is in the calling program and does not have to be loaded.

If you use the (prog) addition, the call is external. The subroutine is in the program prog. When you call the subroutine, the entire program prog is loaded into the internal session of the calling program (if it has not been already). The loaded program belongs to the program group of the calling program. However, if the subroutine belongs to a function group, a new additional program group is created. The program group to which the external subroutine belongs determines the interface work areas and screens that it will use. However, this assignment can vary dynamically, so it is best to avoid using external subroutines.

Function Modules

You call function modules using the

CALL FUNCTION func ...

Function module calls are external unless a function module is called by another procedure within the same function group. When you call a function module, its entire function group is loaded into the internal session of the calling program (unless it has already been loaded). Within the internal session, the function group forms an additional program group with its own interface work areas and screens. This means that function modules provide better encapsulation of data and screens than external subroutines.

Methods

You call a method using the

CALL METHOD [ref->|class=>]meth ...

If you omit the ref or class part of the statement, the call is local within the same class. The class is not reloaded.

If you use one of the above (ref or class). the method of a particular class is called either through an object reference ref or through the class name class. When you call the method, the entire class pool is loaded into the internal session of the calling program (unless it has already been loaded). The class pool forms an additional program group in the internal session, which does not share data and screens with the caller, and from which you cannot call external subroutines.

Leaving a Called Procedure

You can leave a procedure using the

EXIT.

and

CHECK logexp.

statement.

 

 

End of Content Area