P_PurReqnProcFlowGR

DDL: P_PURREQNPROCFLOWGR SQL: PPURREQNPFGR Type: view COMPOSITE

P_PurReqnProcFlowGR is a Composite CDS View in SAP S/4HANA. It reads from 2 data sources (P_PurchasingDocHistory, I_PurgDocScheduleLine) and exposes 8 fields with key fields ReferenceDocumentendasPrecedingDocument, SubsequentDocument, SubsequentDocumentItem.

Data Sources (2)

SourceAliasJoin Type
P_PurchasingDocHistory _purgDocHist inner
I_PurgDocScheduleLine schedgLine from

Annotations (6)

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

Fields (8)

KeyFieldSource TableSource FieldDescription
KEY ReferenceDocumentendasPrecedingDocument
KEY SubsequentDocument P_PurchasingDocHistory MaterialDocument
KEY SubsequentDocumentItem
SubsequentDocumentCategory P_PurchasingDocHistory PurchaseOrderTransactionType
MaterialDocumentYear _matDoc MaterialDocumentYear
CompanyCode _matDoc CompanyCode
PurchaseRequisition I_PurgDocScheduleLine PurchaseRequisition
PurchaseRequisitionItem I_PurgDocScheduleLine PurchaseRequisitionItem
@VDM.private: true
@VDM.viewType: #COMPOSITE
@AbapCatalog.sqlViewName: 'PPURREQNPFGR'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #PRIVILEGED_ONLY
//@AccessControl.privilegedAssociations:  [ '_purgDocHist' ]


@ClientHandling.algorithm: #SESSION_VARIABLE

define view P_PurReqnProcFlowGR as

//PO-->GR, PO-->SES-->GR

//EKET(Find PO for the PR) then Look for GR for the PO

select from  I_PurgDocScheduleLine as schedgLine
          inner join     P_PurchasingDocHistory as _purgDocHist
                              on  _purgDocHist.PurchasingDocument     = schedgLine.PurchasingDocument
                              and _purgDocHist.PurchasingDocumentItem = schedgLine.PurchasingDocumentItem

          association to I_PurchasingDocumentItem as _purgDocItem
                              on  _purgDocItem.PurchasingDocument     = schedgLine.PurchasingDocument
                              and _purgDocItem.PurchasingDocumentItem = schedgLine.PurchasingDocumentItem

          association to I_MaterialDocumentRecord as _matDoc
                          on  _purgDocHist.MaterialDocumentYear = _matDoc.MaterialDocumentYear
                          and _purgDocHist.MaterialDocument     = _matDoc.MaterialDocument
                          and _purgDocHist.MaterialDocumentItem = _matDoc.MaterialDocumentItem
{
  key case when ( _purgDocHist.PurchaseOrderTransactionType = 'S' ) or
                ( _purgDocHist.ReferenceDocument = _purgDocHist.MaterialDocument ) or
                ( _purgDocHist.ReferenceDocument like '5%' ) or                         //3209157

                ( _purgDocHist.ReferenceDocument = '' )

                    then _purgDocHist.PurchasingDocument
           else
                   _purgDocHist.ReferenceDocument
      end                                                    as   PrecedingDocument,

  key case when ( _purgDocHist.PurchaseOrderTransactionType = 'S' ) or
                ( _purgDocHist.ReferenceDocument = _purgDocHist.MaterialDocument ) or
                ( _purgDocHist.ReferenceDocument like '5%' ) or                         //3209157

                ( _purgDocHist.ReferenceDocument = '' )
                    then _purgDocHist.PurchasingDocumentItem
           else
                  cast( _purgDocHist.ReferenceDocumentItem as char5)
       end                                                   as   PrecedingDocumentItem,

  key _purgDocHist.MaterialDocument                          as   SubsequentDocument,
  key cast(_purgDocHist.MaterialDocumentItem as char5)       as   SubsequentDocumentItem,

      case when ( _purgDocHist.PurchaseOrderTransactionType = 'S' ) or
                ( _purgDocHist.ReferenceDocument = _purgDocHist.MaterialDocument ) or
                ( _purgDocHist.ReferenceDocument like '5%' ) or                         //3209157

                ( _purgDocHist.ReferenceDocument = '' )
                then cast( 'F'  as ebstyp)
        else
          cast( 'S'  as ebstyp)
        end                                                  as   PrecedingDocumentCategory,

      _purgDocHist.PurchaseOrderTransactionType              as   SubsequentDocumentCategory,


      _matDoc.MaterialDocumentYear,
      _matDoc.CompanyCode,


      //For Filtering

      schedgLine.PurchaseRequisition       as PurchaseRequisition,
      schedgLine.PurchaseRequisitionItem   as PurchaseRequisitionItem


}
where
( _purgDocHist.PurchaseOrderTransactionType = '1' or //Goods Receipt

  ( _purgDocHist.PurchaseOrderTransactionType = 'S' and _purgDocHist.Quantity is not initial ) ) //   Service Entry Sheet

//Why Quantity is not initial condition?

//In case SES is created and deleted, quantity in history is initialized. Hence, quantity is not initia, then do not show

//This can be achived through associating with ses view and condition with IsDeleted field. But with new association complexity increases

and _purgDocItem.PurchasingDocumentCategory = 'F'          //PO

/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MATERIALDOCUMENTRECORD",
"I_PURCHASINGDOCUMENTITEM",
"I_PURGDOCSCHEDULELINE",
"P_PURCHASINGDOCHISTORY"
],
"ASSOCIATED":
[
"I_MATERIALDOCUMENTRECORD",
"I_PURCHASINGDOCUMENTITEM"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/