cancel
Showing results for 
Search instead for 
Did you mean: 

Set user created variable in macro in DP

Former Member
0 Kudos

I am trying to use a variable in a macro on the demand planning grid. The logic needs to go as follows.

Initialize a user defined variable and set to 0 at the default event.

If a change is made to certain rows, set the variable to 1 at the default event.

Then if the variable is 1, add the rows together at the default event.

I have all of it written except for the variable part. I looked in the SAP help and could not find what I needed. I also searched the forum with no luck. I am looking for what the syntax needs to be and what elements are needed to accomplish this.

Can someone please help?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I added the space and it lets me activate the macro.

Here is how I am setting the variable:

If Data Input for Total Demand

IF

Data Input?

ROW_VALUES_CHANGED(

Cell: Base Forecast ( P 07.2005 )

) = 1

OR

ROW_VALUES_CHANGED(

Cell: Forecast Adjustments ( P 07.2005 )

) = 1

OR

ROW_VALUES_CHANGED(

Cell: Promo Forecast ( P 07.2005 )

) = 1

Set Demand Change Variable to 1 : ( 1 Iterations : P 07.2008; P 07.2008 )

Set Demand Change Variable to 1

LAYOUTVARIABLE_SET( 'CHANGE' ; 1 )

ENDIF

Former Member
0 Kudos

So is it working as expected now?

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes!!! Thank you for your prompt, helpful, and knowledgeable response!!!

Former Member
0 Kudos

I am trying to use those variables and I am getting a funny error when I try to save the macro.

Error:

"The field "LAYOUTVAR_VALUE(" is unknown, but there is a field with the similar

name "CON_LAYOUTVAR_VALUE". "CON_LAYOUTVAR_VALUE".

Macro(s) Was/Were Not Generated, Macro Book Was Not Saved"

However when I try to use the variable they suggest it does not exist either and I get the same mesage asking me to use the same variable they are suggesting.

Here is the macro I am trying to create. I have the portion of the macro for the variable initialization and set created successfully.

This is the part with the trouble. I am trying to say, if the variable equals 1 to execute the calculation. Do you know what I could be doing wrong?

Calculate Total Demand New

Condition (IF)

(Control Statement) The Demand Change Variable equals 1 (Operator/Function) LAYOUTVAR_VALUE('CHANGE')

(Operator/Fucntion) = 1

(Step) Calculate Total Demand : ( 24 Iterations : P 07.2008; P 06.2010 )

Row: TOTAL DEMAND ( Frm P 07.2008 ) =

Row: Base Forecast ( Frm P 07.2008 )

+

Row: Forecast Adjustments ( Frm P 07.2008 )

+

Row: Promo Forecast ( Frm P 07.2008 )

(Condition) ENDIF

Former Member
0 Kudos

Hi Stacy.

First of all, how are you using LAYOUTVARIABLE_SET?

Secondly, you will need a <space> after the 1st bracket before 'CHANGE' and then one after before the closing bracket.

M

Former Member
0 Kudos

HI Stacey.

Try the function:

LAYOUTVARIABLE_SET() to set the variable

syntax=( 'name of variable' ; value of variable )

and then:

LAYOUTVAR_VALUE() to return value or LAYOUTVARIABLE() to return characters

syntax=( 'name of variable').

Would recommend that you look at the example macros in the macro workbench, book: 9AEXAMPLES.

Hope this helps.

Mark.

Edited by: percx on Jan 15, 2008 3:34 PM