Sunday, December 12, 2021

Internal Table Expressions in ABAP 7.4

In this Post will show you what operation we can perform in Internal table in ABAP 7.4 New Syntax.

➢While reading data from Internal table, if records not found in Internal table then it through dump, To avoid dump we used TRY and CATCH to capture the exceptions. But If you don't want to use TRY and CATHC then we have another option we can used OPTIONAL key to avoid dump.

➤ Read data from Internal table based on Index.
Before 7.4
READ TABLE lt_vbak INTO ls_vbak INDEX 1.
IF sy-subrc EQ 0.

ENDIF.

After 7.4
TRY.
    DATA(ls_vbaklt_vbak[ ].
  CATCH cx_sy_itab_line_not_found .
ENDTRY.

➣If you don't want to use TRY and CATCH then use below syntax: 

DATA(ls_vbakVALUE #lt_vbak[ OPTIONAL ).


➤ Read data from Internal table with key.
 Before 7.4
READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln ls_vbap-vbeln
                                         erdat ls_vbap-erdat.
IF sy-subrc EQ 0.

ENDIF.

➢ After 7.4
TRY.
    DATA(ls_vbaklt_vbak[ vbeln ls_vbap-vbeln
                             erdat ls_vbap-erdat  ].
  CATCH cx_sy_itab_line_not_found.
ENDTRY.

OR
DATA(ls_vbakVALUE #lt_vbak[ vbeln ls_vbap-vbeln
                                  erdat ls_vbap-erdat ] OPTIONAL ).

➤ Records exist in internal table.
 Before 7.4
READ TABLE lt_vbak INTO ls_vbak TRANSPORTING
          NO FIELDS WITH KEY vbeln ls_vbap-vbeln.
IF sy-subrc EQ 0.

ENDIF.

➢ After 7.4
IF line_existslt_vbak[ vbeln ls_vbap-vbeln ] ).

ENDIF.

➤ Get the Index number from Internal table 
 Before 7.4
READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln ls_vbap-vbeln.
IF sy-subrc EQ 0.
  lv_index sy-tabix.
ENDIF.

➢ After 7.4
DATA(lv_indexline_indexlt_vbak[ vbeln ls_vbap-vbeln ] ).

No comments:

Post a Comment

SALV 8: Adding Custom PF STATUS in ALV

Note: First create Custom PF Status using below Link: https://sapabapc.blogspot.com/2022/08/create-custom-pf-status.html *&-------------...