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 F5_Mmim_Matstockquanvalbydat3.
-- 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.
-- Parameters: P_EndDate : sydate
CREATE VIEW F5_Mmim_Matstockquanvalbydat3 AS
SELECT
Material,
Plant,
StorageLocation,
ResourceId,
Batch,
Supplier,
SDDocument,
SDDocumentItem,
WBSElementInternalID,
Customer,
InventoryStockType,
InventorySpecialStockType,
CompanyCode,
MaterialBaseUnit,
MatlWrhsStkQtyInMatlBaseUnit,
ValuationArea,
InventoryValuationType,
CostEstimate,
Currency,
case when InventoryStockType = '01' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as CurrentStock AS dec213endasCurrentStock,
case when InventoryStockType = '03' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as ReturnsBlockedStockQuantity AS dec213endasReturnsBlockedStockQuantity,
case when InventoryStockType = '04' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as TransferStockStorageLocQty AS dec213endasTransferStockStorageLocQty,
case when InventoryStockType = '05' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as TransferStockPlantQuantity AS dec213endasTransferStockPlantQuantity,
case when InventoryStockType = '06' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as StockInTransitQuantity AS dec213endasStockInTransitQuantity,
case when InventoryStockType = '07' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as BlockedStockQuantity AS dec213endasBlockedStockQuantity,
case when InventoryStockType = '08' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as RestrictedStockQuantity AS dec213endasRestrictedStockQuantity,
case when InventoryStockType = '09' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as TiedEmptiesStockQuantity AS dec213endasTiedEmptiesStockQuantity,
case when InventoryStockType = '10' then cast( MatlWrhsStkQtyInMatlBaseUnit as abap.dec(21,3) ) else cast( 0 as abap.dec(21,3 ) ) end as GoodsReceiptBlockedStockQty AS dec213endasGoodsReceiptBlockedStockQty,
case when InventoryStockType = '01' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as CurrentStockValue AS dec232endasCurrentStockValue,
case when InventoryStockType = '02' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as QualityInspectionStockValue AS dec232endasQualityInspectionStockValue,
case when InventoryStockType = '03' then cast( 0 as abap.dec(23,2 ) ) else cast( 0 as abap.dec(23,2 ) ) end as ReturnsBlockedStockValue AS dec232endasReturnsBlockedStockValue,
case when InventoryStockType = '04' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as TransferStockStorageLocValue AS dec232endasTransferStockStorageLocValue,
case when InventoryStockType = '05' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as TransferStockPlantValue AS dec232endasTransferStockPlantValue,
case when InventoryStockType = '06' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as StockInTransitValue AS dec232endasStockInTransitValue,
case when InventoryStockType = '07' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as BlockedStockValue AS dec232endasBlockedStockValue,
case when InventoryStockType = '08' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as RestrictedStockValue AS dec232endasRestrictedStockValue,
case when InventoryStockType = '09' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as TiedEmptiesStockValue AS dec232endasTiedEmptiesStockValue,
case when InventoryStockType = '10' then StockValue else cast( 0 as abap.dec(23,2 ) ) end as GoodsReceiptBlockedStockValue AS dec232endasGoodsReceiptBlockedStockValue,
case when InventoryStockType = '01' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as CurrentStockCurVal AS dec232endasCurrentStockCurVal,
case when InventoryStockType = '02' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as QualityInspectionStockCurVal AS dec232endasQualityInspectionStockCurVal,
case when InventoryStockType = '03' then cast( 0 as abap.dec(23,2 ) ) else cast( 0 as abap.dec(23,2 ) ) end as ReturnsBlockedStockCurVal AS dec232endasReturnsBlockedStockCurVal,
case when InventoryStockType = '04' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as TransferStockStorageLocCurVal AS dec232endasTransferStockStorageLocCurVal,
case when InventoryStockType = '05' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as TransferStockPlantCurVal AS dec232endasTransferStockPlantCurVal,
case when InventoryStockType = '06' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as StockInTransitCurVal AS dec232endasStockInTransitCurVal,
case when InventoryStockType = '07' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as BlockedStockCurVal AS dec232endasBlockedStockCurVal,
case when InventoryStockType = '08' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as RestrictedStockCurVal AS dec232endasRestrictedStockCurVal,
case when InventoryStockType = '09' then StockCurrentValue else cast( 0 as abap.dec(23,2 ) ) end as TiedEmptiesStockCurVal AS dec232endasTiedEmptiesStockCurVal
FROM F6_MMIM_MATSTOCKQUANVALBYDAT3
;