11 Applying Advanced SAP BPM Concepts and Extensions
I do the very best I know how, the very best I can, and I mean to keep on doing so until the end.
—Abraham Lincoln
In the previous chapter, we explored different aspects of implementing an SAP Business Process Management (SAP BPM) process: modeling, configuring, compiling, and deploying. Now that the process has been deployed in the SAP Process Orchestration (SAP PO) server, you might be tempted to think that we can proceed with running and testing the process. That’s not entirely the case!
At this point, you know how to build SAP BPM processes from the ground up and deploy them to SAP NetWeaver AS Java, so we’ll move on to the next step and explore how to configure the deployed processes using the service-oriented architecture (SOA) configuration functionality available in SAP NetWeaver Administrator. The SOA configuration will enable you to indicate the actual endpoint of the services to be consumed by your SAP BPM process.
Notions of SAP BPM custom Enterprise Java Bean (EJB) functions and aspects covering the testing and debugging of a running process will also be explored in this chapter, and we’ll look at advanced concepts, such as how to consume and leverage SAP BPM internal functionalities from an external application using the provided SAP BPM application programming interface (API) and OData. The chapter also provides some recommendations and best practices to take into consideration during the process of designing and implementing a process using SAP BPM.
11.1 Service-Oriented Architecture Configuration
Depending on the flow objects used in the Business Process Model and Notation (BPMN) model of the process, you may need to perform some extra configuration steps. These extra configurations are mostly needed for flow objects that facilitate the exchange of messages (send or receive) with other systems, such as the Advanced Adapter Engine Extended (AEX). The flow objects in question include the following:
-
Start event
SAP BPM receives a message from an external system to start the process. -
Intermediary event
SAP BPM receives a message from the outside world to resume a waiting process. -
Automated activity
SAP BPM calls an external system. The message is sent from SAP BPM to the outside world.
We’ll explore the different configuration settings for each one of these flow objects in the following sections.
11.1.1 Configuration for an Automated Activity
During design time, you need to configure a service reference in the settings of the automated activity. A service reference is created for the outbound service interface that has been assigned to the automated activity. At this point, there are no references to the actual endpoint of the service.
The service reference can then be configured at runtime to point to the desired system, providing the service or the service endpoint. This is especially useful because the same SAP BPM process will need to be transported through the landscape: development, test, acceptance, and production. The endpoint that the SAP BPM process will need to call for those different environments won’t be the same. Therefore, you need to reconfigure this setting at runtime to point to the relevant environment-specific endpoint.
As Figure 11.1 depicts, SAP BPM can use web services (WS), XI 3.0 message protocol, or Remote Function Calls (RFCs) to communicate with other systems. Different configuration approaches apply depending on whether the service reference used for the automated activity uses RFC, XI 3.0, or the WS as message protocol. The next sections will explore those approaches.
Configuration for Web Services
If the service reference setting of the automated activity is set to WS (Figure 11.2), this implies that the service will be consumed as a web service. The WS message protocol is used in the following scenarios:
-
Calling an external system via the AEX
In this case, the AEX plays a mediation role.
-
Calling an external service directly without using the AEX
This requires that the external system exposes its service using Simple Object Access Protocol (SOAP) as a web service. -
Calling the SAP backend system directly
This approaches requires the SAP backend to expose a SOAP service.
If the service provided is mediated via the AEX, then the sender communication channel used should have the Message Protocol set to SOAP (Figure 11.3).
To configure the service reference, follow these steps:
- After the SAP BPM process has been deployed, log in to SAP NetWeaver Administrator.
- Navigate to the SOA tab and then to Application and Scenario Communication.
- Click on the Application Communication link (Figure 11.4). Alternatively, go to http://<hostname>:<port>/nwa/appcommunication. From this page, you can configure the inbound and outbound communication of an SAP BPM development component (DC).
- You’re redirected to another screen, which contains a list of all applications or DCs. From the list, select the name of your DC.
-
A screen is populated at the bottom with two tabs:
-
Consumed Service Groups
This tab includes all the services that SAP BPM consumes. All service interfaces used in an automated activity will be configurable from this page. -
Provided Services
This tab includes the list of services that the process provides. This includes the message triggers used for start events and intermediary events.
-
Consumed Service Groups
Because we’re interested in configuring the services that the process calls or consumes, select the Consumed Service Groups tab.
Figure 11.5 shows an example of what a process looks like that has been newly deployed and not yet configured. The figure shows that the service group called SG_CurrencyWS has the WS connectivity type and the provider system pointing to the local system. Furthermore, the processing state is currently red (Failed).
Your next steps will be as follows:
- Click on the Edit button in the Consumed Service Groups tab.
- Select the service group that you want to configure, and open the Provider System column dropdown menu.
- If the correct system provider already exists, then you can select it from the dropdown. In this case, you need to create a new one, so select the <create...> option (Figure 11.6).
- You’re forwarded to a new screen to create a new provider system. Fill in the details by providing a meaningful name and a description. Don’t forget to choose Other as the System Type. Then, click on Next (Figure 11.7 1).
- On the next screen, fill in the URL of the Web Service Description Language (WSDL) of the web service to be called 2. Provide a user name and password if the service requires authentication. Click on Next to move to the next screen.
- On the next screen, the web service is automatically tested using the WSDL and authentication details that you provided. If all goes well, you’ll see a message indicating success. If it fails, then you’ll need to go back to the previous steps and make the required corrections.
- Click on Finish. You’re forwarded back to the original screen. Make sure that the newly created provider system is selected (Figure 11.8).
- Click on the Save button to store your configuration.
- Click on the Refresh button on the right side of the screen to get the updated status of the service group with the new provider system. You should now see an Error, Warning, or Successful status. In our example, the configuration ended in a warning (in yellow), as shown in Figure 11.8.
Congratulations! You’ve successfully configured the service group to point to the runtime web service.
Note that this ability to configure different endpoints after deployment is a very useful feature that provides flexibility. If the service provider moves or changes its URL, you only need to reconfigure the service provider, and then you’re ready to go. You don’t need to change or redeploy the SAP BPM DC.
Note
If you get an error or warning in the service group, you can see more details about the problem by clicking on the Show Log button (Figure 11.8). A new screen will pop up with log details from the SAP NetWeaver Log Viewer.
If your Services Registry is configured with your SAP PO installation, then you can let the system automatically discover the provider system by clicking on the Auto Assign button. The system automatically looks up and discovers the provider system via the Service Registry. You can remove this assignment at any point by selecting the <none> option in the Provider System dropdown.
Configuration for XI 3.0
The XI 3.0 message protocol is an SAP-proprietary message protocol based on SOAP and enhanced with extra information, such as routing and monitoring. Most importantly, the XI 3.0 message protocol supports reliable messaging.
The XI 3.0 message protocol is used in the following scenarios:
-
Calling a service provided by the AEX from an SAP BPM process
In this case, the AEX plays a mediation role. It goes without saying that the service being called from the AEX can point to any system (SAP backend or legacy). -
Calling the SAP BPM process
The SAP BPM process exposes an XI 3.0 endpoint that can be consumed from the AEX.
If the SAP BPM process is calling the AEX, then the sender communication channel should have the Message Protocol field set to XI 3.0 (Figure 11.9).
When dealing with the XI 3.0 message protocol as a medium of communication between SAP BPM and the AEX, the SAP BPM process needs to be represented in AEX as a communication component of type business component. This communication component is used in the integrated configuration (ICO) for sending or receiving messages from SAP BPM. Figure 11.10 shows an ICO example that receives a call from an SAP BPM process.
Note that the ICO uses BC_DemoBPM as the sender communication component. This information will be handy when setting up the service group configuration in SAP NetWeaver Administrator.
In SAP NetWeaver Developer Studio, when importing the service interface and service group, you’ll need to configure the service reference, as shown in Figure 11.11.
You’ll also notice in Figure 11.11 that the Type field is set to XI and that the Sender Component field is set to BC_DemoBPM, thus matching the sender communication component used in the ICO. This is the mechanism by which SAP BPM can send the message directly to the correct ICO. If this setup is correctly performed, then there is no need to make extra configurations in SAP NetWeaver Administrator. After the SAP BPM process has been deployed to the server, it’s also possible to change the details of the sender component from within SAP NetWeaver Administrator.
To configure the service reference in SAP NetWeaver Administrator for an XI 3.0-based communication, follow these steps:
- After the process has been deployed, go to http://<hostname>:<port>/nwa/appcommunication. You might need to log in.
- You’re redirected to a screen showing a list of all applications or DCs. From the list, select the name of your DC.
- The bottom screen is then populated with details of the selected DC. In the Consumed Service Groups tab, select the XI-based service group (Figure 11.12 1).
- Click on the Edit button.
- You’ll see a list of service references, which is part of the service group that you selected in the previous step.
- Select the desired service references, and click on Show Details (Figure 11.12 2 and 3).
- In the screen populated at the bottom, select the Configuration tab.
- From the new tab, it’s then possible to select the General tab.
- Change the Sender Component field 4.
- Click on Save to store your configuration.
Configuration for Remote Function Call
If your BPM process will be calling an SAP function module, then you need to use the RFC protocol. This means that SAP BPM will directly call the SAP backend system. During design time (in SAP NetWeaver Developer Studio), one of the first steps will be to import the RFC function structures (input and output). During the import, you’ll need to specify the service group for the connection to the backend. The service reference associated with the service group is automatically assigned the RFC type (Figure 11.13).
After the process has been deployed to the SAP PO server, it’s time to configure the service group from SAP NetWeaver Administrator by following these steps:
- After the process has been deployed, log in to SAP NetWeaver Administrator.
- Navigate to the SOA, and then to Application and Scenario Communication.
- Click on the Application Communication link. Alternatively, go to http://<hostname>:<port>/nwa/appcommunication. From this page, you can configure the endpoints of the services used in an SAP BPM DC.
- You’re redirected to a screen showing a list of all applications or DCs. From the list, select the name of your DC.
- A screen is populated at the bottom with two tabs: Consumed Service Groups and Provided Services. Because you’re interested in configuring the services that the process calls, select the Consumed Service Groups tab. Configure the service reference as shown in Figure 11.14, in which you can see that the service group called SG_BAPI_USER_GET_DETAIL has the RFC connectivity type and a provider system not configured.
- Click on the Edit button in the Consumed Service Groups tab to configure it.
- Select the service group, and open the Provider System dropdown.
- If the correct provider system already exists, then it can be selected from the dropdown. In this case, you need to create it. Proceed by selecting the <create...> option (Figure 11.14).
- You’re forwarded to a new screen to create a new provider system. Fill in the details by providing the name (System ID) of the backend system, a Client, and a System Type. Note that System Type should always be ABAP. Click on Next to proceed with the wizard (Figure 11.15 1).
- On the next screen, fill in all RFC connectivity details, such as the Target Host, System Number, and login credentials (User Name and Password) 2.
- Click the Next button to proceed to the next screen of the wizard. Keep all the default values.
- Click the Finish button.
11.1.2 Configuration for a Start Event or Intermediary Event
Both start events and intermediary events are used by SAP BPM to receive messages from an external system. The start event receives a message and starts a new instance of a process, whereas the intermediary event receives a message in the middle of the process, when the process is idle and waiting. When a matching message is received, the process resumes.
Although used for slightly different purposes in SAP BPM, the configuration of these two flow objects are the same. They both handle messages going toward SAP BPM. These two types of inbound connectivity toward SAP BPM are automatically configured to provide both XI and WS message protocols. It’s up to the system calling the SAP BPM process to decide which one of these message protocols is more suitable to use. SAP PO automatically configures XI and WS for you, so you don’t need to perform additional configurations. However, you can configure or assign a communication profile to a connection of the WS type. A communication profile groups a set of policies that the connection between the consumer and SAP BPM needs to adhere to. In a communication profile, settings of what authentication method to use can be configured. This includes elements such as user name and password (basic), X.509 Client Certificate, SAP Logon Tickets, Security Assertion Markup Language (SAML) Assertion, and so on.
Create a Communication Profile
A communication profile can be created via the following steps:
- After the SAP BPM process has been deployed, log in to SAP NetWeaver Administrator.
- Navigate to the SOA tab, and then select the Technical Configuration subtab.
- On the subsequent screen, click on the System Connections link.
- On the following screen, select the Communication Profile tab.
- Click on the New button to start the wizard to create a new communication profile.
- Specify the name and description of your communication profile—for example, “BASIC_AUTH_LOCALHOST”. Then, click on Next to move to the next screen.
- Specify the desired connection type and authentication settings.
- Click on the Finish button.
Note
Communication profiles only apply to connections of the WS type. A service provided by an SAP BPM process with a connection type of XI can’t be configured or modified after deployment. Therefore, you can’t assign a communication profile to a configuration for a connection of type XI.
Assign a Communication Profile
As previously mentioned, a configuration of the start event or intermediary event is restricted to assigning a communication profile to the connections of the WS type. Follow these steps to assign a communication profile:
- After the SAP BPM process has been deployed, log in to SAP NetWeaver Administrator.
- Navigate to the SOA tab, and then go to Application and Scenario Communication.
- You’re redirected to a screen showing a list of all applications or DCs. From the list, select the name of your DC.
- A screen is populated at the bottom; click on the Provided Services tab.
- Select the service interface that the SAP BPM process provides or exposes, and click on the Edit button.
- Click on the Assign Profile button to select the desired communication profile.
- Click on the Save button to activate the change.