15
Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC 6.0, Basis/ABA 7.1 For more information, visit the Business Process Modeling homepage . Summary This whitepaper explains how to start the BPM Process which is designed using NetWeaver Process composer from ABAP or ECC Backend. With respect to SOA paradigm; it highlights the usage of “Services” to integrate the backend with SAP NetWeaver Process Composer. In this particular mentioned scenario NetWeaver BPM acts as service provider by allowing simple steps to model a new web service and an existing ABAP program is re-used without any major changes to consume the service provided by NetWeaver BPM. The article also touches on few points to avoid problems while working on this particular scenario. Author: Priti Mulchandani Company: SAP Labs India Pvt. Ltd. Created on: 9 March 2009 Author Bio Priti is Principal Consultant in SAP Labs India and belongs to Custom Development department which mainly focuses on customer related projects. Priti has been working in SAP from last 4 years and has been involved in different technical and functional areas as per the requirements from SAP customers. Recently she has also been involved with SOA oriented projects with special focus on composition layer. SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 1

Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

  • Upload
    others

  • View
    18

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC 6.0, Basis/ABA 7.1

For more information, visit the Business Process Modeling homepage.

Summary This whitepaper explains how to start the BPM Process which is designed using NetWeaver Process composer from ABAP or ECC Backend. With respect to SOA paradigm; it highlights the usage of “Services” to integrate the backend with SAP NetWeaver Process Composer. In this particular mentioned scenario NetWeaver BPM acts as service provider by allowing simple steps to model a new web service and an existing ABAP program is re-used without any major changes to consume the service provided by NetWeaver BPM.

The article also touches on few points to avoid problems while working on this particular scenario.

Author: Priti Mulchandani

Company: SAP Labs India Pvt. Ltd.

Created on: 9 March 2009

Author Bio Priti is Principal Consultant in SAP Labs India and belongs to Custom Development department which mainly focuses on customer related projects. Priti has been working in SAP from last 4 years and has been involved in different technical and functional areas as per the requirements from SAP customers. Recently she has also been involved with SOA oriented projects with special focus on composition layer.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 1

Page 2: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

Table of Contents Why BPM from ABAP – Purpose .......................................................................................................................3

List of Steps – “How To”..................................................................................................................................3 Tips to Avoid Issues......................................................................................................................................10

Related Content................................................................................................................................................14 Copyright...........................................................................................................................................................15

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 2

Page 3: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

Why BPM from ABAP – Purpose Our customer had a batch report in backend ECC, which runs every morning and fires different leave approval requests to various processors based on employee organizational details. There were other steps as part of the complete leave approval process and those steps were modeled easily with NetWeaver BPM process Modeler.

But then one of the main steps was to trigger the whole process only when the batch report runs and start the process instances based on the information which is only available with batch report in backend ECC.

I went through various blogs on sdn and found couple of very helpful examples including the one on “Triggering a Guided Procedure from ABAP” but unlike guided procedures; starting a BPM process is quite simple as it hides many of the complex networking(such as GP Core WSIL) details from consumption. Moreover all the backend information such as employee organizational details can be directly provided while starting the process itself. This was possible trough “Start Event” and its associated service interface in BPM Process Composer.

List of Steps – “How To”

Following are steps needed to achieve the above requirement: 1. First identify how your Start Service Interface should look like. I.e. decide the parameters and the

information which would be passed to Start Event Service Interface from ABAP system.

It’s very simple to directly design the new service interface from within BPM process composer itself. Just create a new service interface from Service Interface Node available in the process modeling.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 3

Page 4: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

The design view of Service Interface will help you to easily design the service interface using context menu. The New Service Interface after the design could look something like this:

It’s important to note that the service interface has only Input Parameter(s) and no output parameters for the obvious reasons that we will only start the process from the client side and hence the service remains asynchronous.

Note: For the effective service interface, make sure you have well designed input parameters; i.e. just having a single attribute of simple data type in the input might give some problems later; but it can also be the issue due to version in which I worked. Nevertheless, it’s always a good practice to have a well defined service interface closely matching to existing sample SAP service interface. In the Source tab of WSDL, use the “Validate” functionality (available in context menu) to check the same.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 4

Page 5: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

For the designed service interface, we should be able to now see the WSDL also in the Source tab. As we have not deployed the whole project yet, we could directly copy this WSDL in the local file and use it for creation of client proxy at this point.

