P_STKONINTERVALBOUNDARYBASIC12

DDL: P_STKONINTERVALBOUNDARYBASIC12 Type: view_entity COMPOSITE Package: ODATA_MM_IM_STOCKINDATERANGE

Stock on interval boundry quantity basic view branch 2

P_STKONINTERVALBOUNDARYBASIC12 is a Composite CDS View that provides data about "Stock on interval boundry quantity basic view branch 2" in SAP S/4HANA. It reads from 2 data sources (I_MaterialDocumentRecord, I_MaterialDocumentRecord) and exposes 43 fields with key fields StockIdentifyingMaterial, Plant, StockIdfgStorageLocation, StockIdentifyingBatch, SpecialStockIdfgSupplier. Part of development package ODATA_MM_IM_STOCKINDATERANGE.

Data Sources (2)

SourceAliasJoin Type
I_MaterialDocumentRecord I_MaterialDocumentRecord from
I_MaterialDocumentRecord I_MaterialDocumentRecord union_all

Parameters (3)

NameTypeDefault
P_StartDate sydate
P_EndDate sydate
P_GroupByField nsdm_groupby_fields

Annotations (8)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
EndUserText.label Stock on interval boundry quantity basic view branch 2 view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
VDM.viewType #COMPOSITE view
VDM.private true view

Fields (43)

KeyFieldSource TableSource FieldDescription
KEY StockIdentifyingMaterial StockIdentifyingMaterial
KEY Plant Plant
KEY StockIdfgStorageLocation StockIdfgStorageLocation
KEY StockIdentifyingBatch StockIdentifyingBatch
KEY SpecialStockIdfgSupplier SpecialStockIdfgSupplier
KEY SpecialStockIdfgSalesOrder SpecialStockIdfgSalesOrder
KEY SpecialStockIdfgSalesOrderItem SpecialStockIdfgSalesOrderItem
KEY SpecialStockIdfgWBSElement SpecialStockIdfgWBSElement
KEY SpecialStockIdfgCustomer SpecialStockIdfgCustomer
KEY InventorySpecialStockType InventorySpecialStockType
KEY InventoryStockType InventoryStockType
KEY SpecialStockIdfgStockOwner SpecialStockIdfgStockOwner
KEY ResourceID ResourceID
KEY CompanyCode CompanyCode
KEY CostEstimate CostEstimate
KEY InventoryValuationType InventoryValuationType
KEY IsSupplierStockValuation IsSupplierStockValuation
KEY InventorySpecialStockValnType InventorySpecialStockValnType
KEY MaterialBaseUnit MaterialBaseUnit
KEY Currency CompanyCodeCurrency
MatlWrhsStkQtyOnStartDate
MatlWrhsStkQtyOnEndDate MatlStkChangeQtyInBaseUnit
KEY Plant Plant
KEY StockIdfgStorageLocation StockIdfgStorageLocation
KEY StockIdentifyingBatch StockIdentifyingBatch
KEY SpecialStockIdfgSupplier SpecialStockIdfgSupplier
KEY SpecialStockIdfgSalesOrder SpecialStockIdfgSalesOrder
KEY SpecialStockIdfgSalesOrderItem SpecialStockIdfgSalesOrderItem
KEY SpecialStockIdfgWBSElement SpecialStockIdfgWBSElement
KEY SpecialStockIdfgCustomer SpecialStockIdfgCustomer
KEY InventorySpecialStockType InventorySpecialStockType
KEY InventoryStockType InventoryStockType
KEY SpecialStockIdfgStockOwner SpecialStockIdfgStockOwner
KEY ResourceID ResourceID
KEY CompanyCode CompanyCode
KEY CostEstimate CostEstimate
KEY InventoryValuationType InventoryValuationType
KEY IsSupplierStockValuation IsSupplierStockValuation
KEY InventorySpecialStockValnType InventorySpecialStockValnType
KEY MaterialBaseUnit MaterialBaseUnit
KEY Currency CompanyCodeCurrency
MatlWrhsStkQtyOnStartDate
MatlWrhsStkQtyOnEndDate MatlStkChangeQtyInBaseUnit
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Stock on interval boundry quantity basic view branch 2'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
  serviceQuality: #D,
  sizeCategory: #XXL,
  dataClass: #MIXED
}
@VDM:
      {
        viewType: #COMPOSITE,
        private: true
      }
define view entity P_STKONINTERVALBOUNDARYBASIC12 
 with parameters
    @Environment.systemField: #SYSTEM_DATE
    P_StartDate : sydate,
    @Environment.systemField: #SYSTEM_DATE
    P_EndDate   : sydate,
    P_GroupByField   : nsdm_groupby_fields
as select from I_MaterialDocumentRecord

