Skip to Content
0
Former Member
Jul 03, 2006 at 08:24 AM

hi friends i have problem on display of quantity for every year on each mon

18 Views

i have problem in decalring the fields .i.e quantity to every month from jan to dec in row wise and in column it should be under particular year.i have written the code but i have some doubt where i am unable to offset particular month.please give me solution where i am wrong.

report zexample1.

Tables: s997.

Types: dat(2) type p,

sal(6) type p decimals 2,

sal1(6) type p .

selection-screen begin of block b1 with frame title text-001.

select-options: werks for s997-werks,

matnr for s997-matnr,

mvgr1 for s997-mvgr1,

mvgr2 for s997-mvgr2,

mvgr3 for s997-mvgr3,

vkorg for s997-vkorg,

vtweg for s997-vtweg,

kunag for s997-pkunag.

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-002.

select-options: spmon for s997-spmon obligatory.

selection-screen end of block b2.

*selection-screen begin of block b3 with frame title text-003.

*

*parameters: day radiobutton group rg1,

  • cust radiobutton group rg1,

  • mat radiobutton group rg1.

*

*selection-screen end of block b3.

*

data: begin of sales occurs 0,

spmon type s997-spmon,

werks type s997-werks,

mvgr1 type s997-mvgr1,

mvgr2 type s997-mvgr2,

mvgr3 type s997-mvgr3,

vkorg type s997-vkorg,

vtweg type s997-vtweg,

pkunag type s997-pkunag,

UMMENGE type s997-UMMENGE,

matnr type s997-matnr,

end of sales.

data: begin of sales_cust occurs 0,

pkunag type s997-pkunag,

spmon type s997-spmon,

werks type s997-werks,

mvgr1 type s997-mvgr1,

mvgr2 type s997-mvgr2,

mvgr3 type s997-mvgr3,

vkorg type s997-vkorg,

vtweg type s997-vtweg,

end of sales_cust.

data: begin of sales_mat occurs 0,

matnr type s997-matnr,

pkunag type s997-pkunag,

sptag type s997-sptag,

werks type s997-werks,

mvgr1 type s997-mvgr1,

mvgr2 type s997-mvgr2,

mvgr3 type s997-mvgr3,

vkorg type s997-vkorg,

vtweg type s997-vtweg,

UMMENGE type s997-UMMENGE,

end of sales_mat.

data: begin of sales_mat1 occurs 0,

mvgr1 type s997-mvgr1,

matnr type s997-matnr,

pkunag type s997-pkunag,

maktx type makt-maktx,

jan type sal1,

feb type sal1,

mar type sal1,

apr type sal1,

may type sal1,

jun type sal1,

jul type sal1,

aug type sal1,

sep type sal1,

oct type sal1,

nov type sal1,

dec type sal1,

end of sales_mat1.

data: begin of sales1 occurs 0,

spmon type dat,

jan type sal,

feb type sal,

mar type sal,

apr type sal,

may type sal,

jun type sal,

jul type sal,

aug type sal,

sep type sal,

oct type sal,

nov type sal,

dec type sal,

end of sales1.

data: begin of sales_cust1 occurs 0,

pkunag type s997-pkunag,

name1 type kna1-name1,

jan type sal,

feb type sal,

mar type sal,

apr type sal,

may type sal,

jun type sal,

jul type sal,

aug type sal,

sep type sal,

oct type sal,

nov type sal,

dec type sal,

end of sales_cust1.

data: begin of sales3 occurs 0,

sptag type dat,

jan type sal,

feb type sal,

mar type sal,

apr type sal,

may type sal,

jun type sal,

jul type sal,

aug type sal,

sep type sal,

oct type sal,

nov type sal,

dec type sal,

end of sales3.

data: begin of sales2 occurs 0,

spmon type dat,

end of sales2.

data: flag type p,

jan type sal,

feb type sal,

mar type sal,

apr type sal,

may type sal,

jun type sal,

jul type sal,

aug type sal,

sep type sal,

oct type sal,

nov type sal,

