I_PT_SAFTInvoiceListHeader

DDL: I_PT_SAFTINVOICELISTHEADER SQL: IPTSAFTILHDR Type: view COMPOSITE

SAF-T PT Invoice List Header

I_PT_SAFTInvoiceListHeader is a Composite CDS View that provides data about "SAF-T PT Invoice List Header" in SAP S/4HANA. It reads from 2 data sources (I_SAFTInvoiceListHeader, I_PT_BillgDocDgtlSgntr) and exposes 42 fields with key field PortugueseInvoiceNumber. It has 9 associations to related views.

Data Sources (2)

SourceAliasJoin Type
I_SAFTInvoiceListHeader a from
I_PT_BillgDocDgtlSgntr b inner

Associations (9)

CardinalityTargetAliasCondition
[0..*] I_SAFTCustTaxRegnNmbr _CustTaxRegNmbr a.PayerParty = _CustTaxRegNmbr.CustomerNum
[0..1] I_PT_SAFTBillgDocCustAddrHist _CustHist _CustHist.BillingDocument = a.BillingDocument and _CustHist.Customer = a.PayerParty and _CustHist.CompanyCode = a.CompanyCode
[0..1] I_PT_SAFTBillingOneTimeCust _OneTimeCustomer $projection.PortugueseInvoiceNumber = _OneTimeCustomer.PortugueseInvoiceNumber and $projection.CompanyCode = _OneTimeCustomer.CompanyCode
[0..1] I_ReversalReason _RevReason $projection.reversalreason = _RevReason.ReversalReason
[0..1] I_CustomerPaymentTerms _Terms $projection.CustomerPaymentTerms = _Terms.CustomerPaymentTerms
[0..1] I_PT_SAFTBillingHdrTaxLikeMatl _TaxLikeMat $projection.PortugueseInvoiceNumber = _TaxLikeMat.PortugueseInvoiceNumber
[0..1] I_SAFTJournalEntry _JournalEntry _JournalEntry.ReferenceDocumentType = 'VBRK' and _JournalEntry.OriginalReferenceDocument = a.BillingDocument and _JournalEntry.Ledger = '0L' and not( _JournalEntry.AccountingDocumentCategory = 'U' ) and not( _JournalEntry.AccountingDocumentCategory = 'V' ) and not( _JournalEntry.AccountingDocumentCategory = 'W' )
[0..1] I_PT_SAFTBillingPlanHeader _BillingPlanHdr $projection.PortugueseInvoiceNumber = _BillingPlanHdr.PortugueseInvoiceNumber
[0..1] I_PT_SAFTBillingPrcgCndnHdr _PrcgCndnHdr $projection.PortugueseInvoiceNumber = _PrcgCndnHdr.PortugueseInvoiceNumber

Annotations (11)

NameValueLevelField
AbapCatalog.sqlViewName IPTSAFTILHDR view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #CHECK view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #D view
ClientHandling.algorithm #SESSION_VARIABLE view
AccessControl.personalData.blocking #BLOCKED_DATA_INCLUDED view
EndUserText.label SAF-T PT Invoice List Header view

Fields (42)

