For an opportunity, there is an associated OQT (Opportunity Qualification template) IBPO QUALIFICATION which has to be sent for approval using SAP workflows.
This OQT is a Java survey application that is embedded inside an opportunity.
The requirement was that when ever an OQT is saved, a workflow should be triggered to send this OQT for approval. The OQT save button is a Java button that cannot be recognized directly by SAP system.
SAP CRM 2007
1. Go to transaction CRM_SURVEY_SUITE.
2. Go to Application -> Opportunities -> IBPO Qualification
3. Go to Extras -> Settings
When this survey is saved, it makes a call to CRM_SVY_OPPORT_PAI function module. This is the linkage of the Java application to SAP.
4. Go to SE37 and open the CRM_SVY_OPPORT_PAI function module.
5. Go to Edit -> Enhancement Operations -> Show Implicit Enhancement Operations.
This would show the implicit enhancement points for the function modules. By default, the implicit enhancement points are at the start and end of the FM.
6. Click on the Enhance button
7. Go to the end of the FM and click on the yellow line. Now go to Edit -> Enhancement Operations -> Create Enhancement.
8. Now you would get a popup. Select 'Code'.
9. Now enter the details of the new enhancement.
10. A new enhancement would be created ad the following code would be added to the end of the FM.
11. Now write the code to trigger the event of the business object inside this enhancement. This code would be executed when ever an OQT is saved.
Call the FM SAP_WAPI_CREATE. This FM accepts the business object name, Opportunity GUID and business object event name as input and triggers the BO event.
12. Save and activate the enhancement. Go to Function Module -> Activate Enhancement.
13. Save the Function Module.
14. Associate the Z business object ZBO_TEST -> OQTSaved event as a triggering event of a workflow and do the required processing. (BO creation and event association with the workflow is out of scope of this document).
15. Execute the Opportunity transaction. On save of the OQT, the function module CRM_SVY_OPPORT_PAI would get triggered which would in turn trigger the business object event. This would trigger your workflow!
NOTE: This implementation can be used for save on any survey. Also enhancement of any function module can be done similarly. This approach might seem simple, but has vast implications so should be used with care. Also function module enhancement is only possible on SAP CRM 2007; older versions do not support it.
The issue of triggering a workflow from a Java save button was solved.