dec type sal,

jan1 type sal1,

feb1 type sal1,

mar1 type sal1,

apr1 type sal1,

may1 type sal1,

jun1 type sal1,

jul1 type sal1,

aug1 type sal1,

sep1 type sal1,

oct1 type sal1,

nov1 type sal1,

dec1 type sal1,

jan2 type sal1,

feb2 type sal1,

mar2 type sal1,

apr2 type sal1,

may2 type sal1,

jun2 type sal1,

jul2 type sal1,

aug2 type sal1,

sep2 type sal1,

oct2 type sal1,

nov2 type sal1,

dec2 type sal1,

mvgr type s997-mvgr1.

start-of-selection.

select * from s997 into corresponding fields of table sales where werks

in werks and matnr in matnr and mvgr1 in mvgr1 and mvgr2 in mvgr2 and

mvgr3 in mvgr3 and vkorg in vkorg and vtweg in vtweg and pkunag in kunag

and spmon in spmon.

sort sales by spmon+4(2).

skip .

if spmon+5(2) = '03'.

loop at sales.

at end of spmon+4(2).

move sales-spmon+4(2) to sales2-spmon.

append sales2.

endat.

endloop.

sort sales2 by spmon.

loop at sales1.

at new spmon.

move sales2-spmon to sales1-spmon.

append sales1.

endat.

endloop.

sort sales1 by spmon.

loop at sales1.

loop at sales where spmon+4(2) = sales1-spmon.

case sales-spmon+4(2).

when '01'.

sales1-jan = sales1-jan + sales-ummenge.

when '02'.

sales1-feb = sales1-feb + sales-ummenge.

when '03'.

sales1-mar = sales1-mar + sales-ummenge.

when '04'.

sales1-apr = sales1-apr + sales-ummenge.

when '05'.

sales1-may = sales1-may + sales-ummenge.

when '06'.

sales1-jun = sales1-jun + sales-ummenge.

when '07'.

sales1-jul = sales1-jul + sales-ummenge.

when '08'.

sales1-aug = sales1-aug + sales-ummenge.

when '09'.

sales1-sep = sales1-sep + sales-ummenge.

when '10'.

sales1-oct = sales1-oct + sales-ummenge.

when '11'.

sales1-nov = sales1-nov + sales-ummenge.

when '12'.

sales1-dec = sales1-dec + sales-ummenge.

endcase.

endloop.

*sales1-jan = sales1-jan / 100000.

*sales1-feb = sales1-feb / 100000.

*sales1-mar = sales1-mar / 100000.

*sales1-apr = sales1-apr / 100000.

*sales1-may = sales1-may / 100000.

*sales1-jun = sales1-jun / 100000.

*sales1-jul = sales1-jul / 100000.

*sales1-aug = sales1-aug / 100000.

*sales1-sep = sales1-sep / 100000.

*sales1-oct = sales1-oct / 100000.

*sales1-nov = sales1-nov / 100000.

*sales1-dec = sales1-dec / 100000.

modify sales1.

clear sales1.

endloop.

*

*

loop at sales1.

*

*sales1-jan = sales1-jan + jan.

*sales1-feb = sales1-feb + feb.

*sales1-mar = sales1-mar + mar.

*sales1-apr = sales1-apr + apr.

*sales1-may = sales1-may + may.

*sales1-jun = sales1-jun + jun.

*sales1-jul = sales1-jul + jul.

*sales1-aug = sales1-aug + aug.

*sales1-sep = sales1-sep + sep.

*sales1-oct = sales1-oct + oct.

*sales1-nov = sales1-nov + nov.

*sales1-dec = sales1-dec + dec.

*at end of spmon.

jan = sales1-jan.

feb = sales1-feb.

mar = sales1-mar.

apr = sales1-apr.

may = sales1-may.

jun = sales1-jun.

jul = sales1-jul.

aug = sales1-aug.

sep = sales1-sep.

oct = sales1-oct.

nov = sales1-nov.

dec = sales1-dec.

*

*endat.

