ECC版本11年文档写了一个,现在因为语法升级,再写一下
https://wenku.baidu.com/view/18315332a32d7375a4178010
现在就不解释加注释了,show一下新语法就行了。
report yabap_750_intable.
"内表定义新方式:
types:begin of ty_1,
name type string,
value type string,
end of ty_1.
data: itab1 type table of ty_1.
"单条:
itab1 = value # ( name = 'mark' value = 'ABAP' ).
"多条:
itab1 = value # ( ( name = 'mark' value = 'ABAP' )
( name = 'mark' value = 'Python' )
).
"定义新内表(不含原有内表数据) append
data(itab2) = value ty_1 ( ( name = 'mark' value = 'ABAP' )
( name = 'mark' value = 'Python' )
).
"定义新内表(含原有内表数据) append
data(itab2) = value # ( base itab1 ( name = 'mark' value = 'JAVA' )
( name = 'mark' value = 'Ruby' )
).
"按条件取值(read table)
data(wa_read) = itab2[ value = 'JAVA' ]
"按条件取值(read table)optional 换成default后面加结构
data(wa_read) = itab2[ value = 'GO' optional ]
"按条件判断(read table)
if line_exists( itab1[ name = 'mark' ] ).
wrtie: / 'It is exists.'.
endif.
"按条件定位(read table)
data(lv_index) = line_index( itab1[ name = 'mark' ] ).
"值修改(替换modify intab和assgin)
itab1[ name = 'mark' ]-name = 'MARK'.
cl_demo_output->display( itab1 ).
又说我没写够300字啊~
有些觉得不怎么会用的新语法发现在有些重构中原厂应用了,
尤其是在比如以前比较慢的流程中,虽然不知道会快多少,但是APO的重写代码中由一开始就这样,那么,就对于读取原厂代码就比较重要了(简单的算法级代码)。
data(l_red) = reduce i ( init sum = 0 for i = 1 | until i > 10 next sum = sum i ) .
write: l_red.