abap简单实现form递归
Posted south-wall
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了abap简单实现form递归相关的知识,希望对你有一定的参考价值。
需求:根据物料号查询下层物料清单
DATA LV_MATNR LIKE ZMARA_TEST-MATNR VALUE ‘000000000000000001‘.
DATA: LT_MAT LIKE TABLE OF ZMARA_TEST.
PERFORM FRM_MULTIPLY USING LV_MATNR.
BREAK-POINT.
FORM FRM_MULTIPLY USING P_LV_MATNR LIKE ZMARA_TEST-MATNR.
DATA: LT_MAT_TEMP LIKE TABLE OF ZMARA_TEST, "必须定义局部变量,每层变量之间不共享
LS_MAT_TEMP LIKE ZMARA_TEST.
SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_MAT_TEMP
FROM ZMARA_TEST
WHERE ZMATNR = P_LV_MATNR.
IF LT_MAT_TEMP IS NOT INITIAL.
LOOP AT LT_MAT_TEMP INTO LS_MAT_TEMP.
APPEND LS_MAT_TEMP TO LT_MAT.
PERFORM FRM_MULTIPLY USING LS_MAT_TEMP-MATNR. "form递归,循环调用本身
ENDLOOP.
ENDIF.
ENDFORM.
效果展示
以上是关于abap简单实现form递归的主要内容,如果未能解决你的问题,请参考以下文章
通过阶乘的例子,练习在JavaScript, Scala和ABAP里实现尾递归(Tail Recursion)