P_MX_OperationalAcctDocItem

DDL: P_MX_OPERATIONALACCTDOCITEM Type: view CONSUMPTION

P_MX_OperationalAcctDocItem is a Consumption CDS View in SAP S/4HANA. It reads from 3 data sources (I_OperationalAcctgDocItem, I_StRpJournalEntryHeaderLog, I_JournalEntryItem) and exposes 45 fields with key fields SourceLedger, Ledger, CompanyCode, AccountingDocument, FiscalYear. It has 1 association to related views.

Data Sources (3)

SourceAliasJoin Type
I_OperationalAcctgDocItem DocumentItem inner
I_StRpJournalEntryHeaderLog I_StRpJournalEntryHeaderLog inner
I_JournalEntryItem JournalEntryItem from

Parameters (4)

NameTypeDefault
P_Ledger fins_ledger
P_FiscalYear fis_gjahr_no_conv
P_FromPostingDate fis_budat_from
P_ToPostingDate fis_budat_to

Associations (1)

CardinalityTargetAliasCondition
[0..1] I_JournalEntryItemOneTimeData _OneTimeAccountBP _OneTimeAccountBP.CompanyCode = $projection.CompanyCode and _OneTimeAccountBP.AccountingDocument = $projection.AccountingDocument and _OneTimeAccountBP.FiscalYear = $projection.FiscalYear and _OneTimeAccountBP.AccountingDocumentItem = $projection.AccountingDocumentItem

Annotations (10)

NameValueLevelField
AbapCatalog.compiler.compareFilter true view
AbapCatalog.sqlViewName PMXOPERADOCIT view
AccessControl.personalData.blocking #BLOCKED_DATA_INCLUDED view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #P view
ObjectModel.usageType.sizeCategory #XL view
Metadata.ignorePropagatedAnnotations true view
VDM.private true view
VDM.viewType #CONSUMPTION view

Fields (45)

KeyFieldSource TableSource FieldDescription
KEY SourceLedger I_JournalEntryItem SourceLedger
KEY Ledger I_JournalEntryItem Ledger
KEY CompanyCode I_JournalEntryItem CompanyCode
KEY AccountingDocument I_JournalEntryItem AccountingDocument
KEY FiscalYear
KEY AccountingDocumentItem I_JournalEntryItem AccountingDocumentItem
KEY StatryRptgEntity I_StRpJournalEntryHeaderLog StatryRptgEntity
KEY StatryRptCategory I_StRpJournalEntryHeaderLog StatryRptCategory
KEY StatryRptRunID I_StRpJournalEntryHeaderLog StatryRptRunID
OrganizationBPName1
Country
TaxNumber1
DigInvcOp1
DigInvcOp2
ExchangeRate
DocumentReferenceID
AmountInTransactionCurrency I_JournalEntryItem AmountInTransactionCurrency
TransactionCurrency I_JournalEntryItem TransactionCurrency
DebitCreditCode I_JournalEntryItem DebitCreditCode
ReferenceDocument I_JournalEntryItem ReferenceDocument
ReferenceDocumentContext I_JournalEntryItem ReferenceDocumentContext
ReferenceDocumentType I_JournalEntryItem ReferenceDocumentType
IsReversal I_JournalEntryItem IsReversal
IsReversed I_JournalEntryItem IsReversed
SenderLogicalSystem
AccountingDocumentHeaderText
TransactionCode
JrnlEntryCntrySpecificRef1
OplAcctgDocItmCntrySpcfcRef1 I_OperationalAcctgDocItem OplAcctgDocItmCntrySpcfcRef1
PaymentMethod I_OperationalAcctgDocItem PaymentMethod
JrnlEntryCntrySpecificRef5
TaxNumberLineItem I_OperationalAcctgDocItem Reference3IDByBusinessPartner
PostingDate I_JournalEntryItem PostingDate
FinancialAccountType I_JournalEntryItem FinancialAccountType
Customer I_JournalEntryItem Customer
Supplier I_JournalEntryItem Supplier
AccountingDocumentType I_JournalEntryItem AccountingDocumentType
ClearingDate I_JournalEntryItem ClearingDate
ClearingDocFiscalYear I_JournalEntryItem ClearingDocFiscalYear
InvoiceReference I_JournalEntryItem InvoiceReference
InvoiceReferenceFiscalYear
_Customer I_JournalEntryItem _Customer
_Supplier I_JournalEntryItem _Supplier
_JournalEntry I_JournalEntryItem _JournalEntry
_OneTimeAccountBP _OneTimeAccountBP
@AbapCatalog: {
  compiler.compareFilter: true,
  sqlViewName: 'PMXOPERADOCIT'
}
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType: {
  dataClass: #MIXED,
  serviceQuality: #P,
  sizeCategory: #XL
}
@Metadata.ignorePropagatedAnnotations: true
@VDM: {
  private: true,
  viewType: #CONSUMPTION
}

