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

itab chk

Former Member
0 Likes
848

hi,

i have itab1-belnr , bukrs , wrbtr and

itab2-belnr, bukrs , wrbtr.

i want to chk if itab1-belnr = itab2-belnr

then deduct wrbtr and kept in itab1 like,

itab1-wrbtr = (itab1-wrbtr) - (itab2-wrbtr)

how can i do this . can any one gide me?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
832

Hi Santosini,

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY BELNR = ITAB1-BELNR.

IF SY-SUBRC = 0.

itab1-wrbtr = itab1-wrbtr - itab2-wrbtr.

MODIFY ITAB1.

ENDIF.

ENDLOOP.

THANKS ARJUN

hi,

i have itab1-belnr , bukrs , wrbtr and

itab2-belnr, bukrs , wrbtr.

i want to chk if itab1-belnr = itab2-belnr

then deduct wrbtr and kept in itab1 like,

itab1-wrbtr = (itab1-wrbtr) - (itab2-wrbtr)

how can i do this . can any one gide me?

6 REPLIES 6
Read only

Former Member
0 Likes
832

hi,

data:ind like sy-tabix.

loop at itab1.

ind = sy-tabix.

read table itab2 with key belnr = itab1-belnr.

if sy-subrc eq 0.

itab1-wrbtr = (itab1-wrbtr) - (itab2-wrbtr)

modify itab1 index ind.

endif.

endloop.

Reward if helpful

Regards

Vodka.

Read only

Former Member
0 Likes
832

Hi,

loop at itab1.

clear itab2.

read table itab2 with key belnr = itab1-belnr.

if sy-subrc eq 0.

itab1-wrbtr = itab1-wrbtr - itab2-wrbtr.

modify itab1.

endif.

clear itab1.

endloop.

Regards,

Sankar.

Edited by: sankar on Mar 25, 2008 6:32 AM

Read only

Former Member
0 Likes
833

Hi Santosini,

LOOP AT ITAB1.

READ TABLE ITAB2 WITH KEY BELNR = ITAB1-BELNR.

IF SY-SUBRC = 0.

itab1-wrbtr = itab1-wrbtr - itab2-wrbtr.

MODIFY ITAB1.

ENDIF.

ENDLOOP.

THANKS ARJUN

Read only

Former Member
0 Likes
832

Hi,

do like this.


LOOP AT itab1.
  LOOP AT itab2 WHERE belnr = itab1-belnr.
    itab1-wrbtr = itab1-wrbtr - itab2-wrbtr.
  ENDLOOP.
  MODIFY itab1.
ENDLOOP.

rgds,

bharat.

Read only

Former Member
0 Likes
832

try this..

loop at itab1.

read itab2 with key belnr = itab1-belnr.

itab1-wrbtr = itab1-wrbtr - itab2-wrbtr.

modify itab1.

clear:itab1,itab2.

endloop.

Regards

Sugumar G

Edited by: Sugumar Ganesan on Mar 25, 2008 6:30 AM

Read only

Former Member
0 Likes
832

Hi,

Use this code.

sort itab2 by belnr.

loop at itab1 into wa_itab1.

read table itab2 into wa_itab2 with key wa_itab1-belnr binary

search.

if sy-subrc = 0.

wa_itab1-wrbtr = wa_itab1-wrbtr - wa_itab2-wrbtr.

modify itab1 from wa_itab1 transporting wrbtr.

endif.

endloop.

This will solve your problem i guess.

Reward points if useful.

Regards,

Sowmya.