0% found this document useful (0 votes)
22 views5 pages

Note 418801 - Creating A User Exit Macro

The document describes how to create a user exit macro to customize standard macros in SAP APO. It provides detailed steps to build the macro using the macro builder tool and create the corresponding user exit in transaction SMOD. It also explains how to interface with the required tables and includes a sample code for filling planning board entries.

Uploaded by

selimozugur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

Note 418801 - Creating A User Exit Macro

The document describes how to create a user exit macro to customize standard macros in SAP APO. It provides detailed steps to build the macro using the macro builder tool and create the corresponding user exit in transaction SMOD. It also explains how to interface with the required tables and includes a sample code for filling planning board entries.

Uploaded by

selimozugur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SAP Note 418801 - Creating a user exit macro

Note Language: English Version: 4 Validity: Valid Since 16.02.2006

Summary

Symptom
You cannot use a standard macro.

Other terms
Macro
Macro/SAPAPO/SDP94
/SAPAPO/SNP94

Reason and Prerequisites


Possible causes:

o Parameters required to calculate the line entries are not available


in the macrobuilder and must first be generated from database
tables.

o More complicated calculations are necessary to determine the line


entries.

Solution
You can create a user exit macro to correct the problem. We shall outline
the exact procedure for this below.

As of SCM Release 5.0, we recommend that you use a Business Add-In (BAdI)
macro instead of a user exit macro (see SAP online documentation).

Creating the macro

o Use Transaction /SAPAPO/ADVM to call the macrobuilder.

o Select a macro book.

o Use Drag and Drop to move the icon labeled 'User exit macro' from
the Shuffler into the middle of the screen and attach it to the
icon with the name 'Macro'. Rename it.

o If required, link the user exit macro icon you have just created
with one of the event icons located in the right-hand screen.

Creating the user exit

o Start Transaction SMOD.

o Enter APODM005 in the 'Enhancement' field. Select 'Display'.

o Then choose 'Components' or Shift+F11 and double-click the name of


the function module.

o Double-click the include contained in the function module to enter


the source code.

28.06.2012 Page 1 of 5
SAP Note 418801 - Creating a user exit macro

Interface
Below we exaplain how to fill the interface of the user exit. The user only
fills or changes the following tables:

- T_C_TAB

- T_E_TAB_OLD

The T_C_TAB table is the actual output table in this case. T_E_TAB_OLD
provides information about data changes and must be maintained for
technical reasons. All other tables act as input parameters.

The values on the planning board are stored under the V field name in the
T_C_TAB table. The table entries are explicitly defined by their Z line
index and their C column index. The T_I_COLS table provides the column
information here while the line information is returned from an inner join
via the T_I_PLOB_VALUES and T_I_LINES tables.

The parameters of the following tables are used to calculate lines and
columns:

Interface parameter
------------------------------------------------------------------
| Table | Field | Description |
------------------------------------------------------------------
| T_I_COLS | VONTG | Lower date limit |
| T_I_COLS | BISTG | Upper date limit |
------------------------------------------------------------------
| T_I_PLOB_VALUES | SELECTION | Table composed of the |
| | | IOBJNM characteristic and a
|
| | | range structure |
| T_I_PLOB_VALUES | PLOBJ | (for join condition) |
| T_I_PLOB_VALUES- | IOBJNM | Technical name of the |
| SELECTION | | rel. characteristic |
------------------------------------------------------------------
| T_I_LINES | FELDH | Technical name of the
|
| | | rel. key figure |
| T_I_LINES | GRIDNR | Name of the rel. grid |
| T_I_LINES | KRIT1 | (for join condition) |
------------------------------------------------------------------
| T_C_TAB / T_E_TAB_OLD | Z | Line index of planning board
|
| T_C_TAB / T_E_TAB_OLD | C | Column index of planning
board |
| T_C_TAB / T_E_TAB_OLD | V | num. planning board entry
|
------------------------------------------------------------------

To manipulate the planning board entries, you must use the source code of
the user exit to adjust the grid entries of the T_C_TAB table
appropriately. In this case, each individual cell is addressed using the
coordinates of the grid. Proceed as follows:

o Determine column C from the T_I_COLS table depending on the VONTG

28.06.2012 Page 2 of 5
SAP Note 418801 - Creating a user exit macro

and BISTG date limits.

o Use the internal table T_I_PLOB_VALUES-SELECTION to check that the


solution is unique and, if necessary, determine
T_I_PLOB_VALUES-PLOBJ.

o In table T_I_LINES, use the following key fields

- T_I_PLOB_VALUES-PLOBJ

- FELDH

- GRIDNR = '001'

to determine the line number Z = T_I_LINES-LINE.

o In the T_C_TAB table, enter the required value for the determined
line and column index under T_C_TAB-V.

