cancel
Showing results for 
Search instead for 
Did you mean: 

Pass Parameter Values to Company Code Hierarchy text nodes in CDS View/CDS Query

regysm21
Active Participant
0 Kudos

Hi experts,

I have a requirement that I need to pass a parameter value (which then filters the backend data) to a text node in a Company Code Hierarchy (created with manage global hierarchies app in S4). So the logic should be, when the text node of the hierarchy is selected, then the parameter value should be used for it, otherwise the child nodes (which are the company codes) should be displayed.

I tried several options but somehow it is not working to pass the values. My cds view looks like this:


@ObjectModel.usageType.sizeCategory: #XXL 
@ObjectModel.usageType.serviceQuality: #X 
@ObjectModel.usageType.dataClass: #MIXED 
@ObjectModel.supportedCapabilities: [ #ANALYTICAL_QUERY ]
@AbapCatalog.sqlViewName: 'ZCOVRDUEACCTRB2'
@EndUserText.label: 'Overdue Accounts Receivables Custom2'
@VDM.viewType: #CONSUMPTION
@Metadata.ignorePropagatedAnnotations: true
@AccessControl.authorizationCheck: #PRIVILEGED_ONLY
@ClientHandling.algorithm: #SESSION_VARIABLE
@Analytics.query: true
@OData.publish: true

define view ZC_OVERDUEACCTRBLS2

  with parameters

    @EndUserText.label: 'Open on Key Date'
    @Consumption.defaultValue: 'TODAY'
    @Consumption.valueHelpDefinition: [{
      entity: {
        name: 'C_GregorianCalSglDateFuncVH',
        element: 'DateFunction'
      }
    }]
    P_DateFunction          : datefunctionid,

    @Consumption.derivation: {
      lookupEntity: 'I_SglGregorianCalDateFunction',
      resultElement: 'DateFunctionStartDate',
      binding: [
        { targetParameter : 'P_DateFunction' ,
          type : #PARAMETER, value : 'P_DateFunction' }
      ]
    }
    @Consumption.hidden: true
    P_KeyDate               : sydate,

    @Consumption.hidden: true
    @Environment.systemField: #SYSTEM_LANGUAGE
    P_Language              : sylangu,

    @Consumption.defaultValue: 'USD'
    P_DisplayCurrency       : vdm_v_display_currency,

    @Consumption.defaultValue: 'M'
    @Consumption.valueHelpDefinition: [{ entity: { name: 'I_ExchangeRateType' , element: 'ExchangeRateType' }
                                      }]
    P_ExchangeRateType      : kurst_curr,

    @Consumption.defaultValue: '30'
    P_NetDueInterval1InDays : farp_net_due_interval1,

    @Consumption.defaultValue: '60'
    P_NetDueInterval2InDays : farp_net_due_interval2,

    @Consumption.defaultValue: '90'
    P_NetDueInterval3InDays : farp_net_due_interval3,

    P_Nodevalue             : abap.char(50)

  as select from ZI_OVERDUEACCOUNTSRECEIVABL5( P_KeyDate: :P_KeyDate,
                                               P_DisplayCurrency: :P_DisplayCurrency,
                                               P_ExchangeRateType: :P_ExchangeRateType,
                                               P_NetDueInterval1InDays: :P_NetDueInterval1InDays,
                                               P_NetDueInterval2InDays: :P_NetDueInterval2InDays,
                                               P_NetDueInterval3InDays: :P_NetDueInterval3InDays,
                                               P_Nodevalue: :P_Nodevalue )
  
{
  @AnalyticsDetails.query.axis: #ROWS
  @ObjectModel.foreignKey.association: '_Company'
  @Consumption.filter: {  selectionType: #HIERARCHY_NODE, multipleSelections: false, mandatory: false }
  @EndUserText.label: 'Company Code'
  CompanyCode,
  
  @Consumption.filter: {selectionType: #SINGLE, multipleSelections: true, mandatory: false}
  @EndUserText.label: 'Customer'
  @AnalyticsDetails.query.axis: #ROWS
  Customer,
  NetDueIntervalText,
  SpecialGLCode,
  GLAccount,
  CreditSegment,

  _SpecialGLCode._Text[1:Language = :P_Language].SpecialGLCodeLongName                       as SpecialGLCodeName,
  _GLAccount._Text[1:Language = :P_Language].GLAccountLongName                               as GLAccountLongName,
  _CreditManagementSegment._Text[1:Language = :P_Language].CreditSegmentName                 as CreditSegmentName,

  _Company.CompanyCodeName                                                                   as CompanyCodeName,
  _Customer.CustomerName                                                                     as CustomerName,
  CustomerCountry,
  _CustomerCountry._Text[1:Language = :P_Language].CountryName                               as CustomerCountryName,
  CustomerRegion,
  _CustomerRegion._RegionText[1:Language = :P_Language].RegionName                           as CustomerRegionName,
  AccountingClerk,
  _AccountingClerk.AccountingClerkName                                                       as AccountingClerkName,
  ReconciliationAccount,
  _ReconciliationAccount._Text[1:Language = :P_Language].GLAccountLongName                   as ReconciliationAccountLongName,

  CustomerAccountGroup                                                                       as CustomerAccountGroup,
  _CustomerAccountGroup._CustomerAccountGroupText[1:Language = :P_Language].AccountGroupName as CustomerAccountGroupName,
  CustomerClassification                                                                     as CustomerClassification,
  _CustomerClassification._Text[1:Language = :P_Language].CustomerClassificationDesc         as CustomerClassificationDesc,
  CreditRiskClass,
  _CreditRiskClass._Text[1:Language = :P_Language].CreditRiskClassName                       as CreditRiskClassName,

  ExchangeRateType,

  @Semantics.currencyCode:true
  DisplayCurrency,

  @DefaultAggregation: #SUM
  NumberOfOpenItems,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  AmountInDisplayCurrency,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  TotalOverdueAmtInDspCrcy,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  TotalNotOvrdAmtInDspCrcy,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  NetDueIntvl1AmtInDspCrcy,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  NetDueIntvl2AmtInDspCrcy,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  NetDueIntvl3AmtInDspCrcy,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'DisplayCurrency'
  NetDueLastIntvlAmtInDspCrcy,

  @Consumption.hidden: true
  @DefaultAggregation: #FORMULA
  @AnalyticsDetails.query.formula: '(NetDueIntvl1AmtInDspCrcy + NetDueIntvl2AmtInDspCrcy + NetDueIntvl3AmtInDspCrcy + NetDueLastIntvlAmtInDspCrcy)'
  1.0                                                                                        as TotalAmountInDisplayCrcy, 


  @Consumption.hidden: true
  @DefaultAggregation: #FORMULA
  @AnalyticsDetails.query.formula: 'NDIV0( $projection.TotalAmountInDisplayCrcy / AmountInDisplayCurrency)'
  1.0                                                                                        as OverdueReceivablesInPercent, /

  @EndUserText.label: 'Overdue Receivables Ratio'
  @DefaultAggregation: #FORMULA
  @AnalyticsDetails.query.formula: 'CASE WHEN $projection.OverdueReceivablesInPercent > 1 THEN 1 ELSE $projection.OverdueReceivablesInPercent END'
  @AnalyticsDetails.query.decimals: 4
  1.0                                                                                        as OverdueReceivablesRatio

}

-----

Do you have any suggestions how I could make this work?

Thank you in advance!

Marissa
Advisor
Advisor
0 Kudos

Hi regysm21,

Could you please confirm if you're working SAP S/4HANA Cloud 2308?

Best regards,
Marissa

regysm21
Active Participant
0 Kudos

Hi Marissa, we are on S4/HANA 2022 on Premise.

Thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

regysm21
Active Participant
0 Kudos

Hi Experts, any suggestion on this topic please?

Thank you!