ABAP HANA 751 : Inline Declaration
Inline Declaration reduces the number of lines to be written and hence reduces the effort for logic development and make maintenance easy and less costly.
The inline declaration should be an essential part of a good coding convention designed for ABAP development for S4 HANA.
Below are the most important type of Inline Declarations:
Inline Variable Declaration
ABAP HANA 751 : Inline Variable Declaration
Inline Declaration make it possible to define variables and work areas on the fly. There is no need to write a separate line for variable declaration. This construct also help to reduce lines of code.
Sample Source Code: Variant 1
Output: Variant 1
Sample Source Code: Variant 2
Output: Variant 2
Inline field-symbol declaration
ABAP HANA 751 : Inline Field-symbol Declaration
SAP ABAP 7.51 Inline Declaration make it possible to define field-symbols on the fly. There is no need to write a separate line for field-symbol declaration. This construct also helps to reduce lines of code.
Sample Source Code: Variant 1 – READ TABLE…
Output: Variant 1
Sample Source Code: Variant 2 – LOOP…
Output: Variant 2
Inline declaration in SQL
ABAP HANA 751 : Inline Field-symbol Declaration
SAP ABAP 7.51 Inline Declaration make it possible to define Internal Table, Work area and Variable on the fly from within the query. There is no need to write a separate line for Internal Table, Work area, and Variable declaration. This construct effectively helps to reduce lines of code and saves costly effort.
Declaring Variables, work areas and internal table inline in SQL statements are emerging as a good programming practice. This also gives flexibility that if in future programmer plans to select one/more field(s) in the query, in that case, there is no need to adjust internal table’s/work area’s type. This saves effort during maintenance also.
Sample Source Code: Variant 1 – Internal tables
Output: Variant 1
No comments:
Post a Comment