P_LogcDocFreightOrderItem is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (I_TransportationOrderItem) and exposes 16 fields with key field TransportationOrderUUID. It has 3 associations to related views.
@AccessControl.authorizationCheck: #NOT_REQUIRED@VDM: {
private: true,
viewType: #CONSUMPTION
}@Metadata.ignorePropagatedAnnotations: truedefineviewentity P_LogcDocFreightOrderItem
asselectfrom I_TransportationOrderItem
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
// needed for Auth
association [0..1] to I_TransportationOrder as _TransportationOrder on $projection.TransportationOrderUUID = _TransportationOrder.TransportationOrderUUID
{
key TransportationOrderUUID,
_TransportationOrder.TransportationOrder,
TranspOrdItem,
// USE THE SAME LOGIC ASIN P_LogcDocFreightOrder
cast (
casewhen _TransportationOrder.TransportationOrderCategory = 'TO'
then 'FO'
when _TransportationOrder.TransportationOrderCategory = 'FU'
then 'FU'
when _TransportationOrder.TransportationOrderCategory = 'BO'
then 'FB'
endas ehfnd_log_doc_category) as ProdCmplncLogsDocumentCategory,
@ObjectModel.text.association: '_ProductText'
ProductID as Product,
@Semantics.quantity.unitOfMeasure: 'OrderQuantityUnit'
TranspOrdItemQuantity as OrderQuantity,
//@Semantics.unitOfMeasure: true@ObjectModel.text.association: '_QuantityUnitText'
TranspOrdItemQuantityUnit as OrderQuantityUnit,
cast ('' as classifiedasdangerousgood) as ClassifiedAsDangerousGood,
cast( '' as val_text) as ClassifiedAsDangerousGoodName,
// needed to mark the blocked logistic document items
cast (
casewhen TranspOrdItemDngrsGdsSts = 'F' // /scmtms/dg_status - Blocked – Transport Forbidden
then 'X'
when TranspOrdItemDngrsGdsSts = 'G' // /scmtms/dg_status - Blocked – Decision Pending
then 'X'
endas boole_d) as IsBlocked,
// Associations
_ProductText,
_QuantityUnitText,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.TransportationOrderCategory as TransportationOrderCategory,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.TransportationOrderType as TransportationOrderType,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.PurchasingOrgExternalID as PurchasingOrgExternalID,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.PurchasingGroupExternalID as PurchasingGroupExternalID,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.TranspOrdResponsiblePerson as TranspOrdResponsiblePerson,
@ObjectModel.readOnly:true@Consumption.hidden: true
_TransportationOrder.TransportationMode as TransportationMode
}
where// use only items where the Chemical Complinace Relevant Flag istrue
_Product.IsChemicalComplianceRelevant = 'Y'
and(
_TransportationOrder.TransportationOrderCategory = 'TO' // Freight Orderor _TransportationOrder.TransportationOrderCategory = 'FU' // Freight Unit
or _TransportationOrder.TransportationOrderCategory = 'BO' // Freight Booking
)
and TranspOrdItemCategory = 'PRD' // Product
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PRODUCT",
"I_TRANSPORTATIONORDER",
"I_TRANSPORTATIONORDERITEM"
],
"ASSOCIATED":
[
"I_PRODUCTTEXT",
"I_UNITOFMEASURETEXT"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/