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

TMVL in Select Statement

Former Member
0 Likes
1,190

Hi Experts,

I am using *Select statement in which I need to use TMVL function. But the system does not recognize TMVL function in *SELECT statement.

The script I am using is written below.

*SELECT(%DEP_LOOP%,ID,TIME,ID>=%TIME_SET% AND ID<= TMVL(5,%TIME_SET%), AND LEVEL = MONTH)

The purpose of the above statement is to use a loop from a minimum time to the maximum time.

Also guide me can I use LOOKUP within TMVL? Need your urgent expert opinion.

Regards,

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member186338
Active Contributor
0 Likes

Hi Sami,

You can't use TMVL inside SELECT, because TMVL is processed later than SELECT!

What do you want to achieve? Select next 5 months?

And what do you want to achieve with LOOKUP?

Vadim

former_member186338
Active Contributor
0 Likes

P.S.

If you want to scope next 5 months:

*XDIM_MEMBERSET TIME=%TIME_SET%,TMVL(1,%TIME_SET%),TMVL(2,%TIME_SET%)...

P.P.S.

If you absolutely need to put next 5 months into some variable to use it in the FOR/NEXT loop there is another trick! But first you have to explain your full script idea!

Former Member
0 Likes

Hi Vadim,

Thanks for your reply.

I lookup the member NO_OF_MONTHS from another model.

This LOOKUP value will be used in the main model in FOR loop.

for eg. No_of_months = 4

then in the main model the for loop should start from the %TIME_SET% till the No_of_months.

e.g

if TIME_SET = 2016.01

then loop should work for 2016.01, 2016.02, 2016.03 and 2016.04 respectively.

I hope you understand.

Regards

former_member186338
Active Contributor
0 Likes

Full script please!

Why do you need FOR/NEXT? It's a common error to use FOR/NEXT where it's not required! You can use scope...

Vadim

former_member186338
Active Contributor
0 Likes

P.S. The way to use TMVL for the loop is like:

*FOR %N%=0,1,2,3,4

*XDIM_MEMBERSET TIME=TMVL(%N%,%TIME_SET)

...

*NEXT

Former Member
0 Likes

Hi Vadim,

Please find below the script logic.

*LOOKUP CAPEX_DRIVER

*DIM ALIFE:ACC_CAP_D= "ASSETLIFE"

*DIM CURRENCY= "PKR"

*DIM VERSION = "Plan"

*DIM ASSET_SUPER = CI3

*DIM TIME = NO_TIME

*DIM ENTITY = %ENTITY_SET%

*ENDLOOKUP

*XDIM_MEMBERSET VERSION = Plan

*XDIM_MEMBERSET ACC_CAP_M = COST, ASSETDEPEXP

//*XDIM_MEMBERSET TIME = NO_TIME

*XDIM_MEMBERSET ASSET_SUPER = CI3

*XDIM_MEMBERSET COST_CENTER = 1010102001

*XDIM_MEMBERSET PROJECT = P002

*XDIM_MEMBERSET ENTITY = 1000

*SELECT(%DEP_LOOP%,ID,TIME,ID>=2016.01 AND ID <= TMVL(5,2016.01) AND LEVEL = MONTH)

//need help in the above select statement. The value ASSETLIFE is LOOKED up from CAPEX Driver model. The loop should work with the life defined in the driver model. For each ASSER super the life is different. Right now trying to test on single asset super.

//*FOR %PERIOD% = %MTHLY_LOOP%

*SELECTCASE ACC_CAP_M

     *CASE ASSETVALUE > 0

     *FOR %DEP% = %DEP_LOOP%

*WHEN ACC_CAP_M

*IS "COST"

*REC(EXPRESSION =  %VALUE%/LOOKUP(ALIFE), TIME = TMVL(1,%DEP%), ACC_CAP_M = ASSETDEPEXP)

*ENDWHEN

*NEXT

*ENDSELECT

former_member186338
Active Contributor
0 Likes

Absolutely incorrect script! Can you explain calculation logic in words with some sample tables?

Former Member
0 Likes

Capex Driver:

This below cost exist in the main CAPEX model against each Asset Super Class (Laptop, Desktop, car etc)

We need to build a mechanism in order to calculate the depreciation based on the life in months set in capex driver model. 

For eg. The car depreciation calculated by the system from 2016.02 till 2017.01 = 550,000 + salvage value 150,000 = 700,00 i.e the original cost of Car.

The above planned depreciation we want to calculate in BPC.

former_member186338
Active Contributor
0 Likes

Now it's more or less clear!

Just one extra question - normally the depreciation is started not in the month of purchase but from the next month - is it your case?

And please estimate number of different Asset categories you will have (like number of Asset Super Number)?

Former Member
0 Likes

Hi Vadim,

My mistake.. yes it will start from the next month.

The asset super no. is same as Asset categories. The number range is from 30000 till 70000

Regards

former_member186338
Active Contributor
0 Likes

Then I can give you a good advice - stop developing script for this scenario. On the production volumes it will calculate endlessly due to multiple nested FOR/NEXT loops. Start badi development! It's not a great job - just one day for ABAP developer!

Vadim

P.S. There are a lot of calculation scenarios that can be implemented by script logic. This is the opposite case - custom logic badi will do the job!

Former Member
0 Likes

Hi Vadim,

The count of asset categories will not exceed 200. Though the number range is bit long.

can you help me in the script logic. I don't want to do ABAP for this script. I am thinking of the ABAP code as a last option.

Regards

former_member186338
Active Contributor
0 Likes

Think about BADI as the first option. Trying to create script is a waste of time. Even 200 categories will generate endless script.

Vadim

Try to think how you will transform Life in Month as signed data into number of REC's in the script