ABAP 7.40 快速參考-內聯宣告

SAPxiao發表於2024-08-15
7.40 之前 7.40
資料
DATA text TYPE string.
text = 'ABC'.
DATA(text) = 'ABC'.
迴圈進入工作區
DATA wa like LINE OF itab.
LOOP AT itab INTO wa.
...
ENDLOOP.
LOOP AT itab INTO DATA(wa).
  ...
ENDLOOP.
呼叫方法
DATA a1 TYPE ...
DATA a2 TYPE ...

oref->meth( 
        IMPORTING p1 = a1
        IMPORTING p2 = a2 ).
oref->meth( 
        IMPORTING p1 = DATA(a1)
        IMPORTING p2 = DATA(a2) ).
分配時迴圈
FIELD-SYMBOLS: <line> type …
LOOP AT itab ASSIGNING <line>.
  ...
ENDLOOP.
LOOP AT itab
   ASSIGNING FIELD-SYMBOL(<line>).
   ...
ENDLOOP.
讀取分配
FIELD-SYMBOLS: <line> type …
READ TABLE itab
           ASSIGNING <line>.
READ TABLE itab

   ASSIGNING FIELD-SYMBOL(<line>).
選擇進入
DATA itab TYPE TABLE OF dbtab.

SELECT * FROM dbtab
         INTO TABLE itab
        WHERE fld1 = lv_fld1.
SELECT * FROM dbtab
   INTO TABLE @DATA(itab) 
        WHERE fld1 = @lv_fld1.
選擇單進
SELECT SINGLE f1 f2
  FROM dbtab
  INTO (lv_f1, lv_f2)
WHERE ... WRITE: / lv_f1, lv_f2.
SELECT SINGLE f1 AS my_f1,
              f2 AS abc
         FROM dbtab
         INTO DATA(ls_struct)
        WHERE ...

WRITE: / ls_struct-my_f1,
         ls_struct-abc.

相關文章