What is Inline Declaration?
Inline declaration in SAP ABAP meaning is to declare and initialize the data object at some time. Data object means the variable which hold the data. Data object can be any of the ABAP built in types, structures, internal tables, filed symbols, class objects etc.
Different types of inline declarations:
- Datatype declaration/Variable declaration
- Inline Internal table declaration
- Inline Work area declaration
- Inline Field symbol declaration
1. Datatype declaration/Variable declaration:
Inline declaration of sap built-in datatypes such as char, string integer etc. is known as Inline datatype declaration. We will see how each of these types are being declared from old to new way.
String declaration: Let’s see how the String variable can be declared using new ABAP Syntax – Inline declaration.
Here, in old syntax for define the string we used DATA keyword and then the assignment of value happened once after the definition. Whereas in new syntax, definition and assignment can take place with single statement.
Note: while declaring string using inline concept, must use backward quotation (` `) for the text. If you use ( ‘ ‘ ) , system understands it as a character datatype with length.
Character declarations : To declare character variable, we must use below syntax.
Note: char27 is sap standard data element for declaration character field of length 27.
Integer declaration: For declaring the integer type, we can use below syntax.
By using above syntax, we can directly declare the variables for string, character and integer. But in order to handle the syntax for packed integer (TYPE P), Dates, Time, NUMC you need to have deep understanding of remaining part of the ABAP 7.4 Syntaxes. You can check here for details: CONV Operator in ABAP 7.4Syntax.