ARTIClE
Field Symbols, ASSIGN INCREMENT
The examples shows how the statement ASSIGN behaves when the
addition INCREMENT is used.
ABAP_SOURCE_CODE
ABAP_EXEC
ABAP_DESCRIPTION
This example shows why you should use the addition INCREMENT in
the statement ASSIGN only if you want to access sequences of
similar memory areas and that the typing of the field symbol must match
the specification made in casting_spec
. Any access which is not appropriate as shown in the example can
produce the following behavior:
The first ASSIGN statement returns the value 0 in sy-subrc
in both Unicode and non-Unicode systems. In Unicode systems,
<(>
word is assigned the associated memory area of struc-int1
and struc-int2 which assumes type c . In non-Unicode
systems, word is only assigned the memory area of
struc-int1 which assumes type c .
The second ASSIGN statement terminates with a runtime error in
both Unicode and non-Unicode systems since the data type of
struc-word does not match the typing of int .
The third ASSIGN statement terminates with a runtime error in
Unicode systems since the system tries to assign the component
struc-stri to word , and as the structure is deep and
the typing of word is flat, no casting is possible. In
non-Unicode systems, word is assigned the memory area of
struc-int2 which assumes type c .
The fourth ASSIGN statement terminates with a runtime error in
Unicode systems since the system tries to assign the component
struc-stri to int , and as the structure is deep and
the typing of int is flat, no casting is possible. In
non-Unicode systems, a runtime error occurs since the data type of
struc-word does not match the typing of int .
The fifth and the sixth ASSIGN statement both return the value 4
in sy-subrc in Unicode systems since the system tries to allocate
memory area outside the structure struc specified after RANGE
. In non-Unicode systems, a runtime error occurs since the system
tries to assign the component struc-stri to word
or int , and as the structure is deep and the typings of
word and int are flat, no casting is
possible.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved