New ABAP Syntax

Inline Declaration – while assigning the value to a variable

Now the compiler understands the context and define the variable by just using DATA syntax. For example:


Data: lv_ebeln type ebeln.
....
....
Data(lv_ebeln2) = lv_ebeln.

As you can see from the debugger, the new variable is same that of lv_ebeln which is of type ebeln.

Some more interesting usage.


  DATA(lv_lines) = LINES( lt_matdoc ).
  DATA(lv_String) = 'Hello World'.

However you cannot use the inline declaration while assigning values from a function module. Try this


CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input         = ls_matdoc-matnr
 IMPORTING
   OUTPUT        = Data(lv_material)

It will give a syntax error.

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