Note 418801 - Creating A User Exit Macro
Note 418801 - Creating A User Exit Macro
Summary
Symptom
You cannot use a standard macro.
Other terms
Macro
Macro/SAPAPO/SDP94
/SAPAPO/SNP94
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).
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.
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:
28.06.2012 Page 2 of 5
SAP Note 418801 - Creating a user exit macro
- T_I_PLOB_VALUES-PLOBJ
- FELDH
- GRIDNR = '001'
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 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.
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.
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