Col seguente metodo è possibile riempire qualunque tipo di range dinamicamente In questo esempio l'ho fatto attraverso un metodo di una classe, ma è estendibile anche ad una FORM.
data: lr_var type range of konp-kschl,
lr_fix type range of konp-kschl,
lv_kschl_var type konp-kschl,
lv_kschl_fix type konp-kschl.
clear: lv_kschl_var,
lv_kschl_fix.
refresh: lr_var,
lr_fix.
select parval1
from zvx_cr_params
where objid eq @zvx_cl_rebate_const=>gc_parm_obj_dc01
and param eq @zvx_cl_rebate_const=>gc_parm_qual_kwert_cond
and parval2 eq 'V'
into @lv_kschl_var. "<-Tabella Condizioni righe VARIABILI
call method me->fill_range
exporting
p_signopt = 'IEQ'
p_low = lv_kschl_var
p_high = ''
changing
pt_range = lr_var.
endselect.
IL METODO RICHIAMATO:
method fill_range.
field-symbols:
<range> type any,
<sign> type any,
<option> type any,
<low> type any,
<high> type any.
data:
lv_ref type ref to data.
check not ( p_signopt is initial and
p_low is initial and
p_high is initial ).
create data lv_ref like line of pt_range.
assign lv_ref->* to <range>.
check sy-subrc = 0.
assign component 'SIGN' of structure <range> to <sign>.
check sy-subrc = 0.
assign component 'OPTION' of structure <range> to <option>.
check sy-subrc = 0.
assign component 'LOW' of structure <range> to <low>.
check sy-subrc = 0.
assign component 'HIGH' of structure <range> to <high>.
check sy-subrc = 0.
<sign> = p_signopt(1).
<option> = p_signopt+1(2).
<low> = p_low.
<high> = p_high.
read table pt_range with key table_line = <range> binary search
transporting no fields.
check sy-subrc <> 0.
insert <range> into pt_range index sy-tabix.
endmethod.