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: 

multiplying two fields of different internal tables

Former Member
0 Kudos

hi gurus,

i wanna multiply two diffent fields of two differnt internal tables. consider two internal tables to be it_ckis and it_marm. now i wanna multiply it_ckis-menge with it_marm-umrez and divide by it_marm-umren.

this is my current reqiuirement.

Thanks in advance,

Regards,

alson.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
loop at it_ckis.
   read table it_marm with key field1 eq it_ckis-field1.
   if sy-subrc eq 0.
      v_temp = it_ckis-menge * it_marm-umrez.
      v_temp = v_temp / it_marm-umren.
   endif.
endloop.
7 REPLIES 7

Former Member
0 Kudos
loop at it_ckis.
   read table it_marm with key field1 eq it_ckis-field1.
   if sy-subrc eq 0.
      v_temp = it_ckis-menge * it_marm-umrez.
      v_temp = v_temp / it_marm-umren.
   endif.
endloop.

Former Member
0 Kudos

hi

do a nested looping and then multiply the fields based on the common key..

for example:


LOOP AT IT_CKIS.
  LOOP AT IT_MARM WHERE (keyfield) = IT_CKIS-(keyfield).
    (variable) = ( IT_CKIS-MENGE * IT_MARM-UMREX ) / IT_MARM-UMREN.
    IT_CKIS-(field) = (variable).
    MODIFY IT_CKIS.
  ENDLOOP.
ENDLOOP.

OR


LOOP AT IT_CKIS.
  READ TABLE IT_MARM WITH KEY (keyfield) = IT_CKIS-(keyfield).
  IF SY-SUBRC EQ 0.
    (variable) = ( IT_CKIS-MENGE * IT_MARM-UMREX ) / IT_MARM-UMREN.
    IT_CKIS-(field) = (variable).
    MODIFY IT_CKIS.
  ENDIF.
ENDLOOP.

hope this helps...

thx

pavan

former_member181962
Active Contributor
0 Kudos

loop at it_ckis.

read table it_marm with kye matnr = it_ckis-matnr.

if sy-subrc = 0.

if not it_marm-umren is initial.

v_value = it_ckis-menge * ( it_marm-umrez / it_marm-umren ).

endif.

endif.

endloop.

Regards,

Ravi

navin_khedikar2
Contributor
0 Kudos

HI

Loop at it_ckis

READ TABLE it_marm INTO (wa) WITH KEY () whatever u mention)

variable = ( it_ckis-menge * it_marm-umrez ) / it_marm-umren

modfy table (where u have to store)

endloop.

**Please reward suitable points***

With Regards

Navin Khedikar

Former Member
0 Kudos

loop at it_ckis .

read table it_marm with key matnr = it_ckis .

if sy-subrc = 0.

it_ckis-menge = ( it_ckis -menge * it_marm-umrez ) / it_marm-umren.

endif.

write : it_ckis-menge.

"or you can modify it_ckis.

endloop.

regards

shiba dutta

Former Member
0 Kudos

Hi,

<b>loop at it_ckis.

var = sy-tabix.

read table it_mam var with key (use a key field which having in both da tables) v_temp = it_ckis-menge * it_marm-umrez.

v_temp = v_temp / it_marm-umren.

endif.

endloop.</b>

0 Kudos

I have the same problem but this code is a littlebit outdated. Can someone give me an answer in the new syntax?