KeyFieldSource TableSource FieldDescription
KEY PortugueseInvoiceNumber I_PT_BillgDocDgtlSgntr PortugueseInvoiceNumber
PortugueseInvoiceDate I_PT_BillgDocDgtlSgntr PortugueseInvoiceDate
BillingDocumentDate I_SAFTInvoiceListHeader BillingDocumentDate
FiscalYear I_SAFTInvoiceListHeader FiscalYear
SDDocumentCategory I_SAFTInvoiceListHeader SDDocumentCategory
char3asDocumentType
CompanyCode I_SAFTInvoiceListHeader CompanyCode
BillingDocumentIsCancelled I_SAFTInvoiceListHeader BillingDocumentIsCancelled
ReversalReason
FiscalPeriod
SourceBillingDocumentType
PortugueseDigitalSignature I_PT_BillgDocDgtlSgntr PortugueseDigitalSignature
PortugueseDgtlSgntrKeyVersion I_PT_BillgDocDgtlSgntr PortugueseDgtlSgntrKeyVersion
PTDgtlSgntrSystemDateTimeText I_PT_BillgDocDgtlSgntr PTDgtlSgntrSystemDateTimeText
CreatedByUser I_SAFTInvoiceListHeader CreatedByUser
ExchangeRateDate I_SAFTInvoiceListHeader ExchangeRateDate
CompanyCodeCurrency I_PT_BillgDocDgtlSgntr CompanyCodeCurrency
dec287asTotalTaxAmount
dec287asTotalNetAmount
TotalGrossAmount
char5asWorkType
CustomerPaymentTerms I_SAFTInvoiceListHeader CustomerPaymentTerms
BillingDocument I_SAFTInvoiceListHeader BillingDocument
PayerParty I_SAFTInvoiceListHeader PayerParty
char70asDocumentTransaction
BillingDocumentCategory I_SAFTInvoiceListHeader BillingDocumentCategory
PT_SeriesDocumentNumber I_PT_BillgDocDgtlSgntr PT_SeriesDocumentNumber
PT_SeriesDocumentType I_PT_BillgDocDgtlSgntr PT_SeriesDocumentType
_OneTimeCustomer _OneTimeCustomer
_CustHist _CustHist
_CustTaxRegNmbr _CustTaxRegNmbr
_CompanyCode I_SAFTInvoiceListHeader _CompanyCode
_PayerParty I_SAFTInvoiceListHeader _PayerParty
_TaxCheck _TaxCheck
_Settlement _Settlement
_RevReason _RevReason
_CancelBillingDocument _CancelBillingDocument
_TaxLikeMat _TaxLikeMat
_Terms _Terms
_CustomerPaymentTerms _CustomerPaymentTerms
_BillingPlanHdr _BillingPlanHdr
_PrcgCndnHdr _PrcgCndnHdr
@AbapCatalog.sqlViewName: 'IPTSAFTILHDR'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #D
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@EndUserText.label: 'SAF-T PT Invoice List Header'
define view I_PT_SAFTInvoiceListHeader
  as select from           I_SAFTInvoiceListHeader   as a
    inner join             I_PT_BillgDocDgtlSgntr    as b        on  b.BillingDocument = a.BillingDocument
                                                                 and b.CompanyCode     = a.CompanyCode
    left outer to one join I_PT_SAFTWorkingDocType   as w        on  b.NumberRangeInterval = w.NumberRangeInterval
                                                                 and b.CompanyCode         = w.CompanyCode
                                                                 and a.FiscalYear          = w.FiscalYear
    left outer to one join P_PT_SAFTTAXLAND          as t        on t.Customer = a.PayerParty

    left outer to one join I_PT_SAFTSummaryInvoice   as s        on  b.CompanyCode         = s.CompanyCode
                                                                 and a.FiscalYear          = s.FiscalYear
                                                                 and b.NumberRangeInterval = s.NumberRangeInterval

    left outer to one join I_InvoiceListRemuneration as Discount on a.BillingDocument = Discount.InvoiceList

  association [0..*] to I_SAFTCustTaxRegnNmbr          as _CustTaxRegNmbr  on  a.PayerParty = _CustTaxRegNmbr.CustomerNum

  association [0..1] to I_PT_SAFTBillgDocCustAddrHist  as _CustHist        on  _CustHist.BillingDocument = a.BillingDocument
                                                                           and _CustHist.Customer        = a.PayerParty
                                                                           and _CustHist.CompanyCode     = a.CompanyCode

  association [0..1] to I_PT_SAFTBillingOneTimeCust    as _OneTimeCustomer on  $projection.PortugueseInvoiceNumber = _OneTimeCustomer.PortugueseInvoiceNumber
                                                                           and $projection.CompanyCode             = _OneTimeCustomer.CompanyCode

  association [0..1] to I_ReversalReason               as _RevReason       on  $projection.reversalreason = _RevReason.ReversalReason

  association [0..1] to I_CustomerPaymentTerms         as _Terms           on  $projection.CustomerPaymentTerms = _Terms.CustomerPaymentTerms

  association [0..1] to I_PT_SAFTBillingHdrTaxLikeMatl as _TaxLikeMat      on  $projection.PortugueseInvoiceNumber = _TaxLikeMat.PortugueseInvoiceNumber

  association [0..1] to I_SAFTJournalEntry             as _JournalEntry    on  _JournalEntry.ReferenceDocumentType     = 'VBRK'
                                                                           and _JournalEntry.OriginalReferenceDocument = a.BillingDocument
                                                                           and _JournalEntry.Ledger                    = '0L'
                                                                           and not(
    _JournalEntry.AccountingDocumentCategory                                                                           = 'U'
  )
                                                                           and not(
    _JournalEntry.AccountingDocumentCategory                                                                           = 'V'
  )
                                                                           and not(
    _JournalEntry.AccountingDocumentCategory                                                                           = 'W'
  )

  association [0..1] to I_PT_SAFTBillingPlanHeader     as _BillingPlanHdr  on  $projection.PortugueseInvoiceNumber = _BillingPlanHdr.PortugueseInvoiceNumber

  association [0..1] to I_PT_SAFTBillingPrcgCndnHdr    as _PrcgCndnHdr     on  $projection.PortugueseInvoiceNumber = _PrcgCndnHdr.PortugueseInvoiceNumber

