New Syntax of reading internal table

1

ABAP  New Syntax of reading internal table with index and keys.

 

 

ABAP 7.40 release provides a new syntax to read internal table in a new way.

SCARR table entries.

3.jpg

SAMPLE CODE- KEY READ

SELECT FROM scarr INTO TABLE @DATA(lt_scarr).
* New Syntax
DATA(ls_scarrlt_scarr[ carrid ‘AA’ ].
* Old way of reading table
“READ TABLE lt_scarr INTO ls_spfli WITH KEY carrid = ‘AA’.
IF sysubrc IS INITIAL.
  cl_demo_output=>display_datals_scarr ).
ENDIF.

OUTPUT

 

2.jpg

SAMPLE CODE - Index Read

SELECT FROM scarr INTO TABLE @DATA(lt_scarr).
* New Syntax index read
DATA(ls_scarrlt_scarr[ ].
IF sysubrc IS INITIAL.
  cl_demo_output=>display_datals_scarr ).
ENDIF.

OUTPUT

4.jpg

SPFLI table entries.

5.jpg

SAMPLE CODE- Multiple Key Read

SELECT FROM spfli INTO TABLE @DATA(lt_spfli).
* New Syntax
DATA(ls_spflilt_spfli[ carrid ‘AA’ connid ‘0017’ ].
IF sysubrc IS INITIAL.
  cl_demo_output=>display_datals_spfli ).
ENDIF.

OUTPUT

6.jpg


 

 

 

3 comments

  1. Please remove the Subrc checks after accessing the internal table.
    Example:
    TRY .
    WRITE: / t_data[ TABLE_LINE = sy-INDEX ].
    CATCH cx_sy_itab_line_not_found.
    WRITE: / ‘Not found’, sy-INDEX.
    ENDTRY.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s