{
  key StockIdentifyingMaterial,
  key Plant,
  key StockIdfgStorageLocation,
  key StockIdentifyingBatch,
  key SpecialStockIdfgSupplier,
  key SpecialStockIdfgSalesOrder,
  key SpecialStockIdfgSalesOrderItem,
  key SpecialStockIdfgWBSElement,
  key SpecialStockIdfgCustomer,
  key InventorySpecialStockType,
  key InventoryStockType,
  key SpecialStockIdfgStockOwner,
  key ResourceID,

      // Further Stock Groups

  key CompanyCode,
  key CostEstimate,

      // fields for derivation of stock values

  key InventoryValuationType,
  key IsSupplierStockValuation,
  key InventorySpecialStockValnType,

      // unit

  key MaterialBaseUnit,
  key CompanyCodeCurrency                     as Currency,

      // Quantities

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      cast (0 as nsdm_stock_qty)                as MatlWrhsStkQtyOnStartDate,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      MatlStkChangeQtyInBaseUnit          as MatlWrhsStkQtyOnEndDate,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      case when MatlStkChangeQtyInBaseUnit > 0 
               then MatlStkChangeQtyInBaseUnit 
               else cast( 0 as  nsdm_stock_qty) end as MatlStkIncrQtyInMatlBaseUnit,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      case when MatlStkChangeQtyInBaseUnit < 0 
               then MatlStkChangeQtyInBaseUnit 
               else cast( 0 as  nsdm_stock_qty) end as MatlStkDecrQtyInMatlBaseUnit,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      case when MatlStkChangeQtyInBaseUnit > 0 
                then MatlStkChangeQtyInBaseUnit
                else cast( 0 as  nsdm_stock_qty) end as NetGoodsRcptQtyInBaseUnit,

      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      case when MatlStkChangeQtyInBaseUnit < 0 
                then MatlStkChangeQtyInBaseUnit
                else cast( 0 as  nsdm_stock_qty) end as NetGoodsIssueQtyInBaseUnit
}

where
      MaterialBaseUnit <> '' // value only material does not have meins

  // no transfer posting in any cases

  and InventoryStockType <> ''
  and IssuingOrReceivingStockType = ''
  and PostingDate      <= $parameters.P_EndDate
  and PostingDate      >  $parameters.P_StartDate

  
  union all
  
  
  select from I_MaterialDocumentRecord

