cancel
Showing results for 
Search instead for 
Did you mean: 

Macros for Extra fields in Product Master(/n/sapapo/mat1)

Former Member
0 Kudos

I have added two new extra fields in Extras tab of Product
Master namely: From date and To date.

These two fields will be populated by the business users as
per the material can be used for Planning by them.

(For ex:- Let ABC is a material used in DE location from the
period 01.10.2010 to 31.12.2014.)

I want to write a macro based on these 2 fields in APO so
that user can’t be able to enter the data after this period for the following
materials.

What macro I can used .Please can you explain with the help
of an example?

Accepted Solutions (1)

Accepted Solutions (1)

rajkj
Active Contributor
0 Kudos

If you intend to use location product master extra attributes, you can use the following macro functions,

MATLOC_EXTRA( n ; ACT_PRODUCT ; ACT_LOCATION ; ACT_VERSION ) - To return numerical values

MATLOC_EXTRA_C( n ; ACT_PRODUCT ; ACT_LOCATION ; ACT_VERSION)  - To return character values

where n is the number of extra field. Standard APO allows you to use 5 extra attributes i.e. 1 to 5.

In case of global products, the macro functions are

MAT_EXTRA( n ; ACT_PRODUCT ;  ACT_VERSION ) - To return numerical values

MATLOC_EXTRA_C( n ; ACT_PRODUCT ; ACT_VERSION)  - To return character values

To assign values, you can use the following macro functions

MAT_EXTRA_SET( n ; '<field value>' ; ACT_PRODUCT ;  ACT_VERSION )

MATLOC_EXTRA_SET( n ; '<field value>' ; ACT_PRODUCT ;  ACT_LOCATION ; ACT_VERSION )

e.g. Assume "From Date" is your 1st attribute where as "To Date" is the second.

Then MATLOC_EXTRA_C( 1 ; ACT_PRODUCT ; ACT_LOCATION ; ACT_VERSION ) returns the 'From Date' value i.e. MATLOC_EXTRA_C( 1 ; 'ABC' ; 'DE' ; '000' ).

If you use the date format YYYYMMDD to assign values to 'From Date' and 'To Date', then you can make use the Date macro functions otherwise, you need to use custom functions to convert the dates

For instance, if 'From Date' is 20101001, then

DATE( MATLOC_EXTRA_C( 1 ; ACT_PRODUCT ; ACT_LOCATION ; ACT_VERSION ) ) returns the number of days between 0001/01/01 and specified date.

You can refer the data function at

http://help.sap.com/saphelp_SCM700_ehp02/helpdata/en/1d/310eb0d0ee11d4b2e40050da385632/frameset.htm

For more examples, pl refer 9AEXAMPLES macro books using t.code /SAPAPO/ADVM

Thanks,
Rajesh

Former Member
0 Kudos

Hi Rajesh,

thanks For your reply!!!

I used "ATT05" freely defined attribute in my system and it is a CHAR data element with space 40, it is already in the system.

I want to assign date in this attribute like format " 20130916"(i.e. 16th October,2013)" in this attribute only and then I try to write a macro which will compare bucket date with this date and accordingly Key figure will be set for lock or unlock.

Will it be possible to assign date like this in CHAR data element and read. Currently we are using monthly bucket format in our system i.e. data shows according to monthly wise(M06.2013,M07.2013 etc.).  I have written a macro for this also. Can you please tell me whether it solve my purpose or not.

This macro should works for all the products and location currently planned in the system.

It will take TO DATE after this date material is becoming obsolete.

Macro is like this:-

>TEST MACRO

> Read date from ATT105 : ( 18 Iterations :M06.2013;M11.2014 )

Action Box 1:

LAYOUTVARIABLE_SET ( 'TO_DATE' ;

DATE(

MATLOC_EXTRA_C (

5 ;

ACT_PRODUCT ;

ACT_LOCATION ;

ACT_VERSION

)

)

)

Step 2:

Bucket date : ( 18 Iterations :M06.2013;M11.2014 )

Action Box 2:

