ABAPASSIGN_INCREMENT - ASSIGN INCREMENT
CL_GUI_FRONTEND_SERVICES - Frontend Services ABAP Short ReferenceThis documentation is copyright by SAP AG.
ASSIGN INCREMENT
Variant 6
ASSIGN f INCREMENT n TO <fs>.
Additions
1. ... CASTING ... or
2. ... RANGE r
Effect
Increments the field symbol <fs>, starting from f, by n times the length off. You cannot use offset/length addressing in f. If the system cannot assign fto the field symbol - that is, if it addresses an invalid memory area - the field symbol remains unchanged and sy-subrc is set to 4.
See Assigning Fields to Field Symbols.
- SY-SUBRC = 0:
- The field was assigned successfully.
- SY-SUBRC = 4:
- The field was not assigned successfully. the field symbol
- remains unchanged
Example
DATA: cf(26) TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz'.
FIELD-SYMBOLS: <fs> TYPE c.
ASSIGN cf(2) TO <fs>.
DO 5 TIMES.
WRITE <fs>.
ASSIGN <fs> INCREMENT 3 TO <fs>.
ENDDO.
In this example, the field symbol points to the first two characters of the field cf. Then ineach loop pass, the field symbol is incremented 3 times 2 characters. The system then displays the result: ab gh mn st yz.
Example
TYPES: BEGIN OF comp,
f1 TYPE string,
f2 TYPE i,
END OF comp.
DATA: BEGIN OF stru,
k1 TYPE comp,
k2 TYPE comp,
k3 TYPE comp,
k4 TYPE comp,
END OF stru.
FIELD-SYMBOLS:
ASSIGN stru-k1 TO
DO 4 TIMES.
...
ASSIGN
ENDDO.
This example shows you how to edit a sequence of identically-typed sub-structures in a loop.
Exceptions
For more information on the exceptions that can be raised by the ASSIGN statement, see ASSIGN Exceptions.
Related
Fill RESBD Structure from EBP Component Structure BAL Application Log Documentation
This documentation is copyright by SAP AG.
Length: 3364 Date: 20120518 Time: 192216 triton ( 83 ms )