o If you want to change a value for the table, save the earlier
T_C_TAB entry in the table with the same structure, that is,
T_E_TAB_OLD. If you enter a new value into the T_C_TAB table, you
must insert a null value into the T_E_TAB_OLD table for the
corresponding rows and column number.

Notes

o If you want to make changes at the lowest level of granularity, you


must ensure that your selection is unique. We shall only consider
this case here.

o You can find the technical names for key figures and
characteristics in Transaction /SAPAPO/SDP8B.

Sample code
The following function module fills all buckets for the FELDH key figure
within the time interval VONTG to BISTG with a constant value V. The
selection is determined by the IOBJNM and CHAR_VAL fields, whereby the
first field provides the technical name of the characteristic and the
second indicates the value of the characteristic.

FUNCTION zfill_buckets
*"----------------------------------------------------------------------
*"*"Global interface:
*" IMPORTING
*" VALUE(I_CUBE) TYPE /SAPAPO/INFOCUBE
*" VALUE(I_LAYOUT) TYPE /SAPAPO/LAYOUT
*" VALUE(I_SCTYP) TYPE /SAPAPO/SCTYP
*" VALUE(I_MACRO_NAME) TYPE /SAPAPO/TXMAK
*" VALUE(I_ACT_PLOBJ) TYPE /SAPAPO/PLOBJ
*" VALUE(VONTG) TYPE BEGDA
*" VALUE(BISTG) TYPE ENDDA
*" VALUE(IOBJNM) TYPE /SAPAPO/IOBJNM OPTIONAL
*" VALUE(CHAR_VAL) TYPE /SAPAPO/CHAVL
*" VALUE(FELDH) TYPE /SAPAPO/IOBJNM
*" VALUE(V) TYPE I

28.06.2012 Page 3 of 5
SAP Note 418801 - Creating a user exit macro

*" TABLES
*" T_I_PLOB_VALUES TYPE /SAPAPO/DM_T_PLOB_VALUES
*" T_I_DRILL_HIER STRUCTURE /SAPAPO/PGAN
*" T_I_LINES STRUCTURE /SAPAPO/MCP6_LI
*" T_I_COLS STRUCTURE /SAPAPO/PGCOLS
*" T_C_TAB STRUCTURE /SAPAPO/MXSOP
*" T_E_TAB_OLD STRUCTURE /SAPAPO/MXSOP
*"----------------------------------------------------------------------
DATA: l_selection LIKE LINE OF t_i_plob_values-selection.
DATA: l_line LIKE LINE OF t_i_lines.
DATA: l_tab LIKE LINE OF t_c_tab.
DATA: l_col LIKE LINE OF t_i_cols.
DATA: l_column LIKE t_i_cols-column.
DATA: l_cnt TYPE i.
DATA: l_gridnr TYPE char3 VALUE '001'.
DATA: l_index LIKE sy-tabix.

* read table t_i_cols index 1 into l_col.


LOOP AT t_i_cols INTO l_col WHERE bistg <= bistg
AND vontg >= vontg.
l_column = l_col-column.

LOOP AT t_i_plob_values.
* For checking uniqueness calculate # entries
CLEAR l_cnt.
LOOP AT t_i_plob_values-selection INTO l_selection
WHERE iobjnm = iobjnm
AND low = char_val.
l_cnt = l_cnt + 1.
IF l_cnt > 1.
EXIT.
ENDIF.
ENDLOOP.

IF sy-subrc <> 0 OR l_cnt > 1.


CONTINUE.
ENDIF.
READ TABLE t_i_plob_values-selection WITH KEY
iobjnm = iobjnm
low = char_val
z = l_line-line
c = l_column
TRANSPORTING NO FIELDS.
* store old value
IF sy-subrc = 0.
MODIFY t_e_tab_old FROM l_tab INDEX sy-tabix.
ELSE.
APPEND l_tab TO t_e_tab_old.
ENDIF.
* store new value
l_tab-v = v.
MODIFY t_c_tab FROM l_tab INDEX l_index.
ENDLOOP.
ENDLOOP.

ENDFUNCTION.

28.06.2012 Page 4 of 5
SAP Note 418801 - Creating a user exit macro

Header Data
Release Status: Released for Customer
Released on: 16.02.2006 09:45:22
Master Language: German
Priority: Correction with medium priority
Category: Consulting
Primary Component: SCM-APO-FCS-MAC MacroBuilder

Secondary Components:
SCM-APO-SNP-MAC MacroBuilder

Valid Releases
Software Component Release From To and
Release Release Subsequent
SAP_APO 30 30A 30A
SAP_APO 310 310 310
SCM 400 400 400
SCM 410 410 410
SCM 500 500 500
SCM 510 510 510

Related Notes
Number Short Text
1119651 Creating a BAdI macro
1045639 Consulting notes in SNP/CTM
539797 Collective consulting note on macros

28.06.2012 Page 5 of 5

You might also like