@AbapCatalog.sqlViewName: 'PIBDLVPROCFLOWC'
@AbapCatalog.compiler.compareFilter: true
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #MANDATORY
@EndUserText.label: 'Inbound Delivery Process Flow Successors'
@VDM.private: true
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.dataClass: #MIXED
@ObjectModel.usageType.serviceQuality: #C
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.compositionRoot:true
// Inbound Delivery BPF: Successors of Inbound Delivery
define view P_InbDelivProcFlowChildren
// Lane 7 (Putaway): Inbound Delivery > WM Transfer Order
as select distinct from P_DeliveryProcFlowTransfOrd as WMTransferOrder // Successor WM Transfer Order
inner join I_InboundDelivery as InboundDelivery on InboundDelivery.InboundDelivery = WMTransferOrder.DeliveryDocument
association [0..1] to I_InboundDelivery as _InboundDelivery on $projection.InboundDelivery = _InboundDelivery.InboundDelivery
{
key WMTransferOrder.DeliveryDocument as InboundDelivery,
key WMTransferOrder.PrecedingDocument,
key WMTransferOrder.PrecedingDocumentCategory,
key WMTransferOrder.SubsequentDocument,
key cast('Q2' as subsequ_doc_cat) as SubsequentDocumentCategory,
cast( '' as vdm_purchaseorder) as PurchaseOrder,
WMTransferOrder.WarehouseNumber,
WMTransferOrder.WrhsMgmtTransferOrder,
cast('' as mblnr ) as MaterialDocument,
cast('0000' as mjahr) as MaterialDocumentYear,
cast('' as re_belnr) as SupplierInvoice,
cast('0000' as gjahr) as FiscalYear,
cast ('' as vbeln_vl ) as OutboundDelivery,
_InboundDelivery
}
// Lane 8 (Goods Movement): Inbound Delivery > Goods Receipt/Cancelation
union all select distinct from I_SDDocumentProcessFlow as GoodsReceipt // Successor: Goods Receipt/ Reversal Material Document
inner join I_InboundDelivery as InboundDelivery on InboundDelivery.InboundDelivery = GoodsReceipt.PrecedingDocument
left outer join P_DelivProcFlowLatestTransfOrd as WMTransferOrder on WMTransferOrder.DeliveryDocument = InboundDelivery.InboundDelivery
association [0..1] to I_InboundDelivery as _InboundDelivery on $projection.InboundDelivery = _InboundDelivery.InboundDelivery
{
key cast(GoodsReceipt.PrecedingDocument as vbeln_vl) as InboundDelivery,
key InboundDelivery.InboundDelivery as PrecedingDocument,
key InboundDelivery.SDDocumentCategory as PrecedingDocumentCategory,
key GoodsReceipt.SubsequentDocument as SubsequentDocument,
key case GoodsReceipt.SubsequentDocumentCategory
when 'R' then
case when GoodsReceipt.GoodsMovementType = ''
then
cast ('R4' as subsequ_doc_cat)
else
cast ('R2' as subsequ_doc_cat)
end
when 'h' then
case when GoodsReceipt.GoodsMovementType = ''
then
cast ('h4' as subsequ_doc_cat)
else
cast ('h2' as subsequ_doc_cat)
end
else GoodsReceipt.SubsequentDocumentCategory
end as SubsequentDocumentCategory,
cast( '' as vdm_purchaseorder) as PurchaseOrder,
cast('' as lgnum) as WarehouseNumber,
cast('0000000000' as wm_transfer_order) as WrhsMgmtTransferOrder,
GoodsReceipt.SubsequentDocument as MaterialDocument,
GoodsReceipt.MaterialDocumentYear,
cast('' as re_belnr) as SupplierInvoice,
cast('0000' as gjahr) as FiscalYear,
cast ('' as vbeln_vl ) as OutboundDelivery,
_InboundDelivery
}
where
GoodsReceipt.PrecedingDocumentCategory = '7' and
( GoodsReceipt.SubsequentDocumentCategory = 'R' or
GoodsReceipt.SubsequentDocumentCategory = 'h' ) and
WMTransferOrder.WrhsMgmtTransferOrder is null
// Lane 8 (Goods Movement): Warehouse Transfer Order -> Goods Receipt/Cancelation
union all select distinct from I_SDDocumentProcessFlow as GoodsReceipt // Successor: Goods Receipt/ Reversal Material Document
inner join I_InboundDelivery as InboundDelivery on InboundDelivery.InboundDelivery = GoodsReceipt.PrecedingDocument
and InboundDelivery.SDDocumentCategory = GoodsReceipt.PrecedingDocumentCategory
inner join P_DelivProcFlowLatestTransfOrd as LatestWMTransferOrder on LatestWMTransferOrder.DeliveryDocument = GoodsReceipt.PrecedingDocument
inner join P_DeliveryProcFlowTransfOrd as WMTransferOrder on WMTransferOrder.DeliveryDocument = LatestWMTransferOrder.DeliveryDocument
and WMTransferOrder.PrecedingDocument = LatestWMTransferOrder.DeliveryDocument
and WMTransferOrder.PrecedingDocumentCategory = GoodsReceipt.PrecedingDocumentCategory
and WMTransferOrder.SubsequentDocument = LatestWMTransferOrder.WrhsMgmtTransferOrder
and WMTransferOrder.SubsequentDocumentCategory = 'Q'
association [0..1] to I_InboundDelivery as _InboundDelivery on $projection.InboundDelivery = _InboundDelivery.InboundDelivery
{
key cast(GoodsReceipt.PrecedingDocument as vbeln_vl) as InboundDelivery,
key cast(WMTransferOrder.SubsequentDocument as preced_doc) as PrecedingDocument,
key cast('Q2' as preced_doc_cat) as PrecedingDocumentCategory,
key GoodsReceipt.SubsequentDocument as SubsequentDocument,
key case GoodsReceipt.SubsequentDocumentCategory
when 'R' then
case when GoodsReceipt.GoodsMovementType = ''
then
cast ('R4' as subsequ_doc_cat)
else
cast ('R2' as subsequ_doc_cat)
end
when 'h' then
case when GoodsReceipt.GoodsMovementType = ''
then
cast ('h4' as subsequ_doc_cat)
else
cast ('h2' as subsequ_doc_cat)
end
else GoodsReceipt.SubsequentDocumentCategory
end as SubsequentDocumentCategory,
cast( '' as vdm_purchaseorder) as PurchaseOrder,
cast('' as lgnum) as WarehouseNumber,
cast('0000000000' as wm_transfer_order) as WrhsMgmtTransferOrder,
GoodsReceipt.SubsequentDocument as MaterialDocument,
GoodsReceipt.MaterialDocumentYear,
cast('' as re_belnr) as SupplierInvoice,
cast('0000' as gjahr) as FiscalYear,
cast ('' as vbeln_vl ) as OutboundDelivery,
_InboundDelivery
}
where
GoodsReceipt.PrecedingDocumentCategory = '7' and
( GoodsReceipt.SubsequentDocumentCategory = 'R' or
GoodsReceipt.SubsequentDocumentCategory = 'h' )
// Lane 9 (Invoicing): Inbound Delivery > Supplier Invoice
union all select distinct from I_InboundDeliveryItem as InboundDeliveryItem
inner join I_PurchasingDocHistory as History on InboundDeliveryItem.ReferenceSDDocument = History.PurchasingDocument
inner join I_SupplierInvoice as Invoice on History.MaterialDocument = Invoice.SupplierInvoice
association [0..1] to I_InboundDelivery as _InboundDelivery on $projection.InboundDelivery = _InboundDelivery.InboundDelivery
{
key InboundDeliveryItem.InboundDelivery,
key cast(InboundDeliveryItem.ReferenceSDDocument as preced_doc ) as PrecedingDocument,
key InboundDeliveryItem.ReferenceSDDocumentCategory as PrecedingDocumentCategory,
key cast(Invoice.SupplierInvoice as subsequ_doc ) as SubsequentDocument,
key cast('2' as subsequ_doc_cat) as SubsequentDocumentCategory,
cast(InboundDeliveryItem.ReferenceSDDocument as preced_doc ) as PurchaseOrder,
cast('' as lgnum) as WarehouseNumber,
cast('0000000000' as wm_transfer_order) as WrhsMgmtTransferOrder,
cast('' as mblnr ) as MaterialDocument,
cast('0000' as mjahr) as MaterialDocumentYear,
Invoice.SupplierInvoice,
Invoice.FiscalYear,
cast ('' as vbeln_vl ) as OutboundDelivery,
_InboundDelivery
}
where
InboundDeliveryItem.ReferenceSDDocumentCategory = 'V'