P_MaterialWarehouseStockCheck2

DDL: P_MATERIALWAREHOUSESTOCKCHECK2 SQL: PMATLWHSESTKCHK2 Type: view BASIC

P_MaterialWarehouseStockCheck2 is a Basic CDS View in SAP S/4HANA. It reads from 1 data source (matdoc) and exposes 23 fields with key fields StockIdentifyingMaterial, Plant, StockIdfgStorageLocation, StockIdentifyingBatch, SpecialStockIdfgSupplier.

Data Sources (1)

SourceAliasJoin Type
matdoc matdoc from

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PMATLWHSESTKCHK2 view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
VDM.private true view
VDM.viewType #BASIC view

Fields (23)

KeyFieldSource TableSource FieldDescription
KEY StockIdentifyingMaterial matbf
KEY Plant werks
KEY StockIdfgStorageLocation lgort_sid
KEY StockIdentifyingBatch charg_sid
KEY SpecialStockIdfgSupplier lifnr_sid
KEY SpecialStockIdfgSalesOrder mat_kdauf
KEY SpecialStockIdfgSalesOrderItem mat_kdpos
KEY SpecialStockIdfgWBSElement mat_pspnr
KEY SpecialStockIdfgCustomer kunnr_sid
KEY SpecialStockIdfgStockOwner disub_owner_sid
KEY InventorySpecialStockType sobkz
KEY InventoryStockType lbbsa_sid
KEY MaterialBaseUnit meins
KEY MaterialParallelUnit /cwm/meins_sid
MatlStkQtyInBaseUnit
MatlStkQtyInParUnit
LastPostingDate
LastPostingPeriod
CompanyCode
FiscalYearVariant
CostEstimate kalnr
Batch charg_whs_sg
TodayDate
@AbapCatalog.sqlViewName: 'PMATLWHSESTKCHK2'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey:true 
@AccessControl.authorizationCheck: #NOT_REQUIRED
//@EndUserText.label: 'Material Warehouse Stock Check'

@ClientHandling.algorithm: #SESSION_VARIABLE

@ObjectModel.usageType.serviceQuality : #D
@ObjectModel.usageType.sizeCategory   : #XXL
@ObjectModel.usageType.dataClass      : #MIXED

@VDM.private: true
@VDM.viewType: #BASIC

define view P_MaterialWarehouseStockCheck2
 as select from matdoc 

{
 key matbf                                                                             as StockIdentifyingMaterial,
 key werks                                                                             as Plant,
 key lgort_sid                                                                         as StockIdfgStorageLocation,
 key charg_sid                                                                         as StockIdentifyingBatch,
 key lifnr_sid                                                                         as SpecialStockIdfgSupplier,
 key mat_kdauf                                                                         as SpecialStockIdfgSalesOrder,
 key mat_kdpos                                                                         as SpecialStockIdfgSalesOrderItem,
 key mat_pspnr                                                                         as SpecialStockIdfgWBSElement,
 key kunnr_sid                                                                         as SpecialStockIdfgCustomer,
 key disub_owner_sid                                                                   as SpecialStockIdfgStockOwner,
 key sobkz                                                                             as InventorySpecialStockType,
 key lbbsa_sid                                                                         as InventoryStockType,
  @Semantics.unitOfMeasure: true
 key meins                                                                             as MaterialBaseUnit,
  @Semantics.unitOfMeasure: true
 key /cwm/meins_sid                                                                    as MaterialParallelUnit,
  
  @DefaultAggregation:#SUM
  @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
  cast ( sum( stock_qty ) as  nsdm_stock_qty preserving type )                         as MatlStkQtyInBaseUnit,

  @DefaultAggregation:#SUM
  @Semantics.quantity.unitOfMeasure: 'MaterialParallelUnit'
  cast (  sum( /cwm/stock_qty ) as  /cwm/stock_qty preserving type )                   as MatlStkQtyInParUnit
  
  ,cast ( max( budat )         as nsdm_last_mvt_posting_date   preserving type)        as LastPostingDate
  ,cast ( max( gjper )         as nsdm_last_mvt_posting_period preserving type)        as LastPostingPeriod // depends on FiscalYearVariant, PostingDate (same order for max)

  ,cast ( max( bukrs )         as bukrs                        preserving type)        as CompanyCode       // depends on Plant (N:1)

  ,cast ( max( periv )         as periv                        preserving type)        as FiscalYearVariant // depends on CompanyCode (N:1)

  ,kalnr                                                                               as CostEstimate // depends on stock ID (and hidden attribute KZBWS)

  ,charg_whs_sg                                                                        as Batch // depends on stock ID 

  ,cast( $session.system_date  as sydatum preserving type )                            as TodayDate 
  }
where
      /cwm/meins_sid        <> ''  
  and lbbsa_sid             <> ''
group by
  matbf,
  werks,
  lgort_sid,
  charg_sid,
  lifnr_sid,
  mat_kdauf,
  mat_kdpos,
  mat_pspnr,
  kunnr_sid,
  disub_owner_sid,
  sobkz,
  lbbsa_sid,
  meins,
  /cwm/meins_sid,
  kalnr,
  charg_whs_sg

having
     sum( stock_qty )      <> 0
  or sum( /cwm/stock_qty ) <> 0