Today to learn about the inner table expression after ABAP 7.4 syntax:
SELECT * FROM mara INTO TABLE @DATA(gt_mara)
UP TO 10 ROWS. DATA gt_mara_sort TYPE SORTED TABLE OF mara WITH UNIQUE KEY primary_key COMPONENTS matnr.
"旧语法
DATA LV_MATKL TYPE MARA-MATKL. READ TABLE GT_MARA INDEX 1 INTO DATA(LS_MARA).
READ TABLE gt_mara_sort INTO DATA(ls_mara_sort1) The INDEX . 1 the USING KEY primary_key .
The READ TABLE gt_mara_sort the INTO the DATA ( ls_mara_sort2 ) the WITH KEY MATNR = 'AT001' . The IF SY-SUBRC is the EQ of 0. The LV_MATKL = LS_MARA_SORT2-MATKL. ENDIF.
" New Syntax the DATA (LS_MARA_NEW) = GT_MARA [ . 1 ].
the DATA ( ls_mara_sort1_new ) = gt_mara_sort1 [ KEY primary_key the INDEX . 1 ] .
"if gt_mara_sort according matnr been sorted according to the binary search
DATA ( ls_mara_sort2_new ) = gt_mara_sort2 [MATNR = 'AT001' ] .
DATA (LV_MATKL_NEW) = GT_MARA_SORT2 [MATNR = 'AT001'] -MATKL.
"Check whether there is some data
"Old Syntax
the READ TABLE gt_mara TRANSPORTING NO the FIELDS the WITH KEY MATNR = 'AT001' .
" New Syntax CHECK line_exists (gt_mara [matnr = ' AT001']).
" Obtained line data table including the " old syntax the DATA lv_tabix the TYPE SY- TABIX. The READ TABLE gt_mara NO TRANSPORTING the FIELDS the WITH KEY MATNR = ' AT001 ' . The IF SY-SUBRC the EQ 0 . Lv_tabix = SY- TABIX. ENDIF . " New syntax the DATA (lv_tabix_new) = line_index (gt_mara [MATNR = ' AT001 ' ]).
Note: If the data does not exist when matnr = 'AT001' when the GT_MARA performed directly
The DATA (LS_MARA ) = GT_MARA [MATNR = 'AT001'] .
Causes the program to dump, it is generally written in the following way:
ASSIGN gt_mara[ matnr = 'AT001' ] TO FIELD-SYMBOL(<fs>). IF sy-subrc EQ 0. * ... ENDIF.
- TAB Learning Technologies love life