SAP ABAP SYNTAX FOR DATA PART FIVE

Continued from syntax for data part four.

Variant 2

DATA f(len).

Additions


As for variant 1

Effect

Creates the field f in the length len .

You can use this variant only for fields of type C , N , P and X . Any other field types must have their standard lengths (see table under effect of variant 1).

The lengths allowed depend on the field type:

Type
Allowed lengths


C
1 - 65535
N
1 - 65535
P
1 - 16
X
1 - 65535

Note

Each byte can contain (one character or) two decimal or hexadecimal digits. Since one place in type P fields is reserved for the sign, a type P field of length 3 can contain 5 digits, whereas a type X field of length 3 can hold 6 digits. Both have an output length of 6.

Variant 3

DATA: BEGIN OF rec,
...
END OF rec.

Effect

Defines the field string rec which groups together all the fields defined for the field string rec between " BEGIN OF REC " and " END OF rec ". Each field carries the prefix " rec- ". Field strings can be nested to any depth. See Data objects .
When a field string needs the same fields as an already defined field string in addition to its own fields, you can include these fields in the field string with INCLUDE STRECTURE . If no additional fields are needed, it is better to use LIKE .

Example

DATA: BEGIN OF PERSON,
        NAME(20) VALUE 'May',
        AGE TYPE I,
      END   OF PERSON.
PERSON-AGE  = 35.
 
The field PERSON-NAME now contains the contents "May".
 DATA: BEGIN OF PERSON1,
        FIRSTNAME(20) VALUE 'Michael'.
        INCLUDE STRUCTURE PERSON.
DATA  END   OF PERSON1.

Notes

  • If you list a field string as a field, this field (" rec ") is type C , but you should not use a field string like a field, if the field string contains number fields (i.e. type I , F or F ). The length of rec is derived from the sum of the lengths of all components of rec . However, since some fields (for example, to the limit of a word), they include padding fields that also contribute to the overall length of rec ; for this reason, you cannot use the lengths of fields that occur before a particular field string component to calculate its offset to the start of the field string.
  • On the other hand, you can guarantee that two fields with the same structure always have the same structure (even where padding fields are concerned). This means that you can compare and assign fields directly below each other (with MOVE , IF , etc.) and do not have to work field by field (e.g. with MOVE-CORRESPONDING ).
    INCLUDE s are aligned according to maxumum alignment of their components. This applies both to INCLUDE s in ABAP/4 programs and also INCLUDE s in Dictionary structures.
  • The TABLES statement automatically defines a field string (the work area. Even the header line belonging to an internal table (see below) is a field string.

RELATED POST

No comments :

Post a Comment