cancel
Showing results for 
Search instead for 
Did you mean: 

Using Layout Variable in DP Macro

alok_jaiswal
Contributor
0 Kudos

Hi,

The requirement which I want to implement is if Sales Orders are greater than zero at location level, then value of Forecast should be equal to Sales Orders. For this I wrote the macro which runs at location level to set the value of flag to 1 if sales orders is greater than zero else 0 using LAYOUTVARIABLE_SET.

Now I am referncing this value of flag(using LAYOUTVAR_VALUE) in other macro. However this macro is running at lowest level i.e. at location,product,country etc. and for some reason it is not getting the value of flag set in other macro.

Please let me know how to make it work or is there any other logic to implement it.

Thanks,

Alok

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi ,

Not sure y we need Laoutvar Value,

Let expect Backlog is SO and  Remaining Unconstrained Fcst as Forecast.

You can create a New KF and write logic as below :

Suman

Former Member
0 Kudos

Hi,

are you running this two macros together (in a collective macro) or one after the other? Also, are you running them as a background job or interactively?

regards,

J.

alok_jaiswal
Contributor
0 Kudos

Hi James,

The two macros are being run separately one after other as part of process chain. First SALES_ORDER_CHECK macro is run at location level which sets the flag and then the other macro is run which uses the value of flag.

Thanks,

Alok

Former Member
0 Kudos

Ok, then the answer to your problem is that the variable is destroyed after execution of the first background job.

If you are running in SNP, and want to keep both processes separated, you can use TS_SET and TS_GET to store data persistently in an internal table. Use your first macro to store the value for your location, then read it in the second macro. In this case, you'll need a third macro to reset the table using TS_SET again and zeroing wathever you wrote in the first place.

If you are in a DP context and can spare a key figure (even an unused cell would do). Write say 99999 at the aggregate level to flag in the first macro and let it dissagregate through your lower levels. In this case, the second macro will find something <>0 and you could easyliy work from there. I suggest you try this second possibility.

thanks,

J.

alok_jaiswal
Contributor
0 Kudos

Hi James,

Yes its in DP context. But I am not sure how exactly to implement your suggestion.

First macro is currently written as below:

IF

Sales Order > 0

then Set

LAYOUTVARIABLE_SET( 'FLAG' ; 1)

else Set

LAYOUTVARIABLE_SET( 'FLAG' ; 0)

END IF

And in the second macro condition is checked as

IF LAYOUTVAR_VALUE( ' FLAG' ) = 1

then

Forecast= Sales Order

END IF

Can you please suggest how to modify them to make it work.

Thanks

Former Member
0 Kudos

Hi,

chose a key figure you can spare.

In the first macro, do the following:

if [salesorder>0] then [cell (or row element) = 99999] else [cell (or row element) =0] endif.

These values will dissagregate to lower level and will be stored in liveCache, accesible for any other macro you run at any other time.

In the second macro, replace IF flag = 1 with:

if [cell (or row element) <> 0] then [fcst = sales order]  endif.

if you find a value <>0, it means that the higher level had sales order >0.

regards,

J.

alok_jaiswal
Contributor
0 Kudos

Hi James,

When i implement the above mentioned logic, macro works if i make the macro as default macros and load the data.

However when i run these macros as part of process chain, I dont get the desired results.

Thanks

Former Member
0 Kudos

1) Are you sure you are executing your second macro at the correrct aggregation level when executed in background? Check by selecting log in the process (and read the cvcs accessed by system) or check number of entries in the selection. If you want to access your detailed level, you must select them in the process.

2) Else, is your "spare ratio" in liveCache (does it allow to save data)? For instance; if you don't put the macro as default,start, etc... (no automatic execution), execute macro 1 interactively, save, exit and go back, is the ratio populated?

Of course, if the ratio cannot save data (2), (1) will not work either.

regards,

J.

alok_jaiswal
Contributor
0 Kudos

James,

I did not properly followed your suggestion 2.

Can you please give steps how to go about testing  it.

Thanks

Former Member
0 Kudos

Hi,

what ratio are you using? is it visible in your planning area (/SAPAPO/MSDP_ADMIN)?