New ABAP Syntax

Inline Declaration – In a select statement

Perhaps this is my favorite as the time saved with inline declaration is really significant and it also comes handy in maintenance and support of the program as it increases the program readability.

Without inline declaration


TYPES:  BEGIN OF ty_matdoc,
          mblnr TYPE mblnr,   "Mat Doc
          mjahr TYPE mjahr,   "Mat Year
          zeile TYPE mblpo,   "Item
          matnr TYPE matnr,   "Material
          charg TYPE charg_d, "Batch
          ebeln TYPE ebeln,   "PO
          ebelp TYPE ebelp,   "PO Item
        END OF ty_matdoc.

DATA: t_matdoc TYPE STANDARD TABLE OF ty_matdoc INITIAL SIZE 0.

SELECT     mblnr
           mjahr
           zeile
           matnr
           charg
           ebeln
           ebelp
      INTO TABLE t_matdoc
      FROM mseg
      WHERE ebeln = lv_ebeln.

With inline declaration


SELECT   mblnr,
         mjahr,
         zeile,
         matnr,
         charg,
         ebeln,
         ebelp
    INTO TABLE @DATA(lt_matdoc)
    FROM mseg
    WHERE ebeln = @lv_ebeln.

Notice the changes:

  • Comma after every field, except for last one.
  • ‘@’ Used for all variables
  • AND no need to remember the data elements for each field!! (Absolute winner)

In the custom program, due to modularization, sometimes it means that these tables will be local in nature. If I need a global table, I will go back to normal type 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