Develop, Debug, and Manage C/C++ Services in SAP Business Connector 4.8
- by Ulrich Schmidt, Senior Developer, SAP AG
- April 28, 2010
Discover how SAP Business Connector C/C++ services work internally. Find out when it’s best to use them and when you should avoid them. Uncover tips and tricks for creating and debugging SAP BC C/C++ services smoothly.
The four basic rules for C/C++ services
- Keep all C/C++ services (and the interfaces used in their input/output definitions) in a separate package. Don’t mix in Java services and don’t use folder names that are also used for Java services.
- Keep the number of “frontier crossings” (function calls from one language to the other or data copy operations from one heap to the other) between Java and C/C++ to a minimum.
- Use simple data types (primitive arrays, strings, or simple records) for the data exchange between Java and C/C++.
- Don’t use a C/C++ service for ordinary mappings that could equally well be done in a Java service.
Assume you want to exchange electronic documents with a business partner, and these documents need to be digitally signed to become legally binding. The obvious choice for performing this kind of data exchange easily is the SAP Business Connector. However, you don’t want to endow SAP Business Connector with the ability to sign documents automatically. Instead, an authorized human person with full power of attorney needs to sign each document individually before it is sent out.
You have purchased the necessary hardware for that (e.g. a crypto-token that can be plugged into a card reader or USB device during the sending process), but this hardware needs to be accessed via a device driver written in C. How can you use it in your business process implemented on top of the SAP Business Connector?
One little-known feature of SAP Business Connector is the ability to implement services in C/C++ and to seamlessly consume these services from within Flow mappings or Java services. In the above scenario, you could write one such C/C++ service that reads the crypto-token from the card reader and then use the signature in the rest of your business process that is implemented in Flow.
In the following I’ll explain how C/C++ services work and in which situations it makes sense to use them. I’ll provide recommendations about what to pay attention to when designing and implementing C/C++ services and what pitfalls to avoid. I’ll then finish with an actual example illustrating the process of creating, developing, and debugging a C/C++ service.
Would you like to see this full item?