define view P_MX_OperationalAcctDocItem
  with parameters
    P_Ledger          : fins_ledger,
    P_FiscalYear      : fis_gjahr_no_conv,
    P_FromPostingDate : fis_budat_from,
    P_ToPostingDate   : fis_budat_to

  as select from I_JournalEntryItem        as JournalEntryItem

    inner join   I_StRpJournalEntryHeaderLog               on  I_StRpJournalEntryHeaderLog.CompanyCode        = JournalEntryItem.CompanyCode
                                                           and I_StRpJournalEntryHeaderLog.FiscalYear         = JournalEntryItem.FiscalYear
                                                           and I_StRpJournalEntryHeaderLog.AccountingDocument = JournalEntryItem.AccountingDocument

    inner join   I_OperationalAcctgDocItem as DocumentItem on  JournalEntryItem.CompanyCode            = DocumentItem.CompanyCode
                                                           and JournalEntryItem.AccountingDocument     = DocumentItem.AccountingDocument
                                                           and JournalEntryItem.FiscalYear             = DocumentItem.FiscalYear
                                                           and JournalEntryItem.AccountingDocumentItem = DocumentItem.AccountingDocumentItem

  association [0..1] to I_JournalEntryItemOneTimeData as _OneTimeAccountBP on  _OneTimeAccountBP.CompanyCode            = $projection.CompanyCode
                                                                           and _OneTimeAccountBP.AccountingDocument     = $projection.AccountingDocument
                                                                           and _OneTimeAccountBP.FiscalYear             = $projection.FiscalYear
                                                                           and _OneTimeAccountBP.AccountingDocumentItem = $projection.AccountingDocumentItem


