Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

program bug...

Former Member
0 Likes
307

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

1 REPLY 1
Read only

former_member194669
Active Contributor
0 Likes
230

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®