New ABAP Syntax

Inline Declaration – In a read statement

Similar to the select statement, it is one of the most used inline declaration statements. Here I will give an example of each – reading the data in a work area and in field symbol.

Without inline declaration


DATA: s_matdoc TYPE ty_matdoc.

READ TABLE t_matdoc INTO s_matdoc with KEY ebeln = lv_ebeln.

Instead, with inline declaration you can write


READ TABLE t_matdoc INTO DATA(ls_matdoc) with KEY ebeln = lv_ebeln.

The work area will automatically take the structure of the internal table.

Now an example of inline declaration with field symbol.


READ TABLE t_matdoc ASSIGNING FIELD-SYMBOL(<lfs_matdoc>) WITH KEY ebeln = lv_ebeln.

Most of the time, we want local variables for read, so it is beneficial even to use the inline declaration.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share