ranges有四个字段:sign,option,low,high.
**********************************************************************用ranges取数时,它的最大长度是9998,举例:
form frm_get_vbap_01 .
ranges: l_r_vgbel for lips-vgbel, "用于从vbak(vbap)取数
l_r_vgbel_temp for lips-vgbel. "l_r_vgbel的每9998行
data: lt_vbak_temp type table of typ_vbak,
l_len type i value 0,
l_count type i value 0, "统计loop l_r_vgbel,每次清空
l_tabix type i value 0. "统计loop l_r_vgbel,每次不清空
*---汇总交货单中的订单号
loop at gt_lips into gw_lips.
l_r_vgbel-sign = 'I'.
l_r_vgbel-option = 'EQ'.
l_r_vgbel-low = gw_lips-vgbel.
append l_r_vgbel.
endloop.
sort l_r_vgbel by low.
delete adjacent duplicates from l_r_vgbel.
l_len = lines( l_r_vgbel ).
if l_len > 9998.
loop at l_r_vgbel.
move-corresponding l_r_vgbel to l_r_vgbel_temp.
append l_r_vgbel_temp.
l_count = l_count + 1.
l_tabix = l_tabix + 1.
if l_count = 9998 or l_tabix = l_len.
clear lt_vbak_temp.
select vbeln
vkorg
into corresponding fields of table lt_vbak_temp "先选数到暂存表lt_lips_temp
from vbak
where vbeln in s_vbe_va
and vkorg in s_vkorg
and vbeln in l_r_vgbel_temp. "range的9998行
append lines of lt_vbak_temp to gt_vbak. "append to gt_vbak
*---append之后要清空
clear lt_vbak_temp.
clear l_r_vgbel_temp[].
clear l_count.
endif.
endloop.
else.
select vbeln
vkorg
into corresponding fields of table gt_vbak "gt_vbak
from vbak
where vbeln in s_vbe_va
and vkorg in s_vkorg
and vbeln in l_r_vgbel. "l_r_vgbel
endif.
endform. " FRM_GET_VBAP_01
**********************************************************************内表用range删除
data: begin of gt_01 occurs 0,
sno type i,
sname(20),
end of gt_01.
do 59999 times.
gt_01-sno = sy-index.
gt_01-sname = sy-index.
append gt_01.
enddo.
do 59998 times.
ranges: r_sno for gt_01-sno.
r_sno-sign = 'I'.
r_sno-option = 'EQ'.
r_sno-low = sy-index.
append r_sno.
enddo.
delete gt_01 where sno in r_sno."r_sno的数量没限制,至少对59998没限制
loop at gt_01.
write gt_01-sno.
endloop.
**********************************************************************range的合并
ranges: r_sno for gt_01-sno.
ranges: r_sno1 for gt_01-sno.
append lines of r_sno1 to r_sno.
评论