"主要逻辑就是查询下层之前,先做数据处理。
********数据定义
DATA: a TYPE char2,
b TYPE char2,
c TYPE char2,
d TYPE char2.
DATA: BEGIN OF ty_data,
a TYPE char2,
b TYPE char2,
c TYPE char2,
d TYPE char2,
END OF ty_data.
DATA gt_data LIKE TABLE OF ty_data.
DATA gs_data LIKE ty_data.
DATA gt_data1 LIKE TABLE OF ty_data.
DATA gs_data1 LIKE ty_data.
******赋值
gs_data-a = ‘a’.
gs_data-b = ‘b’.
APPEND gs_data TO gt_data.
gs_data-a = ‘a’.
gs_data-b = ‘e’.
APPEND gs_data TO gt_data.
gs_data-a = ‘b’.
gs_data-b = ‘c’.
APPEND gs_data TO gt_data.
gs_data-a = ‘b’.
gs_data-b = ‘d’.
APPEND gs_data TO gt_data.
gs_data-a = ‘c’.
gs_data-b = ‘d’.
APPEND gs_data TO gt_data.
*********显示
WRITE : / , ‘递归前’,/.
LOOP AT gt_data INTO gs_data.
WRITE: gs_data-a , gs_data-b, /.
CLEAR gs_data.
ENDLOOP.
*******主要逻辑
LOOP AT gt_data INTO gs_data WHERE a = ‘a’.
PERFORM frm_get_data USING gs_data-b.
CLEAR gs_data.
ENDLOOP.
*****显示
WRITE : / , ‘递归后’,/.
LOOP AT gt_data1 INTO gs_data1.
WRITE: gs_data1-a , gs_data1-b,gs_data1-c,gs_data1-d, /.
CLEAR gs_data.
ENDLOOP.
&---------------------------------------------------------------------
*& Form frm_get_data
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_get_data USING b.
gs_data1-a = gs_data-a.
gs_data1-b = gs_data-b.
gs_data1-c = gs_data-c.
gs_data1-d = gs_data-d.
APPEND gs_data1 TO gt_data1.
CLEAR gs_data1.
LOOP AT gt_data INTO gs_data where a = b…
PERFORM frm_get_data USING gs_data-b.
ENDLOOP.
ENDFORM.