Application Development and Automation 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: 
Read only

Report

Former Member
0 Likes
988

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
961

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

12 REPLIES 12
Read only

dani_mn
Active Contributor
0 Likes
961

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

Read only

Former Member
0 Likes
961

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

Read only

0 Likes
961

Hi Suresh,

I need column heading dynamically.

Regards,

Read only

Former Member
0 Likes
962

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

Read only

0 Likes
961

'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,

Read only

0 Likes
961

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

Read only

0 Likes
961

Hi Friends,

Thanks to all. It is working now.

Regards,

Mark k

Read only

Former Member
0 Likes
961

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

Read only

Former Member
0 Likes
961

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.

Read only

Former Member
0 Likes
961

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

Read only

Former Member
0 Likes
961

Hi,

Do not forget to reward points to usefull answers.

i have not seen any comments for answers.

Regards,

Suresh

Read only

0 Likes
961

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,