03-03-2007 2:29 PM
Hi,
I have a situation where material number has multiple entries(rows).
I required to show only single row output some of the respective material number quantity fields needs to be ADDED and some of the quantity should be same as a single row field value.
example :
following below code gives us output
<b>'Material' 'Quant1' 'Quant2'</b>
1000-A 10 999
1000-A 20 999
1000-B 10 700
1000-B 20 700
1000-B 30 700
but i need output in 2 lines only.
<b>'Material' 'Quant1' 'Quant2'</b>
1000-A 30 999
1000-B 60 700
i.e Quant1 values should be added and Quant2 values should remain same.
report x.
data: begin of itab occurs 0,
matnr(10) type c,
quant1(4) type c,
qunat2(4) type c,
end of itab.
itab-matnr = '1000-A'.
itab-quant1 = '10'.
itab-quant2 = '999'.
APPEND itab.
itab-matnr = '1000-A'.
itab-quant1 = '20'.
itab-quant2 = '999'.
APPEND itab.
itab-matnr = '1000-B'.
itab-quant1 = '10'.
itab-quant2 = '700'.
APPEND itab.
itab-matnr = '1000-B'.
itab-quant1 = '20'.
itab-quant2 = '700'.
APPEND itab.
itab-matnr = '1000-B'.
itab-quant1 = '30'.
itab-quant2 = '700'.
APPEND itab.
write : /10 'Material' , 30 'Quant1' , 45 'Quant2' .
loop at itab.
write : /10 itab-matnr , 30 itab-quant1 , 45 itab-quant2 .
endloop.
Any ideas?
Regards
Praveen
03-03-2007 3:13 PM
Hi,
Please try this.
...
data: wa_itab like itab.
sort itab by matnr.
loop at itab.
move itab to wa_itab.
at end of matnr.
sum.
write : /10 wa_itab-matnr , 30 itab-quant1 , 45 itab-quant2 .
endat.
endloop.
...
Regards,
Ferry Lianto
03-03-2007 2:33 PM
When you are doing loop-Endloop use AT NEW and SUM for Quant1 field,
And display there only.
Regards,
Amit
Reward all helpful replies.
03-03-2007 2:37 PM
If i use AT NEW ... right hand side values are becomming ****** values.
regards
praveen
03-03-2007 2:41 PM
Yeah they will for that you have to store the values coming before the field used in At new in the variable and then pass it into the block.
that is if u r using 3rd field of the table in at new then pass 1st and 2nd using variables.
Regards,
Amit
Check reply from Suresh and change your Quant1 field to type quantity from character.
Message was edited by:
Amit Khare
03-03-2007 2:47 PM
Amit,
I am not getting you.
do you mind modifying my simple code and showing me output.
regards
praveen
03-03-2007 2:55 PM
tr this..
data:w_mat like itab-material,
w_qt1 like itab-quant1,
w_qt2 like itab-quant2.
sort itab.
loop at itab.
w_qt1 = w_q1 + itab-quant1.
w_qt2 = itab-quant2.
at new itab-material.
write: / itab-material,w_qt1,w_qt2.
clear: w_qt1,w_qt2.
endat.
endloop.
~Suresh
03-03-2007 3:17 PM
Suersh,
with ur logic SUM value is not displaying correctly.
it is displaying 10 and 30 but my output required was 30 and 60.
regards
praveen
03-03-2007 3:18 PM
replace AT NEW with AT END OF in the code.. it should work..
~Suresh
03-03-2007 3:30 PM
03-03-2007 3:32 PM
Ferry,
it resolved my issue with your logic.
thank you.
regards
praveen
03-03-2007 3:13 PM
Hi,
Please try this.
...
data: wa_itab like itab.
sort itab by matnr.
loop at itab.
move itab to wa_itab.
at end of matnr.
sum.
write : /10 wa_itab-matnr , 30 itab-quant1 , 45 itab-quant2 .
endat.
endloop.
...
Regards,
Ferry Lianto