Note: Alternatively one could wait till the complete project is deployed and the web service for start event is generated; in which case WSDL url from J2EE server could then be taken for generating the client proxy.

2. Attach the above service interface to Start Event of BPM process (go to Interface tab in properties

window of Start Event). The Operation would be automatically picked up for the selected service interface.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 5

Page 6: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

3. Provide the Mapping between Service Interface of Start event and Process Context (Output Mapping tab of Properties window).

Note: The process context is data object for storing the data within process instance and is used for exchanging the data between different steps- similar to global data of ABAP program.

In our case, the process context will be used as input to next human activity in the process flow; with this the information from service would be then passed to next human activity.

4. Now Create client proxy in ABAP using WSDL local file saved during step-1:

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 6

Page 7: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

5. After successful generation of client proxy in ABAP system; call the web service from Batch report via the Client Proxy generation class.

// An Excerpt of Batch program which calls the above web service could look as:

DATA: * Reference variables for proxy and exception class lo_clientproxy TYPE REF TO co_i031741teststart, "cl_tim_employeelr_idqr, lo_sys_exception TYPE REF TO cx_ai_system_fault, lv_error TYPE string, * Structures to set and get message content ls_request TYPE i031741start_operation_request." tim_ PARAMETER : p_lid TYPE string, p_empid TYPE string. ls_request-input_parameter-employee-employee_id = p_empid. ls_request-input_parameter-e_leave-e_leave_id = p_lid. CREATE OBJECT lo_clientproxy. TRY. CALL METHOD lo_clientproxy->start_operation EXPORTING input_parameter = ls_request. CATCH cx_ai_system_fault INTO lo_sys_exception. lv_error = lo_sys_exception->if_message~get_text( ). WRITE: 'system fault' , lv_error. ENDTRY.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 7

Page 8: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

6. Continue with Process composer to complete the remaining process as required and deploy the project. This is the time; when web service for service interface which we defined for start event is published along with the end-point on to J2EE server. We can now also test the same in ws-navigator of J2EE server on which it was deployed. With the successful test of Start event web service form ws-navigator, you should be now able to see the running process. For our case, as we need to start the process from backend ECC system; we can now take the final information to complete the whole set up. We need the custom url with end points as indicated in Invocation Parameters in ws-navigator for the web service, so save this url as we will use it in next step.

Note: If you just add “?wsdl” suffix at the end of this url; you should be able to see actual WSDL with binding information.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 8

Page 9: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

7. The last steps are related to ECC backend system - Go to LPCONFIG transaction in ABAP system and define a new logical port for the proxy class which was generated in step 4. In the calling parameters, paste the url that was copied in step above. This url directly contains the information about the specific process to which the start event is associated and thus it is possible to now trigger the specific BPM process when the service is called from ABAP program.

8. You can now run our Batch program passing the necessary information to start event web service from backend ECC system to finally start the BPM Process.

Note: It is quite possible that you receive HTTP 400 or unexpected data stream error as an exception from client proxy; but with that also- possibly the process should have already started in CE server ☺.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 9

Page 10: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

Tips to Avoid Issues

1. If there is no specific user setting made to call the BPM Process Start Event Service from ABAP side (i.e. no user and password for CE server is configured in HTTP destination); the process would get started with default “Guest” user in CE server.

2. After the usage of Start Event service into client proxy, If there is any change specific to “Start Event” WSDL of BPM process ( like change in parameters, new attributes in existing input parameters, new Output mapping of service interface and Process Context) and if the process does not get started, check the endpoint url of service. During the re-deployment of project associated to process and start event WSDL, the endpoint url could get re-generated even though the WSDL has no major changes; in this case you should re-configure LPCONFIG to point to the new endpoint url (check invocation parameter from ws-navigator of J2EE server again).

3. As mentioned in the earlier steps, the service interface should not have any output parameters from the process composer side; hence one would have to remove or manually adjust the output tags if present from the WSDL. (remove <wsdl:output…> tags from the generated WSDL).

4. Avoid referring to external “xsd”s for data types of service parameters. i.e. Use Inline schema as part of start event WSDL. A sample WSDL with inline data types in form of xsd : <?xml version="1.0" encoding="UTF-8" standalone="no"?>

<wsdl:definitions xmlns:p="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:sap="http://www.example.org/PurchaseApprovalProcess/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

