P_CrExpFi

DDL: P_CREXPFI SQL: PCREXPFI Type: view COMPOSITE

P_CrExpFi is a Composite CDS View in SAP S/4HANA. It reads from 2 data sources (I_OperationalAcctgDocItem, I_Customer) and exposes 17 fields. It has 2 associations to related views.

Data Sources (2)

SourceAliasJoin Type
I_OperationalAcctgDocItem _AccountingDocument from
I_Customer I_Customer inner

Parameters (2)

NameTypeDefault
P_ExchangeRateDate vdm_v_exchange_rate_date
P_ExchangeRateType kurst

Associations (2)

CardinalityTargetAliasCondition
[0..1] I_CreditControlArea _CreditControlArea $projection.CreditControlArea = _CreditControlArea.CreditControlArea
[1..1] I_CreditExposureCategory _CreditExposureCategory $projection.CreditExposureCategory = _CreditExposureCategory.CreditExposureCategory

Annotations (6)

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

Fields (17)

KeyFieldSource TableSource FieldDescription
BusinessPartner
CreditSegment
xBseg
CreditControlArea I_OperationalAcctgDocItem CreditControlArea
Customer I_OperationalAcctgDocItem Customer
AccountingDocument I_OperationalAcctgDocItem AccountingDocument
FiscalYear I_OperationalAcctgDocItem FiscalYear
SpecialGLCode I_OperationalAcctgDocItem SpecialGLCode
CreditLimitIsChecked
FinancialAccountType FinancialAccountType
TransactionCurrency TransactionCurrency
AmountInTransactionCurrency AmountInTransactionCurrency
CreditSegmentCurrency
trueasCreditExposure
trueasHedgedExposure
_CreditExposureCategory _CreditExposureCategory
_CreditControlArea _CreditControlArea
// DEPRECATED //

// Performance Improvements ER9K8AU9LH 7.2021, replaced by P_CrExpFi1 //


//@EndUserText.label: 'FI Credit Exposure'

@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.sqlViewName: 'PCREXPFI'
@VDM.private:true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck:  #NOT_REQUIRED
 @AbapCatalog.compiler.compareFilter:true 
define view P_CrExpFi
  with parameters
    P_ExchangeRateDate : vdm_v_exchange_rate_date,
    @Consumption.defaultValue: 'M'
    P_ExchangeRateType : kurst
  as select from I_OperationalAcctgDocItem as _AccountingDocument
  // Link with Customer

    inner join   I_Customer on _AccountingDocument.Customer = I_Customer.Customer

  // Link with Credit Control Area/Credit Segment mapping

  association [0..1] to I_CreditControlArea      as _CreditControlArea      on $projection.CreditControlArea = _CreditControlArea.CreditControlArea

  // Link to exposure type customizing

  association [1..1] to I_CreditExposureCategory as _CreditExposureCategory on $projection.CreditExposureCategory = _CreditExposureCategory.CreditExposureCategory

{
  // Business Partner

  I_Customer._CustomerToBusinessPartner._BusinessPartner.BusinessPartner             as BusinessPartner,

  // Credit Segment

  _CreditControlArea._CreditControlArea2Segment.CreditSegment                        as CreditSegment,

  'Y' as xBseg,

  // Credit Control Area

  _AccountingDocument.CreditControlArea,

  // Original Customer

  _AccountingDocument.Customer,

  // Accounting Document Number

  _AccountingDocument.AccountingDocument,

  // Fiscal Year

  _AccountingDocument.FiscalYear,

  // Special G/L Indicator

  _AccountingDocument.SpecialGLCode,

  // Check if value is relevant for Credit Management - T074U-KLIMP

  _AccountingDocument._SpecialGLCode.CreditLimitIsChecked,

  // Case Exposure Category

  case
  // Special Exposure

    when _AccountingDocument.SpecialGLCode <> ''
    then '300'

  // FI Exposure

    else '200'
  end                                                                                as CreditExposureCategory,

  // Document Type

  FinancialAccountType,

  // Transaction Currency

  @Semantics.currencyCode: true
  TransactionCurrency,

  // Amount in Transaction Currency

  @Semantics.amount.currencyCode: 'TransactionCurrency'
  AmountInTransactionCurrency,

  //===========================================================

  // Currency Conversion to Display Currency

  //===========================================================

  @Semantics.currencyCode: true
  _CreditControlArea._CreditControlArea2Segment._CreditSegment.CreditSegmentCurrency as CreditSegmentCurrency,

  //    @EndUserText.label: 'Credit Limit'

  @Semantics.amount.currencyCode: 'CreditSegmentCurrency'
  currency_conversion(
      amount                => AmountInTransactionCurrency,
      source_currency       => TransactionCurrency,
      target_currency       => _CreditControlArea._CreditControlArea2Segment._CreditSegment.CreditSegmentCurrency,
      exchange_rate_date    => $parameters.P_ExchangeRateDate,
      exchange_rate_type    => $parameters.P_ExchangeRateType,
      error_handling        => 'FAIL_ON_ERROR',
      decimal_shift         => #CDSBoolean.true,
      round                 => #CDSBoolean.true )                                    as CreditExposure,

  // Hedged Exposure

  @Semantics.amount.currencyCode: 'CreditSegmentCurrency'
  currency_conversion(
      amount                => HedgedAmount,
      source_currency       => _AccountingDocument.CreditControlAreaCurrency,
      target_currency       => _CreditControlArea._CreditControlArea2Segment._CreditSegment.CreditSegmentCurrency,
      exchange_rate_date    => $parameters.P_ExchangeRateDate,
      exchange_rate_type    => $parameters.P_ExchangeRateType,
      error_handling        => 'FAIL_ON_ERROR',
      decimal_shift         => #CDSBoolean.true,
      round                 => #CDSBoolean.true )                                    as HedgedExposure,

  // Publish associations

  _CreditExposureCategory,
  _CreditControlArea

}

where
          FinancialAccountType                                        =  'D'
  and     _AccountingDocument.CreditControlArea                       is not initial
  and     _CreditControlArea._CreditControlArea2Segment.CreditSegment <> ''
                          and _CreditControlArea._CreditControlArea2Segment._CreditSegment.CreditSegmentCurrency <> ''
  and(
          ClearingDate                                                =  '00000000'
  )
  and(
    (
          _AccountingDocument.SpecialGLCode != ''
      and _AccountingDocument._SpecialGLCode.CreditLimitIsChecked     =  'X'
    )
    or    _AccountingDocument.SpecialGLCode                           =  ''
  )
  and(
          _AccountingDocument._PaymentDifferenceReason.IsDisputed     =  ''
    or    _AccountingDocument._PaymentDifferenceReason.IsDisputed     is initial
    or    _AccountingDocument._PaymentDifferenceReason.IsDisputed     is null
  )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_BUSINESSPARTNER",
"I_CREDITCONTROLAREA",
"I_CREDITCONTROLAREA2SEGMENT",
"I_CREDITMANAGEMENTSEGMENT",
"I_CUSTOMER",
"I_CUSTOMERTOBUSINESSPARTNER",
"I_OPERATIONALACCTGDOCITEM",
"I_PAYMENTDIFFERENCEREASON",
"I_SPECIALGLCODE"
],
"ASSOCIATED":
[
"I_CREDITCONTROLAREA",
"I_CREDITEXPOSURECATEGORY"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/