cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple Time Periods Selection with Lookup

Former Member
0 Kudos
675

Hello BPC gurus,

The below script working as expected, If I select one month (Ex 01.2018) time period and run the package, the currency conversion based on last year same month (Ex 01.2017) rate conversion. The results are wrong, If I select 12 moths periods (Ex 01.2018 to 12.2018)at a time and execute the package the currency conversion is taking place on 12 months back period(Ex 01.2017). The requirement is to check the conversion factor for previous 12 months for each period even user select multiple months. Ex : If user selects three months 01.2018, 02.2018, 03.2018 the rate conversion should based on 01.2017, 02.2017, 03.2017. I am new to Script logic and don't know how to declare and introduce FOR loop in below script to achieve desired results.

The version is BPC 10 Netweaver

Please help me.

Krishna

*SELECT(%VERSION_LIST%,FX_SOURCE_CATEGORY,VERSION,ID=%VERSION_SET%)

*LOOKUP RATE
*DIM TIME = TMVL(-12,%TIME_SET%)
*DIM R_ENTITY = "GLOBAL"
*DIM VERSION=%VERSION_LIST%
*DIM R_ACCT = SUMMARY_ACCOUNT.RATETYPE
*DIM LKPLC:INPUTCURRENCY = E_ENTITY.CURRENCY
*DIM LKPSUB:INPUTCURRENCY = E_ENTITY.SUBMISSION_CURRENCY
*ENDLOOKUP

*XDIM_MEMBERSET E_ENTITY = BAS(%E_ENTITY_SET%)
*XDIM_MEMBERSET TIME = BAS(%TIME_SET%)

*WHEN RPTCURRENCY
*IS Subm
*WHEN E_ENTITY.SUBMISSION_CURRENCY
*IS <> ""
*WHEN SUMMARY_ACCOUNT.RATETYPE
*IS <> ""
*REC(EXPRESSION = %VALUE%*LOOKUP(LKPSUB),RPTCURRENCY = USD)
*ELSE
*REC(FACTOR=1,RPTCURRENCY = USD)
*ENDWHEN
*ENDWHEN
*ENDWHEN

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor

Your issue is related to TMVL function and LOOKUP in general...

*DIM TIME = TMVL(-12,%TIME_SET%)

TMVL from multiple months containing in %TIME_SET% will result in TMVL(-12, <lowest month in %TIME_SET%>)

For example: %TIME_SET%=01.2018, 02.2018, 03.2018

Then: TMVL(-12,%TIME_SET%) = 01.2017

From help: https://help.sap.com/viewer/a2049170bfeb4178ace32222842c3ec1/10.1/en-US/c8d961d0dbfd4745af4b66727957...

"variables, like %TIME_SET%

  • The first period of the TIME_SET is used as the base period for a negative offset and the last period of the TIME_SET is used as the base period for a positive offset."

In order to work with multiple months in %TIME_SET% you have to create a property in TIME dimension like PREVYEARMONTH and fill it:

01.2018 - 01.2017

02.2018 - 02.2017

...

Then you can use:

*DIM TIME = TIME.PREVYEARMONTH 

Time member for LOOKUP will be selected based on the property.

former_member186338
Active Contributor
0 Kudos

Another way to implement the same logic not using new property will be using of FOR/NEXT loop for TIME in LOOKUP and in WHEN/ENWHEN. But it's slow and not recommended!



Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Kudos

This code:

*SELECT(%VERSION_LIST%,FX_SOURCE_CATEGORY,VERSION,ID=%VERSION_SET%)
*LOOKUP RATE
*DIM TIME = TIME.PREVYEARMONTH
*DIM R_ENTITY = "GLOBAL"
*DIM VERSION=%VERSION_LIST%
*DIM R_ACCT = SUMMARY_ACCOUNT.RATETYPE
*DIM LKPLC:INPUTCURRENCY = E_ENTITY.CURRENCY
*DIM LKPSUB:INPUTCURRENCY = E_ENTITY.SUBMISSION_CURRENCY
*ENDLOOKUP

*XDIM_MEMBERSET E_ENTITY = BAS(%E_ENTITY_SET%)
*XDIM_MEMBERSET TIME = BAS(%TIME_SET%)
*WHEN RPTCURRENCY
*IS Subm
*WHEN E_ENTITY.SUBMISSION_CURRENCY
*IS <> ""
*WHEN SUMMARY_ACCOUNT.RATETYPE
*IS <> ""
*REC(EXPRESSION = %VALUE%*LOOKUP(LKPSUB),RPTCURRENCY = USD)
*ELSE
*REC(FACTOR=1,RPTCURRENCY = USD)
*ENDWHEN
*ENDWHEN
*ENDWHEN

Is OK!

LOOKUP/ENDLOOKUP - is a definition, not a directly executed code.

LOOKUP will be executed at each iteration of WHEN/ENDWHEN loop with current members of WHEN/ENDWHEN loop passed to LOOKUP.

In this case we can look on E_ENTITY and TIME

If current member of TIME in WHEN/ENDWHEN is 2019.02 then LOOKUP will get data from 2018.02 stored in PREVYEARMONTH property of 2019.02

Hope it's clear!

Try to execute script in UJKT

P.S. Same approach with E_ENTITY

Former Member
0 Kudos

Hi Vadim Kalinin,

Thanks for the inputs. I will test above code.

But I realised that One of property RATE_YEAR is available for dimension "Version" (
Version is Catogory dimension )and kept the value as "-1".
Based on this property, the exchange rates should read from previous year.

But the property RATE_YEAR is not picking the previous year exchange rates. shall it require to explictly mention RATE_YEAR property in my code to work or will it read the property without coding.

My above query was related to my original query but not related with alternative solution (New property creation)

The Original code again:

*LOOKUP RATE
//*DIM TIME = TMVL(-12,%TIME_SET%)
*DIM TIME = TIME.ID
*DIM R_ENTITY = "GLOBAL"
*DIM VERSION=%VERSION_LIST%
*DIM R_ACCT = SUMMARY_ACCOUNT.RATETYPE
*DIM LKPLC:INPUTCURRENCY = E_ENTITY.CURRENCY
*DIM LKPSUB:INPUTCURRENCY = E_ENTITY.SUBMISSION_CURRENCY
// Shall I require to add here RATE_YEAR property for VERSION to get 
// Previous year exchange rate.
*ENDLOOKUP
*XDIM_MEMBERSET E_ENTITY = BAS(%E_ENTITY_SET%)
*XDIM_MEMBERSET TIME = BAS(%TIME_SET%)
*WHEN RPTCURRENCY
*IS Subm
*WHEN E_ENTITY.SUBMISSION_CURRENCY
*IS <> ""
*WHEN SUMMARY_ACCOUNT.RATETYPE
*IS <> ""
*REC(EXPRESSION = %VALUE%*LOOKUP(LKPSUB),RPTCURRENCY = USD)
*ELSE
*REC(FACTOR=1,RPTCURRENCY = USD)
*ENDWHEN
*ENDWHEN
*ENDWHEN
former_member186338
Active Contributor
0 Kudos

kittu25

You need to get some very basic training in BPC!

The property in CATEGORY dimension is related to the standard FX procedure using *RUN_PROGRAM CURR_CONVERSION

not you custom WHEN/ENDWHEN!!!!

former_member186338
Active Contributor
0 Kudos
kittu25

P.S. And the answer to your next question - can we use standard *RUN_PROGRAM CURR_CONVERSION?

No, you can't!

Standard program convert ONLY LC (Local Currency) and you want to convert "Subm"