我们赋值的时候可以 destination = source 比如 gc_d = gc_s 有时候可以看到等号前有个问好
gc_d ?= gc_s 这是因为gc_s不是一个静态类型,而是一个引用类型,而且gc_d的类型要比gc_s更加泛化一些。
更加详细内容,参见ABAP文档
Syntax
MOVE source {TO|?TO} destination.
destination {=|?=} source.
Effect
Both these statements assign the content of the operand source to the data object destination. The variants with the language element TO or the assignment operator = are valid for all assignments between operands that are not reference variables, and for assignments between reference variables for which the static type of source is more specific than or the same as the static type of destination(narrowing cast).
Variants with the language element ?TO or the assignment operator ?= (casting operator ) must be used if the source and destination are reference variables and the static type of source is more general than the static type of destination (widening cast). For assignments between operands that are not reference variables, use of the question mark ? is not permitted.
The data object destination can be any data object that can be listed at a write position, and the data object source can be a data object, a predefined function or a functional method (as of release 6.10). The data type of the data object destination must either be compatible with the data type of source, or it must be possible to convert the content of source into the data type of destination according to one of the conversion rules.
Notes
- If source and/or destination are field symbols, then, as in all ABAP commands, the system works with the content of the data objects to which the field symbols point. The actual pointer content of a field symbol can only be changed using the statement ASSIGN or the addition ASSIGNING when processing internal tables (value semantics). If source and destination are reference variables, the reference contained in source is assigned to destination (reference semantics).
- Strings and internal tables are addressed internally using references. When assignments are made between strings and between internal tables (as of release 6.10), only the reference is transferred, for performance reasons. After the assignment, the actual string or the actual table body of the source as well as the target object are addressed (sharing). When the object is accessed to change it, the sharing is canceled and a copy of the content is made. The sharing is displayed in the memory consumption display of the ABAP debugger and in the Memory Inspector tool (as of release 6.20).
- Obsolete Form: MOVE PERCENTAGE
Exceptions
Catchable Exceptions
- Cause: Operand cannot be interpreted as number
Runtime Error: CONVT_NO_NUMBER (catchable)
- Cause: Overflow with arithmetic operation (type P, with specified length)
Runtime Error: BCD_FIELD_OVERFLOW (catchable) - Cause: Operand too large or (intermediate) result too large
Runtime Error: CONVT_OVERFLOW (catchable)
- Cause: Source or target variable are not reference variables
Runtime Error: MOVE_CAST_REF_ONLY
Non-Catchable Exceptions
- Cause: Source field (type P) does not contain correct BCD format.
Runtime Error: BCD_BADDATA - Cause: Assignment for deep structures not permitted if these overlap.
Runtime Error: MOVE_COMPLEX_OVERLAP - Cause: Type conflict with the assignment between object references.
Runtime Error: MOVE_INTERFACE_NOT_SUPPORTED,
Runtime Error: MOVE_IREF_NOT_CONVERTIBLE,
Runtime Error: MOVE_IREF_TO_OREF,
Runtime Error: MOVE_OREF_NOT_CONVERTIBLE - Cause: Type conflict with the assignment between data references.
Runtime Error: MOVE_DREF_NOT_COMPATIBLE - Cause: Assignment between the types involved not supported.
Runtime Error: MOVE_NOT_SUPPORTED - Cause: Constants and literals must not be overwritten.
Runtime Error: MOVE_TO_LIT_NOTALLOWED - Cause: onstants and literals must not be overwritten.
Runtime Error: MOVE_TO_LIT_NOTALLOWED_NODATA - Cause: During a loop in an internal table, an attempt was made to overwrite a reference variable that is linked with the internal table by REFERENCE INTO.
Runtime Error: MOVE_TO_LOOP_REF
ABAP MOVE指令详解
4603

被折叠的 条评论
为什么被折叠?



