@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #CONSUMPTION
@VDM.private: true
//@EndUserText.label: 'Production Order Popover'
define view entity P_MPEProdnOrderPover
as select from I_ManufacturingOrder as mfgorder
association [0..1] to I_SalesDocumentItem as _SalesDocumentItem on _SalesDocumentItem.ReferenceSDDocument = $projection.ReferenceSDDocument
and _SalesDocumentItem.ReferenceSDDocumentItem = $projection.ReferenceSDDocumentItem
and _SalesDocumentItem.ReferenceSDDocumentCategory = 'B' //Quotation
association [0..1] to P_MPEProdnOrdItmDvtnDurn as _OrdData on $projection.ManufacturingOrder = _OrdData.ManufacturingOrder
association [0..1] to I_StatusCodeText as _StatusText on _StatusText.StatusCode = $projection.orderstatus
and _StatusText.StatusProfile = ''
and _StatusText.Language = $session.system_language
association [0..1] to I_ManufacturingOrder as _LeadingMfgOrder on $projection.LeadingOrder = _LeadingMfgOrder.ManufacturingOrder
association [0..1] to I_WBSElement as _WBSElement2 on $projection.WBSElementInternalID = _WBSElement2.WBSElementInternalID
{
key mfgorder.ManufacturingOrder,
//Bill of Operations
@UI.hidden: true
mfgorder.MfgOrderInternalID as OrderInternalBillOfOperations,
//Manufactoring Order Category
@UI.hidden: true
mfgorder.ManufacturingOrderCategory,
//Production Plant
@UI.hidden: true
mfgorder.ProductionPlant,
//Material
mfgorder.Material,
//Material Description
@Semantics.text
mfgorder._Material._Text[1: Language = $session.system_language].MaterialName,
//Order Status
_OrdData.OrderStatus,
//Milestone Status
case
when _OrdData.OrderStatus = 'I0013' then '' // => DELETED
when _OrdData.OrderStatus = 'I0076' then '' // => MARKED FOR DELETION
when _OrdData.OrderStatus = 'I0045' then '' // => TECHNICALLY COMPLETED
when _OrdData.OrderStatus = 'I0046' then '' // => CLOSED
// => DELIVERED
when _OrdData.OrderStatus = 'I0012' and _OrdData.PlannedActualDlvDvtnDurn <= 0 then 'DELV' // 'Delivered'
when _OrdData.OrderStatus = 'I0012' and _OrdData.PlannedActualDlvDvtnDurn > 0 then 'DELD' // 'Delivered - Delayed'
when _OrdData.OrderStatus = 'I0012' and _OrdData.PlannedActualDlvDvtnDurn is null then 'DELD' // 'Delivered - Delayed'
when _OrdData.PlannedCurrentAvailDvtnDurn > 0 then 'DELO' // 'part. Delivered - Overdue/ Delivered - Overdue'
// => partially DELIVERED
when _OrdData.OrderStatus = 'I0074' and _OrdData.PlannedCurrentAvailDvtnDurn <= 0 and _OrdData.OrderIsConfirmed = '' then 'INPR' // 'partially Delivery - in Progress'
when _OrdData.OrderStatus = 'I0074' and _OrdData.PlannedCurrentAvailDvtnDurn <= 0 and _OrdData.OrderIsConfirmed = 'X' then 'CMPL' // 'Confirmed-Completed' => partially delivery has not started until now
when _OrdData.OrderStatus = 'I0074' and _OrdData.PlannedCurrentAvailDvtnDurn <= 0 then 'NULL' // 'Teststatus'
// => CONFIRMED
when _OrdData.OrderStatus = 'I0009' and _OrdData.PlannedActualEndDvtnDurn <= 0 then 'CMPL' // 'Confirmed-Completed'
when _OrdData.OrderStatus = 'I0009' and _OrdData.PlannedActualEndDvtnDurn > 0 then 'CMPD' // 'Confirmed-Completed Delayed'
when _OrdData.OrderStatus = 'I0009' and _OrdData.PlannedActualEndDvtnDurn is null then 'CMPD' // 'Confirmed-Completed Delayed'
when _OrdData.PlannedCurrentEndDvtnDurn > 0 then 'ENDO' // 'Confirmed-End Overdue'
// => PARTIALLY CONFIRMED
when _OrdData.OrderStatus = 'I0010' and _OrdData.PlannedActualStartDateDvtnDurn <= 0 then 'INPR' // 'Partially Confirmed - In Progress'
when _OrdData.OrderStatus = 'I0010' and _OrdData.PlannedActualStartDateDvtnDurn > 0 then 'INPD' // 'Partially Confirmed - In Progress Delayed'
when _OrdData.OrderStatus = 'I0010' and _OrdData.PlannedActualStartDateDvtnDurn is null then 'INPD' // 'Partially Confirmed - In Progress Delayed'
when _OrdData.PlannedCurrentStrtDateDvtnDurn > 0 then 'STOV' // 'Partially Confirmed - Start Overdue'
// => RELEASED
when _OrdData.OrderStatus = 'I0002' and _OrdData.PlannedActlReleaseDateDvtnDurn <= 0 then 'RELE' // 'Released'
when _OrdData.OrderStatus = 'I0002' and _OrdData.PlannedActlReleaseDateDvtnDurn > 0 then 'RELD' // 'Released - Delayed'
when _OrdData.OrderStatus = 'I0002' and _OrdData.PlannedActlReleaseDateDvtnDurn is null then 'RELD' // 'Released - Delayed'
// => PARTIALLY RELEASED
when _OrdData.OrderStatus = 'I0042' and _OrdData.PlannedActlReleaseDateDvtnDurn <= 0 then 'RELE' // 'Partially Released'
when _OrdData.OrderStatus = 'I0042' and _OrdData.PlannedActlReleaseDateDvtnDurn > 0 then 'RELD' // 'Partially Released - Delayed'
when _OrdData.OrderStatus = 'I0042' and _OrdData.PlannedActlReleaseDateDvtnDurn is null then 'RELD' // 'Partially Released - Delayed'
when _OrdData.PlannedCurrReleaseDateDvtnDurn > 0 then 'RELO' // 'Partially Released - Overdue'
when _OrdData.OrderStatus = 'I0001' then 'CREA' // => CREATED
// when _OrdData.OrderStatus = 'I0074' then 'CMPL' // 'Confirmed-Completed' => JUST IN TIME,
else ''
end as ProductionMilestoneStatus,
//Order Priority
mfgorder.ManufacturingOrderImportance,
//Order Type
mfgorder.ManufacturingOrderType,
//Order Type Description
@Semantics.text
mfgorder._MfgOrderType._Text[1: Language = $session.system_language].ManufacturingOrderTypeName,
//Scheduled Release Date
mfgorder.MfgOrderScheduledReleaseDate,
//Scheduled Release Time => NOT AVAILABLE IN PRODUCTION ORDER <=
//Basic Start Date
mfgorder.MfgOrderPlannedStartDate,
//Basic Start Time
mfgorder.MfgOrderPlannedStartTime,
//Basic End Date
mfgorder.MfgOrderPlannedEndDate,
//Basic End Time
mfgorder.MfgOrderPlannedEndTime,
//Scheduled Start Date
mfgorder.MfgOrderScheduledStartDate,
//Actual Starte Date
mfgorder.MfgOrderActualStartDate,
//Actual Start Time
mfgorder.MfgOrderActualStartTime,
//Actual End Date
mfgorder.MfgOrderActualEndDate,
//Actual End Time => NOT AVAILABLE IN PRODUCTION ORDER <=
//Goods receipt processing time in days
_OrdData.MaterialGoodsReceiptDuration,
//Unit of Measure on Header Level
mfgorder.ProductionUnit,
//Order Quantity
@Semantics.quantity.unitOfMeasure: 'ProductionUnit'
mfgorder.MfgOrderPlannedTotalQty,
//Scrap Quantity
@Semantics.quantity.unitOfMeasure: 'ProductionUnit'
mfgorder.MfgOrderPlannedScrapQty,
//Goods Receipt Quantity
@Semantics.quantity.unitOfMeasure: 'ProductionUnit'
mfgorder.ActualDeliveredQuantity,
//Expected Deviation Quantity
@Semantics.quantity.unitOfMeasure: 'ProductionUnit'
mfgorder.ExpectedDeviationQuantity * (-1) as ExpectedDeviationQuantity,
//Open Quantity
@Semantics.quantity.unitOfMeasure: 'ProductionUnit'
cast( case
when IsCompletelyDelivered = 'X' then 0
when MfgOrderPlannedTotalQty - MfgOrderPlannedScrapQty - ActualDeliveredQuantity - ExpectedDeviationQuantity < 0 then 0
else MfgOrderPlannedTotalQty - MfgOrderPlannedScrapQty - ActualDeliveredQuantity - ExpectedDeviationQuantity
end as abap.quan(17,3) ) as OpenQuantity,
//Delivery Completed Indicator
mfgorder.IsCompletelyDelivered,
//Product Version
mfgorder.ProductionVersion,
//Product Version Description
@Semantics.text
mfgorder._ProductionVersion.ProductionVersionText,
//Production Version Plant
@UI.hidden: true
mfgorder._ProductionVersion.Plant,
//Production Line
mfgorder._ProductionVersion.ProductionLine,
//Production Line Description
@Semantics.text
mfgorder._ProductionVersion._ProductionLine._WorkCenterTextBySemanticKey[ 1: Language = $session.system_language ].WorkCenterText,
//Order Start is late
case
when _OrdData.OrderIsPartiallyConfirmed= 'X' and _OrdData.ConfirmedStartDelayInSeconds > 0 then 'X'
when (_OrdData.OrderIsReleased= 'X' and _OrdData.OrderIsConfirmed= '') and _OrdData.CurrentStartDelayInSeconds > 0 then 'X'
else ''
end as OrderExecutionStartIsLate,
//Order End is late
case
when _OrdData.OrderIsConfirmed= 'X' and _OrdData.ConfirmedEndDelayInSeconds > 0 then 'X'
when (_OrdData.OrderIsPartiallyConfirmed= 'X' and _OrdData.OrderIsConfirmed = '') and _OrdData.CurrentEndDelayInSeconds > 0 then 'X'
else ''
end as OrderExecutionEndIsLate,
//MRP Plant
@UI.hidden: true
mfgorder.PlanningPlant as MRPPlant,
//MRP Controller
mfgorder.MRPController,
//MRP Controller Description
@Semantics.text
mfgorder._MRPController.MRPControllerName,
//Production Supervisor
mfgorder.ProductionSupervisor,
//Production Supervisor Description
@Semantics.text
mfgorder._ProductionSupervisor.ProductionSupervisorName,
//Superior Order Material
_LeadingMfgOrder.Material as LeadingMfgOrderMaterial,
//Superior Order Material Name
_LeadingMfgOrder._Material._Text[1: Language = $session.system_language].MaterialName as LeadingMfgOrderMaterialName,
//Leading Order
mfgorder.LeadingOrder,
//Sales Document (follow-up Document should be a SD Order, if available)
_SalesDocumentItem.SalesDocument as SlsDoc,
//Sales Document (further data to find the follow-up document)
_SalesDocumentItem.SalesDocumentItem as SlsDocItm,
//Sales Document Category (further data to find the follow-up document)
_SalesDocumentItem.SDDocumentCategory as SlsDocCat,
//Sales Document Category Description
@Semantics.text
_SalesDocumentItem._SDDocumentCategory._Text[1: Language = $session.system_language].SDDocumentCategoryName as SlsDocCatName,
//If follow-up document is not available take the actual document
coalesce( _SalesDocumentItem.SalesDocument, mfgorder.SalesOrder ) as SDDocument,
//If follow-up document is not available take the actual document
coalesce( _SalesDocumentItem.SalesDocumentItem, mfgorder.SalesOrderItem ) as SDDocumentItem,
//If follow-up document is not available take the actual document
coalesce( _SalesDocumentItem.SDDocumentCategory, mfgorder._SalesDocumentItem.SDDocumentCategory ) as SDDocumentCategory,
//If follow-up document is not available take the actual document
@Semantics.text
coalesce( _SalesDocumentItem._SDDocumentCategory._Text[1: Language = $session.system_language].SDDocumentCategoryName,
mfgorder._SalesDocumentItem._SDDocumentCategory._Text[1: Language = $session.system_language].SDDocumentCategoryName ) as SDDocumentCategoryName,
//Reference Document which is needed to find the follow-up document (Quotation)
mfgorder.SalesOrder as ReferenceSDDocument,
//Reference Document which is needed to find the follow-up document (Quotation Item)
mfgorder.SalesOrderItem as ReferenceSDDocumentItem,
//Customer (Sold-to Party)
mfgorder._SalesDocument.SoldToParty,
//Customer (Sold-to Party) Name
@Semantics.text
mfgorder._SalesDocument._SoldToParty.CustomerName,
//Authority Check for Customer (Sold-to Party)
mfgorder._SalesDocument._SoldToParty.AuthorizationGroup,
//WBS Element
_WBSElement.WBSElement,
//Element Description
@Semantics.text
_WBSElement.WBSDescription,
cast( case
when _WBSElement.ResponsiblePerson = '00000000' or _WBSElement.ResponsiblePerson is null
then _WBSElement2._EntProjectResponsiblePerson.PersonWorkAgreement
else
_WBSElement.ResponsiblePerson
end as ps_s4_vernr preserving type ) as ProjectResponsiblePerson,
cast( case
when _WBSElement.ResponsiblePerson = '00000000' or _WBSElement.ResponsiblePerson is null
then _WBSElement2._EntProjectResponsiblePerson._WorkforcePerson.PersonFullName
else
_WBSElement.ResponsiblePersonName
end as ad_namtext preserving type ) as ProjectResponsiblePersonName,
//Project
_WBSElement._Project.Project,
//Project Description
@Semantics.text
//To use the language key leads to errors in this case
_WBSElement._Project.ProjectDescription,
//Inspection Lot
mfgorder.InspectionLot,
dats_tims_to_tstmp( mfgorder.LastChangeDate, mfgorder.LastChangeTime,
abap_system_timezone( $session.client,'NULL' ),
$session.client,'NULL' ) as LastChangeDateTime,
@UI.hidden:true
mfgorder.Product,
//Associations
mfgorder._OrderInternalID as _OrdInternalBillOfOperations,
_MfgOrderCategory,
_Material,
_StatusText,
_MfgOrderType,
_ProductionVersion,
_ProductionPlant as _Plant,
mfgorder._PlanningPlant as _MRPPlant,
_MRPController,
_ProductionSupervisor,
_WBSElement,
mfgorder.WBSElementInternalID,
mfgorder._SalesDocument._SoldToParty
}
where
mfgorder.ManufacturingOrderCategory = '10'; //Production Orders