P_RO_SAFTPurInvHdr1

DDL: P_RO_SAFTPURINVHDR1 SQL: PROSAFTPURIH1 Type: view CONSUMPTION Package: GLO_FIN_IS_SAFT_RO

Pur Inv Header for RO SAFT Base 1

P_RO_SAFTPurInvHdr1 is a Consumption CDS View that provides data about "Pur Inv Header for RO SAFT Base 1" in SAP S/4HANA. It reads from 4 data sources (I_RO_SAFTDocumentTypeMap, I_StRpJournalEntryHeaderLog, P_RO_SAFTInvoiceItemCount, P_RO_SAFTJournalEntryItemExc) and exposes 11 fields with key fields StatryRptCategory, StatryRptgEntity, StatryRptRunID, SourceLedger, Ledger. Part of development package GLO_FIN_IS_SAFT_RO.

Data Sources (4)

SourceAliasJoin Type
I_RO_SAFTDocumentTypeMap DocType inner
I_StRpJournalEntryHeaderLog Log from
P_RO_SAFTInvoiceItemCount P_RO_SAFTInvoiceItemCount inner
P_RO_SAFTJournalEntryItemExc P_RO_SAFTJournalEntryItemExc inner

Parameters (1)

NameTypeDefault
P_AlternativeGLAccountIsUsed saft_ro_alt_gl_account_flag

Annotations (12)

NameValueLevelField
AbapCatalog.sqlViewName PROSAFTPURIH1 view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
VDM.viewType #CONSUMPTION view
VDM.private true view
EndUserText.label Pur Inv Header for RO SAFT Base 1 view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.sizeCategory #L view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.dataClass #TRANSACTIONAL view
AccessControl.authorizationCheck #MANDATORY view
AccessControl.personalData.blocking #BLOCKED_DATA_INCLUDED view

Fields (11)

KeyFieldSource TableSource FieldDescription
KEY StatryRptCategory I_StRpJournalEntryHeaderLog StatryRptCategory
KEY StatryRptgEntity I_StRpJournalEntryHeaderLog StatryRptgEntity
KEY StatryRptRunID I_StRpJournalEntryHeaderLog StatryRptRunID
KEY SourceLedger Acdoca SourceLedger
KEY Ledger Acdoca Ledger
KEY CompanyCode Acdoca CompanyCode
KEY FiscalYear Acdoca FiscalYear
KEY AccountingDocument Acdoca AccountingDocument
PostingDate Acdoca PostingDate
AccountingDocumentType Acdoca AccountingDocumentType
AccountingDocumentItem
@AbapCatalog.sqlViewName:'PROSAFTPURIH1'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey:true
@VDM.viewType: #CONSUMPTION
@VDM.private:true
@EndUserText.label: 'Pur Inv Header for RO SAFT Base 1'
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.sizeCategory: #L
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #TRANSACTIONAL
@AccessControl.authorizationCheck: #MANDATORY
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED

/**
    - This view selects exactly one item of each purchase invoice
    - The selected item is a supplier item
    - In case of more suppliers it is the item whose AccountingDocumentItem is the highest
**/

define view P_RO_SAFTPurInvHdr1
  with parameters
    P_AlternativeGLAccountIsUsed : saft_ro_alt_gl_account_flag

  as select from           I_StRpJournalEntryHeaderLog                                                                          as Log

    inner join             P_RO_SAFTJournalEntryItemExc(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed) as Acdoca             on  Acdoca.AccountingDocument   = Log.AccountingDocument
                                                                                                                                                      and Acdoca.CompanyCode          = Log.CompanyCode
                                                                                                                                                      and Acdoca.FiscalYear           = Log.FiscalYear
                                                                                                                                                      and Acdoca.FinancialAccountType = 'K'

    inner join             P_RO_SAFTInvoiceItemCount(P_AlternativeGLAccountIsUsed: $parameters.P_AlternativeGLAccountIsUsed)    as ItemCount          on  ItemCount.AccountingDocument     = Acdoca.AccountingDocument
                                                                                                                                                      and ItemCount.CompanyCode            = Acdoca.CompanyCode
                                                                                                                                                      and ItemCount.FiscalYear             = Acdoca.FiscalYear
                                                                                                                                                      and ItemCount.PostingDate            = Acdoca.PostingDate
                                                                                                                                                      and ItemCount.AccountingDocumentType = Acdoca.AccountingDocumentType
                                                                                                                                                      and ItemCount.TaxType                = 'V'

    inner join             I_RO_SAFTDocumentTypeMap                                                                             as DocType            on  DocType.AccountingDocumentType    = Acdoca.AccountingDocumentType
                                                                                                                                                      and DocType.CompanyCode               = Acdoca.CompanyCode
                                                                                                                                                      and DocType.RO_SAFTSourceDocumentType = '03'

    left outer to one join I_RO_SAFTSpecialGLIndicator                                                                          as SpecialGLIndicator on  Acdoca.CompanyCode          = SpecialGLIndicator.CompanyCode
                                                                                                                                                      and Acdoca.FinancialAccountType = SpecialGLIndicator.AccountType
                                                                                                                                                      and Acdoca.SpecialGLCode        = SpecialGLIndicator.SpecialGLCode

{
  key Log.StatryRptCategory,
  key Log.StatryRptgEntity,
  key Log.StatryRptRunID,
  key Acdoca.SourceLedger,
  key Acdoca.Ledger,
  key Acdoca.CompanyCode,
  key Acdoca.FiscalYear,
  key Acdoca.AccountingDocument,
      Acdoca.PostingDate,
      Acdoca.AccountingDocumentType,
      max(Acdoca.AccountingDocumentItem) as AccountingDocumentItem
}
where
  SpecialGLIndicator.SpecialGLCode is null

group by
  Log.StatryRptCategory,
  Log.StatryRptgEntity,
  Log.StatryRptRunID,
  Acdoca.SourceLedger,
  Acdoca.Ledger,
  Acdoca.CompanyCode,
  Acdoca.FiscalYear,
  Acdoca.AccountingDocument,
  Acdoca.PostingDate,
  Acdoca.AccountingDocumentType