Você está na página 1de 7

How to Trigger an Event Using APO Planning Book Macro

How to Trigger an Event Using APO Planning Book Macro


Applies to:
SAP APO 3.0 and above

Summary
There are some instances when we want to be able to raise an event using an APO Planning Book Macro.
For example, there may be a need to allow the users to execute a certain background job or process chain
by just running a macro in the Interactive Planning screen. The background job or process chain can be set
to run after a certain event. The user can then execute a Planning Book macro which triggers the needed
event. This document describes the steps to implement this kind of functionality.
Author(s): Emmanuel Nepomuceno
Company: Hewlett Packard Asia Pacific
Created on: 19 December 2006

Author Bio
Emmanuel Nepomuceno is a SAP specialist working for Hewlett Packards Global Delivery
Center in the Philippines. Hes involved in various projects using APO, BW and ABAP/4.

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


1

How to Trigger an Event Using APO Planning Book Macro

Table of Contents
Applies to: ........................................................................................................................................ 1
Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
Implementing the User Function in SE37 ........................................................................................ 3
Using the User Function in the Macro Workbench.......................................................................... 5
Related Content............................................................................................................................... 6
Disclaimer and Liability Notice......................................................................................................... 7

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


2

How to Trigger an Event Using APO Planning Book Macro

Implementing the User Function in SE37


1) Create function module Z_C_MACRO_RAISEEVNT in transaction SE37.

NOTE: It is very important that you configure the function module as shown below. Other configurations
(e.g. more parameters) may not work.
2) Specify the parameters in the CHANGING tab

3) Specify the parameters in the TABLES tab

4) Write the source code in the SOURCE CODE tab

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


3

How to Trigger an Event Using APO Planning Book Macro

Source Code Listing:

FUNCTION Z_C_MACRO_RAISEEVNT .
*"---------------------------------------------------------------------*"*"Local Interface:
*" TABLES
*"

VALUE_TAB STRUCTURE /SAPAPO/VALUE_TAB

*" CHANGING
*"

REFERENCE(F_CALC_ERROR) TYPE CHAR1

*"

REFERENCE(F_ARGUMENT) TYPE /SAPAPO/MXVAL

*"----------------------------------------------------------------------

CONSTANTS: c_error(1) type c value 'X'.


DATA: l_value_tab TYPE /sapapo/value_tab,
l_event TYPE /sapapo/funstring.

clear f_calc_error.

READ TABLE value_tab into l_value_tab index 1.


IF sy-subrc NE 0.
f_calc_error = c_error.
EXIT.
ENDIF.

l_event = l_value_tab-string.

CALL FUNCTION 'BP_EVENT_RAISE'


EXPORTING
eventid

= l_event

EXCEPTIONS
SAP DEVELOPER NETWORK | sdn.sap.com
2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


4

How to Trigger an Event Using APO Planning Book Macro

bad_eventid

=1

eventid_does_not_exist = 2
eventid_missing
raise_failed
OTHERS

=3
=4
= 5.

IF sy-subrc <> 0.
f_calc_error = c_error.
ENDIF.

ENDFUNCTION.

Using the User Function in the Macro Workbench


Go to the Macro Workbench and enter your planning book and then do the following steps:
1) Add your user function to the list of available user functions by proceeding to the Edit
->Edit User function Menu.

2) Enter the name of your function

3) Specify the parameter settings (the default is OK).

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


5

How to Trigger an Event Using APO Planning Book Macro

4) Construct your Macro and macro steps:

NOTE: You may also try to place the macro function within an action box.

Related Content

SAP Developer Network

Online Help for Planning Book Macros

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


6

How to Trigger an Event Using APO Planning Book Macro

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or
seek to hold, SAP responsible or liable with respect to the content of this document.

SAP DEVELOPER NETWORK | sdn.sap.com


2006 SAP AG

BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com


7

Você também pode gostar