{

  key b.PortugueseInvoiceNumber,

      b.PortugueseInvoiceDate,
      a.BillingDocumentDate,
      a.FiscalYear,
      a.SDDocumentCategory,

      cast(case
          when a.SDDocumentCategory = 'M' or a.SDDocumentCategory = 'N' or a.SDDocumentCategory = '5'
            then 'FT'
          when a.SDDocumentCategory = 'S' or a.SDDocumentCategory = 'O' or a.SDDocumentCategory = '6'
               or a.SDDocumentCategory = '4'
            then 'NC'
          when a.SDDocumentCategory = 'P'
            then 'ND'
          else 'FT'
      end as abap.char(3))                                                                                                       as DocumentType,

      a.CompanyCode,

      a.BillingDocumentIsCancelled,

      case when a.BillingDocumentIsCancelled is not initial or
      //Required for Cancelled Proforma Invoices

                a.AccountingTransferStatus = 'E'
            then 'A'
           when s.InvcSmmryItemStatus is not initial
            then s.InvcSmmryItemStatus
           else 'N'
      end                                                                                                                        as DocumentBillingStatus,

      a._AccountingDocument.ReversalReason,
      a._AccountingDocument.FiscalPeriod,
      cast ( 'P' as abap.char(4) )                                                                                               as SourceBillingDocumentType,

      b.PortugueseDigitalSignature,
      b.PortugueseDgtlSgntrKeyVersion,

      @Semantics.dateTime:true
      b.PTDgtlSgntrSystemDateTimeText,

      a.CreatedByUser,

      a.ExchangeRateDate,

      @Semantics.currencyCode: true
      b.CompanyCodeCurrency                                                                                                      as CompanyCodeCurrency,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @OData.v2.amount.noDecimalShift:true 
      cast(
      case when a.TransactionCurrency = a._CompanyCode.Currency
        then
          coalesce(abs(_TaxCheck.ConditionAmount ),0)
        else
          case when a.AccountingExchangeRate < 0
            then abs(division(_TaxCheck.ConditionAmount,AccountingExchangeRate,7))
            else abs(_TaxCheck.ConditionAmount * AccountingExchangeRate)
          end
      end as abap.dec(28,7))                                                                                                     as TotalTaxAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @OData.v2.amount.noDecimalShift:true 
      cast(
      case when a.TransactionCurrency = a._CompanyCode.Currency
        then
          coalesce(abs(a.TotalNetAmount + Discount.TotalRemunerationNetAmount),0)
        else
          case when a.AccountingExchangeRate < 0
            then abs(division((a.TotalNetAmount + Discount.TotalRemunerationNetAmount),AccountingExchangeRate,7))
            else abs((a.TotalNetAmount + Discount.TotalRemunerationNetAmount) * AccountingExchangeRate)
          end
      end as abap.dec(28,7))                                                                                                     as TotalNetAmount,

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      @OData.v2.amount.noDecimalShift:true 
      cast(b.TotalGrossAmount as abap.dec(28,7))                                                                                 as TotalGrossAmount,

      @Semantics.currencyCode: true
      case when a.TransactionCurrency <> a._CompanyCode.Currency
      then a.TransactionCurrency
      else cast('' as waers)
      end                                                                                                                        as TransactionCurrency,

      @Semantics.amount.currencyCode: 'TransactionCurrency'
      case when a.TransactionCurrency <> a._CompanyCode.Currency
        then a.TotalNetAmount + a.TotalTaxAmount //Original values are in document currency

        else 0
      end                                                                                                                        as InvoiceAmountInFrgnCurrency,

      case when a.TransactionCurrency <> a._CompanyCode.Currency
        then a.AccountingExchangeRate
        else 0
      end                                                                                                                        as ExchangeRate,
      cast( case
        when w.WorkType is not initial
         then w.WorkType
        when a.SDDocumentCategory = 'U'
         then 'PF'
        else ' ' end as abap.char(5))                                                                                            as WorkType,

      case
      when a.SDDocumentCategory = 'U'  or w.NumberRangeInterval = b.NumberRangeInterval
        then 'X'
        else ' '
      end                                                                                                                        as SalesDocumentIsWorkingDocument,
      a.CustomerPaymentTerms,

      a.BillingDocument,
      a.PayerParty,


      case when t.CustomerCountry is not initial
        then
          case when VATRegistrationCountry is not initial
            then a.VATRegistrationCountry
            else t.CustomerCountry
          end
        else
          ''
      end                                                                                                                        as VATRegistrationCountry,

      cast ( concat_with_space(concat(substring(_JournalEntry.DocumentDate,1,4),
       concat('-',
         concat(substring(_JournalEntry.DocumentDate,5,2),
           concat('-', substring(_JournalEntry.DocumentDate,7,2))))),
             concat_with_space(_JournalEntry.AccountingDocumentType, _JournalEntry.AccountingDocument, 1), 1) as abap.char(70) ) as DocumentTransaction,

      a.BillingDocumentCategory,

      b.PT_SeriesDocumentNumber as PT_SeriesDocumentNumber,  //NEW DOC TYPE

      b.PT_SeriesDocumentType as PT_SeriesDocumentType,   //ATCUD


      _OneTimeCustomer,
      _CustHist,
      _CustTaxRegNmbr,
      a._CompanyCode,
      a._PayerParty                                                                                                              as _PayerParty,
      _TaxCheck,
      _Settlement,
      _RevReason,
      _CancelBillingDocument,
      _TaxLikeMat,
      _Terms,
      _CustomerPaymentTerms,
      _BillingPlanHdr,
      _PrcgCndnHdr

}
where
  //     CancelledBillingDocument  =  '' and //Do not select cancel documents

  a.BillingDocumentCategory <> 'P' //Do not select DP Requests