Skip to Content
avatar image
Former Member

BPC NW: Looping in Logic Script

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

Add comment
10|10000 characters needed 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

  • 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

  • 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

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 24, 2016 at 08:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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