Sie sind auf Seite 1von 3

FIELD SYMBOLS:

Generally we use the explicit work area to process the internal table like appending and modifying the
records. We can reduce the time and improve the performance of the program by using the field
symbols.

Field symbols are similar to de-referenced pointers in C. While using the field symbols system uses the
same memory allocated to that particular field in the record instead of moving it to work area and
processing which increases the performance. No need to use the append or modify statements.

Data : it_bseg type standard table of bseg.


Field-symbols: <I_bseg> like line of it_bseg.

Loop at it_bseg assigning <I_bseg>

Endloop.

TYPE ANY:

Field symbols of type ANY are used when the type of the data that would be assigned to it is not known.
And the Type assignment is carried out during run time.

If we do not specify the type, the field symbol inherits all of the technical attributes of the field assigned
to it. If we specify the type, the system checks the compatibility of the field symbol and the field we are
assigning to it during the ASSIGN statement.

Field symbols accessing by component name:

LOOP AT lt_1 ASSIGNING <ls_1>.

ASSIGN COMPONENT lv_field OF STRUCTURE <ls_1> TO <lv_field>.

CHECK <lv_field> IS ASSIGNED.

WRITE: / <lv_field>.
ENDLOOP

Subroutines:
There are two types of subroutines in sap abap.

1. Local Subroutines
2. External SUbroutines.

Local Subroutines :
These are the subroutines in which definition(perform) and implementation(Form) are available in the
same program.

External Subroutines:

Subroutines which contains definition and implementation are available in different programs are called
as external subroutines. The implemented program must be of type Sub-routine pool.

Passing values with subroutines:

There are three ways to pass the values to the subroutines.

1. Pass by reference
2. Pass by value
3. Pass by value and return

Pass By reference:

In this type, the actual and formal parameters are referred to the same memory. If the formal
parameter is changes, the actual parameter will also get change.

Actual parameters are the parameters which we use in definition I.e at the time of Perform statament.
Formal Parameters are the parameters which we use at the time of implementation I.e, at the time of
FORM statements.

PERFORM subr USING a.

FORM subr USING a.


….
ENDFORM.

Pass By Value:

In this type the actual and formal parameters will be referring to separate memories. If the formal
parameter is changed, the actual parameter will not be changed.
The keyword VALUE() will identify that it is pass by value else it is pass by reference.
PERFORM subr USING VALUE(A).

Pass By Value and Return:

In this type, the actual and formal parameters will be referring to separate memories. If the formal
parameter is changed, the actual parameter is also changed after executing the FORM...ENDFORM.

The key word CHANGING( ) will identify that it is pass by value else it is pass by reference.
Passage Description Advantages
Method
By reference Passes a pointer to the original memory location. Very efficient
By value Allocates a new memory location for use within the subroutine. Prevents changes to
The memory is freed when the subroutine ends. passed variable
By value and Similar to pass by value, but the contents of the new memory is Allows changes and
result copied back into the original memory before returning. allows a rollback

Das könnte Ihnen auch gefallen