P_CalculatedAllwncCustomers

DDL: P_CALCULATEDALLWNCCUSTOMERS SQL: PCALALLWNCCUST Type: view COMPOSITE

P_CalculatedAllwncCustomers is a Composite CDS View in SAP S/4HANA. It reads from 1 data source (I_OperationalAcctgDocItem) and exposes 18 fields with key fields CompanyCode, AccountingDocument, FiscalYear, AccountingDocumentItem. It has 3 associations to related views.

Data Sources (1)

SourceAliasJoin Type
I_OperationalAcctgDocItem I_OperationalAcctgDocItem from

Parameters (1)

NameTypeDefault
P_KeyDate sydate

Associations (3)

CardinalityTargetAliasCondition
[1..1] P_CalculatedAllwncCrdtAccount _DoubtfulReceivables _DoubtfulReceivables.CreditGLAccount = $projection.GLAccount
[0..1] I_Customer _ReferencedCustomer _ReferencedCustomer.Customer = $projection.ReferencedCustomer
[0..1] I_OperationalAcctgDocItem _ReferencedDocument _ReferencedDocument.AccountingDocument = $projection.ReferencedDocument and _ReferencedDocument.CompanyCode = $projection.CompanyCode and _ReferencedDocument.FiscalYear = $projection.ReferencedFiscalYear and _ReferencedDocument.AccountingDocumentItem = $projection.ReferencedDocumentItem

Annotations (7)

NameValueLevelField
AbapCatalog.sqlViewName PCALALLWNCCUST view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
ClientHandling.algorithm #SESSION_VARIABLE view
VDM.viewType #COMPOSITE view
VDM.private true view

Fields (18)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode CompanyCode
KEY AccountingDocument AccountingDocument
KEY FiscalYear FiscalYear
KEY AccountingDocumentItem AccountingDocumentItem
SpecialGLCode SpecialGLCode
ReferencedCustomer
ReferencedDocument
ReferencedDocumentItem
ReferencedFiscalYear
AccountingDocumentType AccountingDocumentType
PostingDate PostingDate
NetDueDate
GLAccount GLAccount
AmountInCompanyCodeCurrency AmountInCompanyCodeCurrency
CompanyCodeCurrency CompanyCodeCurrency
AssignmentReference AssignmentReference
_ReferencedCustomer _ReferencedCustomer
_ReferencedDocument _ReferencedDocument
@AbapCatalog.sqlViewName: 'PCALALLWNCCUST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey:true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM.viewType: #COMPOSITE
@VDM.private: true
define view P_CalculatedAllwncCustomers
  with parameters
    P_KeyDate : sydate
  as select from I_OperationalAcctgDocItem
  association [1..1] to P_CalculatedAllwncCrdtAccount as _DoubtfulReceivables on  _DoubtfulReceivables.CreditGLAccount = $projection.GLAccount
  association [0..1] to I_Customer                    as _ReferencedCustomer  on  _ReferencedCustomer.Customer = $projection.ReferencedCustomer
  association [0..1] to I_OperationalAcctgDocItem     as _ReferencedDocument  on  _ReferencedDocument.AccountingDocument     = $projection.ReferencedDocument
                                                                              and _ReferencedDocument.CompanyCode            = $projection.CompanyCode
                                                                              and _ReferencedDocument.FiscalYear             = $projection.ReferencedFiscalYear
                                                                              and _ReferencedDocument.AccountingDocumentItem = $projection.ReferencedDocumentItem
{
  key CompanyCode,
  key AccountingDocument,
  key FiscalYear,
  key AccountingDocumentItem,

      case SpecialGLCode
        when '' then cast( '' as fis_kunnr )  // Key 50 or 40: calculated allowance - no direct customer assignment

        else cast( Customer as fis_kunnr )    // Key 19 or 09: special allowance - direct customer assignment

      end                                                                     as AssignedCustomer,

      case SpecialGLCode
        when '' then AmountInCompanyCodeCurrency               //Key 50 or 40 - calculated allowance

        else 0                                                 //Key 19 or 09

      end                                                                     as CalcdAllwncForDoubtfulAccts,

      case SpecialGLCode
        when '' then 0                                         //Key 50 or 40

        else AmountInCompanyCodeCurrency                       //Key 19 or 09 - special allowance

      end                                                                     as SpclAllwncForDoubtfulAccts,

      SpecialGLCode,
      cast(substring(AssignmentReference, 1, 10) as fis_kunnr)                as ReferencedCustomer,
      cast(substring(AssignmentReference, 1, 10) as farp_belnr_d)             as ReferencedDocument,
      cast(substring(AssignmentReference, 11, 3) as fis_buzei )               as ReferencedDocumentItem,
      cast(substring(AssignmentReference, 14, 4) as fis_gjahr  )              as ReferencedFiscalYear,

      AccountingDocumentType,
      PostingDate,
      cast('00000000' as farp_netdt)                                          as NetDueDate,

      case SpecialGLCode
        when '' then cast('CA' as farp_dav_document_category)
        else cast('SP' as farp_dav_document_category)
      end                                                                     as BadDebtReserveDocumentCategory,

      GLAccount,
      AmountInCompanyCodeCurrency,
      CompanyCodeCurrency,
      AssignmentReference,

      _ReferencedCustomer,
      _ReferencedDocument
}
where
           GLAccount     =  _DoubtfulReceivables.CreditGLAccount
  and      PostingDate   <= :P_KeyDate
  and(
    (
           SpecialGLCode =  ''
      and(
           PostingKey    =  '50'
        or PostingKey    =  '40'
      )
    )
    or(
           SpecialGLCode != ''
      and(
           PostingKey    =  '19'
        or PostingKey    =  '09'
      )
    )
  )