P_PurReqAddDelivery is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (I_Purchaserequisitionitem) and exposes 12 fields with key fields PurchaseRequisition, PurchaseRequisitionItem. It has 3 associations to related views.
@AbapCatalog.sqlViewName: 'PDELIVADD'
@AbapCatalog.compiler.compareFilter: true@AccessControl.authorizationCheck: #NOT_REQUIRED@ClientHandling.algorithm: #SESSION_VARIABLE@VDM.private: true@VDM.viewType: #COMPOSITE@AbapCatalog.preserveKey:true//@ObjectModel.semanticKey:['PurchaseRequisition', 'PurchaseRequisitionItem']@ObjectModel.usageType.serviceQuality: #B@ObjectModel.usageType.sizeCategory: #L@ObjectModel.usageType.dataClass: #TRANSACTIONALdefineview P_PurReqAddDelivery
asselectfrom I_Purchaserequisitionitem as _PurReqnItem
association [0..1] to I_StorageLocationAddress as _StorageLocationAddress on $projection.Plant = _StorageLocationAddress.Plant
and $projection.StorageLocation = _StorageLocationAddress.StorageLocation
and $projection.ItemDeliveryAddressID = _StorageLocationAddress.AddressID
association [0..1] to I_Supplier as _Subcontractor on $projection.Subcontractor = _Subcontractor.Supplier
association [0..1] to I_Customer as _Customer on $projection.PurReqnReceivingCustomer = _Customer.Customer
{
key _PurReqnItem.PurchaseRequisition,
key _PurReqnItem.PurchaseRequisitionItem,
_PurReqnItem.Plant,
_PurReqnItem.StorageLocation,
_PurReqnItem.ManualDeliveryAddressID,
_PurReqnItem.ItemDeliveryAddressID,
_PurReqnItem.Subcontractor,
_PurReqnItem.PurReqnReceivingCustomer,
//Delivery Address ID
case//manual deliv address
when _PurReqnItem.ManualDeliveryAddressID <> ''
then _PurReqnItem.ManualDeliveryAddressID
//referenced other address
when _PurReqnItem.ItemDeliveryAddressID <> ''
then _PurReqnItem.ItemDeliveryAddressID
//address from supplier
when _PurReqnItem.Subcontractor <> ''
//then _Supplier.AddressID
then _Subcontractor.AddressID
//address from customer
when _PurReqnItem.PurReqnReceivingCustomer <> ''
//then _PurReqnItem.AddressID
then _Customer.AddressID
//default address from Plant and item not thrid party
when _PurReqnItem.ManualDeliveryAddressID = '' and _PurReqnItem.ItemDeliveryAddressID = ''
and Subcontractor = '' and PurReqnReceivingCustomer = '' and PurchasingDocumentItemCategory <> '5'
then _Plant.AddressID
else
''
endas DeliveryAddressID,
//Address type
casewhen _PurReqnItem.PurchasingDeliveryAddressType isnot initial
then _PurReqnItem.PurchasingDeliveryAddressType
//manual deliv address
when ManualDeliveryAddressID <> ''
thencast ( 'U' as purreqnaddrtype preserving type)
//referenced other address
when ItemDeliveryAddressID <> ''
thencasewhen ItemDeliveryAddressID = _StorageLocationAddress.AddressID
thencast ( 'L' as purreqnaddrtype preserving type)
elsecast( 'R' as purreqnaddrtype preserving type) //Reference Address
end//address from supplier
when Subcontractor <> ''
thencast ( 'S' as purreqnaddrtype preserving type)
//address from customer
when PurReqnReceivingCustomer <> ''
thencast ( 'C' as purreqnaddrtype preserving type )
//default address from Plant and item not thrid party
when ManualDeliveryAddressID = '' and ItemDeliveryAddressID = ''
and Subcontractor = '' and PurReqnReceivingCustomer = ''
and PurchasingDocumentItemCategory <> '5'
and _PurReqnItem.DeliveryAddressID <> ''
thencast ( 'P' as purreqnaddrtype preserving type)
elsecast ( 'P' as purreqnaddrtype preserving type)
endas AddressType,
_Customer.Customer,
_Subcontractor,
_Customer
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CUSTOMER",
"I_PLANT",
"I_PURCHASEREQUISITIONITEM",
"I_STORAGELOCATIONADDRESS",
"I_SUPPLIER"
],
"ASSOCIATED":
[
"I_CUSTOMER",
"I_STORAGELOCATIONADDRESS",
"I_SUPPLIER"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/