matinal:SAP ABAP7.40新语法 数据声明

2023-10-26 14:27:43 浏览数 (2)

代码语言:javascript复制
"Data Statement
"before
DATA text TYPE string.
text = `ABC`.
"740
DATA(text) = `ABC`.

"Loop at into work area
"before
DATA wa like LINE OF itab.
LOOP AT itab INTO wa.
…
ENDLOOP.
"740
LOOP AT itab INTO DATA(wa).  
  …
ENDLOOP.

"Call method
"before
DATA a1 TYPE …
DATA a2 TYPE …
oref->meth( IMPORTING p1 = a1
            IMPORTING p2 = a2
          ).
"740
oref->meth(
        IMPORTING p1 = DATA(a1)
        IMPORTING p2 = DATA(a2) ).

"Loop at assigning
"before
FIELD-SYMBOLS: <line> type …
LOOP AT itab ASSIGNING <line>.
  …
ENDLOOP.
"740
LOOP AT itab
   ASSIGNING FIELD-SYMBOL(<line>).
   …
ENDLOOP.

"Read assigning
"before
FIELD-SYMBOLS: <line> type …
READ TABLE itab
           ASSIGNING <line>.
"740
READ TABLE itab
   ASSIGNING FIELD-SYMBOL(<line>).
   
"Select into table
"before
DATA itab TYPE TABLE OF dbtab.
SELECT * FROM dbtab
  INTO TABLE itab
 WHERE fld1 = lv_fld1.
"740
SELECT * FROM dbtab
  INTO TABLE @DATA(itab) 
 WHERE fld1 = @lv_fld1.
 
"Select single into
"before
SELECT SINGLE f1 f2 
  FROM dbtab
  INTO (lv_f1, lv_f2)
 WHERE …
WRITE: / lv_f1, lv_f2.
"740
SELECT SINGLE f1 AS my_f1,
              F2 AS abc  
  FROM dbtab
  INTO @DATA(ls_structure)
 WHERE …
WRITE: / ls_structure-my_f1,ls_structure-abc.

0 人点赞