P_MX_JrnlEntrItmInvcCompType
Select Compesantion type for the document
P_MX_JrnlEntrItmInvcCompType is a Consumption CDS View that provides data about "Select Compesantion type for the document" in SAP S/4HANA. It reads from 6 data sources and exposes 91 fields with key fields SourceLedger, Ledger, CompanyCode, AccountingDocument, FiscalYear. Part of development package GLO_FIN_IS_GL_MX_JE.
Data Sources (6)
| Source | Alias | Join Type |
|---|---|---|
| P_MX_JournalEntryGRHistory2 | GoodsReceiptDetails | inner |
| I_StRpJournalEntryHeaderLog | I_StRpJournalEntryHeaderLog | inner |
| P_MX_JrnlEntrItmInvcDetails | P_MX_JrnlEntrItmInvcDetails | inner |
| P_MX_JrnlEntrItmInvcDetails | P_MX_JrnlEntrItmInvcDetails | union_all |
| P_JrnlEntrAddlClrgInformation | PaidInvoices | from |
| P_JrnlEntrAddlClrgInformation | PaidInvoices | union_all |
Parameters (4)
| Name | Type | Default |
|---|---|---|
| P_Ledger | fins_ledger | |
| P_FiscalYear | fis_gjahr_no_conv | |
| P_FromPostingDate | fis_budat_from | |
| P_ToPostingDate | fis_budat_to |
Annotations (10)
| Name | Value | Level | Field |
|---|---|---|---|
| AbapCatalog.sqlViewName | PMXINVCOMP | view | |
| AbapCatalog.compiler.compareFilter | true | view | |
| AccessControl.personalData.blocking | #NOT_REQUIRED | view | |
| VDM.private | true | view | |
| VDM.viewType | #CONSUMPTION | view | |
| ClientHandling.algorithm | #SESSION_VARIABLE | view | |
| ObjectModel.usageType.sizeCategory | #XL | view | |
| ObjectModel.usageType.serviceQuality | #P | view | |
| ObjectModel.usageType.dataClass | #MIXED | view | |
| Metadata.ignorePropagatedAnnotations | true | view |
Fields (91)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | SourceLedger | DocumentDetails | SourceLedger | |
| KEY | Ledger | DocumentDetails | Ledger | |
| KEY | CompanyCode | DocumentDetails | CompanyCode | |
| KEY | AccountingDocument | DocumentDetails | AccountingDocument | |
| KEY | FiscalYear | DocumentDetails | FiscalYear | |
| StatryRptCategory | StatryRptCategory | |||
| StatryRptgEntity | StatryRptgEntity | |||
| StatryRptRunID | StatryRptRunID | |||
| AccountingDocumentItem | DocumentDetails | AccountingDocumentItem | ||
| DocumentReferenceID | DocumentReferenceID | |||
| AmountInTransactionCurrency | DocumentDetails | AmountInTransactionCurrency | ||
| TransactionCurrency | DocumentDetails | TransactionCurrency | ||
| ElectronicInvoiceUUID | ElectronicInvoiceUUID | |||
| JrnlEntryCntrySpecificRef5 | DocumentDetails | JrnlEntryCntrySpecificRef5 | ||
| TaxNumber1 | TaxNumber1 | |||
| IsFormatedForDigitalInvoice | IsFormatedForDigitalInvoice | |||
| Country | Country | |||
| Supplier | DocumentDetails | Supplier | ||
| Customer | DocumentDetails | Customer | ||
| FinancialAccountType | DocumentDetails | FinancialAccountType | ||
| ClearingDocFiscalYear | DocumentDetails | ClearingDocFiscalYear | ||
| IsReversal | DocumentDetails | IsReversal | ||
| IsReversed | DocumentDetails | IsReversed | ||
| PaymentMethod | DocumentDetails | PaymentMethod | ||
| InvoiceReferenceFiscalYear | DocumentDetails | InvoiceReferenceFiscalYear | ||
| AccountingDocumentType | DocumentDetails | AccountingDocumentType | ||
| PostingDate | DocumentDetails | PostingDate | ||
| ClearingDate | ||||
| P_Ledger | ||||
| P_FiscalYear | ||||
| P_FromPostingDate | ||||
| SourceLedger | ||||
| KEY | Ledger | InvoiceDetails | Ledger | |
| KEY | CompanyCode | P_JrnlEntrAddlClrgInformation | ClearingCompanyCode | |
| KEY | AccountingDocument | P_JrnlEntrAddlClrgInformation | ClearingAccountingDocument | |
| KEY | FiscalYear | P_JrnlEntrAddlClrgInformation | ClearingDocFiscalYear | |
| StatryRptCategory | InvoiceDetails | StatryRptCategory | ||
| StatryRptgEntity | InvoiceDetails | StatryRptgEntity | ||
| StatryRptRunID | InvoiceDetails | StatryRptRunID | ||
| AccountingDocumentItem | InvoiceDetails | AccountingDocumentItem | ||
| DocumentReferenceID | InvoiceDetails | DocumentReferenceID | ||
| AmountInTransactionCurrency | ||||
| TransactionCurrency | InvoiceDetails | TransactionCurrency | ||
| ElectronicInvoiceUUID | InvoiceDetails | ElectronicInvoiceUUID | ||
| JrnlEntryCntrySpecificRef5 | InvoiceDetails | JrnlEntryCntrySpecificRef5 | ||
| TaxNumber1 | InvoiceDetails | TaxNumber1 | ||
| IsFormatedForDigitalInvoice | InvoiceDetails | IsFormatedForDigitalInvoice | ||
| Country | InvoiceDetails | Country | ||
| Supplier | InvoiceDetails | Supplier | ||
| Customer | InvoiceDetails | Customer | ||
| FinancialAccountType | InvoiceDetails | FinancialAccountType | ||
| ClearingDocFiscalYear | P_JrnlEntrAddlClrgInformation | ClearingDocFiscalYear | ||
| IsReversal | InvoiceDetails | IsReversal | ||
| IsReversed | InvoiceDetails | IsReversed | ||
| PaymentMethod | InvoiceDetails | PaymentMethod | ||
| InvoiceReferenceFiscalYear | InvoiceDetails | InvoiceReferenceFiscalYear | ||
| AccountingDocumentType | InvoiceDetails | AccountingDocumentType | ||
| PostingDate | InvoiceDetails | PostingDate | ||
| ClearingDate | InvoiceDetails | ClearingDate | ||
| P_Ledger | ||||
| P_FiscalYear | ||||
| P_FromPostingDate | ||||
| SourceLedger | ||||
| KEY | Ledger | SupplierInvoiceDetails | Ledger | |
| KEY | CompanyCode | SupplierInvoiceDetails | CompanyCode | |
| KEY | AccountingDocument | P_MX_JournalEntryGRHistory2 | MaterialDocumentNumber | |
| KEY | FiscalYear | P_MX_JournalEntryGRHistory2 | MaterialDocumentYear | |
| StatryRptCategory | SupplierInvoiceDetails | StatryRptCategory | ||
| StatryRptgEntity | SupplierInvoiceDetails | StatryRptgEntity | ||
| StatryRptRunID | SupplierInvoiceDetails | StatryRptRunID | ||
| AccountingDocumentItem | SupplierInvoiceDetails | AccountingDocumentItem | ||
| DocumentReferenceID | SupplierInvoiceDetails | DocumentReferenceID | ||
| AmountInTransactionCurrency | ||||
| TransactionCurrency | SupplierInvoiceDetails | TransactionCurrency | ||
| ElectronicInvoiceUUID | SupplierInvoiceDetails | ElectronicInvoiceUUID | ||
| JrnlEntryCntrySpecificRef5 | SupplierInvoiceDetails | JrnlEntryCntrySpecificRef5 | ||
| TaxNumber1 | SupplierInvoiceDetails | TaxNumber1 | ||
| IsFormatedForDigitalInvoice | SupplierInvoiceDetails | IsFormatedForDigitalInvoice | ||
| Country | SupplierInvoiceDetails | Country | ||
| Supplier | SupplierInvoiceDetails | Supplier | ||
| Customer | SupplierInvoiceDetails | Customer | ||
| FinancialAccountType | SupplierInvoiceDetails | FinancialAccountType | ||
| ClearingDocFiscalYear | SupplierInvoiceDetails | ClearingDocFiscalYear | ||
| IsReversal | SupplierInvoiceDetails | IsReversal | ||
| IsReversed | SupplierInvoiceDetails | IsReversed | ||
| PaymentMethod | SupplierInvoiceDetails | PaymentMethod | ||
| InvoiceReferenceFiscalYear | SupplierInvoiceDetails | InvoiceReferenceFiscalYear | ||
| AccountingDocumentType | SupplierInvoiceDetails | AccountingDocumentType | ||
| PostingDate | SupplierInvoiceDetails | PostingDate | ||
| ClearingDate | SupplierInvoiceDetails | ClearingDate | ||
| IsOriginalDocument |
@AbapCatalog.sqlViewName: 'PMXINVCOMP'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.personalData.blocking: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType: { sizeCategory: #XL , serviceQuality: #P, dataClass: #MIXED }
@Metadata.ignorePropagatedAnnotations:true
define view P_MX_JrnlEntrItmInvcCompType
with parameters
P_Ledger : fins_ledger,
P_FiscalYear : fis_gjahr_no_conv,
P_FromPostingDate : fis_budat_from,
P_ToPostingDate : fis_budat_to
as select distinct from P_MX_JrnlEntrItmInvcDetails( P_Ledger : $parameters.P_Ledger,
P_FiscalYear : $parameters.P_FiscalYear,
P_FromPostingDate : $parameters.P_FromPostingDate,
P_ToPostingDate : $parameters.P_ToPostingDate ) as DocumentDetails
// process all original documents (invoices and payments)
{
key DocumentDetails.SourceLedger,
key DocumentDetails.Ledger,
key DocumentDetails.CompanyCode,
key DocumentDetails.AccountingDocument,
key DocumentDetails.FiscalYear,
//Audit Trail
StatryRptCategory,
StatryRptgEntity,
StatryRptRunID,
DocumentDetails.AccountingDocumentItem,
DocumentReferenceID,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
DocumentDetails.AmountInTransactionCurrency,
@Semantics.currencyCode:true
DocumentDetails.TransactionCurrency,
ElectronicInvoiceUUID,
DocumentDetails.JrnlEntryCntrySpecificRef5,
TaxNumber1,
IsFormatedForDigitalInvoice,
@DefaultAggregation: #MIN
cast ( case
when DocumentDetails.TransactionCurrency <> 'MXN' then ExchangeRate
else 0
end as ukurs_curr preserving type ) as ExchangeRate,
Country,
DocumentDetails.Supplier,
DocumentDetails.Customer,
DocumentDetails.FinancialAccountType,
DocumentDetails.ClearingDocFiscalYear,
DocumentDetails.IsReversal,
DocumentDetails.IsReversed,
DocumentDetails.PaymentMethod,
DocumentDetails.InvoiceReferenceFiscalYear,
DocumentDetails.AccountingDocumentType,
DocumentDetails.PostingDate,
cast ('00000000' as augdt ) as ClearingDate, //partial payments may not have a clearing date, causing aggregation in upper view to break
'X' as IsOriginalDocument
}
where
(
DocumentDetails.IsReversal <> 'X'
)
union all
// process all related documents, for example, invoices paid by a given payment document
select from P_JrnlEntrAddlClrgInformation as PaidInvoices
inner join P_MX_JrnlEntrItmInvcDetails( P_Ledger : $parameters.P_Ledger,
P_FiscalYear : $parameters.P_FiscalYear,
P_FromPostingDate : $parameters.P_FromPostingDate,
P_ToPostingDate : $parameters.P_ToPostingDate ) as InvoiceDetails on InvoiceDetails.CompanyCode = PaidInvoices.ClearingCompanyCode
and InvoiceDetails.CompanyCode = PaidInvoices.CompanyCode
and InvoiceDetails.AccountingDocument = PaidInvoices.AccountingDocument
and InvoiceDetails.FiscalYear = PaidInvoices.FiscalYear
inner join I_StRpJournalEntryHeaderLog on I_StRpJournalEntryHeaderLog.CompanyCode = PaidInvoices.ClearingCompanyCode
and I_StRpJournalEntryHeaderLog.AccountingDocument = PaidInvoices.ClearingAccountingDocument
and I_StRpJournalEntryHeaderLog.FiscalYear = PaidInvoices.ClearingDocFiscalYear
and I_StRpJournalEntryHeaderLog.StatryRptCategory = InvoiceDetails.StatryRptCategory
and I_StRpJournalEntryHeaderLog.StatryRptgEntity = InvoiceDetails.StatryRptgEntity
and I_StRpJournalEntryHeaderLog.StatryRptRunID = InvoiceDetails.StatryRptRunID
{
// use the payment document key for all the invoices being paid
key InvoiceDetails.SourceLedger,
key InvoiceDetails.Ledger,
key PaidInvoices.ClearingCompanyCode as CompanyCode,
key PaidInvoices.ClearingAccountingDocument as AccountingDocument,
key PaidInvoices.ClearingDocFiscalYear as FiscalYear,
InvoiceDetails.StatryRptCategory,
InvoiceDetails.StatryRptgEntity,
InvoiceDetails.StatryRptRunID,
InvoiceDetails.AccountingDocumentItem,
InvoiceDetails.DocumentReferenceID,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
abs(InvoiceDetails.AmountInTransactionCurrency) as AmountInTransactionCurrency,
@Semantics.currencyCode:true
InvoiceDetails.TransactionCurrency,
InvoiceDetails.ElectronicInvoiceUUID,
InvoiceDetails.JrnlEntryCntrySpecificRef5,
InvoiceDetails.TaxNumber1,
InvoiceDetails.IsFormatedForDigitalInvoice,
@DefaultAggregation: #MIN
cast ( case
when InvoiceDetails.TransactionCurrency <> 'MXN' then InvoiceDetails.ExchangeRate
else 0
end as ukurs_curr preserving type ) as ExchangeRate,
InvoiceDetails.Country,
InvoiceDetails.Supplier,
InvoiceDetails.Customer,
InvoiceDetails.FinancialAccountType,
PaidInvoices.ClearingDocFiscalYear,
InvoiceDetails.IsReversal,
InvoiceDetails.IsReversed,
InvoiceDetails.PaymentMethod,
InvoiceDetails.InvoiceReferenceFiscalYear,
InvoiceDetails.AccountingDocumentType,
InvoiceDetails.PostingDate,
InvoiceDetails.ClearingDate,
'' as IsOriginalDocument
}
where
(
PaidInvoices.FinancialAccountType <> 'S' //disregard GL transfer documents
//This filters only the old mexico reporting type of invoices, the Document Reference ID field MUST have a '-' or ' 'in it,
//so the fields CFD_CBB_Serie and CFD_CBB_NumFol are filled in the SAT report
and(
(
(
InvoiceDetails.Country = 'MX'
and InvoiceDetails.IsFormatedForDigitalInvoice = 'X'
)
or
//This filters the Foreing compensation invoices that MUST have info in the field Document Reference ID
(
InvoiceDetails.Country <> 'MX'
and InvoiceDetails.DocumentReferenceID is not null
and InvoiceDetails.DocumentReferenceID <> ''
)
)
//If the Document have a UUID it is a valid Invoice no other filters are needed
or(
InvoiceDetails.ElectronicInvoiceUUID is not null
and InvoiceDetails.ElectronicInvoiceUUID <> ''
)
)
)
union all
// take compensation details from MM supplier invoices (MIRO) to include them under the related goods receipt (MIGO) document node
select from P_MX_JrnlEntrItmInvcDetails( P_Ledger : $parameters.P_Ledger,
P_FiscalYear : $parameters.P_FiscalYear,
P_FromPostingDate : $parameters.P_FromPostingDate,
P_ToPostingDate : $parameters.P_ToPostingDate ) as SupplierInvoiceDetails
inner join P_MX_JournalEntryGRHistory2 as GoodsReceiptDetails on GoodsReceiptDetails.Ledger = SupplierInvoiceDetails.Ledger
and GoodsReceiptDetails.CompanyCode = SupplierInvoiceDetails.CompanyCode
and GoodsReceiptDetails.AccountingDocument = SupplierInvoiceDetails.AccountingDocument
and GoodsReceiptDetails.FiscalYear = SupplierInvoiceDetails.FiscalYear
{
key SupplierInvoiceDetails.SourceLedger,
key SupplierInvoiceDetails.Ledger,
key SupplierInvoiceDetails.CompanyCode,
key GoodsReceiptDetails.MaterialDocumentNumber as AccountingDocument,
key GoodsReceiptDetails.MaterialDocumentYear as FiscalYear,
SupplierInvoiceDetails.StatryRptCategory,
SupplierInvoiceDetails.StatryRptgEntity,
SupplierInvoiceDetails.StatryRptRunID,
SupplierInvoiceDetails.AccountingDocumentItem,
SupplierInvoiceDetails.DocumentReferenceID,
@DefaultAggregation: #SUM
@Semantics: { amount : {currencyCode: 'TransactionCurrency'} }
abs(SupplierInvoiceDetails.AmountInTransactionCurrency) as AmountInTransactionCurrency,
@Semantics.currencyCode:true
SupplierInvoiceDetails.TransactionCurrency,
SupplierInvoiceDetails.ElectronicInvoiceUUID,
SupplierInvoiceDetails.JrnlEntryCntrySpecificRef5,
SupplierInvoiceDetails.TaxNumber1,
SupplierInvoiceDetails.IsFormatedForDigitalInvoice,
@DefaultAggregation: #MIN
cast ( case
when SupplierInvoiceDetails.TransactionCurrency <> 'MXN' then SupplierInvoiceDetails.ExchangeRate
else 0
end as ukurs_curr preserving type ) as ExchangeRate,
SupplierInvoiceDetails.Country,
SupplierInvoiceDetails.Supplier,
SupplierInvoiceDetails.Customer,
SupplierInvoiceDetails.FinancialAccountType,
SupplierInvoiceDetails.ClearingDocFiscalYear,
SupplierInvoiceDetails.IsReversal,
SupplierInvoiceDetails.IsReversed,
SupplierInvoiceDetails.PaymentMethod,
SupplierInvoiceDetails.InvoiceReferenceFiscalYear,
SupplierInvoiceDetails.AccountingDocumentType,
SupplierInvoiceDetails.PostingDate,
SupplierInvoiceDetails.ClearingDate,
'' as IsOriginalDocument
}
Learn More
- What Is a CDS View in SAP S/4HANA?
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- CDS View Annotations — A Complete Guide
- CDS View Field Mapping and Associations
- Understanding the SAP S/4HANA Data Model
- CDS View Extensions and Custom Fields in SAP S/4HANA
- Released APIs and Stability Contracts in SAP S/4HANA