name="PurchaseApprovalProcess"

targetNamespace="http://www.example.org/PurchaseApprovalProcess/">

<wsdl:types>

<xsd:schema

targetNamespace="http://www.example.org/PurchaseApprovalProcess/">

<xsd:element name="PurchaseApprovalProcessAction_In">

<xsd:complexType>

<xsd:sequence>

<xsd:element

name="PurchaseApprovalActionMessage" type="sap:PurchaseApprovalProcessActionMessage" />

</xsd:sequence>

</xsd:complexType>

</xsd:element>

<xsd:complexType name="product">

<xsd:sequence>

<xsd:element minOccurs="1" name="productID"

type="xsd:string" />

<xsd:element minOccurs="1" name="productDescription"

type="xsd:string">

</xsd:element>

<xsd:element minOccurs="1" name="productQuantity"

type="xsd:decimal">

</xsd:element>

<xsd:element minOccurs="1" name="productPrice"

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 10

Page 11: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

type="xsd:decimal">

</xsd:element>

<xsd:element minOccurs="0" name="orderComment"

type="xsd:string">

</xsd:element>

<xsd:element minOccurs="1" name="orderTotalAmount"

type="xsd:decimal" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="requester">

<xsd:sequence>

<xsd:element minOccurs="1" name="requesterName"

type="xsd:string">

</xsd:element>

<xsd:element minOccurs="0" name="requesterCountry"

type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType

name="PurchaseApprovalProcessActionMessage">

<xsd:sequence>

<xsd:element name="product" type="sap:product" />

<xsd:element name="requester" type="sap:requester" />

</xsd:sequence>

</xsd:complexType>

</xsd:schema>

</wsdl:types>

<wsdl:message name="PurchaseApprovalProcessAction_InRequest">

<wsdl:part element="sap:PurchaseApprovalProcessAction_In"

name="parameters" />

</wsdl:message>

<wsdl:message name="PurchaseApprovalProcessAction_InResponse">

</wsdl:message>

<wsdl:message name="PurchaseApprovalProcessAction_InResponse1">

<wsdl:part

element="sap:PurchaseApprovalProcessAction_InResponse"

name="parameters" />

</wsdl:message>

<wsdl:message name="PurchaseApprovalProcessAction_In_faultMsg">

<wsdl:part name="parameters" type="xsd:string" />

</wsdl:message>

<wsdl:portType name="PurchaseApprovalProcess">

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 11

Page 12: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

<wsdl:operation name="PurchaseApprovalProcessAction_In">

<wsdl:input

message="sap:PurchaseApprovalProcessAction_InRequest" />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="PurchaseApprovalProcessSOAP"

type="sap:PurchaseApprovalProcess">

<soap:binding style="document"

transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="PurchaseApprovalProcessAction_In">

<soap:operation soapAction="http://www.example.org/PurchaseApprovalProcess/PurchaseApprovalProcessAction_In" />

<wsdl:input>

<soap:body use="literal" />

</wsdl:input>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="PurchaseApprovalProcess">

<wsdl:port binding="sap:PurchaseApprovalProcessSOAP"

name="PurchaseApprovalProcessSOAP">

<soap:address location="http://www.example.org/" />

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 12

Page 13: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

5. To make the whole design more simple, one should first decide on process context (context being referred in whole process flow) and then decide the interface of Start Event Service. This helps avoiding re-mapping between both the objects again and again. However in case some inconsistencies are related to data types between two objects, it’s also a good idea to use Expression Editor within process composer for example to perform the conversion between parameters of service and parameters of process context while mapping.

6. One can use same WSDL and deploy the project on completely different CE/J2EE server; however the

ABAP code would not undergo any changes. Simply the logical port configured using LPCONFIG should reflect to binding url pointing to new server. This clarifies the “Design Once but Use more than Once” principle.

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 13

Page 14: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

Related Content SAP Library for BPM

Triggering Guided Procedure Process in CE 7.1 from ABAP

Overview and Sample Example in BPM

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 14

Page 15: Triggering NetWeaver BPM Process from ABAP...Triggering NetWeaver BPM Process from ABAP Applies to: NetWeaver CE 7.1.1 including Business Process Management, Process Composer, ECC

Triggering NetWeaver BPM Process from ABAP

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com © 2009 SAP AG 15

Copyright © Copyright 2009 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 Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems, Inc., 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.