{
  key StockIdentifyingMaterial,
  key Plant,
  key StockIdfgStorageLocation,
  key StockIdentifyingBatch,
  key SpecialStockIdfgSupplier,
  key SpecialStockIdfgSalesOrder,
  key SpecialStockIdfgSalesOrderItem,
  key SpecialStockIdfgWBSElement,
  key SpecialStockIdfgCustomer,
  key InventorySpecialStockType,
  key InventoryStockType,
  key SpecialStockIdfgStockOwner,
  key ResourceID,

      // Further Stock Groups

  key CompanyCode,
  key CostEstimate,

      // fields for derivation of stock values

  key InventoryValuationType,
  key IsSupplierStockValuation,
  key InventorySpecialStockValnType,

      // unit

  key MaterialBaseUnit,
  key CompanyCodeCurrency                     as Currency,

      // Quantities

      cast (0 as nsdm_stock_qty)                as MatlWrhsStkQtyOnStartDate,
      MatlStkChangeQtyInBaseUnit           as MatlWrhsStkQtyOnEndDate,

      case when MatlStkChangeQtyInBaseUnit > 0 
               then MatlStkChangeQtyInBaseUnit 
               else cast( 0 as  nsdm_stock_qty) end as MatlStkIncrQtyInMatlBaseUnit,

      case when MatlStkChangeQtyInBaseUnit < 0 
               then MatlStkChangeQtyInBaseUnit 
               else cast( 0 as  nsdm_stock_qty) end as MatlStkDecrQtyInMatlBaseUnit,

      case when MatlStkChangeQtyInBaseUnit > 0 
                and
                (
                     ((instr($parameters.P_GroupByField, 'Material') > 0 ) and (StockIdentifyingMaterial <> IssgOrRcvgStkIdfgMaterial))
                  or ((instr($parameters.P_GroupByField, 'Plant') > 0 ) and (Plant <> IssgOrRcvgStkIdfgPlant))
                  or ((instr($parameters.P_GroupByField, 'StorageLocation') > 0 ) and (StockIdfgStorageLocation <> IssgOrRcvgStkIdfgStorLoc))
                  or ((instr($parameters.P_GroupByField, 'Batch') > 0 ) and (StockIdentifyingBatch <> IssgOrRcvgStkIdfgBatch))
                  or ((instr($parameters.P_GroupByField, 'Supplier') > 0 ) and (SpecialStockIdfgSupplier <> IssgOrRcvgSpclStkIdfgSupplier))
                  or ((instr($parameters.P_GroupByField, 'SalesOrder') > 0 ) and (SpecialStockIdfgSalesOrder <> IssgOrRcvgSalesOrder))
                  or ((instr($parameters.P_GroupByField, 'SlsOrdItm') > 0 ) and ( SpecialStockIdfgSalesOrderItem <> IssgOrRcvgSalesOrderItem ))
                  or ((instr($parameters.P_GroupByField, 'WBSElementInternalID') > 0 ) and ( SpecialStockIdfgWBSElement <> IssgOrRcvgWBSElement ))
                  or ((instr($parameters.P_GroupByField, 'Customer') > 0 ) and ( SpecialStockIdfgCustomer <> IssgOrRcvgSpclStkIdfgCustomer )) 
                  or ((instr($parameters.P_GroupByField, 'SpclStkType') > 0 ) and ( InventorySpecialStockType <> IssgOrRcvgStkIdfgSpclStkType )) 
                  or ((instr($parameters.P_GroupByField, 'InventoryStockType') > 0 ) and ( InventoryStockType <> IssuingOrReceivingStockType )) 
                  or ((instr($parameters.P_GroupByField, 'SpclStkOwnr') > 0 ) and ( SpecialStockIdfgStockOwner <> IssgOrRcvgSpclStkIdfgStkOwner )) 
                  or ((instr($parameters.P_GroupByField, 'ResourceID') > 0 ) and ( ResourceID <> IssgOrRcvgResourceID )) 
                  or ((instr($parameters.P_GroupByField, 'InventoryValuationType') > 0 ) and ( InventoryValuationType <> IssuingOrReceivingValType ))
                )
                then MatlStkChangeQtyInBaseUnit
                else cast( 0 as  nsdm_stock_qty)
          end                                  as NetGoodsRcptQtyInBaseUnit,

      case when MatlStkChangeQtyInBaseUnit < 0 
                  and
                (
                   ((instr($parameters.P_GroupByField, 'Material') > 0 ) and (StockIdentifyingMaterial <> IssgOrRcvgStkIdfgMaterial))
                  or ((instr($parameters.P_GroupByField, 'Plant') > 0 ) and (Plant <> IssgOrRcvgStkIdfgPlant))
                  or ((instr($parameters.P_GroupByField, 'StorageLocation') > 0 ) and (StockIdfgStorageLocation <> IssgOrRcvgStkIdfgStorLoc))
                  or ((instr($parameters.P_GroupByField, 'Batch') > 0 ) and (StockIdentifyingBatch <> IssgOrRcvgStkIdfgBatch))
                  or ((instr($parameters.P_GroupByField, 'Supplier') > 0 ) and (SpecialStockIdfgSupplier <> IssgOrRcvgSpclStkIdfgSupplier))
                  or ((instr($parameters.P_GroupByField, 'SalesOrder') > 0 ) and (SpecialStockIdfgSalesOrder <> IssgOrRcvgSalesOrder))
                  or ((instr($parameters.P_GroupByField, 'SlsOrdItm') > 0 ) and ( SpecialStockIdfgSalesOrderItem <> IssgOrRcvgSalesOrderItem ))
                  or ((instr($parameters.P_GroupByField, 'WBSElementInternalID') > 0 ) and ( SpecialStockIdfgWBSElement <> IssgOrRcvgWBSElement ))
                  or ((instr($parameters.P_GroupByField, 'Customer') > 0 ) and ( SpecialStockIdfgCustomer <> IssgOrRcvgSpclStkIdfgCustomer )) 
                  or ((instr($parameters.P_GroupByField, 'SpclStkType') > 0 ) and ( InventorySpecialStockType <> IssgOrRcvgStkIdfgSpclStkType )) 
                  or ((instr($parameters.P_GroupByField, 'InventoryStockType') > 0 ) and ( InventoryStockType <> IssuingOrReceivingStockType )) 
                  or ((instr($parameters.P_GroupByField, 'SpclStkOwnr') > 0 ) and ( SpecialStockIdfgStockOwner <> IssgOrRcvgSpclStkIdfgStkOwner )) 
                  or ((instr($parameters.P_GroupByField, 'ResourceID') > 0 ) and ( ResourceID <> IssgOrRcvgResourceID )) 
                  or ((instr($parameters.P_GroupByField, 'InventoryValuationType') > 0 ) and ( InventoryValuationType <> IssuingOrReceivingValType ))
                )
                then MatlStkChangeQtyInBaseUnit
                else cast( 0 as  nsdm_stock_qty)
          end                                  as NetGoodsIssueQtyInBaseUnit
}

where
      MaterialBaseUnit <> ''  // value only material does not have meins

  and InventoryStockType <> ''
  and IssuingOrReceivingStockType <> ''
  and PostingDate      <= $parameters.P_EndDate
  and PostingDate      >  $parameters.P_StartDate