Ansicht
Dokumentation

ABAPASSIGN_COMPONENT - ASSIGN COMPONENT

ABAPASSIGN_COMPONENT - ASSIGN COMPONENT

RFUMSV00 - Advance Return for Tax on Sales/Purchases   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

ASSIGN COMPONENT

Variant 2

ASSIGN COMPONENT idx  OF STRUCTURE struc TO <fs>.

ASSIGN COMPONENT name OF STRUCTURE struc TO <fs>.

Additions

1. ... CASTING ... or
2. ... TYPE type
3. ... DECIMALS dec
4. ... RANGE r

Effect

If the field name or idx has the type C or is a substructure that does not contain an internal table, it is regarded as a component name, otherwise is is regarded as a component number. The corresponding component of the structured field struc is assigned to the field symbol <fs>.

Return Value

SY-SUBRC = 0:
Assignment successful.
SY-SUBRC = 4:
The system could not assign the field to the field symbol.

Note

If idx has the value 0, the entire structure is assigned to the field symbol.

  • Before Release 6.10, assigning structure components to field symbols was the only way of accessing components of formal parameters or field symbols if these were typed unstructured. Since Release 6.10, you can also specify componenents of unstructured typed field symbols and formal parameters. when specifying a data object dynamically.


Example

PROGRAM P1MAIN.
  DATA: BEGIN OF STR,
          A VALUE 'a',
          B VALUE 'b',
          C VALUE 'c',
          D VALUE 'd',
        END   OF STR,
        CN(5) VALUE 'D'.
  FIELD-SYMBOLS <FS> TYPE ANY.
  DO 3 TIMES.
    ASSIGN COMPONENT SY-INDEX OF
           STRUCTURE STR TO <FS>.
    IF SY-SUBRC <> 0. EXIT. ENDIF.
    WRITE <FS>.
  ENDDO.
  ASSIGN COMPONENT CN OF STRUCTURE STR TO <FS>.
  WRITE <FS>.

Output: a b c d

Exceptions


For more information on the exceptions that can be raised by the ASSIGN statement, see ASSIGN Exceptions.

Related

FIELD-SYMBOLS, UNASSIGN

Additional help

Assigning Data Objects to Field Symbols






General Material Data   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 3822 Date: 20240420 Time: 161634     sap01-206 ( 45 ms )