RANGES:r_vbeln FOR lips-vbeln.
r_vbeln-sign = 'I'.
r_vbeln-option = 'EQ'.
LOOP AT gt_item INTO gw_item .
r_vbeln-low = gw_item-vbeln.
APPEND r_vbeln.
ENDLOOP.
DATA: line TYPE i.
SORT:r_vbeln.
DELETE ADJACENT DUPLICATES FROM r_vbeln.
IF LINES( r_vbeln ) > .
REFRESH r_vbeln.
r_vbeln-sign = 'I'.
r_vbeln-option = 'BT'.
SORT gt_item BY vbeln.
READ TABLE gt_item INTO gw_item INDEX .
r_vbeln-low = gw_item-vbeln.
CLEAR:line.
DESCRIBE TABLE gt_item LINES line.
READ TABLE gt_item INTO gw_item INDEX line.
r_vbeln-high = gw_item-vbeln.
SELECT vbeln posnr vgbel vgpos INTO TABLE gt_lips FROM lips WHERE vgbel BETWEEN r_vbeln-low and r_vbeln-high.
ELSE.
SELECT vbeln posnr vgbel vgpos INTO TABLE gt_lips FROM lips WHERE vgbel IN r_vbeln.
ENDIF.