SAP ASSIGN INCREMENT ABEXA



Get Example source ABAP code based on a different SAP table
  


ID ASSIGN-INCREMENT

Field Symbols, ASSIGN INCREMENT
The examples shows how the statement ASSIGN behaves when the addition INCREMENT is used.

ABAP_SOURCE_CODE
DEMO CL_DEMO_ASSIGN_INCREMENT

ABAP_DESCRIPTION
This example shows why the addition INCREMENT in the statement ASSIGN should be used only to access sequences of similar memory areas and that the typing of the field symbol must match the specification in casting_spec. Inappropriate access as shown in the example can produce the following behavior:
The first ASSIGN statement returns the value 0 in sy-subrc . < word> is assigned the contiguous memory area of struc-int1 and struc-int2 and this is cast to the type c.
The second ASSIGN statement terminates with a runtime error because the data type of struc-word does not match the typing of < int>.
The third ASSIGN statement terminates with a runtime error because the system tries to assign the component struc-stri to < word>, but it is deep and the typing of < word> is flat, which means that no casting is possible.
The fourth ASSIGN statement terminates with a runtime error because the system tries to assign the component struc-stri to < int>, but it is deep and the typing of < int> is flat, which means that no casting is possible.
The fifth and the sixth ASSIGN statements both return the value 4 in sy-subrc because the system tries to assign memory area outside the structure struc specified after RANGE.