2010 Feb 11 3:47 AM
Hi ,
I have below code..
data: lv_update_field(50).
if not it_bsid_vertn[] is initial.
sort it_bsid by vertn.
loop at it_bsid_vertn assigning <fs_bsid_vertn>.
** parallel cursor approach
clear w_index.
read table it_bsid assigning <fs_bsid> with key vertn = <fs_bsid_vertn>-vertn binary search.
if sy-subrc = 0.
w_index = sy-tabix.
loop at it_bsid assigning <fs_bsid> from w_index.
if <fs_bsid>-vertn ne <fs_bsid_vertn>-vertn.
exit.
endif.
read table it_ztrans_type_mast assigning <fs_ztrans_type_mast> with key anbwa = <fs_bsid>-anbwa
shkzg = <fs_bsid>-shkzg binary search.
if sy-subrc = 0.
concatenate 'WA_UPDATE-' <fs_ztrans_type_mast>-field_name into lv_update_field.
assign (lv_update_field) to <fs_update_amt>.
<fs_update_amt> = <fs_update_amt> + ( <fs_bsid>-dmbtr * <fs_ztrans_type_mast>-field_value ).
endif.
unassign <fs_ztrans_type_mast>.
clear lv_update_field.
** requirement for ODC calculation
move-corresponding <fs_bsid> to it_bsid_odc_l.
append it_bsid_odc_l.
endloop. what is happening is that if I have two records in it_bsid for same anbwa e.g. ZBC.. so when it comes to statement "assign (lv_update_field) to <fs_update_amt>." it overwrites the first value of ZBC. If there are 2 records of ZBC i want to sum up this value and final value i have to update dynamically in <fs_update_amt> as written through statement.
<fs_update_amt> = <fs_update_amt> + ( <fs_bsid>-dmbtr * <fs_ztrans_type_mast>-field_value ).
Is there any array like concept?? can you tell me how to overcome this ??
Regards,
Santosh
2010 Feb 11 4:12 AM
you need make unique records of your it_bsid based on the key field before going into loop
if sy-subrc = 0.
w_index = sy-tabix.
"<====== Here
loop at it_bsid assigning <fs_bsid> from w_index.
if <fs_bsid>-vertn ne <fs_bsid_vertn>-vertn.
exit.
endif.
a®