‎2007 Aug 29 1:11 PM
hallow
i have 2 difrent tables (itab_1,itab_2)with fields from a1....a12 and i wont to divide all the fields from itab_1 and itab_2 and put them in itab 3
what is the best way to do that
i give example
itab1
a1--a2-a3---a4.....
10--20-30---40
itab2
b1--b2b3---b4......
2----2--4-----5
<b>itab3 <----
result of divide fileds c1=a1/b1</b>
c1--c2c3---c4......
5----10-7.5--8
Regards
<b>i reward</b>
‎2007 Aug 29 1:16 PM
Hi!
If you don't have keys in the tables, but the lines are exatly in the same row, then you could use this way:
LOOP AT it1.
READ TABLE it2 INDEX sy-tabix.
CLEAR it3.
it3-c1 = it1-a1 / it2-b1.
it3-c2 = it1-a2 / it2-b2.
...
APPEND it3.
ENDLOOP.
Regards
Tamá
‎2007 Aug 29 1:15 PM
HI,
do like this.
loop at itab1.
read table itab2 index sy-index.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c2 = itab1-a2 / itab2-b2.
itab3-c3 = itab1-a3 / itab2-b3.
itab3-c4 = itab1-a4 / itab2-b4.
append itab3.
endloop.
reward if helpful
rgds,
bharat.
‎2007 Aug 29 1:16 PM
Hi!
If you don't have keys in the tables, but the lines are exatly in the same row, then you could use this way:
LOOP AT it1.
READ TABLE it2 INDEX sy-tabix.
CLEAR it3.
it3-c1 = it1-a1 / it2-b1.
it3-c2 = it1-a2 / it2-b2.
...
APPEND it3.
ENDLOOP.
Regards
Tamá
‎2007 Aug 29 1:21 PM
data: my_tabix like sy-tabix.
loop at itab1.
my_tabix = sy-tabix.
read table itab2 index my_tabix.
if sy-subrc eq 0.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c1 = itab1-a1 / itab2-b1.
....
append itab3
endif.
endloop.
Reward points if useful, get back in case of query...
Cheers!!!
Message was edited by:
Tripat Pal Singh
‎2007 Aug 29 1:29 PM
Try this,
loop at t_a.
read TABLE t_b index sy-index.
t_c-c1 = t_a-a1 / t_b-b1.
t_c-c2 = t_a-a2 / t_b-b2.
t_c-c3 = t_a-a3 / t_b-b3.
append t_c.
ENDLOOP.
Regards,
Vimal
‎2007 Aug 29 1:37 PM
Forget everything,
Just use:
DIVIDE-CORRESPONDING ITAB1 BY ITAB2.
Plz reward if u find it useful
‎2007 Aug 29 1:42 PM
Hi
loop at itab1.
my_tabix = sy-tabix.
read table itab2 index my_tabix.
if sy-subrc eq 0.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c1 = itab1-a1 / itab2-b1.
....
append itab3
endif.
endloop.reward if usefull
‎2007 Aug 29 2:05 PM
Hi
or try like this
LOOP AT itab1.
READ TABLE itab2 INDEX sy-tabix.
itab3-c1 = itab1-a1 / itab2-b1.
itab3-c2 = itab1-a2 / itab2-b2.
itab3-c3 = itab1-a3 / itab2-b3.
itab3-c4 = itab1-a4 / itab2-b4.
APPEND itab3.
CLEAR itab3
ENDLOOP.reward if useful