Skip to Content
0

BPC NW: Looping in Logic Script

Oct 24, 2016 at 12:08 AM

226

avatar image
Former Member

Hi all,

How to add a loop in logic script?

I want to do like this:

DO 2 TIMES <- how to write like this in logic script?

*START_BADI ZBPC_PRD_BADI_006_A
QUERY=OFF
WRITE=OFF
*END_BADI

*XDIM_MEMBERSET P_ACCOUNT = QTY_PRODUCED_AUTO, QTY_USED_AUTO
*XDIM_MEMBERSET FLOW = M10,M20
*START_BADI ZBPC_PRD_BADI_006_B
QUERY=ON
WRITE=ON
*END_BADI

ENDDO

Thank you for your help.

Kind regards,
Agus Eryanta

10 |10000 characters needed characters left characters exceeded

Hi Angus,

Why would you want to execute same code on same data multiple time? Unless you have some "side effects" which is not a good idea either.

Regards,

Gersh

0
Former Member
Gersh Voldman

Hi Gersh,

In this case I need to use result from Badi A in Badi B, then use result from Badi B in Badi A, and again use result from Badi A in Badi B.

This logic is such of circular logic. Due to the code complexity in that Badi, I separate into two Badi and I loop it in logic script.

Regards,
Agus Eryanta

0

Hi Angus,

Let's assume BADI A processes Data region A and generates Data region B that doesn't overlap with Data region A. Then BADI B processes Data region B and generates Data region C that doesn't overlap with Data regions A or B.

Now if you execute BADI A again it will produce same results as the first time. This probably mean that BADI A or B (or both) change original data. That's what called a "side effect".

This is not a good approach, especially in Planning. Users repeat their modeling multiple time. Do you want them to get different results every time?

Regards,

Gersh

1
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Vadim Kalinin Oct 24, 2016 at 08:59 AM
1

Strange idea... What do you want ta achieve?

In general in order to loop some statements you can use for/next:

*FOR %I%=1,2

//SOME CODE

*NEXT

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I just need to execute these badi twice without rewrite these code twice. I'm looking for simple code to achieve that.

Thank you

0

I have already answered you - FOR/NEXT will execute code inside FOR/NEXT number of times...

But it's useless, because 2 times it's better to repeat code!

0
Former Member
Vadim Kalinin

Thank you , your answer is help me to simplify my code. In case I need more iteration, now I just add the number.

Thank you

0