Tuesday, June 23, 2009

Structure Enhancements and Unicode Programs

Since Release 3.0, the ABAP Dictionary structures and database tables that are delivered by SAP can be subsequently enhanced with Customizing-Includes or append structures. Such changes cause problems in unicode programs if the enhancement changes the unicode fragment view.

For this reason, the option to classify structures and database tables was introduced, which makes it possible to recognize and handle problems related to structure enhancements. This classification is used during the program check to create a warning at all points where it works with structures, and where later structure enhancements can cause syntax errors or changes in program behavior. When you define a structure or a database table in the ABAP Dictionary, you can specify the enhancement categories that are displayed in the following table as classification.

Level Category Meaning
1 Not classified The structure does not have an enhancement category.
2 Cannot be enhanced The structure may not be enhanced.
3 Can be enhanced and character-type All structure components and their enhancements have to be character-type flat.
4 Can be enhanced and character-type or numeric. All structure components and their enhancements have to be flat.
5 Any enhancements All structure components and their enhancements can have any data type.

The warnings displayed after the program check - depending on the effects of the structure enhancements that are permitted - are classified into three levels from the following table.

Level Type of Check Meaning
A Syntax check An enhancement that fully utilizes the enhancement category of the relevant structure. It leads to a syntax error.
B Extended check Permitted enhancements can, but do not always have to, result in a syntax error.
C Extended check Permitted enhancements cannot result in syntax errors, although changes to program behavior do result in semantic problems.

Example

If the structure ddic_struc in the ABAP Dictionary is defined only with flat components but is classified as Any enhancements, then the following program section leads to a warning during the syntax check. If the structure were enhanced by a deep component after the program was delivered, the program would be syntactically incorrect and no longer executable. This is why in this case you either have to classify the structure ddic_struc in the ABAP Dictionary as Can be enhanced and character-type or else you cannot specify the offset/length in the program.

DATA: my_struc TYPE ddic_struc,
str TYPE string,
off TYPE i,
len TYPE i.
...
str = my_struc+off(len).

No comments:

Blog Archive