SORT gt_conth BY conno.
SORT gt_invret_if BY conno .
LOOP AT gt_conth ASSIGNING FIELD-SYMBOL(<fs_conth>).
LOOP AT gt_invret_if ASSIGNING FIELD-SYMBOL(<invret>)
WHERE conno = is_conth-conno.
"业务处理逻辑(此处不张贴无用代码)
ENDLOOP.
ENDLOOP.
2、使用排序表按INDEX 优化,同样是30000多条业务数据,耗时3秒多。效率提升非常明显
DATA:index TYPE syst_index VALUE '1'.
SORT gt_conth BY conno.
SORT gt_invret_if BY conno .
LOOP AT gt_conth ASSIGNING FIELD-SYMBOL(<fs_conth>).
LOOP AT gt_invret_if ASSIGNING FIELD-SYMBOL(<invret>) FROM index
IF <invret>-conno <> <fs_conth>-conno.
index = sy-tabix.
EXIT.
ENDIF.
"业务处理逻辑(此处不张贴无用代码)
ENDLOOP.
ENDLOOP.