Application Development 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: 

Problem with modify command....

aarif_baig
Active Participant
0 Kudos

Hi abapers,

loop at itab.

read table ifinal with key kunnr = itab-kunnr.

if sy-subrc = 0.

move: ifinal-dmbtr to itab-dmbtr.

modify itab index sy-tabix.

endif.

endloop.

Now the problem is that when i am using modify index sy-tabix it creating an additional entry

and when i am using only modify itab its working fine so wat could be the reason that modify index sy-tabix is

not working propertly.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try with the following code


Data: lv_index type sytabix.
loop at itab.
lv_index = sy-tabix.
read table ifinal with key kunnr = itab-kunnr.
if sy-subrc = 0.
move: ifinal-dmbtr to itab-dmbtr.
modify itab index lv_index .
endif.
endloop.

Regards,

Raju.

9 REPLIES 9

Former Member
0 Kudos

Hi,

Try with the following code


Data: lv_index type sytabix.
loop at itab.
lv_index = sy-tabix.
read table ifinal with key kunnr = itab-kunnr.
if sy-subrc = 0.
move: ifinal-dmbtr to itab-dmbtr.
modify itab index lv_index .
endif.
endloop.

Regards,

Raju.

0 Kudos

thanks all of u for ur quick response,

see actually i have already solved the problem,

the only thing that i wanted to know that why is this happening...

like any reason..

0 Kudos

Hi Aarif,

When you read the internal table your SY_TABIX changes and it takes the SY_TABIX of internal table(READ) and not the Loop one.

So, by assigning SY-tabix to lv_tabix after the Loop, solves your problem.

Hope this resolves your query.

Regards,

Manish

0 Kudos

Thanks manish..

u gave me the answer wat i was looking for..

Former Member
0 Kudos

Hi Arif,

try this..

loop at itab.

read table ifinal with key kunnr = itab-kunnr.

if sy-subrc = 0.

move: ifinal-dmbtr to itab-dmbtr.

modify itab transporting dmbtr.

endif.

endloop.

alex_m
Active Contributor
0 Kudos

Hi,

The problem with your code is the right sy-tabix not used.

Try out this.

loop at itab.

read table ifinal with key kunnr = itab-kunnr.

v_index = sy-tabix.

if sy-subrc = 0.

move: ifinal-dmbtr to itab-dmbtr.

modify itab index v_index.

endif.

endloop.

Former Member
0 Kudos

Hi Aarif,

I am assuming there is one-to-one relationship between itab and ifinal.

Try using following code.

sort itab by kunnr.

sort ifinal by kunnr.

data: l_index like sy-tabix.

l_index = 1.

loop at itab.

loop at ifinal from l_index.

if ifinal-kunnr eq itab-kunnr.

move: ifinal-dmbtr to itab-dmbtr.

elseif ifinal-kunnr gt itab-kunnr.

move sy-tabix to l_index.

exit.

endif.

endloop.

modify itab transporting dmbtr.

endloop.

Regards,

Anil Salekar

Former Member
0 Kudos

assign sy-tabix value to one varaible and then use modify statement

regards,

Prajakta

Former Member
0 Kudos

Hi,

Better to use TRANSPORTING addition also..