1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| select 'FR04514' FRS_Company_Code,
'' FRS_Subunit_Code,
'10' Period_Type,
to_char(odt.yshipdate,'YYYYMM') Period,
'500000' Account_Code,
prs.sku Local_Material_Number,
'PCE' Unit_of_measure,
sum(odt.qtyship) Quantity,
'' Net_Sales,
yt.ycodecli Sold_to_code,
yt.ycodecli Customer_number,
ps.name Customer_txt,
yt.yname Customer_txt_2,
decode(ps.pstype,1000,'4',2000,'5',null) Channel_Number,
sum(odt.ymontantfacttv) Gross_Sales,
yt.ycodecli Ship_to_code
from meidbo.ps$m ps,
meidbo.ytit$m yt,
meidbo.od$m od,
meidbo.oddt$m odt,
meidbo.pr$m pr,
meidbo.prsk$m prs
where ps.STATUS=1000 and
yt.YTOVALIDATE=0 and
yt.YSTATUS=1000 and
od.ypladistkey='001000A20' and
pr.yhistdata<>1 and
od.ordertype not in (5000,6000,8000) and
od.yorigine in (500,1000,3000,4000)
and yt.mkey=ps.ytitkey(+)
and ps.mkey=od.pskey
and od.mkey=odt.odkey
and pr.mkey=odt.prkey
and pr.mkey=prs.prkey
and to_char(odt.yshipdate,'YYYYMM')=:sMoisParam
group by
'FR04514',
'',
'10',
to_char(odt.yshipdate,'YYYYMM'),
'500000',
prs.sku,
'PCE',
'',
yt.ycodecli,
yt.ycodecli,
ps.name,
yt.yname,
decode(ps.pstype,1000,'4',2000,'5',null),
yt.ycodecli
union
select 'FR04514' FRS_Company_Code,
'' FRS_Subunit_Code,
'10' Period_Type,
to_char(odt.yshipdate,'YYYYMM') Period,
'500000' Account_Code,
prs.sku Local_Material_Number,
'PCE' Unit_of_measure,
sum(odt.qtyship) Quantity,
'' Net_Sales,
lpad(yg.ycodecli,10,0) Sold_to_code,
lpad(yg.ycodecli,10,0) Customer_number,
'' Customer_txt,
replace(yg.yname,'.','') Customer_txt_2,
'6' Channel_Number,
sum(odt.ymontantfacttv) Gross_Sales,
lpad(yg.ycodecli,10,0) Ship_to_code
from meidbo.ygro$m yg,
meidbo.od$m od,
meidbo.oddt$m odt,
meidbo.pr$m pr,
meidbo.prsk$m prs
where yg.YSTATUS=1000 and
yg.ycategory=2000 and
pr.yhistdata<>1 and
od.ordertype not in (5000,6000,8000) and
od.yorigine in (500,1000,4000)
and yg.mkey=od.ygrokey
and od.mkey=odt.odkey
and pr.mkey=odt.prkey
and pr.mkey=prs.PRKEY
and to_char(odt.yshipdate,'YYYYMM')=:sMoisParam1
group by
'FR04514',
'',
'10',
to_char(odt.yshipdate,'YYYYMM'),
'500000',
prs.sku,
'PCE',
'',
lpad(yg.ycodecli,10,0),
lpad(yg.ycodecli,10,0),
'',
yg.yname,
'6',
lpad(yg.ycodecli,10,0)
union
select 'FR04514' FRS_Company_Code,
'' FRS_Subunit_Code,
'10' Period_Type,
to_char(odt.yshipdate,'YYYYMM') Period,
'500000' Account_Code,
prs.sku Local_Material_Number,
'PCE' Unit_of_measure,
sum(odt.qtyship) Quantity,
'' Net_Sales,
lpad(yp.ycodecli,10,0) Sold_to_code,
lpad(yp.ycodecli,10,0) Customer_number,
'' Customer_txt,
replace(yp.yname,'.','') Customer_txt_2,
'6' Channel_Number,
sum(odt.ymontantfacttv) Gross_Sales,
lpad(yp.ycodecli,10,0) Ship_to_code
from meidbo.ypla$m yp,
meidbo.od$m od,
meidbo.oddt$m odt,
meidbo.pr$m pr,
meidbo.prsk$m prs
where yp.YSTATUS=1000 and
od.ypladistkey<>'001000A20' and
od.ordertype not in (5000,6000,8000) and
od.yorigine in(500,1000,2000,5000) and
pr.yhistdata<>1 and
yp.mkey=od.ypladistkey and
od.mkey=odt.odkey
and pr.mkey=odt.prkey
and pr.mkey=prs.prkey
and to_char(odt.yshipdate,'YYYYMM')=:sMoisParam2
group by
'FR04514',
'',
'10',
to_char(odt.yshipdate,'YYYYMM'),
'500000',
prs.sku,
'PCE',
'',
lpad(yp.ycodecli,10,0),
lpad(yp.ycodecli,10,0),
yp.yname,
'',
'6',
lpad(yp.ycodecli,10,0)
order by Customer_number; |
Partager