P_LogcDocPurchaseItem is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (R_PurchasingDocumentItem) and exposes 17 fields with key fields PurchasingDocument, PurchasingDocumentItem. It has 3 associations to related views.
@AccessControl.authorizationCheck: #NOT_REQUIRED@VDM: {
private: true,
viewType: #CONSUMPTION
}@Metadata.ignorePropagatedAnnotations: truedefineviewentity P_LogcDocPurchaseItem
// asselectfrom I_PurchasingDocumentItem
// USE R_ VIEWAS WORKAROUND - SWITCH BACK TO I_ VIEW UNTIL THE PurgProdCmplncDngrsGoodsStatus IS CONTAINED
asselectfrom R_PurchasingDocumentItem
association [0..1] to I_Product as _Product on $projection.Product = _Product.Product
association [0..*] to I_ProductText as _ProductText on $projection.Product = _ProductText.Product
// needed to redefine because of different cardinality between the union views
association [0..*] to I_UnitOfMeasureText as _QuantityUnitText on $projection.OrderQuantityUnit = _QuantityUnitText.UnitOfMeasure
{
key PurchasingDocument,
key PurchasingDocumentItem,
// USE THE SAME LOGIC ASIN P_LogcDocPurchase
cast ('PO' as ehfnd_log_doc_category) as ProdCmplncLogsDocumentCategory, // Purchase Order (EHFND_LOG_DOC_CATEGORY)
// cast (
// case// when PurchasingDocumentCategory = 'F'
// then 'PO'
// endas ehfnd_log_doc_category) as ProdCmplncLogsDocumentCategory,
// use the material as the related product
@ObjectModel.text.association: '_ProductText'
Material as Product,
@Semantics.quantity.unitOfMeasure: 'OrderQuantityUnit'
OrderQuantity,
// @Semantics.unitOfMeasure: true@ObjectModel.text.association: '_QuantityUnitText'
OrderQuantityUnit,
cast ('' as classifiedasdangerousgood) as ClassifiedAsDangerousGood,
cast( '' as val_text) as ClassifiedAsDangerousGoodName,
// needed to mark the blocked logistic document items
cast (
casewhen PurgProdCmplncDngrsGoodsStatus = 'F' // Blocked – Dangerous Goods Transport Forbidden
then 'X'
when PurgProdCmplncDngrsGoodsStatus = 'H' // Partially Blocked – Dangerous Goods Transport Forbidden
then 'X'
endas boole_d) as IsBlocked,
// Associations
_ProductText,
_QuantityUnitText,
//Needed for Authorization check
@ObjectModel.readOnly: true@Consumption.hidden: true
_PurchasingDocument.PurchasingDocumentType as PurchasingDocumentType,
@ObjectModel.readOnly: true@Consumption.hidden: true
_PurchasingDocument.PurchasingOrganization as PurchasingOrganization,
@ObjectModel.readOnly: true@Consumption.hidden: true
_PurchasingDocument.PurchasingGroup as PurchasingGroup,
@ObjectModel.readOnly: true@Consumption.hidden: true
IsEndOfPurposeBlocked,
@ObjectModel.readOnly: true@Consumption.hidden: true
PurchasingDocumentCategory,
@ObjectModel.readOnly: true@Consumption.hidden: true
_PurchasingDocument.PurchasingDocumentOrigin as PurchasingDocumentOrigin,
@ObjectModel.readOnly: true@Consumption.hidden: true
Plant
}
where// use only items where the Chemical Complinace Relevant Flag istrue
_Product.IsChemicalComplianceRelevant = 'Y'
and(
PurchasingDocumentCategory = 'F'
)
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PRODUCT",
"R_PURCHASINGDOCUMENT",
"R_PURCHASINGDOCUMENTITEM"
],
"ASSOCIATED":
[
"I_PRODUCTTEXT",
"I_UNITOFMEASURETEXT"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/