matinal:SAP ABAP7.40 新语法-内表操作表达式达式

2023-10-26 14:28:12 浏览数 (1)

代码语言:javascript复制
*使用新语法,如果没找到则会抛出异常CX_SY_ITAB_LINE_NOT_FOUND
"Read Table index
"before
READ TABLE itab INDEX idx INTO wa.
"740
wa = itab[ idx ].

"Read Table using key
"before
READ TABLE itab INDEX idx USING KEY key INTO wa.
"740
wa = itab[ KEY key INDEX idx ].

"Read Table with key
"before
READ TABLE itab WITH KEY col1 = … col2 = … INTO wa.
"740
wa = itab[ col1 = … col2 = … ].

"Read Table with key components
"before
READ TABLE itab WITH TABLE KEY key COMPONENTS col1 = … col2 = … INTO wa.
"740
wa = itab[ KEY key col1 = … col2 = … ].

"Does record exist?
"before
READ TABLE itab … TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
  …
ENDIF.
"740
IF line_exists( itab[ … ] ).
    …
ENDIF.

"Get table index
"before
DATA idx type sy-tabix.
READ TABLE … TRANSPORTING NO FIELDS.
idx = sy-tabix.
"740
DATA(idx) = line_index( itab[ … ] ).

0 人点赞