P_BG_SAFTPURINVOICEHEADER

DDL: P_BG_SAFTPURINVOICEHEADER Type: view_entity CONSUMPTION Package: GLO_FIN_IS_SAFT_BG

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)

SourceAliasJoin Type
I_JournalEntry Bkpf inner
I_OperationalAcctgDocItem Bseg inner
P_BG_SAFTINVOICEITEMCOUNT CountFilter inner
P_BG_SAFTPURINVHDR Header from

Parameters (3)

NameTypeDefault
P_AlternativeGLAccountIsUsed saft_bg_alt_gl_account_flag
P_UserSystemIdentifier sysid
P_VATRegistration stceg

Annotations (7)

NameValueLevelField
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)

KeyFieldSource TableSource FieldDescription
KEY SourceLedger P_BG_SAFTPURINVHDR SourceLedger Source Ledger
KEY CompanyCode P_BG_SAFTPURINVHDR CompanyCode Receiver Company Code
KEY FiscalYear P_BG_SAFTPURINVHDR FiscalYear G/L Fiscal Year
KEY AccountingDocument P_BG_SAFTPURINVHDR AccountingDocument Journal Entry
KEY Ledger P_BG_SAFTPURINVHDR Ledger Ledger
AccountingDocumentItem P_BG_SAFTPURINVHDR AccountingDocumentItem Posting View Item
FiscalPeriod I_JournalEntry FiscalPeriod Tax period
PostingDate I_JournalEntry PostingDate Posting Date for GR
InvoiceDate I_JournalEntry DocumentDate Journal Entry Date
TaxReportingDate I_JournalEntry TaxReportingDate Tax Reporting Date
AccountingDocumentType I_JournalEntry AccountingDocumentType Journal Entry Type
AccountingDocCreatedByUser I_JournalEntry AccountingDocCreatedByUser User which created overhead document
Supplier Supplier Supplier Supplier
HouseNumber1endasStreetName
BPAddrCityNameendasCityName
PostalCodeendasPostalCode
CountryendasCountry
BG_SAFTInvoiceType P_BG_SAFTPURINVHDR BG_SAFTSourceDocumentType
VATRegistrationendasSupplierTaxID5
GLAccountendasActiveGLAccount
BG_SAFTSystemID
PaymentTermsName
SelfBillingValueItemDesc

Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.

-- Derived SQL interpretation of CDS view P_BG_SAFTPURINVOICEHEADER.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
-- Parameters: P_AlternativeGLAccountIsUsed : saft_bg_alt_gl_account_flag, P_UserSystemIdentifier : sysid, P_VATRegistration : stceg

CREATE VIEW P_BG_SAFTPURINVOICEHEADER AS
SELECT
  Header.SourceLedger AS SourceLedger,
  Header.CompanyCode AS CompanyCode,
  Header.FiscalYear AS FiscalYear,
  Header.AccountingDocument AS AccountingDocument,
  Header.Ledger AS Ledger,
  Header.AccountingDocumentItem AS AccountingDocumentItem,
  Bkpf.FiscalPeriod AS FiscalPeriod,
  Bkpf.PostingDate AS PostingDate,
  Bkpf.DocumentDate AS InvoiceDate,
  Bkpf.TaxReportingDate AS TaxReportingDate,
  Bkpf.AccountingDocumentType AS AccountingDocumentType,
  Bkpf.AccountingDocCreatedByUser AS AccountingDocCreatedByUser,
  Supplier.Supplier AS 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 AS HouseNumber1endasStreetName,
  case when TaxType.BPTaxLongNumber <> '0' then Supplier.BPAddrCityName else coalesce(OTC.CityName, Supplier.BPAddrCityName) end as CityName AS BPAddrCityNameendasCityName,
  case when TaxType.BPTaxLongNumber <> '0' then Supplier.PostalCode else coalesce(OTC.PostalCode, Supplier.PostalCode) end as PostalCode AS PostalCodeendasPostalCode,
  case when TaxType.BPTaxLongNumber <> '0' then Supplier.Country else coalesce(OTC.Country, Supplier.Country) end as Country AS CountryendasCountry,
  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 AS VATRegistrationendasSupplierTaxID5,
  case $parameters.P_AlternativeGLAccountIsUsed when 'X' then Bseg._GLAccountInCompanyCode.AlternativeGLAccount else Bseg.GLAccount end as ActiveGLAccount AS GLAccountendasActiveGLAccount,
  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
FROM P_BG_SAFTPURINVHDR AS Header
INNER JOIN I_JournalEntry AS Bkpf ON /* join condition not captured in parsed metadata */
INNER JOIN I_OperationalAcctgDocItem AS Bseg ON /* join condition not captured in parsed metadata */
INNER JOIN P_BG_SAFTINVOICEITEMCOUNT AS CountFilter ON /* join condition not captured in parsed metadata */
;