cancel
Showing results for 
Search instead for 
Did you mean: 

maximum loops *for *next allowed in bpc logic script

former_member1013626
Participant
0 Kudos

Hi,

  I am trying the below logic script but I get the following error. I have 5 loops for 5 variable using *for/*next. Is it because of more looping? I did not get this error when tried with 2 loops.

at UJKT:

"no more space for extending..

at validation in BPC web client:

error: "unhandled error(HTTP Status:500):unmarshal.invalid.xml"

*XDIM_MEMBERSET TIME AS %TIME_VAR%=BAS(2014.TOTAL)

*SELECT(%PROD_SKU_VAR%,"[ID]",PRODUCT_SKU,"[CALC]='N'")

*SELECT(%PROD_VAR%,"[ID]",PRODUCT,"[CALC]='N'")

*SELECT(%UOM_VAR%,"[ID]",UOM,"[CALC]='N'")

*XDIM_MEMBERSET COMPANY AS %COMPANY_VAR%=DR01,DV01

*XDIM_MEMBERSET UOM=NO_UOM

*XDIM_MEMBERSET VERSION=BUDV0_2014

*XDIM_MEMBERSET TIME=2014.INP

*XDIM_MEMBERSET INPUTCURRENCY=AED

*XDIM_MEMBERSET PRODUCT_SKU=NO_PRDSKU

*XDIM_MEMBERSET PRODUCT=NO_PRD

*XDIM_MEMBERSET METRICS=COGS_PRICE

*WHEN PRODUCT_RM

*IS "<>NO_RM"

*FOR %TIME_LOOP%=%TIME_VAR%

  *FOR %PROD_SKU_LOOP%=%PROD_SKU_VAR%

   *FOR %PROD_LOOP%=%PROD_VAR%

    *FOR %UOM_LOOP%=%UOM_VAR%

     *FOR %COMP_LOOP%=%COMPANY_VAR%

*BEGIN

   *REC(EXPRESSION=([TIME].[%TIME_LOOP%],[PRODUCT].[%PROD_LOOP%],[PRODUCT_SKU].[%PROD_SKU_LOOP%],[INPUTCURRENCY].[NO_INPUTCURR],[UOM].[%UOM_LOOP%],[METRICS].[COGS_VOL],

    [COMPANY].[%COMP_LOOP%])*%VALUE%,TIME=%TIME_LOOP%,PRODUCT=%PROD_LOOP%,PRODUCT_SKU=%PROD_SKU_LOOP%,METRICS="COGS_AMT",COMPANY=%COMP_LOOP%,UOM=%UOM_LOOP%)

*END

     *NEXT

    *NEXT

   *NEXT

  *NEXT

*NEXT

*ENDWHEN

Regards,
Draksharam

Accepted Solutions (1)

Accepted Solutions (1)

former_member1013626
Participant
0 Kudos

Hi,

Even the validation is taking a long time and failing at the end with these loops. It's not throwing any format error though. I had to use these many loops for variables since those can't be hardcoded? is there any other way than loops? your ideas are highly appreciated.

Regards,
Draksharam

former_member186338
Active Contributor
0 Kudos

Hi Draksharam,

I don't think that there is a reason to have all this loops! Why are you using this loops except TIME loop?

Vadim

former_member186338
Active Contributor
0 Kudos

And by the way, *FOR/*NEXT is not a real loop - it's a preprocessor instruction to copy lines of code between *FOR and *NEXT and replace variable with the items from the list in *FOR %VAR%=Item1,item2,...

Vadim

P.S. Always use UJKT to test your scripts...!

former_member186338
Active Contributor
0 Kudos

And where you have seen the following syntax:

*IS "<>NO_RM"

The correct syntax is

*IS <> "NO_RM"

or

*IS <> NO_RM

And what for to use *IS condition instead of scoping before the loop:

*XDIM_MEMBERSET PRODUCT_RM <> NO_RM

Vadim

former_member1013626
Participant
0 Kudos

Hi Vadim,

     I have TIME, product, Product_SKU, UOM, company as variables since the scoped record represented by %VALUE% has different dimension members for these. *for/*next loop is for including a single record in *REC.

Regards,
Draksharam

former_member1013626
Participant
0 Kudos

Hi Vadim,

    Thanks for the reply.

I have made changes in scoping and removed *when. But I still get ABAP run time error at UJKT, saying 'no more storage space available for extending..". As said earlier, I need loops because *REC needs single record and I have 5 variables.

*XDIM_MEMBERSET TIME AS %TIME_VAR%=BAS(2014.TOTAL)

*SELECT(%PROD_SKU_VAR%,"[ID]",PRODUCT_SKU,"[CALC]='N'")

*SELECT(%PROD_VAR%,"[ID]",PRODUCT,"[CALC]='N'")

*SELECT(%UOM_VAR%,"[ID]",UOM,"[CALC]='N'")

*XDIM_MEMBERSET COMPANY AS %COMPANY_VAR%=DR01,DV01

*XDIM_MEMBERSET UOM=NO_UOM

*XDIM_MEMBERSET VERSION=BUDV0_2014

*XDIM_MEMBERSET TIME=2014.INP

*XDIM_MEMBERSET INPUTCURRENCY=AED

*XDIM_MEMBERSET PRODUCT_SKU=NO_PRDSKU

*XDIM_MEMBERSET PRODUCT=NO_PRD

*XDIM_MEMBERSET METRICS=COGS_PRICE

*XDIM_MEMBERSET PRODUCT_RM<>NO_RM

*FOR %TIME_LOOP%=%TIME_VAR%

  *FOR %PROD_SKU_LOOP%=%PROD_SKU_VAR%

   *FOR %PROD_LOOP%=%PROD_VAR%

    *FOR %UOM_LOOP%=%UOM_VAR%

     *FOR %COMP_LOOP%=%COMPANY_VAR%

*BEGIN

   *REC(EXPRESSION=([TIME].[%TIME_LOOP%],[PRODUCT].[%PROD_LOOP%],[PRODUCT_SKU].[%PROD_SKU_LOOP%],[INPUTCURRENCY].[NO_INPUTCURR],[UOM].[%UOM_LOOP%],[METRICS].[COGS_VOL],

    [COMPANY].[%COMP_LOOP%])*%VALUE%,TIME=%TIME_LOOP%,PRODUCT=%PROD_LOOP%,PRODUCT_SKU=%PROD_SKU_LOOP%,METRICS="COGS_AMT",COMPANY=%COMP_LOOP%,UOM=%UOM_LOOP%)

*END

     *NEXT

    *NEXT

   *NEXT

  *NEXT

*NEXT

Regards,
Draksharam

former_member186338
Active Contributor
0 Kudos

Hi Draksharam,

Can you provide a FULL list of dimension members for COGS_VOL and COGS_PRICE. In this case it may be better to scope COGS_VOL and get COGS_PRICE using tuple? Anyway, full info is required!

What I can see for COGS_PRICE:

UOM=NO_UOM

VERSION=BUDV0_2014

TIME=2014.INP

INPUTCURRENCY=AED

PRODUCT_SKU=NO_PRDSKU

PRODUCT=NO_PRD

METRICS=COGS_PRICE

PRODUCT_RM <> NO_RM

COMPANY=??? - Same as for COGS_VOL or...

For COGS_VOL:

UOM=ALL

VERSION=BUDV0_2014 Same as for COGS_PRICE

TIME=BAS(2014.TOTAL)

INPUTCURRENCY=NO_INPUTCURR

PROD_SKU=ALL

PRODUCT=ALL

METRICS=COGS_VOL

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE

COMPANY=??? - Same as for COGS_PRICE

Result:

UOM= Same as COGS_VOL

VERSION= Same as COGS_VOL ???

TIME= Same as COGS_VOL

INPUTCURRENCY=AED ??? Same as for COGS_PRICE

PRODUCT_SKU= Same as COGS_VOL

PRODUCT= Same as COGS_VOL

METRICS=COGS_AMT

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE

COMPANY=??? - Same as for COGS_PRICE

Vadim

former_member186338
Active Contributor
0 Kudos

Hi Draksharam,

May be you stop some strange experiments like "I have made changes in scoping and removed *when." and provide a description of members I asked in the prev post.

REC can't be used without WHEN/ENDWHEN (Read help, it's clearly stated here):

"REC always needs to be accompanied by WHEN / IS / ENDWHEN. Stand-alone REC statements do not have any effect."

*FOR/*NEXT - is not the loop! It's a text copy!!!!

Vadim

former_member1013626
Participant
0 Kudos

Hi Vadim,

     Thanks for the reply. COGS_VOL and COGS_PRICE are members are METRICS dimension.

COMPANY  PRODUCT     PRODUCT_SKU     PRODUCT_RM     UOM     TIME         METRICS

NO_CC       NO_PRD         NO_PRDSKU        213                NO_UOM  2014.INP COGS_PRICE

DR01          2001               9                          213                 EA           2014.01 COGS_VOL

DR01          2002               10                         213                EA            2014.02 COGS_VOL

So, only PRODUCT_RM is common for both COGS_PRICE and COGS_VOL. So, I am using 5 variables for others. How many *FOR/*NEXT loops can be used in logic script? I can try to reduce UOM by pulling that data from 0material infoprovider but even then I will have to user 4 variables.

Hope I have put my question clearly.

Regards,
Draksharam

former_member186338
Active Contributor
0 Kudos

You don't need multiple FOR/NEXT at all!!!

I will adjust my text from prev post, BUT I STILL DO NOT COMPLETELY UNDERSTAND WHERE YOU WANT TO PUT RESULT

For COGS_PRICE:

UOM=NO_UOM

VERSION=BUDV0_2014 - Is it CORRECT?

TIME=2014.INP

INPUTCURRENCY=AED - Is it CORRECT?

PRODUCT_SKU=NO_PRDSKU

PRODUCT=NO_PRD

METRICS=COGS_PRICE

PRODUCT_RM <> NO_RM

COMPANY=NO_CC

For COGS_VOL:

UOM=ALL

VERSION=BUDV0_2014 Same as for COGS_PRICE - Is it CORRECT?

TIME=BAS(2014.TOTAL)

INPUTCURRENCY=NO_INPUTCURR - Is it CORRECT?

PROD_SKU=ALL

PRODUCT=ALL

METRICS=COGS_VOL

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE

COMPANY=DR01,DV01

Result: ????????????????????????????????????

UOM= NO_UOM ?????

VERSION=BUDV0_2014 Same as COGS_VOL ???

TIME= BAS(2014.TOTAL) Same as COGS_VOL????

INPUTCURRENCY=AED ??? Same as for COGS_PRICE

PRODUCT_SKU= ALL - Same as COGS_VOL

PRODUCT= ALL - Same as COGS_VOL

METRICS=COGS_AMT

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE,COGS_VOL

COMPANY=DR01,DV01 - Same as for COGS_VOL

Please make required corrections.

B.R. Vadim

former_member1013626
Participant
0 Kudos

Hi Vadim,

     My answers are below.

For COGS_PRICE:

UOM=NO_UOM

VERSION=BUDV0_2014 - Is it CORRECT? correct.

TIME=2014.INP

INPUTCURRENCY=AED - Is it CORRECT? correct.

PRODUCT_SKU=NO_PRDSKU

PRODUCT=NO_PRD

METRICS=COGS_PRICE

PRODUCT_RM <> NO_RM

COMPANY=NO_CC

For COGS_VOL:

UOM=ALL

VERSION=BUDV0_2014 Same as for COGS_PRICE - Is it CORRECT? Yes.

TIME=BAS(2014.TOTAL)

INPUTCURRENCY=NO_INPUTCURR - Is it CORRECT? yes,

PROD_SKU=ALL

PRODUCT=ALL

METRICS=COGS_VOL

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE. Yes.

COMPANY=DR01,DV01

UOM= NO_UOM ????? No. UOM of COGS_VOL and it's EA, CS,KG, LTR etc.,

VERSION=BUDV0_2014 Same as COGS_VOL ??? Yes.

TIME= BAS(2014.TOTAL) Same as COGS_VOL???? Yes.

INPUTCURRENCY=AED ??? Same as for COGS_PRICE. Yes.

PRODUCT_SKU= ALL - Same as COGS_VOL. No, not all. single record of Product_SKU, same as COGS_VOL.

PRODUCT= ALL - Same as COGS_VOL. No, not all. single record of Product_SKU, same as COGS_VOL.

METRICS=COGS_AMT . Yes.

PRODUCT_RM <> NO_RM ??? Same as for COGS_PRICE,COGS_VOL. No. RM same as COGS_PRICE.

COMPANY=DR01,DV01 - Same as for COGS_VOL. yes.

Regards,
Draksharam

former_member186338
Active Contributor
0 Kudos

Hi,

About results:

UOM= NO_UOM ????? No. UOM of COGS_VOL and it's EA, CS,KG, LTR etc.,


Ok, units of measurement will be the same as COGS_VOL (a bit strange, because you multily Price and Volume=Amount of money - looks like same UOM as Price)


PRODUCT_SKU= ALL - Same as COGS_VOL. No, not all. single record of Product_SKU, same as COGS_VOL.

PRODUCT= ALL - Same as COGS_VOL. No, not all. single record of Product_SKU, same as COGS_VOL.


ALL - I mean single record


Script:

//Scope for COGS_VOL

*XDIM_MEMBERSET UOM=<ALL>

*XDIM_MEMBERSET VERSION=BUDV0_2014

*XDIM_MEMBERSET TIME=BAS(2014.TOTAL)

*XDIM_MEMBERSET INPUTCURRENCY=NO_INPUTCURR

*XDIM_MEMBERSET PRODUCT_SKU=<ALL>

*XDIM_MEMBERSET PRODUCT=<ALL>

*XDIM_MEMBERSET PRODUCT_RM<>NO_RM

*XDIM_MEMBERSET METRICS=COGS_VOL

*XDIM_MEMBERSET COMPANY=DR01,DV01

*WHEN VERSION

*IS *

//Tuple for COGS_PRICE, result to COGS_AMT

*REC(EXPRESSION=%VALUE%*([UOM].[NO_UOM],[TIME].[2014.INP],[INPUTCURRENCY].[AED],[PRODUCT_SKU].[NO_PRDSKU],[PRODUCT].[NO_PRD],[COMPANY].[NO_CC],[METRICS].[COGS_PRICE]),INPUTCURRENCY="AED",METRICS="COGS_AMT")

*ENDWHEN

Vadim



former_member1013626
Participant
0 Kudos

Hi Vadim,

     Your code works correctly as required.

Here are my observations.

1. When I used *select initiate a variable with all members, I had to user *For/*Next loops to pass a single variable record to *REC. But when using *XDIM_MEMBERSET Dimension <ALL>, *REC is picking single record of dimension. This holds true even for multiple members scoped *XDIM_MEMBERSET Dimension Member1,member2.

2. *For/*Next loop is not a real loop(as you said) it's only a shorthand of writing each record separately in the script.

3. *For/*Next function can't be used on more than 2 variables(it's goes into memory error) with substantial records.

Am I right?

Also, thanks again for inputs.

Regards,
Draksharam

former_member186338
Active Contributor
0 Kudos

Hi Draksharam,

Answers:

1. When I used *select initiate a variable with all members, I had to user *For/*Next loops to pass a single variable record to *REC. But when using *XDIM_MEMBERSET Dimension <ALL>, *REC is picking single record of dimension. This holds true even for multiple members scoped *XDIM_MEMBERSET Dimension Member1,member2.

Not exactly! WHEN/ENDWHEN will ALWAYS loop all base member combinations withing the scope defined before WHEN/ENDWHEN.

*FOR/NEXT is used when, for example for each record in WHEN/ENDWHEN you need to generate more then one result. It's better to avoid usage of long and nested FOR/NEXT if possible, because it's slow and sometimes limited (inside single WHEN/ENDWHEN).

2. *For/*Next loop is not a real loop(as you said) it's only a shorthand of writing each record separately in the script.

YES! And you can see it in UJKT in lgx code

3. *For/*Next function can't be used on more than 2 variables(it's goes into memory error) with substantial records.

Not always - it's the limitation of the number of REC's inside single WHEN/ENDWHEN loop when ABAP (not Java script) script calculation engine is enabled in BPC 10 (starting from some SP).

B.R. Vadim

former_member186338
Active Contributor
0 Kudos

P.S. If everything is clear, please close the topic as answered.

Answers (0)