@AbapCatalog.sqlViewName: 'PPRDVALUATIONWD'
@VDM.viewType: #COMPOSITE
@VDM.private: true
@ClientDependent: true
@AbapCatalog.compiler.compareFilter: true
//@EndUserText.label: 'Product Valuation Union (draft)'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view P_ProductValuationWD
as select from I_ProductValuation as ActiveDocument
// left outer join P_ProductD as DraftRootDocument on DraftRootDocument.product = ActiveDocument.Product
// left outer join P_ProductValuationD as DraftDocument on DraftDocument.ParentDraftKey = DraftRootDocument.Draftkey
left outer join P_ProductValuationD as DraftDocument on DraftDocument.ActiveProduct = ActiveDocument.Product
and DraftDocument.ActiveValuationArea = ActiveDocument.ValuationArea
and DraftDocument.ActiveInventoryValuationType = ActiveDocument.ValuationType
{
key cast ( hextobin('00000000000000000000000000000000') as sysuuid_x ) as Draftkey,
key ActiveDocument.Product as ActiveProduct,
key ActiveDocument.ValuationArea as ActiveValuationArea,
key ActiveDocument.ValuationType as ActiveInventoryValuationType,
cast ( hextobin('00000000000000000000000000000000') as sysuuid_x ) as ParentDraftKey,
ActiveDocument.Product,
ActiveDocument.ValuationArea,
ActiveDocument.ValuationType,
ActiveDocument.ValuationClass,
ActiveDocument.PriceDeterminationControl,
// ActiveDocument.TaxClassificationCategory,
// ActiveDocument.ValuationClassInPrevYear, //pstat changes
// ActiveDocument.ValuationClassInPrevPeriod, //pstat changes
// ActiveDocument.FiscalMonthCurrentPeriod, // pstat changes
// ActiveDocument.FiscalYearCurrentPeriod, // pstat changes
cast(ActiveDocument.IsMarkedForDeletion as boole_d) as IsMarkedForDeletion,
ActiveDocument.StandardPrice,
ActiveDocument.PriceUnitQty,
ActiveDocument.InventoryValuationProcedure,
// ActiveDocument.FutureEvaluatedAmountValue, "PSTAT Move
// ActiveDocument.FuturePriceValidityStartDate, "PSTAT Move
// ActiveDocument.TotalValStockQuantity, //pstat
ActiveDocument.MovingAveragePrice,
// ActiveDocument.TotalValStockPrevPeriod, //pstat
// ActiveDocument.TotalValStockPrevPeriodValue, //pstat
// ActiveDocument.TotalValStockPrevYear, //pstat
// ActiveDocument.TotalValStockPrevYearValue, //pstat
ActiveDocument.ValuationCategory,
// ActiveDocument.TotalValStockValue, //pstat
ActiveDocument.ProductUsageType,
ActiveDocument.ProductOriginType,
ActiveDocument.IsProducedInhouse,
// ActiveDocument.ValnClsForSpclStkAtVndr, //pstat
ActiveDocument.ProdCostEstNumber,
// ActiveDocument.CostEstimateNumber,
//Retail field
ActiveDocument.ValuationMargin,
cast( 'X' as boole_d ) as IsActiveEntity,
cast( ' ' as boole_d ) as HasActiveEntity,
cast(
case
when DraftDocument.Draftkey is null
then ' '
else 'X'
end as boole_d) as HasDraftEntity,
cast(DraftDocument.ParentDraftKey as sysuuid_x ) as DraftAdministrativeDataUUID
}
union all
select from P_ProductValuationD as DraftDocument
inner join P_ProductD as DraftRootDocument on DraftRootDocument.Draftkey = DraftDocument.ParentDraftKey
inner join I_DraftAdministrativeData as DraftAdministrativeData on DraftAdministrativeData.DraftUUID = DraftDocument.ParentDraftKey
//
{
key DraftDocument.Draftkey as Draftkey,
key DraftDocument.ActiveProduct as ActiveProduct,
key DraftDocument.ActiveValuationArea as ActiveValuationArea,
key DraftDocument.ActiveInventoryValuationType as ActiveInventoryValuationType,
DraftDocument.ParentDraftKey as ParentDraftKey,
DraftRootDocument.product,
DraftDocument.valuationarea,
DraftDocument.valuationtype,
DraftDocument.valuationclass,
DraftDocument.pricedeterminationcontrol,
// DraftDocument.taxclassificationcategory,
// DraftDocument.valuationclassinprevyear, //pstat changes
// DraftDocument.valuationclassinprevperiod, //pstat changes
// DraftDocument.fiscalmonthcurrentperiod, // pstat changes
// DraftDocument.fiscalyearcurrentperiod, // pstat changes
cast(DraftDocument.ismarkedfordeletion as boole_d) as IsMarkedForDeletion,
DraftDocument.standardprice,
DraftDocument.priceunitqty,
DraftDocument.inventoryvaluationprocedure,
// DraftDocument.futureevaluatedamountvalue, "PSTAT Move
// DraftDocument.futurepricevaliditystartdate, "PSTAT Move
// DraftDocument.totalvalstockquantity, //pstat
DraftDocument.movingaverageprice,
// DraftDocument.totalvalstockprevperiod, //pstat
// DraftDocument.totalvalstockprevperiodvalue, //pstat
// DraftDocument.totalvalstockprevyear, //pstat
// DraftDocument.totalvalstockprevyearvalue, //pstat
DraftDocument.valuationcategory,
// DraftDocument.totalvalstockvalue, //pstat
DraftDocument.productusagetype,
DraftDocument.productorigintype,
DraftDocument.isproducedinhouse,
// DraftDocument.valnclsforspclstkatvndr, //pstat
DraftDocument.prodcostestnumber,
// DraftDocument.costestimatenumber,
//Retail field
DraftDocument.valuationmargin,
cast( ' ' as boole_d ) as IsActiveEntity,
cast( DraftDocument.hasactiveentity as boole_d ) as HasActiveEntity,
cast( ' ' as boole_d ) as HasDraftEntity,
cast(DraftDocument.ParentDraftKey as sysuuid_x ) as DraftAdministrativeDataUUID
}
where
DraftAdministrativeData.CreatedByUser = $session.user
or DraftAdministrativeData.InProcessByUser = $session.user
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_DRAFTADMINISTRATIVEDATA",
"I_PRODUCTVALUATION",
"P_PRODUCTD",
"P_PRODUCTVALUATIOND"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/