Ansicht
Dokumentation

ABAPDATA_COMMON - DATA COMMON

ABAPDATA_COMMON - DATA COMMON

General Material Data   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

DATA, COMMON PART

Short Reference



DATA BEGIN OF COMMON PART $[name$].
  ...
  DATA ...
  ...
DATA END OF COMMON PART $[name$].


Effect

This variant of the statement DATA with the additions BEGIN OF COMMON PART and END OF COMMON PART defines a global interface work area that can be used jointly by the programs of a program group. All data objects declared between these statements using DATA are part of this common area.

The addition COMMON PART can only be used in the global declaration part of an ABAP program. Multiple common data areas can be declared in a program, but they cannot be nested. Every common data area must be given a unique name using the name addition. The addition name can be omitted only if there is just one common data area in a program.

The following rules apply:

  • In all programs in a program group that declare common data areas with the same name, these areas must have identical layouts. Common data areas are hence viewed as structures whose structure fragment view must be identical and whose deep components must be compatible (pairwise). If not, the runtime error LOAD_COMMON_PART_STRUCT occurs.

Notes

  • The use of common data areas in otherwise independent programs is highly error-prone with regard to both their maintainability and their functions. Therefore, common data areas should no longer be used. The parameter interfaces of procedures are available for exchanging data between programs.
  • Common data areas for different programs are generally declared in an include program that is embedded in all programs involved. However, multiple use of include programs is no longer recommended.

Example

Declares a common data area struc in the include program part. By including the include program, the three programs param, sum and dis have shared access to the data area struc if they are part of a single program group. The latter is accomplished by loading the programs sum and disp into the program group of param using external subroutine calls. The subroutine display in the program disp outputs the input values to the program param and the result of the summation in the subroutine summing.

* INCLUDE part.
DATA: BEGIN OF COMMON PART struc,
        f1 TYPE i,
        f2 TYPE i,
        s  TYPE i,
      END OF COMMON PART struc.

PROGRAM param.
INCLUDE part.
PARAMETERS:
  p1 TYPE i DEFAULT 20,
  p2 TYPE i DEFAULT 90.
f1 = p1.
f2 = p2.
PERFORM summming IN PROGRAM sum.

PROGRAM sum.
INCLUDE part.
FORM summing.
  s = f1 + f2.
  PERFORM display IN PROGRAM disp.
ENDFORM.

PROGRAM disp.
INCLUDE part.
FORM display.
  WRITE: / f1, f2, s.
ENDFORM.







BAL Application Log Documentation   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 5015 Date: 20240329 Time: 091646     sap01-206 ( 69 ms )