Code: Alles auswählen.
define view Zcds_Rs_Fauf with parameters lv_datum : erdat,
lv_timestamp : CMIG_TIMESTAMP,
lv_zaehl : char1,
lv_sttxt : co_sttxt,
lv_gltrp : co_gltrp
as select from afko as afko
inner join aufk as aufk
on aufk.aufnr = afko.aufnr
inner join afpo as afpo
on afpo.aufnr = afko.aufnr
inner join marc as marc
on marc.matnr = afpo.matnr
and marc.werks = afpo.dwerk
left outer join mbew as mbew
on mbew.matnr = afpo.matnr
and mbew.bwkey = afpo.dwerk
left outer join Zcds_Rs_Jest as jest
on jest.objnr = aufk.objnr
{
afko.mandt,
afko.aufnr,
afpo.posnr,
cast (:lv_datum as datum) as datum ,
cast (:lv_timestamp as cmig_timestamp) as timestamp,
cast (:lv_zaehl as char01) as zaehl,
aufk.aenam,
aufk.aedat,
afko.gltrp,
afpo.ltrmi,
afko.gstrp,
afko.gstri,
afko.dispo,
afko.fevor,
afpo.meins,
afpo.matnr,
afpo.psmng,
case
when mbew.peinh > 0
then afpo.psmng * mbew.stprs / mbew.peinh
end as pswert,
afpo.wemng,
(cast(afpo.psmng as zrsmeng) - cast(afpo.wemng as zrsmeng)) as zrsmeng,
cast (afpo.wewrt as zrswert) as zrswert,
afpo.uebto,
afpo.untto,
afpo.lgort,
cast(:lv_sttxt as co_sttxt) as sttxt,
afpo.elikz,
aufk.loekz,
afpo.xloek,
afpo.dwerk,
afpo.dauat,
afpo.wewrt,
aufk.waers,
afko.ftrms,
afko.gltrs,
afko.gstrs,
afko.ftrmi,
case
when jest.stat = 'I0012'
then 'X'
when jest.stat = 'I0045'
then 'X'
when jest.stat = 'I0046'
then 'X'
else ''
end as jest
}
where afko.gltrp < :lv_gltrp
and aufk.loekz = ' '
and aufk.idat2 = '00000000'
and afpo.elikz = ' '
and afpo.xloek = ' '