Optimize Ranges

ranges: rng_vbelv for vbfa-vbelv.

*&---------------------------------------------------------------------*
*&      Form  OPTIMIZE_RANGE
*&---------------------------------------------------------------------*
form optimize_range.
data:    lv_lvbelv like vbfa-vbelv,   "önceki
lv_nvbelv like vbfa-vbelv,   "yenisi
lv_vbelv  like vbfa-vbelv,   "yenisi
lv_aralik(1),                "aralık
lv_ltabix like sy-tabix,
lv_ntabix like sy-tabix.

sort rng_vbelv.
clear: lv_lvbelv, lv_nvbelv, lv_aralik.
loop at rng_vbelv.
lv_ntabix = sy-tabix.
lv_nvbelv = rng_vbelv-low.
lv_vbelv = lv_nvbelv - 1.
*    condense lv_vbelv.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input  = lv_vbelv
importing
output = lv_vbelv.

if lv_lvbelv is not initial and lv_lvbelv eq lv_vbelv.
lv_ltabix = lv_ntabix - 1.
read table rng_vbelv index lv_ltabix.
rng_vbelv-option = 'BT'.
rng_vbelv-high   = lv_nvbelv.
modify rng_vbelv index lv_ltabix.
delete rng_vbelv index lv_ntabix.
lv_lvbelv = lv_nvbelv.
continue.
endif.
lv_lvbelv = lv_nvbelv.
endloop.
describe table rng_vbelv lines sy-index.
endform.                    " OPTIMIZE_RANGE

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.