P_StandardPurchaseOrders

DDL: P_STANDARDPURCHASEORDERS SQL: PSTDPURORDS Type: view COMPOSITE

P_StandardPurchaseOrders is a Composite CDS View in SAP S/4HANA. It reads from 5 data sources (P_ChangeDocumentItems, I_DemandDrivenPurDocHeader, I_DemandDrivenPurDocItem, I_GoodsMovementDocument, P_DemandDrivenProdslHorizon) and exposes 13 fields with key fields Material, Plant, MRPArea. It has 1 association to related views.

Data Sources (5)

SourceAliasJoin Type
P_ChangeDocumentItems _changedoc left_outer
I_DemandDrivenPurDocHeader _ekko inner
I_DemandDrivenPurDocItem _ekpo inner
I_GoodsMovementDocument _matmovdoc from
P_DemandDrivenProdslHorizon P_DemandDrivenProdslHorizon inner

Parameters (2)

NameTypeDefault
p_days abap.int2
p_date sydatum

Associations (1)

CardinalityTargetAliasCondition
[1..1] I_DemandDrivenProduct1 _ddprod _ddprod.Material = _matmovdoc.Material and _ddprod.Plant = _matmovdoc.Plant and _ddprod.MRPArea = _ekpo.MRPArea

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName PSTDPURORDS view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #COMPOSITE view
VDM.private true view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (13)

KeyFieldSource TableSource FieldDescription
KEY Material I_GoodsMovementDocument Material Vehicle Model
KEY Plant I_GoodsMovementDocument Plant Valuation Area
KEY MRPArea I_DemandDrivenPurDocItem MRPArea MRP Area
PurchasingDocument I_DemandDrivenPurDocHeader PurchasingDocument Purchasing Document
PurchasingDocumentItem
PurchasingInfoRecord I_DemandDrivenPurDocItem PurchasingInfoRecord Info Record
PurchasingOrganization I_DemandDrivenPurDocHeader PurchasingOrganization Purchasing Organization
ReplenishmentType
CreationDate I_DemandDrivenPurDocHeader CreationDate Time Stamp
ReleaseDate P_ChangeDocumentItems CreationDate Time Stamp
PurchasingDocumentCategory I_DemandDrivenPurDocHeader PurchasingDocumentCategory Doc. Category
datsasStartDate
PostingDateendendasDifferenceInDays

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 P_StandardPurchaseOrders.
-- 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: PSTDPURORDS
-- Parameters: p_days : abap.int2, p_date : sydatum

CREATE VIEW P_StandardPurchaseOrders AS
SELECT
  _matmovdoc.Material AS Material,
  _matmovdoc.Plant AS Plant,
  _ekpo.MRPArea AS MRPArea,
  _ekko.PurchasingDocument AS PurchasingDocument,
  cast(_ekpo.PurchasingDocumentItem as abap.char( 5 )) AS PurchasingDocumentItem,
  _ekpo.PurchasingInfoRecord AS PurchasingInfoRecord,
  _ekko.PurchasingOrganization AS PurchasingOrganization,
  cast('B' as abap.char( 1 ) ) AS ReplenishmentType,
  _ekko.CreationDate AS CreationDate,
  _changedoc.CreationDate AS ReleaseDate,
  _ekko.PurchasingDocumentCategory AS PurchasingDocumentCategory,
  cast( case when _ddprod.LeadTimeCalculationMethod = 'HCRE' then _ekko.CreationDate when _ddprod.LeadTimeCalculationMethod = 'HREL' then _changedoc.CreationDate when _ddprod.LeadTimeCalculationMethod is null then _ekko.CreationDate end as abap.dats ) as StartDate AS datsasStartDate,
  case when _ddprod.LeadTimeCalculationMethod = 'HCRE' then case when _ekko.CreationDate = _matmovdoc.PostingDate then 1 else dats_days_between(_ekko.CreationDate,_matmovdoc.PostingDate) end when _ddprod.LeadTimeCalculationMethod = 'HREL' then case when _changedoc.CreationDate = _matmovdoc.PostingDate then 1 else dats_days_between(_changedoc.CreationDate,_matmovdoc.PostingDate) end when _ddprod.LeadTimeCalculationMethod is null then case when _ekko.CreationDate = _matmovdoc.PostingDate then 1 else dats_days_between(_ekko.CreationDate,_matmovdoc.PostingDate) end end as DifferenceInDays AS PostingDateendendasDifferenceInDays
FROM I_GoodsMovementDocument AS _matmovdoc
INNER JOIN I_DemandDrivenPurDocItem AS _ekpo ON /* join condition not captured in parsed metadata */
INNER JOIN I_DemandDrivenPurDocHeader AS _ekko ON /* join condition not captured in parsed metadata */
INNER JOIN P_DemandDrivenProdslHorizon ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN P_ChangeDocumentItems AS _changedoc ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_DemandDrivenProduct1 AS _ddprod ON _ddprod.Material = _matmovdoc.Material AND _ddprod.Plant = _matmovdoc.Plant AND _ddprod.MRPArea = _ekpo.MRPArea  -- association [1..1]
;