LAYOUTVARIABLE_SET ( 'BUCK_EDATE' ;

BUCKET_EDATE(

Row: Opco Adjustment( Frm M06.2013 )

)

)

IF

Condition  BUCKET_EDATE < TO_DATE

LAYOUTVAR_VALUE ( 'BUCK_EDATE' )

>

LAYOUTVAR_VALUE ( 'TO_DATE')

 

Row: Opco Adjustment ( Frm M06.2013 ) =

ROW_INPUT( 0 )

ELSE

Condition

> Row: Opco Adjustment( Frm M06.2013 ) =

ROW_INPUT( 1 )

ENDIF

Please check and revert whether it is correct or not?

The macro is getting activated in the system but it is not working as per the requirement?

Can you please check and tell where am I get wrong.

rajkj
Active Contributor
0 Kudos

I have just made few minor corrections to your macro.

>TEST MACRO

> Read date from ATT105 : ( 1 Iterations :M06.2013;M06.2013 )

Action Box 1: Initialize the variables

LAYOUTVARIABLE_SET ( 'TO_DATE' ;

DATE(

MATLOC_EXTRA_C (

5 ;

ACT_PRODUCT ;

ACT_LOCATION ;

ACT_VERSION

)

)

)

LAYOUTVARIABLE_SET( 'FLAG' ; 0 )

Step 2:

Bucket date : ( 18 Iterations :M06.2013;M11.2014 )

Action Box 2:

LAYOUTVARIABLE_SET ( 'BUCK_EDATE' ;

BUCKET_EDATE(

Row: Opco Adjustment( Frm M06.2013 )      //Note: the data source should be "Column Attributes"

)

)

IF

Condition  BUCKET_EDATE > TO_DATE and FLAG = 0 (product is obsolete)

LAYOUTVAR_VALUE ( 'BUCK_EDATE' )

>

LAYOUTVAR_VALUE ( 'TO_DATE')

AND

LAYOUTVAR_VALUE( 'FLAG' ) = 0

 

Row: Opco Adjustment ( Frm M06.2013 ) =

ROW_INPUT( 0 )

LAYOUTVARIABLE_SET( 'FLAG' ; 1 )

ELSE

Condition

> Row: Opco Adjustment( Frm M06.2013 ) =

ROW_INPUT( 1 )

ENDIF

Former Member
0 Kudos

Hi Rajesh,

One strange behavior I have noticed. I am able to activate the macro in Macro Workbench. After activating and saving it. It looks fine and I am out of the  Data View for which I am creating this macro.

After when I again logged in the data view and  expanding the macro few changes were got lost. I am attaching the screenshot also.


IF

Condition

LAYOUTVAR_VALUE ( 'BUCK_EDATE' )

>

LAYOUTVAR_VALUE ( 'TO_DATE')

AND

LAYOUTVAR_VALUE( 'FLAG' ) = 0

 

Row: Opco Adjustment ( Frm M06.2013 ) = // these two Rows I have added got lost after I activate and save it.

ROW_INPUT( 0 )

LAYOUTVARIABLE_SET( 'FLAG' ; 1 )

ELSE

Condition

> Row: Opco Adjustment( Frm M06.2013 ) = // these two Rows I have added got lost after I activate and save it.

ROW_INPUT( 1 )

ENDIF

Refer the attachment I have made after activating and saving the macro in macro Workbench. what is the cause for it?

rajkj
Active Contributor
0 Kudos

Nitish,

The macro step elements are not indented properly i.e. they are not created at next level compared to the step. You can check the following screenshot for an example on order of step elements in a step.

Then in the first step, you need not to execute it for 18 iterations, one run is sufficient to assign the values to your variables.

- Rajesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Nitish,

You can use macro operator: MATLOC_C

AT102  being the field from the value is read

Like:

LAYOUTVARIABLE_SET ( 'variable'

MATLOC_C ( 'AT102' ; ACT_PRODUCT ; ACT_LOCATION ; ACT_VERSION ) )

and so on

But do notice that this only works on SNP side.

Br,

Juha