[ABAP] ABAP New Syntax / New OPEN SQL
30 Jun 2022 -
1 minute read
π ABAP New Syntax
π Inline Declarations
Inline Declarationμ΄λ? 미리 dataλ₯Ό μ μΈνμ§ μκ³ lineμμ μ μΈνλ λ¬Έλ²
π Data
-
Before 7.40
DATA text TYPE string. text = 'ABAP'.
-
With 7.40
DATA(text) = 'ABAP'.
π LOOP AT INTO wa
-
Before 7.40
DATA : wa LIKE LINE OF itab. LOOP AT itab INTO wa. ... ENDLOOP.
-
With 7.40
LOOP AT itab INTO DATA(wa). ... ENDLOOP.
π SELECT INTO itab
-
Before 7.40
DATA : itab TYPE TABLE OF dbtab. SELECT * FROM dbtab INTO TABLE itab WHERE field = lv_field.
-
With 7.40
SELECT * FROM dbtab INTO TABLE @DATA(itab) WHERE field = lv_field.
π Table Expressions
π READ TABLE index
-
Before 7.40
READ TABLE itab INDEX idx INTO wa.
-
With 7.40
wa = itab[ idx ].
π READ TABLE USING key
-
Before 7.40
READ TABLE itab INDEX idx USING KEY key INTO wa.
-
With 7.40
wa = itab[ KEY key INDEX idx ].
π Does Record Exist?
-
Before 7.40
READ TABLE itab ... TRANSPORTING NO FIELDS. IF sy-subrc = 0. ... ENDIF.
-
With 7.40
IF line_exists( itab[ ... ] ) ... ENDIF.
-
π‘
READ TABLE
μ΄λLOOP AT
보λ€λLINE EXISTS
λ₯Ό μ¬μ©νμ!READ TABLE LT_TEST INDEX1 TRANSPORTING NO FIELDS. IF SY-SUBRC = 0. ENDIF. βββ IF LINE EXISTS( LT_TEST[ 1 ] ). ENDIF.
π Get Table Index
-
Before 7.40
DATA idx TYPE sy-tabix. READ TABLE ... TRANSPORTING NO FIELDS. idx = sy-tabix.
-
With 7.40
DATA(idx) = line_index( itab[ ... ] ).
π New OPEN SQL
π , / @
-
Before 7.40
SELECT field1 field2 FROM dbtab INTO CORRESPONDING FIELDS OF TABLE itab WHERE field1 = field1 AND field2 = field2.
-
With 7.40
SELECT field1, field2 FROM dbtab INTO CORRESPONDING FIELDS OF TABLE @itab WHERE field1 = @field1 AND field2 = @field2.