SDN PCo 03
SDN PCo 03
SDN PCo 03
2: Wire to
the Outside World for SAP
Business Suite-Applications
Notification Scenarios
Applies to:
SAP Business Suite 7 including Enhancement Packages, SAP Plant Connectivity 2.2. For more information,
visit the Manufacturing homepage.
Summary
Learn how SAP Business Suite applications can use PCo notification functionality to receive and process
events triggered by external data sources. This includes sample implementation for automatic processing of
time ticket confirmations in SAP ERP systems.
Author:
Company: SAP AG
Created on: March 9, 2012
Author Bio
Dr. Uwe Dittes made his PhD in chemistry at the University of Heidelberg, followed by certification
as technical operation manager (Chamber of Commerce [IHK]). He worked several years in
chemical and pharmaceutical industry (development & production). Dr. Dittes joined the
development Organization of SAP in 2001. He has a strong expertise in ERP core manufacturing
(SAP PP-PI, SAP PP-SFC) and Business Suite application integration with SAP plant connectivity
(PCo). He has also been working as external lecturer at the Baden-Wrttemberg cooperative State
University (State) in Mannheim, teaching fundamentals of SAP ERP, lean production, cloud computing, and
mathematics.
scn.sap.com
1
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Table of Contents
General Remarks ................................................................................................................................................ 3
Generating and Processing Notifications ........................................................................................................... 3
Basic Assumptions .......................................................................................................................................... 3
First Sample Scenario for Processing Notifications via SAP Business Suite Applications ............................ 4
Creation of Notification Templates (PCo Management Console) ................................................................................. 5
Remote Subscription (SAP Business Suite System).................................................................................................... 6
Remarks....................................................................................................................................................................... 8
Processing Notifications that have been created via PCo Management Console........................................ 11
Next Step: Implement ABAP Methods for Processing Notifications ............................................................. 12
Process Steps for Generation and Processing of Notifications .................................................................................. 13
scn.sap.com
2
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
General Remarks
We recommend reading first three parts of this set of documents for getting familiar with basic concepts of
integrating external data in SAP Business Suite applications by SAP Plant Connectivity (PCo). First chapters
of this document describe principal approach how SAP Business Suite applications can handle notifications.
Using test RPCO_BS_INT_TEST you create subscriptions for value changes of data points: You trigger
creation of application log entries in SAP Business Suite systems when you change values for subscribed
data points. For this you dont require to create a single line of ABAP coding in your system. In addition we
provide sample implementation how to create and process time ticket confirmation messages for production
orders. These confirmation messages are triggered by changing values of distinct data points.
This document is based on the implementation guide that describes how to connect external data
sources to Business Suite with SAP Plant Connectivity (PCo) Release 2.2.
o
Implementation Guide is part of SAP note 1576651 and could be updated without further
notice.
To connect your application, you need to have a good knowledge in ABAP programming and ABAP
Objects programming. In addition, you should know how SAP Plant Connectivity (PCo) works.
You must refer to the system and development prerequisites specified in the documents.
If you need additional help for the implementation after reading this document, you should request
SAP remote-consulting (see SAP note 83020).
The complimentary Customer Support of SAP will not support errors that are caused by
modifications of the SAP standard system or by customer development (see SAP note 7).
Manufacturing machine encounters an error in their internal error checking. This raises maintenance
notifications in the SAP system and triggers alert email notifications of maintenance personnel by
SAP framework.
Computerized numerical control machine (CNC-machine) machine has processed just the 1000th
work piece. Reaching this counter level leads to an automatic production confirmation in the SAP
System.
Filling and weighing machine has consumed the penultimate role on packaging material and raises a
corresponding event. A delivery for replenishing packing material is created via the SAP System.
For some business processes, it makes sense to trigger activities of the SAP Business Suite if certain values
or parameters of external data sources have changed. The following are examples of this:
Business process
The status of a machine changes from processing
to malfunction
scn.sap.com
3
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Business process
The value of a temperature sensor exceeds the
maximum temperature previously specified of
120C
The weight of a semi-finished product is calculated
by means of individual weighing
In the above-mentioned examples, specific Business Suite applications must be automatically addressed.
They receive the required tag data and information via notifications. These notifications are generated and
sent by PCo as soon as the specified trigger conditions are fulfilled. The following applies here:
The selection of the relevant tags is carried out using subscriptions on the part of the Business Suite
applications.
The processing of PCo notifications to be sent back to the Business Suite application can be
controlled using BAdI implementations, for each specific case and in great detail.
First Sample Scenario for Processing Notifications via SAP Business Suite Applications
We want to give you an easy and understandable introduction for notification processing. Therefore SAP
Standard already contains sample implementation that converts content of PCo notification messages into
application log entries. SAP test report RPCO_BS_INT_TEST allows you to subscribe for value changes of
data points. This report is part of integration coding of SAP NetWeaver layer. You dont need to implement
any coding in your system. Just execute following activities:
Create notification template for your OPC DA agent via PCo management console
You already defined a destination channel when you created your first PCo query
Create subscriptions for value changes of data points using test report RPCO_BS_INT_TEST
scn.sap.com
4
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Make sure that your PCo OPC DA agent instance is inactive. Otherwise stop it
Mark new entry for your notification Noti_Templ. Choose tab strip Destinations.
Press button Add Destination Systems. Popup for assigning destinations appears.
scn.sap.com
5
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Select RFC destination that you maintained for your PCo agent.
Keep default values for application (SAPTESTING) and application handle (LOG).
Clear checkbox Test Mode (without PCo) and tick checkbox Logging Active.
scn.sap.com
6
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Execute report and select those data points/tags you want to subscribe for. Result list is displayed
and contains entries for selected data points:
Change values for subscribed data points and press button Write Value Changes.
scn.sap.com
7
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
If value changes are executed you will get application log messages
Press button Application Logs to access log messages that are triggered by notifications
Log entries that contain notification content get value NOT_CBCK in column Activity.
Figure 12: Changed Data Point Values Written in Message Long Text
Remarks
Take following into account:
Check log files of PCo agent in PCo management console in case notifications arent transferred to
SAP Business Suite destination.
Use OPC Quick client for changing data of subscribed data points.
Depending on PCo agent notifications are raised during OPC DA server start though no value
change occurred.
You have to close and reopen PCo management console to see created subscription as well as
subscription items (tab strip Subscription Items)
scn.sap.com
8
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Processing notification content is implemented in handler classes you create using transaction SE24.
These classes have to inherit super class CL_PCO_NOTIF_HANDLER and implement redefined
method EXECUTE of this super class in their own classes. Method EXECUTE contains coding that
controls how notification and its content are processed. In our previous example method EXECUTE
of class CL_PCO_SAPTESTING_NOTIF contains coding that writes data of sent notification into
application log messages.
For linking application and handler classes it is necessary to create an implementation for BAdI
BADI_S_PCO_HANDLE_NOTIF: Use your application as filter value. In method
GET_CLASS_NAME just return name of your handler class thats it! Have a look at BAdI
enhancement implementation S_PCO_IM_SAPTESTING_NOTIF which returns name of class
CL_PCO_SAPTESTING_NOTIF in case notifications are received that are assigned to application
SAPTESTING. Note that you can transfer application specific content via application handle (max.
80 chars) to fine-tune notification processing.
Creation of remote subscriptions from SAP Business Suite doesnt require stopping assigned PCo agent
instance. This is a major advantage compared with notifications you directly create in PCo management
console.
scn.sap.com
9
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
scn.sap.com
10
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Processing Notifications that have been created via PCo Management Console
PCo also allows creating notifications via PCo Management console:
Switch to tab strip Subscription Items and navigate through hierarchy of data points that belong to
assigned OPC server after pressing Browse button.
Select data points for subscription and add them to selection. Press OK.
Maintain name and description but dont tick checkbox Template. Press OK
scn.sap.com
11
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Choose subscriptions item from dropdown list box and press OK. Repeat step for each data
point you want to subscribe.
Switch to tab strip Destination and assign RFC destination for Business Suite system
Notifications created via PCo management console get fixed value for application (PCO_NOTIFY). Name of
notification is assigned as application handle. In our example value of application handle is
My_sample_notification. In SAP standard theres no BAdI implementation for processing such notifications.
But you are free to implement handling of such subscriptions on your own. Take care that you set
PCO_NOTIFY as BAdI filter value for application parameter.
Next Step: Implement ABAP Methods for Processing Notifications
Notifications are triggered by events that are sent from external data source to assigned PCo agents. In case
trigger conditions for raising notification messages are fulfilled PCo transfers notification messages to
previously defined destination systems. Examples for trigger conditions:
Value changes
Formula
scn.sap.com
12
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
OSIsoft PI agent
Socket agent
All source system type except OPC DA PCo continuously transfers tag values and checks fulfillment of
trigger conditions. In case trigger conditions are fulfilled PCo sends notification message to destination
systems. Source systems of type OPC DA check their measured value by themselves and only transfers
data points with deviating values. PCo then raises notification message and transfers it to selected
destination systems.
Process Steps for Generation and Processing of Notifications
The following steps are necessary to be able to generate and process PCo notifications:
Step
System
Activity
scn.sap.com
13
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Step
System
10
Activity
found at the end of this implementation guide.
Start the PCo agent instance
Subscription to tags for which notifications are to be sent if
the trigger conditions are fulfilled
1. Specification of an application handle to which
notifications are to be assigned. Via the application
handle, it is subsequently possible to control the further
processing of notifications when they are received by
the Business Suite applications.
The sample program RPCO_BS_INT_TEST uses
SAPTESTING as the default value for the
application, as well as the log values of the
application handle.
For the filter value of the application SAPTESTING,
there is an active BAdI implementation that can be
used to process and save the contents of the
notification as application log messages.
2. Assignment of a notification template of the
corresponding PCo agent instance
If the specified trigger conditions are fulfilled, PCo sends
the notification per RFC call as an XML document to the
corresponding recipients in the Business Suite.
In this case, the function module
S_PCO_RFC_EXECUTE_RECEIVE_EVNT is
executed, in which the processing of the notification is
to take place:
First the system checks whether a class for notification
processing exists for the application specified in the
corresponding application handle.
If this is the case, an instance of this class is generated
and the EXECUTE instance method of the class is
executed.
scn.sap.com
14
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Setting the severity to Error, if error messages are part of the notification
Generation of an application log entry containing the name and the description of the notification
Evaluation of the passed expressions and generation of the corresponding application log entries
o Conversion of the expressions into instances of the exception class CX_PCO_BS_INT,
since this can easily be implemented in application logs
Creation of error messages for the application log
Saving of the application logs and posting of the changes
Type
Data type
Optional
IT_ERROR_MSG
Importing
Type PCO_T_QUERY_MESSAGE_OBJ
IT_EXPR_DATA
Importing
Type PCO_T_EXPR_DATA
IS_APPL_HANDLE
Importing
Type PCO_S_APPL_HANDLE
IS_NOTIF_HEADER
IV_TEST_MODE
Importing
Importing
Type PCO_S_NOTIF_HEADER
Type BOOLE_D
X
X
Description
Error messages for notifications
(Object inst.)
PCo expression data
PCo: Data structure for application
handle
PCo: Header data for notification
'X': Test mode
2. Next, assign the exception class CX_PCO_BS_INT (PCo Suite Integration: Exception Class)
3. After this, copy the following ABAP coding into the method:
METHOD execute.
* This redefined method writes data of sent notification into
* application log
DATA:
lt_exc_obj
TYPE pco_t_exc_obj.
DATA:
ls_bal_context TYPE bal_s_cont,
scn.sap.com
15
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
ls_expr_data
DATA:
lv_log_handle
lv_msg_severity
lv_msg_stext
lv_msg_txt
DATA:
lo_exc_obj
lo_pco_util
* Determine message
IF it_error_msg[]
lv_msg_severity
ELSE.
lv_msg_severity
ENDIF.
TYPE pco_s_expr_data.
TYPE
TYPE
TYPE
TYPE
balloghndl,
s_pco_query_message_severity,
text40,
string.
scn.sap.com
16
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
EXPORTING
it_exc_obj
is_appl_handle
iv_activity
iv_bal_subobj
iv_msg_severity
iv_req_type
CHANGING
cv_log_handle
=
=
=
=
=
=
lt_exc_obj
is_appl_handle
cl_pco_utility=>gc_act_not_cbck
cl_pco_utility=>gc_bal_subobj_tag
lv_msg_severity
cl_pco_query_xml_builder=>gc_req_type_tag
= lv_log_handle ).
scn.sap.com
17
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Type
Data type
IS_APPL_HANDLE
Importing
Type PCO_S_APPL_HANDLE
EV_CLASS_NAME
Exporting
Type SEOCLSNAME
Optional
Description
PCo: Data structure for application
handle
Name of the class processing
notifications
2. Then assign the exception class CX_PCO_BS_INT (PCo Suite Integration: Exception Class).
3. Finally, copy the following ABAP coding into the method:
METHOD if_ex_s_pco_handle_notif~get_class_name.
* Processing of notifications is executed with the help of classes that
* inherit super class CL_PCO_NOTIF_HANDLER.
* Based on entered application handle information this BAdI
* implementation returns the name of handler class
CONSTANTS:
lc_appl_name_saptesting TYPE pco_s_appl_handle-appl
VALUE 'SAPTESTING',
lc_class_name_saptesting TYPE seoclsname
VALUE 'CL_PCO_SAPTESTING_NOTIF'.
CLEAR: ev_class_name.
IF is_appl_handle-appl = lc_appl_name_saptesting.
ev_class_name = lc_class_name_saptesting.
ENDIF.
ENDMETHOD.
scn.sap.com
18
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Determination of the confirmation number from the application handles of the notification
Read operation for confirmation number
Read order number of the corresponding production order from the database
Determination of sequence and operation number
Generation of confirmation using the BAPI BAPI_PRODORDCONF_CREATE_TT.
Execution of posting by calling the function module BAPI_TRANSACTION_COMMIT
Type
Data type
IT_ERROR_MSG
Importing
Type PCO_T_QUERY_MESSAGE_OBJ
Optional
X
IT_EXPR_DATA
Importing
Type PCO_T_EXPR_DATA
IS_APPL_HANDLE
Importing
Type PCO_S_APPL_HANDLE
IS_NOTIF_HEADER
IV_TEST_MODE
Importing
Importing
Type PCO_S_NOTIF_HEADER
Type BOOLE_D
X
X
Description
Error messages for notifications
(Object inst.)
PCo expression data
PCo: Data structure for application
handle
PCo: Header data for notification
'X': Test mode
2. Next, assign the exception class CX_PCO_BS_INT (PCo Suite Integration: Exception Class)
3. After this, copy the following ABAP coding into the method:
METHOD execute.
DATA:
lt_conf
DATA:
ls_appl_handle
ls_cafko_ru
ls_cafvc_ru
ls_afvc
pco_s_appl_handle,
cafko_ru,
cafvc_ru,
afvc,
scn.sap.com
19
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
ls_conf
ls_expr_data
TYPE bapi_pp_timeticket,
TYPE pco_s_expr_data.
scn.sap.com
20
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Return of the class name of the handler class (ZUD_RK_CONF), if the application name of the
application handle has the value PRODORDCON.
Type
Data type
IS_APPL_HANDLE
Importing
Type PCO_S_APPL_HANDLE
Optional
Description
PCo: Data structure for application handle
EV_CLASS_NAME
Exporting
Type SEOCLSNAME
2. Next assign exception class CX_PCO_BS_INT (PCo Suite Integration: exception class).
3. Finally, copy the following ABAP Coding into the method:
METHOD if_ex_s_pco_handle_notif~get_class_name.
CONSTANTS:
lc_appl_name_prodordcon TYPE pco_s_appl_handle-appl
VALUE 'PRODORDCON',
lc_class_name_zud_rk_conf TYPE seoclsname
VALUE 'ZUD_RK_CONF'.
CLEAR ev_class_name.
IF is_appl_handle-appl = lc_appl_name_prodordcon.
ev_class_name = lc_class_name_zud_rk_conf.
ENDIF.
ENDMETHOD.
scn.sap.com
21
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Related Content
How to Create Custom Query Agent Using SAP PCo 2.1 SDK
Manufacturing Execution For Process Industries
Production Planning and Control for Discrete Industries
State of the Art Maintaining Process Instructions with XSteps - Available Functional Enhancements
For more information, visit the Manufacturing homepage.
scn.sap.com
22
SAP Plant Connectivity 2.2: Wire to the Outside World for SAP Business Suite-Applications Notification Scenarios
Copyright
Copyright 2012 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9,
iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server,
PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes,
BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX,
Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Oracle Corporation.
JavaScript is a registered trademark of Oracle Corporation, used under license for technology invented and implemented by Netscape.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned
herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and
other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document
serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.
scn.sap.com
23