P_ChmlCmplMktReqAndCov is a Composite CDS View in SAP S/4HANA. It reads from 4 data sources (ehfndv_cci_mcvrg, ehfndv_cci_mreq, ehfndv_cci_mreq, ehfndv_cci_prod) and exposes 13 fields. It has 2 associations to related views.
@AbapCatalog:
{
sqlViewName: 'PCCMKTREQCOV',
compiler.compareFilter: true
}
--Access Control: Authorizations Checks
@AccessControl:
{
authorizationCheck: #NOT_REQUIRED
}
--Client Handling of the view@ClientHandling.algorithm: #SESSION_VARIABLE
--VDM view type
@VDM.viewType: #COMPOSITE@VDM.private: true/*----------------------------------------------------------------------------------------------------------------------
Market requests with corresponding market coverages and product assignment for later calculations
------------------------------------------------------------------------------------------------------------------------*/defineview P_ChmlCmplMktReqAndCov
as/*----------------------------------------------------------------------------------------------------------------------
Selectall market requests and coverages for the unpackaged product
------------------------------------------------------------------------------------------------------------------------*/selectfrom ehfndv_cci_mreq as _MarketRequest
association [0..*] to ehfndv_cci_mcvrg as _MarketCoverage on _MarketRequest.chmlcmplncinfouuid = _MarketCoverage.chmlcmplncinfouuid
and _MarketRequest.country = _MarketCoverage.country
// dummy constant selection to avoid issues withcase statement with constants (notnull-preserving topic)
association [1..1] to P_ChmlCmplConstants as _Constants on _Constants.Constant1 = _Constants.Constant1
{
key _MarketRequest.chmlcmplncinfouuid as chemicalcomplianceuuid,
_MarketRequest.country as country,
// to be able to summarize the values later, the 0 values must also be returned
//request
casewhen _MarketRequest.chmlcmplncprodnisreqd = 'X' then _Constants[inner].Constant1
when _MarketRequest.chmlcmplncprodnisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncprodnisreqd isnullthen _Constants[inner].Constant0 // chmlcmplncprodnisreqd isnot set --> Request isnot processed for sales allowed
endas ProductionRequested,
casewhen _MarketRequest.chmlcmplncsalesisreqd = 'X' then _Constants[inner].Constant1
when _MarketRequest.chmlcmplncsalesisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncsalesisreqd isnullthen _Constants[inner].Constant0 // chmlcmplncsalesisreqd isnot set --> Request isnot processed for sales allowed
endas SalesRequested,
//coverage
casewhen _MarketCoverage.chmlcmplncprodnallwd = 'X' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd = 'N' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd = 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd <> 'N' and _MarketCoverage.chmlcmplncprodnallwd <> 'X' and _MarketCoverage.chmlcmplncprodnallwd <> 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd isnullthen _Constants[inner].Constant0 // chmlcmplncprodnallwd isnot set --> Request isnot processed for sales allowed
endas ProductionProcessed,
casewhen _MarketCoverage.chmlcmplncsalesallwd = 'X' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd = 'N' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd = 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd <> 'N' and _MarketCoverage.chmlcmplncsalesallwd <> 'X' and _MarketCoverage.chmlcmplncsalesallwd <> 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd isnullthen _Constants[inner].Constant0 // chmlcmplncsalesallwd isnot set --> Request isnot processed for sales allowed
endas SalesProcessed,
//unprocessed
casewhen _MarketRequest.chmlcmplncprodnisreqd = 'X' thencasewhen _MarketCoverage.chmlcmplncprodnallwd = 'X' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd = 'N' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd = 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd <> 'N' and _MarketCoverage.chmlcmplncprodnallwd <> 'X' and _MarketCoverage.chmlcmplncprodnallwd <> 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd isnullthen _Constants[inner].Constant1 // chmlcmplncprodnallwd isnot set --> Request isnot processed for sales allowed
endwhen _MarketRequest.chmlcmplncprodnisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncprodnisreqd isnullthen _Constants[inner].Constant0
endas ProductionUnprocessed,
casewhen _MarketRequest.chmlcmplncsalesisreqd = 'X' thencasewhen _MarketCoverage.chmlcmplncsalesallwd = 'X' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd = 'N' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd = 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd <> 'N' and _MarketCoverage.chmlcmplncsalesallwd <> 'X' and _MarketCoverage.chmlcmplncsalesallwd <> 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd isnullthen _Constants[inner].Constant1 // chmlcmplncsalesallwd isnot set --> Request isnot processed for sales allowed
endwhen _MarketRequest.chmlcmplncsalesisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncsalesisreqd isnullthen _Constants[inner].Constant0
endas SalesUnprocessed
}
/*----------------------------------------------------------------------------------------------------------------------
Selectall market coverages specific for the packaged product (market requests are always for the unpackaged product)
------------------------------------------------------------------------------------------------------------------------*/unionallselectfrom ehfndv_cci_mreq as _MarketRequest
innerjoin ehfndv_cci_prod as _ProductAssignment on _MarketRequest.chmlcmplncinfouuid = _ProductAssignment.chmlcmplncinfouuid
innerjoin ehfndv_cci_mcvrg as _MarketCoverage on _ProductAssignment.chmlcmplncinfouuid = _MarketCoverage.chmlcmplncinfouuid
and _MarketRequest.country = _MarketCoverage.country
// dummy constant selection to avoid issues withcase statement with constants (notnull-preserving topic)
association [1..1] to P_ChmlCmplConstants as _Constants on _Constants.Constant1 = _Constants.Constant1
{
key _MarketRequest.chmlcmplncinfouuid as chemicalcomplianceuuid,
_MarketRequest.country as country,
// to be able to summarize the values later, the 0 values must also be returned
//request
casewhen _MarketRequest.chmlcmplncprodnisreqd = 'X' then _Constants[inner].Constant1
when _MarketRequest.chmlcmplncprodnisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncprodnisreqd isnullthen _Constants[inner].Constant0 // chmlcmplncprodnisreqd isnot set --> Request isnot processed for sales allowed
endas ProductionRequested,
casewhen _MarketRequest.chmlcmplncsalesisreqd = 'X' then _Constants[inner].Constant1
when _MarketRequest.chmlcmplncsalesisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncsalesisreqd isnullthen _Constants[inner].Constant0 // chmlcmplncsalesisreqd isnot set --> Request isnot processed for sales allowed
endas SalesRequested,
//coverage
casewhen _MarketCoverage.chmlcmplncprodnallwd = 'X' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd = 'N' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd = 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd <> 'N' and _MarketCoverage.chmlcmplncprodnallwd <> 'X' and _MarketCoverage.chmlcmplncprodnallwd <> 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd isnullthen _Constants[inner].Constant0 // chmlcmplncprodnallwd isnot set --> Request isnot processed for sales allowed
endas ProductionProcessed,
casewhen _MarketCoverage.chmlcmplncsalesallwd = 'X' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd = 'N' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd = 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd <> 'N' and _MarketCoverage.chmlcmplncsalesallwd <> 'X' and _MarketCoverage.chmlcmplncsalesallwd <> 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd isnullthen _Constants[inner].Constant0 // chmlcmplncsalesallwd isnot set --> Request isnot processed for sales allowed
endas SalesProcessed,
//unprocessed
casewhen _MarketRequest.chmlcmplncprodnisreqd = 'X' thencasewhen _MarketCoverage.chmlcmplncprodnallwd = 'X' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd = 'N' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd = 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncprodnallwd <> 'N' and _MarketCoverage.chmlcmplncprodnallwd <> 'X' and _MarketCoverage.chmlcmplncprodnallwd <> 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncprodnallwd isnullthen _Constants[inner].Constant1 // chmlcmplncprodnallwd isnot set --> Request isnot processed for sales allowed
endwhen _MarketRequest.chmlcmplncprodnisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncprodnisreqd isnullthen _Constants[inner].Constant0
endas ProductionUnprocessed,
casewhen _MarketRequest.chmlcmplncsalesisreqd = 'X' thencasewhen _MarketCoverage.chmlcmplncsalesallwd = 'X' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd = 'N' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd = 'R' then _Constants[inner].Constant0
when _MarketCoverage.chmlcmplncsalesallwd <> 'N' and _MarketCoverage.chmlcmplncsalesallwd <> 'X' and _MarketCoverage.chmlcmplncsalesallwd <> 'R' then _Constants[inner].Constant1
when _MarketCoverage.chmlcmplncsalesallwd isnullthen _Constants[inner].Constant1 // chmlcmplncsalesallwd isnot set --> Request isnot processed for sales allowed
endwhen _MarketRequest.chmlcmplncsalesisreqd <> 'X' then _Constants[inner].Constant0
when _MarketRequest.chmlcmplncsalesisreqd isnullthen _Constants[inner].Constant0
endas SalesUnprocessed
}