[ABAP] ABAP New Syntax / New OPEN SQL


🌝 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.
    

Categories:

SAP/ABAP