P_BG_SAFTPURINVOICEHEADER
Purchase Invoice Header For BG SAFT
P_BG_SAFTPURINVOICEHEADER is a Consumption CDS View that provides data about "Purchase Invoice Header For BG SAFT" in SAP S/4HANA. It reads from 4 data sources (I_JournalEntry, I_OperationalAcctgDocItem, P_BG_SAFTINVOICEITEMCOUNT, P_BG_SAFTPURINVHDR) and exposes 23 fields with key fields SourceLedger, CompanyCode, FiscalYear, AccountingDocument, Ledger. Part of development package GLO_FIN_IS_SAFT_BG.
Data Sources (4)
| Source | Alias | Join Type |
|---|---|---|
| I_JournalEntry | Bkpf | inner |
| I_OperationalAcctgDocItem | Bseg | inner |
| P_BG_SAFTINVOICEITEMCOUNT | CountFilter | inner |
| P_BG_SAFTPURINVHDR | Header | from |
Parameters (3)
| Name | Type | Default |
|---|---|---|
| P_AlternativeGLAccountIsUsed | saft_bg_alt_gl_account_flag | |
| P_UserSystemIdentifier | sysid | |
| P_VATRegistration | stceg |
Annotations (7)
| Name | Value | Level | Field |
|---|---|---|---|
| VDM.viewType | #CONSUMPTION | view | |
| VDM.private | true | view | |
| AccessControl.authorizationCheck | #NOT_REQUIRED | view | |
| Metadata.ignorePropagatedAnnotations | true | view | |
| ObjectModel.usageType.serviceQuality | #X | view | |
| ObjectModel.usageType.sizeCategory | #S | view | |
| ObjectModel.usageType.dataClass | #MIXED | view |
Fields (23)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | SourceLedger | P_BG_SAFTPURINVHDR | SourceLedger | |
| KEY | CompanyCode | P_BG_SAFTPURINVHDR | CompanyCode | |
| KEY | FiscalYear | P_BG_SAFTPURINVHDR | FiscalYear | |
| KEY | AccountingDocument | P_BG_SAFTPURINVHDR | AccountingDocument | |
| KEY | Ledger | P_BG_SAFTPURINVHDR | Ledger | |
| AccountingDocumentItem | P_BG_SAFTPURINVHDR | AccountingDocumentItem | ||
| FiscalPeriod | I_JournalEntry | FiscalPeriod | ||
| PostingDate | I_JournalEntry | PostingDate | ||
| InvoiceDate | I_JournalEntry | DocumentDate | ||
| TaxReportingDate | I_JournalEntry | TaxReportingDate | ||
| AccountingDocumentType | I_JournalEntry | AccountingDocumentType | ||
| AccountingDocCreatedByUser | I_JournalEntry | AccountingDocCreatedByUser | ||
| Supplier | Supplier | Supplier | ||
| HouseNumber1endasStreetName | ||||
| BPAddrCityNameendasCityName | ||||
| PostalCodeendasPostalCode | ||||
| CountryendasCountry | ||||
| BG_SAFTInvoiceType | P_BG_SAFTPURINVHDR | BG_SAFTSourceDocumentType | ||
| VATRegistrationendasSupplierTaxID5 | ||||
| GLAccountendasActiveGLAccount | ||||
| BG_SAFTSystemID | ||||
| PaymentTermsName | ||||
| SelfBillingValueItemDesc |
@AbapCatalog.viewEnhancementCategory: [#NONE]
@VDM.viewType: #CONSUMPTION
@VDM.private:true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define view entity P_BG_SAFTPURINVOICEHEADER
with parameters
P_AlternativeGLAccountIsUsed : saft_bg_alt_gl_account_flag,
P_UserSystemIdentifier : sysid,
P_VATRegistration : stceg
as select from P_BG_SAFTPURINVHDR as Header
inner join I_JournalEntry as Bkpf on Bkpf.AccountingDocument = Header.AccountingDocument
and Bkpf.CompanyCode = Header.CompanyCode
and Bkpf.FiscalYear = Header.FiscalYear
and Bkpf.AccountingDocumentType = Header.AccountingDocumentType
and Bkpf.PostingDate = Header.PostingDate
inner join I_OperationalAcctgDocItem as Bseg on Bseg.AccountingDocument = Header.AccountingDocument
and Bseg.CompanyCode = Header.CompanyCode
and Bseg.FiscalYear = Header.FiscalYear
and Bseg.AccountingDocumentItem = Header.AccountingDocumentItem
and Bseg.AccountingDocumentType = Header.AccountingDocumentType
and Bseg.PostingDate = Header.PostingDate
inner join P_BG_SAFTINVOICEITEMCOUNT as CountFilter on CountFilter.AccountingDocument = Header.AccountingDocument
and CountFilter.FiscalYear = Header.FiscalYear
and CountFilter.CompanyCode = Header.CompanyCode
and CountFilter.PostingDate = Header.PostingDate
and CountFilter.AccountingDocumentType = Header.AccountingDocumentType
left outer to one join I_Supplier as Supplier on Supplier.Supplier = Bseg.Supplier
// Supplier country
left outer to one join I_Country as BsegStcegCountry on BsegStcegCountry.Country = left(
Bseg.VATRegistration, 2
)
// Supplier specific table with Supplier VAT number information
left outer to one join P_BG_SAFTSUPPLIERID as TaxType on TaxType.Supplier = Bseg.Supplier
left outer to one join I_PaymentTerms as PayTerms on Bseg.PaymentTerms = PayTerms.PaymentTerms
left outer to one join I_BG_SAFTOneTimeSupplier as OTC on OTC.AccountingDocument = Bseg.AccountingDocument
and OTC.CompanyCode = Bseg.CompanyCode
and OTC.FiscalYear = Bseg.FiscalYear
and OTC.AccountingDocumentItem = Bseg.AccountingDocumentItem
{
key Header.SourceLedger,
key Header.CompanyCode,
key Header.FiscalYear,
key Header.AccountingDocument,
key Header.Ledger,
Header.AccountingDocumentItem,
Bkpf.FiscalPeriod,
Bkpf.PostingDate,
Bkpf.DocumentDate as InvoiceDate,
Bkpf.TaxReportingDate,
Bkpf.AccountingDocumentType,
Bkpf.AccountingDocCreatedByUser,
Supplier.Supplier,
case when TaxType.BPTaxLongNumber <> '0' then concat_with_space( Supplier.BPAddrStreetName, Supplier._AddressDefaultRepresentation.HouseNumber, 1 )
else coalesce(OTC.StreetName, concat_with_space( Supplier.BPAddrStreetName, Supplier._AddressDefaultRepresentation.HouseNumber, 1 ))
end as StreetName,
case when TaxType.BPTaxLongNumber <> '0' then Supplier.BPAddrCityName
else coalesce(OTC.CityName, Supplier.BPAddrCityName)
end as CityName,
case when TaxType.BPTaxLongNumber <> '0' then Supplier.PostalCode
else coalesce(OTC.PostalCode, Supplier.PostalCode)
end as PostalCode,
case when TaxType.BPTaxLongNumber <> '0' then Supplier.Country
else coalesce(OTC.Country, Supplier.Country)
end as Country,
Header.BG_SAFTSourceDocumentType as BG_SAFTInvoiceType,
case
when Bseg.VATRegistration <> '' and BsegStcegCountry.IsEuropeanUnionMember = 'X' then
case
when BsegStcegCountry.Country = 'BG' then replace(Bseg.VATRegistration, 'BG', '10')
else cast(concat('11', Bseg.VATRegistration) as bptaxnumxl)
end
when TaxType.BPTaxLongNumber = 'EXCLUDE' then cast($parameters.P_VATRegistration as bptaxnumxl)
when TaxType.BPTaxLongNumber <> '0' then TaxType.BPTaxLongNumber
else OTC.VATRegistration
end as SupplierTaxID5,
case $parameters.P_AlternativeGLAccountIsUsed
when 'X' then Bseg._CompanyCode.CountryChartOfAccounts
else Bseg.ChartOfAccounts
end as ActiveChartOfAccounts,
case $parameters.P_AlternativeGLAccountIsUsed
when 'X' then Bseg._GLAccountInCompanyCode.AlternativeGLAccount
else Bseg.GLAccount
end as ActiveGLAccount,
cast(concat( $parameters.P_UserSystemIdentifier, concat( concat( concat( '/', cast( $session.client as char3 )), '/' ) , Header.AccountingDocument ) ) as text18) as BG_SAFTSystemID,
coalesce(PayTerms._Text[1: Language='W'].PaymentTermsName, PayTerms._Text[1: Language='E'].PaymentTermsName) as PaymentTermsName,
'N' as SelfBillingValueItemDesc,
concat(
concat( Header.CompanyCode, Header.FiscalYear ),
concat( Header.AccountingDocumentType, Header.AccountingDocument )
) as BusinessTransactionTypeName,
cast(
case
when Bkpf.AlternativeReferenceDocument <> '' then Bkpf.AlternativeReferenceDocument
when Bkpf.DocumentReferenceID <> '' then Bkpf.DocumentReferenceID
else Bkpf.AccountingDocument
end
as fis_xblnr_alt_alpha) as AlternativeReferenceDocument
}
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