Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view F6_MMIM_MATSTOCKQUANVALBYDATE.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
-- SQL view name: F6MMIM_MATSTVAL
-- Parameters: P_EndDate : sydate
CREATE VIEW F6_MMIM_MATSTOCKQUANVALBYDATE AS
SELECT
Material,
Plant,
StorageLocation,
ResourceId,
Batch,
Supplier,
SDDocument,
SDDocumentItem,
WBSElementInternalID,
Customer,
InventoryStockType,
InventorySpecialStockType,
CompanyCode,
CostEstimate,
ValuationArea,
InventoryValuationType,
IsSupplierStockValuation,
InventorySpecialStockValnType,
Currency,
MaterialBaseUnit,
MatlWrhsStkQtyInMatlBaseUnit,
case when ( InventorySpecialStockType = 'O' or InventorySpecialStockType = 'V' or InventorySpecialStockType = 'W' or InventorySpecialStockType = ' ' or ( ( InventorySpecialStockType = 'E' or InventorySpecialStockType = 'Q' or InventorySpecialStockType = 'T' ) and InventorySpecialStockValnType <> '' ) or ( ( InventorySpecialStockType = 'F' or InventorySpecialStockType = 'R' ) and ( InventorySpecialStockValnType <> '' or IsSupplierStockValuation = 'X' ) ) ) and ( MatlWrhsStkQtyInMatlBaseUnit <> 0 and _MaterialStockValueByKeyDate( P_EndDate: $parameters.P_EndDate).InventoryQty <> 0 ) then cast( round( cast( division( cast(_MaterialStockValueByKeyDate( P_EndDate: $parameters.P_EndDate ).AmountInCompanyCodeCurrency as abap.dec(23,2) ), cast(_MaterialStockValueByKeyDate( P_EndDate: $parameters.P_EndDate ).InventoryQty as abap.dec(23,3) ) , 7 ) as abap.dec(16,7) ) * cast(MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ), 2 ) as abap.dec(23,2) ) when ( InventorySpecialStockType = 'K' or InventorySpecialStockType = 'M' or InventorySpecialStockType = 'B' or InventorySpecialStockType = 'I' or InventorySpecialStockType = 'C' or InventorySpecialStockType = 'J' or InventorySpecialStockType = 'P' or InventorySpecialStockType = 'Y' ) then cast( 0 as abap.dec(23,2 ) ) when ( InventorySpecialStockType = 'O' or InventorySpecialStockType = 'V' or InventorySpecialStockType = 'W' or InventorySpecialStockType = ' ' or ( ( InventorySpecialStockType = 'E' or InventorySpecialStockType = 'Q' or InventorySpecialStockType = 'T' ) and InventorySpecialStockValnType <> '' ) or ( ( InventorySpecialStockType = 'F' or InventorySpecialStockType = 'R' ) and ( InventorySpecialStockValnType <> '' or IsSupplierStockValuation = 'X' ) ) ) and MatlWrhsStkQtyInMatlBaseUnit <> 0 and _MaterialStockValueByKeyDate( P_EndDate: $parameters.P_EndDate).InventoryQty = 0 and _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MaterialPriceControl = 'S' and _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MatPriceUnitInCoCodeCurrency <> 0 then cast( round( cast( division( _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).StandardPriceInCoCodeCrcy, _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MatPriceUnitInCoCodeCurrency, 7 ) as abap.dec(16,7) ) * cast(MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ), 2 ) as abap.dec(23,2) ) when ( InventorySpecialStockType = 'O' or InventorySpecialStockType = 'V' or InventorySpecialStockType = 'W' or InventorySpecialStockType = ' ' or ( ( InventorySpecialStockType = 'E' or InventorySpecialStockType = 'Q' or InventorySpecialStockType = 'T' ) and InventorySpecialStockValnType <> '' ) or ( ( InventorySpecialStockType = 'F' or InventorySpecialStockType = 'R' ) and ( InventorySpecialStockValnType <> '' or IsSupplierStockValuation = 'X' ) ) ) and MatlWrhsStkQtyInMatlBaseUnit <> 0 and _MaterialStockValueByKeyDate( P_EndDate: $parameters.P_EndDate).InventoryQty = 0 and _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MaterialPriceControl = 'V' and _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MatPriceUnitInCoCodeCurrency <> 0 then cast( round( cast( division( _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MovingAveragePriceInCoCodeCrcy, _MaterialLedgerPrice( P_EndDate: $parameters.P_EndDate ).MatPriceUnitInCoCodeCurrency, 7 ) as abap.dec(16,7) ) * cast(MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ), 2 ) as abap.dec(23,2) ) else cast( 0 as abap.dec(23,2 ) ) end as StockValue AS dec232endasStockValue,
cast( round( division( _CurrentInvtryPrice.InventoryPrice, _CurrentInvtryPrice.MaterialPriceUnitQty, 5 ) * cast(MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) , 2 ) as abap.dec(23,2) ) as StockCurrentValue AS dec232asStockCurrentValue
FROM Fb_Mmim_Matstockquanvalbydate
;