endloop.

endif.

write:/ 'From : ',spmon-low.

write: ' To : ', spmon-high.

*

write:/ sy-uline(162).

write: / 'Months' COLOR 3, 16 'Quantity' COLOR 4.

format color 6 intensified off.

write:/ sy-uline, 'january',11 sy-vline,12 jan , sy-vline,

/ 'february',11 sy-vline, 12 feb, sy-vline,

/'march',11 sy-vline, 12 mar,sy-vline,

/ 'april',11 sy-vline, 12 apr, sy-vline,

/ 'may',11 sy-vline, 12 may, sy-vline,

/ 'june', 11 sy-vline,12 jun, sy-vline,

/ 'july' ,11 sy-vline, 12 jul,sy-vline,

/ 'august' ,11 sy-vline, 12 aug,sy-vline,

/ 'september',11 sy-vline, 12 sep,sy-vline,

/ 'october',11 sy-vline, 12 oct, sy-vline,

/'november',11 sy-vline, 12 nov, sy-vline,

/ 'december',11 sy-vline, 12 dec, sy-vline.

format color off intensified on.

*write:/ sales1-jan , / sales1-feb,

*/ sales1-mar, / sales1-apr, / sales1-may,

  • / sales1-jun, / sales1-jul,/ ,sales1-aug,

  • / sales1-sep, / sales1-oct, /

  • sales1-nov,/ sales1-dec.

sort sales by spmon+4(2).

if spmon+5(2) = '04'.

loop at sales.

at end of spmon+4(2).

move sales-spmon+4(2) to sales2-spmon.

append sales2.

endat.

endloop.

sort sales2 by spmon.

loop at sales1.

at new spmon.

move sales2-spmon to sales1-spmon.

append sales1.

endat.

endloop.

sort sales1 by spmon.

loop at sales1.

loop at sales where spmon+4(2) = sales1-spmon.

case sales-spmon+4(2).

when '01'.

sales1-jan = sales1-jan + sales-ummenge.

when '02'.

sales1-feb = sales1-feb + sales-ummenge.

when '03'.

sales1-mar = sales1-mar + sales-ummenge.

when '04'.

sales1-apr = sales1-apr + sales-ummenge.

when '05'.

sales1-may = sales1-may + sales-ummenge.

when '06'.

sales1-jun = sales1-jun + sales-ummenge.

when '07'.

sales1-jul = sales1-jul + sales-ummenge.

when '08'.

sales1-aug = sales1-aug + sales-ummenge.

when '09'.

sales1-sep = sales1-sep + sales-ummenge.

when '10'.

sales1-oct = sales1-oct + sales-ummenge.

when '11'.

sales1-nov = sales1-nov + sales-ummenge.

when '12'.

sales1-dec = sales1-dec + sales-ummenge.

endcase.

endloop.

modify sales1.

clear sales1.

endloop.

loop at sales1.

jan = sales1-jan.

feb = sales1-feb.

mar = sales1-mar.

apr = sales1-apr.

may = sales1-may.

jun = sales1-jun.

jul = sales1-jul.

aug = sales1-aug.

sep = sales1-sep.

oct = sales1-oct.

nov = sales1-nov.

dec = sales1-dec.

endloop.

endif.

*append sales1.

*clear sales1.

format color 6 intensified off.

write: / sy-uline,22 jan , sy-vline,

/20 sy-vline, 22 feb, sy-vline,

/20 sy-vline, 22 mar,sy-vline,

/20 sy-vline, 22 apr, sy-vline,

/20 sy-vline, 22 may, sy-vline,

/20 sy-vline,22 jun, sy-vline,

/20 sy-vline, 22 jul,sy-vline,

/20 sy-vline, 22 aug,sy-vline,

/20 sy-vline, 22 sep,sy-vline,

/20 sy-vline, 22 oct, sy-vline,

/20 sy-vline, 22 nov, sy-vline,

/20 sy-vline, 22 dec, sy-vline.

format color off intensified on.

*write:/ sy-uline(162).