2006 Oct 27 7:08 PM
hi,
my requirement is :
i have 2 internal tables ioutput and iouput1.
iouput has matnr, minbe, labst.
there are 4 records for the same matnr with different labst.
using 'collect' i add those records to ioutput1.
so now ioutput1 has all minbe,labst added.
but i require to add just the labst's and not minbe.
-ioutput-
matnr minbe labst
1 1 1
1 1 2
1 1 3
1 1 4
-ioutput-
matnr minbe labst
1 4 10
now how do i get
-ioutput-
matnr minbe labst
1 1 10
cheers,
Aditya
2006 Oct 27 7:13 PM
Make a READ TABLE output index 1. iF sy-subrc = 0 Set MINBE to 1.
I hope this could bea the easiest way.
2006 Oct 27 7:09 PM
hi,
my requirement is :
i have 2 internal tables ioutput and iouput1.
iouput has matnr, minbe, labst.
there are 4 records for the same matnr with different labst.
using 'collect' i add those records to ioutput1.
so now ioutput1 has all minbe,labst added.
but i require to add just the labst's and not minbe.
-ioutput-
matnr minbe labst
1 1 1
1 1 2
1 1 3
1 1 4
-ioutput1-
matnr minbe labst
1 4 10
now how do i get
-ioutput1-
matnr minbe labst
1 1 10
cheers,
Aditya
2006 Oct 27 8:09 PM
You could try using "insert" instead of collect.
Example:
insert the first record of ioutput into ioutput1.
Then do a loop through the remainder of ioutput where matnr = ioutput1-matnr and minbe = ioutput1-minbe.
Inside the loop use the statement "ioutput1-labst = ioutput1-labst + ioutput-labst". Hope this helps.
- April King
2007 Mar 28 10:53 AM
Just Change the format of the field MINBE for the ioutput1 table to Character Format the field will not be taken into consideration while the collect statement is working for you.
Thanks
Anirban M.
2006 Oct 27 7:13 PM
Make a READ TABLE output index 1. iF sy-subrc = 0 Set MINBE to 1.
I hope this could bea the easiest way.
2006 Oct 28 5:24 AM
try this code....
loop at ioutput.
read table ioutput1
with key matnr = ioutput-matnr .
if sy-subrc = 0.
ioutput1-labst = ioutput-labst + ioutput1-labst .
modify ioutput1 index sy-tabix.
else.
append ioutput1.
endif.
endloop.
2006 Oct 28 6:33 AM
HI Aditya
Please see if you can acheive the same while extraction.
Eg:
select matnr minbe sum( labst )
into table it_output
from <table>
where <cond>.OR
another manipulating your internal table would be:
data: l_tabix like sy-tabix.
loop at i_output.
l_tabix = sy-tabix.
i_output1-labst = i_output1-labst + i_output-labst.
at end of matnr.
read table i_output index l_tabix.
move: i_output-matnr to i_output1-matnr,
i_output-minbe to i_output1-minbe.
append i_output1.
clear: i_output1.
endat.
endloop.Kind Regards
Eswar
2006 Oct 30 11:38 AM
Hi,
tyr this.
define 2 internal tables itab and itab2 with matnr,minbe and labst fields.
data:sum(10) type c.
*****************************
itab-matnr = 1.
itab-minbe = 1.
itab-labst = 1. SUPPOSE THIS IS YOUR INPUT DATA
append itab.
itab-matnr = 1.
itab-minbe = 1.
itab-labst = 2.
append itab.
itab-matnr = 1.
itab-minbe = 1.
itab-labst = 3.
append itab.
itab-matnr = 1.
itab-minbe = 1.
itab-labst = 4.
append itab.
****************************
sort itab by matnr.
loop at itab.
at new matnr.
sum = 0.
endat.
sum = sum + itab-labst.
itab2-matnr = itab-matnr.
itab2-minbe = itab-minbe.
itab2-labst = itab-labst.
append itab2.
at end of matnr.
write:/ itab2-matnr,itab2-minbe,sum.
endat.
endloop.
do reward points if it helps you,
Regards,
Sowjanya.
2007 May 01 7:43 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |