‎2006 Sep 20 10:41 AM
Hi friends,
I have a table with the data as following.
Item Date Qty
-
A 15.06.2006 10
B 12.06.2006 15
A 20.07.2006 25
A 25.08.2006 50
B 18.09.2006 20
Using the above table, I want a report in the following structure.
Item Jun-qty July-qty Aug-qty Sep-qty Total
A 10 25 50 -- 85
B 15 -- -- 20 35
Total 25 25 50 20 120
Could u please guide me how to do the same in a simpler way.
TIA.
Regards,
Mark K
‎2006 Sep 20 10:58 AM
sort itab by item date.
Loop at itab.
move itab-item to ioutput-item.
lmon = ldate+4(2).
select ktx into lcmon from T247
where spras = sy-langu and mnr = lmon.
concatenate 'ioutput-' lcmon '_qty' into lfield.
assign (lfield) to <f>.
collect ioutput.
endloop.
write : / 'Item '.
select single ktx into lcmon from T247
where spras = sy-langu.
concatenate lcmon '_qty' into lhead.
write lhead.
endselect.
Loop at ioutput.
write : / ioutput-item,
ioutput-Jan_qty,
.... ioutput-Dec_qty.
tot_qty = ioutput_jan_qty + ioutput-feb_qty...
ioutput-Dec_qty.
write : tot_qty.
Endloop.
Please note to stick to 3 character month defn as in the table T247. Here you just have to create an internal table with the below structure.
Begin of ioutput occurs 0,
item(10) type c,
Jan_qty(10) type n,
...
Dec_qty(10) type n,
end of ioutput.
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
‎2006 Sep 20 10:48 AM
HI,
check the logic below.
sort itab by item.
LOOP at itab.
on change of itab-item.
new-line.
write:/ itab-item.
endon.
*we are increasing the write position according to month
<b>if itab-date+2(2) = '06'.
write at 10 itab-qty.
elseif itab-date+2(2) = '07'.
write at 20 itab-qty.
elseif itab-date+2(2) = '08'.
write at 30 itab-qty.
elseif itab-date+2(2) = '09'.
write at 40 itab-qty.</b>
*total at 100 position.
at end of item.
SUM.
write at 100 itab-qty.
endat.
endif.
ENDLOOP.
REgards,
Message was edited by: HRA
‎2006 Sep 20 10:51 AM
Hi,
I have got confusion on Column Heading...<b>Is Item Jun-qty.....Total</b> is the Column Heading? If yes do want to make <b>column Heading Dynamically</b>?
Regards
Suresh
‎2006 Sep 20 11:01 AM
‎2006 Sep 20 10:58 AM
sort itab by item date.
Loop at itab.
move itab-item to ioutput-item.
lmon = ldate+4(2).
select ktx into lcmon from T247
where spras = sy-langu and mnr = lmon.
concatenate 'ioutput-' lcmon '_qty' into lfield.
assign (lfield) to <f>.
collect ioutput.
endloop.
write : / 'Item '.
select single ktx into lcmon from T247
where spras = sy-langu.
concatenate lcmon '_qty' into lhead.
write lhead.
endselect.
Loop at ioutput.
write : / ioutput-item,
ioutput-Jan_qty,
.... ioutput-Dec_qty.
tot_qty = ioutput_jan_qty + ioutput-feb_qty...
ioutput-Dec_qty.
write : tot_qty.
Endloop.
Please note to stick to 3 character month defn as in the table T247. Here you just have to create an internal table with the below structure.
Begin of ioutput occurs 0,
item(10) type c,
Jan_qty(10) type n,
...
Dec_qty(10) type n,
end of ioutput.
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
Message was edited by: Anurag Bankley
‎2006 Sep 20 1:23 PM
'collect ioutput' statment is not working. The data is getting appended instead of adding qty to the already available item.
Kindly guide me to correct this.
Regards,
‎2006 Sep 20 1:34 PM
Define the ioutput fields for Jan-Qty etc as Integer or Pack and it would work.
Otherwise you can also do is
READ TABLE ioutput with key item = itab-item.
<F> = <F> + itab-qty.
MODIDY ioutput index sy-tabix.
Message was edited by: Anurag Bankley
‎2006 Sep 21 5:54 AM
‎2006 Sep 20 11:48 AM
Hi,
Then it must be Normal Report - if you want to make ALV it is complex. Ok.
1) Make Colum Heading
Take all the months,sort and find out Name of the Months then Concatenate with Qty for each month make all the months as one line. Format as one Line according to your report output format.
So You will have
<b>Jan-Qty Feb-Qty Mar-Qty</b>
2) sort by item.
use control block statements to calculate sum item wise and grant total.
Regards,
Suresh
‎2006 Sep 20 12:16 PM
SORT ITAB BY ITEM DATE.
LOOP AT ITAB.
hi,
i think u can do like this.
SORT ITAB BY ITEM DATE.
LOOP AT ITAB.
AT NEW ITEM.
WRITE : / ITAB-ITEM.
ENDAT.
WRITE : ITAB-QTY.
ENDLOOP.
NEW-LINE.
LOOP AT ITAB.
AT LAST.
SUM.
ENDAT.
WRITE : ITAB-QTY.
ENDLOOP.
‎2006 Sep 20 12:17 PM
Hi,
1. Sort the internal table using date field,
2. use the control break statement like
at end of itab-date+3(2)
endat.
in between at and end at, u can do the calculation
if it is useful means, dont forget to give me the point
Regards
Justin
‎2006 Sep 20 12:32 PM
Hi,
Do not forget to reward points to usefull answers.
i have not seen any comments for answers.
Regards,
Suresh
‎2006 Sep 20 1:07 PM
Hi friends,
I am still working on the guidelines given by you all. Once it is through, i will reply and also points will be given.
Regards,