欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

用ABAP代码实现从1累加到100

程序员文章站 2024-03-23 22:06:10
...
itab = VALUE #( FOR j = 1 WHILE j <= 100 ( j ) ).
* Reduce 后面跟类型
* A constructor expression with the reduction operator 
* REDUCE creates a result of a data type specified using type 
* from one or more iteration expressions.
* At least one variable or one field symbol must be specified. The variables or field symbols declared after 
* INIT can only be used after NEXT. 
* At least one iteration expression must then be specified using FOR and it is also possible to specify multiple 
* consecutive iteration expressions.
DATA(sum) = REDUCE i( INIT x = 0 FOR wa IN itab NEXT x = x + wa ).
WRITE: / sum.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
用ABAP代码实现从1累加到100