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

Accesing a Dimension Member Property inside FOR/NEXT Loop

Former Member
0 Likes
449

Hi all,


Per my last message (Thanks Vadim!)


http://scn.sap.com/message/16494561#16494561


Now I'm using RUNALLOCATION  and it's just working fine (more or less )


I want to access Location DIM property "COMPANY CODE" to use it in my RUNALLOC script below to fill %CC% variable.



*XDIM_MEMBERSET TIME=%TIME_SET%

*XDIM_MEMBERSET LOCATION=%PLT%

*XDIM_MEMBERSET KIT=BAS(ALL_KITS)

*XDIM_MEMBERSET COMPONENT=BAS(ALL_COMPONENT)

*XDIM_MEMBERSET KEYFIGURE=YTD_IVOL,YTD_CVOL

*XDIM_MEMBERSET VERSION=A100

*XDIM_MEMBERSET MATG4=NO_MATG4

*XDIM_MEMBERSET CURRENCY=LC

*XDIM_MEMBERSET DATASRC=INPUT

*FOR %PLANT%=%PLT%

/// Access %PLANT%.[COMPANY_CODE] and store it in %CC%

*FOR %KF%=REVAL_BS,REVAL_PL,YU_PL

*RUNALLOCATION

*FACTOR = USING/TOTAL

*DIM KEYFIGURE WHAT=%KF%; WHERE=%KF%; USING=YTD_IVOL; TOTAL=YTD_IVOL

*DIM KIT WHAT=NO_KITS; WHERE=BAS(ALL_KITS); USING=<<<; TOTAL=<<<

*DIM COMPONENT WHAT=NO_COMPONENT; WHERE=BAS(ALL_COMPONENT); USING=<<<; TOTAL=<<<

*DIM BRAND WHAT=NO_BRAND; WHERE=BAS(ALL_BRAND); USING=<<<; TOTAL=<<<

*DIM COUNTRY WHAT=NO_COUNTRY; WHERE=BAS(ALL_COUNTRIES); USING=<<<; TOTAL=<<<

*DIM DATASRC WHAT=INPUT; WHERE=CALC; USING=INPUT; TOTAL=INPUT

// Use %CC% to read values at CC level

*DIM LOCATION WHAT=%CC%; WHERE=%PLANT%; USING=<<<; TOTAL=%PLANT%

*ENDALLOCATION

*NEXT

*NEXT

Do you know if this is feasible? Any workaround?

Thanks a lot

/Laura

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Likes

*SELECT(%CCS%,[COMPANY_CODE],LOCATION,[ID]=%PLT%) //%CCS% - list of codes

*FOR %PLANT%=%PLT% AND %CC%=%CCS%


...


For each PLANT and corresponding CC!


Vadim

former_member186338
Active Contributor
0 Likes

By the way - for RUNALLOCATION you do not need to scope dimensions (using XDIM_MEMBERSET) specified inside RUNALLOCATION/ENDALLOCATION!

Put other XDIM_MEMBERSET statements inside inner FOR/NEXT loop:

*FOR %KF%=REVAL_BS,REVAL_PL,YU_PL

*XDIM_MEMBERSET TIME=%TIME_SET%

*XDIM_MEMBERSET VERSION=A100

*XDIM_MEMBERSET MATG4=NO_MATG4

*XDIM_MEMBERSET CURRENCY=LC

...

Reason - ENDALLOCATION resets scope!

Never use COMMIT

Former Member
0 Likes

Thanks a lot!! As always fast answers and really good advice.

Thanks Vadim.

/Laura.

Former Member
0 Likes

Vadim,

As per my code above, we have the following relation in our Location MD

1:N Company Code to Plants

The issue is that when we process several CCs at a time through that code, all the plants come into the same runallocation (result of %PLT%) and we only want to process only relevant plants for each CC at a time.

I've tried to use *FOR but I'm unable to set , dynamically this relation and in the end all Plants go through the RUNALLOCATION at the same time resulting in a wrong allocation (it takes the total volume of all plants, instead of relevant)

This line of code:

*DIM LOCATION WHAT=%CC%; WHERE=%ALL PLANTS relevant to CC%; USING=<<<; TOTAL=%ALL PLANT revelant to CC%

*ENDALLOCATION

Thanks!

former_member186338
Active Contributor
0 Likes

I do not understand what do you have in the dimension LOCATION!

Please show screenshot of dimension administration and explain the meaning of the members!

Vadim

In my previous code the assumption was 1:1 relationship...

Former Member
0 Likes

Yeah...my bad. I solved it anyway changed FOR from a Plant to a CC perspective.

Thanks anyway

former_member186338
Active Contributor
0 Likes

And used WHERE=[COMPANY_CODE]="%CC%"...?

Answers (0)