Passing Data by Parameters

You can pass data between calling programs and subroutines by using parameters.

You can distinguish between different kinds of parameters:

You define the parameters in the <pass> option of the FORM and PERFORM statements as follows:

Syntax

FORM <subr> [TABLES <formal table list>]
[USING <formal input list>]
[CHANGING <formal output list>]....

PERFORM <subr>[(<prog>)] [TABLES <actual table list>]
[USING <actual input list>]
[CHANGING <actual output list>]....

The options TABLES, USING, and CHANGING must be written in the shown sequence.

The parameters in the lists behind USING and CHANGING can be data objects of all types (see Declaring Data) and field symbols (see Working with Field Symbols). The parameters in the lists behind TABLES can be internal tables with or without a header line. You can transfer internal tables by using TABLES, USING, or CHANGING.

You can specify actual parameters with variable offset and length specifications (for more information about offset specifications, see Specifying Offset Values for Data Objects). You cannot do this for formal parameters. To refer to a part of the formal parameter, assign this part to a field symbol and then pass the field symbol (see Working with Field Symbols).

Offset specifications for actual parameters function as offset specifications for field symbols (see Static ASSIGN with Offset Specifications). You can select memory areas that lie outside the boundaries of the specified actual parameter.

For each formal parameter in a list behind USING and CHANGING in the FORM statement, you can specify different methods of passing data:

Passing by Reference

Passing by Value

Passing by Value and Result

Internal tables that are passed by TABLES, are always called by reference.

For information on how to specify the data types of formal parameters, see

Typing Formal Parameters

Specifying the data types of formal parameters is important for passing structured data to subroutines. How to pass structured data (field strings and internal tables) is explained especially in

Passing Structures to Subroutines

Passing Internal Tables to Subroutines