SAP ABAP OBJECTS DIFF ASSIGNMENTS

Get Example source ABAP code based on a different SAP table
  


ARTICLE

Syntax Revisions in Statements
ABAP Code Snippet
ARTICLE

Cannot Use CLEAR WITH NULL
The statement CLEAR WITH NULL is not permitted in ABAP Objects.

Error message in ABAP Objects if the following syntax is used:

CLEAR f WITH NULL.
Correct syntax:

CONSTANTS hex(1) TYPE x VALUE IS INITIAL.
CLEAR f with hex.
Reason:

Initialization with an incompatible type must be avoided. If required, the statement CLEAR WITH NULL can be replaced by the above sequence of statements.
ABAP Code Snippet
ABAP Code Snippet
ARTICLE

Cannot Use PACK
You cannot use the PACK statement to pack character-like fields in ABAP Objects.

In ABAP Objects, the following statements cause an error message:

DATA: c1(...) TYPE c,
p1(...) TYPE p.

PACK c1 TO p1.
Correct syntax:

DATA: c1(...) TYPE c,
p1(...) TYPE p.

MOVE c1 TO p1.
Cause:

The PACK statement is superfluous, since it works just like the MOVE statement when you assign a character-like field to a packed number.
ABAP Code Snippet
ABAP Code Snippet
ARTICLE

Cannot Use the MOVE PERCENTAGE Statement
You cannot use the MOVE PERCENTAGE in ABAP Objects.

In ABAP Objects, the following statement causes an error message:

MOVE c1 TO c2 PERCENTAGE n.
Correct syntax:

DATA l TYPE i.

DESCRIBE FIELD c1 LENGTH l.
l = l * n / 100.
MOVE c1(l) TO c2.
Cause:

If necessary, you can assign a percentage of a field to another field using other statements.
ABAP Code Snippet
ABAP Code Snippet
ARTICLE

Cannot Perform Arithmetic Operations on Identically-Named StructureComponents
In ABAP Objects, you cannot use statements that perform calculations on identically-named components in two structures.

In ABAP Objects, the following statements cause an error message:

ADD-CORRESPONDING struc1 TO struc2.

DIVIDE-CORRESPONDING struc1 BY struc2.

MULTIPLY-CORRESPONDING struc1 BY struc2.

SUBTRACT-CORRESPONDING struc1 FROM struc2.

Cause:

The system performs calculations regardless of the data type of the component. Just because two components are identically named, it does not follow that the results of these calculations will be meaningful. Therefore, always program these calculations explicitly.
Note:

The same rule applies to the MOVE-CORRESPONDING statement and the INTO CORRESPONDING FIELDS of the SELECT statement. At present, these statements cannot be made illegal for practical reasons. However, you should replace MOVE-CORRESPONDING statements with explicit assignments. This also allows you to bundle and assign structure components in substructures, in both the source and the target structure. If a structure cannot contain a substructure, because it is typed with reference to a database table, you can achieve the same ABAP Code Snippet STRUCTURE | TYPE statement). At least in static cases, you should avoid the INTO CORRESPONDING FIELDS addition of the SELECT statement and replace it with explicit field name in an INTO clause, since this addition affects performance.
ABAP Code Snippet
ABAP Code Snippet
ARTICLE

No summing-up of memory positions
The variants ADD THEN ... UNTIL ... and ADD FROM ... TO ... of the statement ADD are not allowed in ABAP Objects.

In ABAP Objects an error message is issued in the following cases:

ADD f1 THEN f2 UNTIL fn GIVING sum.
Reason:

The functionality of these statements depends on the internal structure of the program's working memory. Such operations should be avoided. As an alternative, you can use the statement ASSIGN< /> with the addition INCREMENT.
ABAP Code Snippet
ABAP Code Snippet
ARTICLE

Cannot Convert Dates
The statements CONVERT DATE and CONVERT INVERTED DATE are not allowed.

An error message occurs in ABAP Objects if the following syntax is used:

CONVERT DATE f1 INTO INVERTED-DATE f2.

CONVERT INVERTED-DATE f2 INTO DATE f1.
Correct syntax:

CONSTANTS comp_nine(20) TYPE c VALUE '09182736455463728190'.

f2 = f1.
TRANSLATE f2 USING comp_nine.

f1 = f2.
TRANSLATE f1 USING comp_nine.
Reason:

Date conversions are used mainly to influence the sort direction in internal tables. This function can be replaced by the additions ASCENDING or DESCENDING of the statement SORT . If required, you can easily program the nines complement yourself using TRANSLATE.
ABAP Code Snippet