2007 Feb 02 7:10 AM
Hi Experts
I have Two internal table itab1,itba2
itab1
MATNR Material no
ZZSTWRT Currency field
Itab2
MATNR Material no
ZZSTWRT Currency field
In both internal table Material field are SAME but currency field may be DIFFERERNCE
I have to display what Difference currency amount between two tables..
How to subtract between two tables ..give me logic idea
output lfollowing ike this..
Material Value itab1 : Material Value tabb2 :currency difference between two tables
2007 Feb 02 7:14 AM
HI,
Use the following code.
Loop at itab1 into wa_1.
read table itab2 into wa_2with key matnr = wa_1-matnr .
diff = wa_2-ZZSTWRT - wa_1-ZZSTWRT.
write: diff.
endloop.
Regards,
Sesh.
2007 Feb 02 7:14 AM
sort itab1.
sort itab2.
loop at itab1.
read table itab2 binary search with key matnr = itab1-matnr.
itab3-matnr = itab2-matnr.
itab3-diff = itab1-ZZSTWRT - itab2-ZZSTWRT.
append itab3.
endloop.kishan negi
2007 Feb 02 7:14 AM
Write code as below:
DATA: d_ZZSTWRT like ZZSTWRT.
Loop at itab1.
Read table itab2 with key matnr = itab1-matnr.
d_ZZSTWRT = itab1-ZZSTWRT - itab2-ZZSTWRT.
write : / itab1-ZZSTWRT, itab2-ZZSTWRT, p_ZZSTWRT.
Endloop.
2007 Feb 02 7:15 AM
Hi,
loop at itab1 and read itab2
subtract the amount and move the same to a variable
modify the itab1 or it_final transporting the amount
Regards
Shiva
2007 Feb 02 7:15 AM
LOOP AT itab1.
LOOP AT itab2 where matnr = itab1-matnr.
curr = itab1-curr - itab2-curr.
WRITE:/ itab1-matnr,
itab2-matnr,
curr.
ENDLOOP.
ENDLOOP.Try similarly.
2007 Feb 02 7:16 AM
use logic like this -
loop at itab1.
read table itab2 with key MATNR = itab1-MATNR.
if sy-subrc = 0.
itab-difference = abs( itab1-ZZSTWRT - itab2-ZZSTWRT ).
append itab.
endif.
endloop.
amit
2007 Feb 02 7:18 AM
try this...
loop at it1.
read table it2 with key MATNR = it1-MATNR.
if sy-subrc = 0.
it-difference = it1-ZZSTWRT - it2-ZZSTWRT.
append it.
endif.
endloop.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |