This blog will guide beginners with the implementation of CAF service in a BPM process with step by step procedure. As a beginner to BPM world, I referred various blogs to import an RFC in a CAF project and implement it in a BPM process and it consumed a lot of time. So I am writing this blog hoping it will help the beginners as I have explained the implementation from scratch.
In this blog we will first create a simple CAF project by importing a RFC – BAPI_CUSTOMER_GETDETAIL from the R/3 system and then implement the CAF service in an automated activity of a simple BPM process to execute the service operation.
Table of Content:
- RFC output from R/3 system
- Importing RFC and generating CAF service
- Testing CAF service
- Implementing CAF in BPM process
- BPM process output
RFC output from R/3 system
The RFC – BAPI_CUSTOMER_GETDETAIL executed in the R/3 system is shown below.
- To import the RFC – The R/3 system connection should be maintained under Window–>Preferences–>Destination Configuration –>R/3 Configuration.
- To Deploy and Run – Connection between NWDS and SAP system should be maintained under Window–>Preferences–>SAP as Java.
- BPM uwl and notification Configuration is maintained in the portal. Please refer the below help link for the same.
Let’s get started:
Importing RFC and generating a CAF service:
Step-1: Open the ‘Service Composer’ perspective and create a new DC. File–>New–>Project and select Composite Application Development Component.
Step-2: Click Next and select the Software Component and click Next.
Step-3: In the next window that appears give the name, language and domain and click next
Step-4: Click Finish in the next window.
The DC will be created with external and modeled nodes as shown below.
Step-5: Right click on the external node and click import–>Import RFC. If you need to more RFC’s or web services you may create package under external node and then import the web service or RFC to avoid confusions.
Step-6: In the dialog that appears search for the RFC BAPI_CUSTOMER_GETDETAIL and select the RFC and click next.
Step-7: In the next dialog select the path for the RFC under external node and the RFC destination.
Note: This RFC destination is to be maintained under http://<host>:<port>/nwa –>configuration –> Security–> Destinations
Step-8: Click Finish. The RFC will be imported.
Step-9: Right click the modeled node and create a new Application Service by providing the package name and Application service name as shown below.
Note: The Application service will be created. Open it. It has 5 tabs
- General – contains general information of the application service
- Dependencies – Contains List with all dependent objects.
- Operations – Contains List with all available operations in this object.
- Datasource – Here we select source for the operation and do mapping.
- Implementation – For Manually implemented operations.
Step-10: Under the operations tab select Add and select custom operation. Give the operation name, description, transaction type. Uncheck the manually implemented check box as we are using RFC to implement the operation here.
Step-11: Click on the created operation under the operations tab and select data types for the input and output parameters of our operation from the data types option as shown. Select the data types and click on Add to input for input parameters and Add to output for output parameters.
Step-12: In the Datasource tab select the details_operation that was created and click select source button. In the window that appears select the RFC that was imported and Click OK.
Note: The input and output parameters of the RFC that you have imported will appear on the source operation side and the data types for the operation that were added in the previous step will appear on the target operation side.
Step-13: Now Map the input and output parameters.
Note: If there are any manually implemented operations then they are implemented in the Details_AppServiceBeanImpl.java file of the Implementation tab. In this case there is no manually implemented operation.
Step-14: Now right click on the application service and click Expose service as web service. The WSDL file will be generated for the operation which can be consumed in BPM process.
Importing RFC and creating CAF part is done. Now we have to generate, build and deploy the CAF project.
Step-15: To Generate right click on the DC demo_caf_2 and click Generate.
Step-16: To Build right click on the DC demo_caf_2 and click Build.
Step-17: To Deploy right click on the DC demo_caf_2 and then click on deploy
Testing CAF service:
- You can test the service by right clicking on the service Details_AppService and click Test Service.
- To test the service SAP_CAF_DEVELOPER/ SAP_CAF_ADMIN role should be assigned to the user in the user management of the http://<host>:<port>/irj/portal.
Implementing CAF service in BPM Process:
The next step is to implement this CAF in a BPM process. Here we are going to create a simple BPM process to get input using human activity and get the details from the implemented CAF using automated activity and display the details through mail as notification activity.
Step-18: Switch to Process Development perspective and create a Process Composer Development Component.
Step-19: In the next window select the software component and click next. Give the name for the DC and click Finish.
Step-20: Open the Process Modelling under the DC and under Process create a new process. In the window that appears give the name for the process, pools and lanes and click Finish.
Step-21: Now import the CAF service as WSDL from the local system. Right click the Service Interface and click on import WSDL. WSDL Import window appears as shown below. Choose Remote Location/ File System as source location and click next
Step-22: In the next window browse the location of the wsdl file from the local workspace and click finish. The service will be imported.
Step-23: Create new XSD file under data types to create a complex data type to hold customer number and salesorg data.
Step-24: Right click on the types and add complex type. Name it and double click on it to create elements. Add the two input elements customer_no and salesorg.
Step-25: Double click on the created complex type to open it. After opening right click on it and select add element.
Step-26: Select the automated activity and click interface tab in the properties and select the imported CAF service from the list.
Step-27: Create Data Objects for input and output and assign datatypes as required by the CAF operation.
Step-28: Apply UI template for getting input by right clicking on the process and click Apply Template. Select UI Task Generation and click next. Give the Task name and choose the process context attributes for the task. Click next.
Step-29: Choose the technology for UI and DC. If there is already created DC select from the list or create a new one by clicking on New. In this case I am creating a new one. Select the software component and give name for DC. Click Finish. The WebDynPro DC will be created.
Step-30: Do the input and output mapping
Step-31: Assign potential owners for the human activity and To address for the notification activity. Specify the subject and message in the mail tab of notification activity.
Step-32: Right click the DC and select Development Component–> Build. After build is finished right the DC and select Development Component–>Deploy
Step-33: After Deployment is finished open the Process Repository from http://<host>:<port>/nwa –>configuration –>Processes and Tasks–> Process Repository. Click Start Process.
Step-34: After starting the process UWL task will be assigned to the potential owners of the human activity. The potential owners of the human activity provide the input as below
Output of BPM process:
The users specified in the To field of the notification activity receive the mail with the customer details as shown below.
Thus we have imported a RFC in a CAF project and implemented the CAF service in a simple BPM process. From this blog we have learnt
- To import an RFC in a CAF project
- To implement the CAF service in BPM process.
Hope this blog will be useful for the beginners to implement a CAF service in a BPM process.