Certified Material
@AbapCatalog.sqlViewName: 'zcm_cons1'
@VDM.viewType: #BASIC
define view zcm_consumption1 as select from aufm as gm
left outer join zcertified_mat as cm on cm.matnr = gm.matnr
inner join mara as m on m.matnr = gm.matnr {
key gm.aufnr,
gm.matnr,
m.mtart,
case when cm.matnr is not null then case gm.shkzg when 'H' then gm.menge else -1 * gm.menge end else 0 end as quantity_certified_material,
case gm.shkzg when 'H' then gm.menge else -1 * gm.menge end as quantity
} where bwart = '261' or bwart = '262'
ZGM_TYPES
contains the movement types. So we can integrate this table in the CDS-View.
@AbapCatalog.sqlViewName: 'zcm_cons1'
@VDM.viewType: #BASIC
define view zcm_consumption1 as select from aufm as gm
left outer join zcertified_mat as cm on cm.matnr = gm.matnr
inner join mara as m on m.matnr = gm.matnr
// workaround to prevent syntax error
inner join zgm_types as t on t.mandt = gm.mandt {
key gm.aufnr,
gm.matnr,
m.mtart,
case when cm.matnr is not null then case gm.shkzg when 'H' then gm.menge else -1 * gm.menge end else 0 end as quantity_certified_material,
case gm.shkzg when 'H' then gm.menge else -1 * gm.menge end as quantity
} where gm.bwart = t.consumption or gm.bwart = t.cancel_consumption
TVARVC
. This table is joined with the view ZCM_CONSUMPTION2
. The join replaces the hardcoded value in the where-clause.
@AbapCatalog.sqlViewName: 'zcm_cons2'
@VDM.viewType: #COMPOSITE
define view zcm_consumption2 as select from zcm_consumption1 as mc
inner join tvarvc as v on v.name = 'ZRAW_MATERIAL_TYPE' and v.type = 'P' and v.low = mc.mtart {
key mc.aufnr,
sum( quantity_certified_material ) as quantity_certified_material,
sum( quantity ) as quantity
} group by mc.aufnr
@AbapCatalog.sqlViewName: 'zcm_proc_ord'
@VDM.viewType: #CONSUMPTION
define view zcm_process_order as select from caufv as po
inner join zcm_consumption2 as c on c.aufnr = po.aufnr {
key po.aufnr,
po.werks,
po.auart,
po.autyp,
c.quantity_certified_material,
c.quantity as consumed_quantity
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
4 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 |