{
      // This view was created to solve the BP Name, Country and TaxNumber for OneTimeBP, supplier and customer in specifics fields

  key JournalEntryItem.SourceLedger,
  key JournalEntryItem.Ledger,
  key JournalEntryItem.CompanyCode,
  key JournalEntryItem.AccountingDocument,
  key cast( JournalEntryItem.FiscalYear as fis_gjahr_no_conv preserving type )                                                                                                                            as FiscalYear,
  key JournalEntryItem.AccountingDocumentItem,
  key I_StRpJournalEntryHeaderLog.StatryRptgEntity,
  key I_StRpJournalEntryHeaderLog.StatryRptCategory,
  key I_StRpJournalEntryHeaderLog.StatryRptRunID,

      cast( coalesce( _OneTimeAccountBP.BusinessPartnerName1, coalesce( JournalEntryItem._Supplier.OrganizationBPName1,  JournalEntryItem._Customer.OrganizationBPName1 ) ) as ad_name1 preserving type ) as OrganizationBPName1,
      cast( coalesce( _OneTimeAccountBP.Country,              coalesce( JournalEntryItem._Supplier.Country,              JournalEntryItem._Customer.Country             ) ) as land1_gp preserving type ) as Country,
      cast( coalesce( _OneTimeAccountBP.TaxID1,               coalesce( JournalEntryItem._Supplier.TaxNumber1,           JournalEntryItem._Customer.TaxNumber1          ) ) as stcd1 preserving type )    as TaxNumber1,

      //This field verify if there is one of the options for separete the prefix to the folio number,

      //that is used in the P_MX_JrnlEntrItmInvcDetails view for logic

      instr( JournalEntryItem._JournalEntry.DocumentReferenceID, '-' )                                                                                                                                    as DigInvcOp1,
      instr( JournalEntryItem._JournalEntry.DocumentReferenceID, ' ' )                                                                                                                                    as DigInvcOp2,

      cast( case when JournalEntryItem._JournalEntry.TransactionCurrency <> 'MXN' then JournalEntryItem._JournalEntry.ExchangeRate end as kursf preserving type )                                         as ExchangeRate,

      JournalEntryItem._JournalEntry.DocumentReferenceID,
      JournalEntryItem.AmountInTransactionCurrency,
      JournalEntryItem.TransactionCurrency,
      JournalEntryItem.DebitCreditCode,

      JournalEntryItem.ReferenceDocument,
      JournalEntryItem.ReferenceDocumentContext,
      JournalEntryItem.ReferenceDocumentType,
      JournalEntryItem.IsReversal,
      JournalEntryItem.IsReversed,
      JournalEntryItem._JournalEntry.SenderLogicalSystem,
      JournalEntryItem._JournalEntry.AccountingDocumentHeaderText,
      JournalEntryItem._JournalEntry.TransactionCode,

      // UUID fields at header and item levels

      JournalEntryItem._JournalEntry.JrnlEntryCntrySpecificRef1,
      DocumentItem.OplAcctgDocItmCntrySpcfcRef1,
      // Manual Payment Details

      DocumentItem.PaymentMethod,
      cast( substring( JournalEntryItem._JournalEntry.JrnlEntryCntrySpecificRef5, 1, 50 ) as figlmx_manualpaymentdetails preserving type )                                                                as JrnlEntryCntrySpecificRef5,

      // Tax Number at line item level

      DocumentItem.Reference3IDByBusinessPartner                                                                                                                                                          as TaxNumberLineItem,

      JournalEntryItem.PostingDate,
      JournalEntryItem.FinancialAccountType,
      JournalEntryItem.Customer,
      JournalEntryItem.Supplier,
      JournalEntryItem.AccountingDocumentType,
      JournalEntryItem.ClearingDate,
      JournalEntryItem.ClearingDocFiscalYear,
      JournalEntryItem.InvoiceReference,
      cast( JournalEntryItem.InvoiceReferenceFiscalYear as fis_gjahr_no_conv preserving type )                                                                                                            as InvoiceReferenceFiscalYear,

      // Associations

      JournalEntryItem._Customer,
      JournalEntryItem._Supplier,
      JournalEntryItem._JournalEntry,
      _OneTimeAccountBP
}
where
        JournalEntryItem.Ledger                   = $parameters.P_Ledger
  and   JournalEntryItem.FiscalYear               = $parameters.P_FiscalYear
  and   JournalEntryItem.PostingDate              between $parameters.P_FromPostingDate and $parameters.P_ToPostingDate
  and   JournalEntryItem.FinancialAccountType     = 'K'
  or    JournalEntryItem.FinancialAccountType     = 'D'
  or(
        JournalEntryItem.FinancialAccountType     = 'S'
    and DocumentItem.OplAcctgDocItmCntrySpcfcRef1 is not null
    and DocumentItem.OplAcctgDocItmCntrySpcfcRef1 is not initial
  )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_CUSTOMER",
"I_JOURNALENTRY",
"I_JOURNALENTRYITEM",
"I_JOURNALENTRYITEMONETIMEDATA",
"I_OPERATIONALACCTGDOCITEM",
"I_STRPJOURNALENTRYHEADERLOG",
"I_SUPPLIER"
],
"ASSOCIATED":
[
"I_CUSTOMER",
"I_JOURNALENTRY",
"I_JOURNALENTRYITEMONETIMEDATA",
"I_SUPPLIER"
],
"BASE":
[
"I_JOURNALENTRYITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/