Skip to Content

Inline declaration… you will love it!

Release 7.40 has some great news, one of them is something that impacts day-to-day coding agility : inline declaration.

What about use a variable without going to the top of your program and declaring it?  Yes, you can do it, especially if you are working locally (inside a code block) and not going to use it anywhere else.

A simple text variable:

DATA(text) = ‘Hello’.

OK, this is not a big deal.. since you may use a declaration like that:

DATA text TYPE string VALUE ‘Hello’.

But a really helpful one is when using Field-Symbols:


Or even better, within SQL statements:

SELECT carrname AS name, carrid AS id
       FROM   scarr
       INTO TABLE @DATA(result).

Looking foward to use it in a day-to-day basis! 🙂

You must be Logged on to comment or reply to a post.
  • Hi

    Good feature ,

    I Have One Doubt in the above SELECT statement..that  you are using @(ITAB) ..

    without mention WHERE Condition …

    What will be the Statement when we want to use WHERE Condition..



    • you can use where condition as before. In my example would be

      SELECT carrname AS name, carrid AS id
             FROM   scarr
             INTO TABLE @DATA(result)

             WHERE carrid EQ ‘001’.

      The only difference is adding comma (,) between selected fields and @ to variables at condition, e.g.:

             WHERE carrid EQ @lv_carrid.

      This is an old post… I’m proud to now use it on my daily coding! 😉