Let me outline some building blocks and necessary APIs for integrations. These APIs are available from S/4 Hana 1709.
Prerequisite: Your CRM system opportunity has been enhanced to store information of CPM commercial project.
Create Commercial Project for Opportunity.
At a certain stage of opportunity, you would like to create Commercial Project in CPM with reference to Opportunity in CRM. You may also like to utilize the planning functionality available in CPM. So, this blog explains how the commercial project and commercial (financial) plans are created with linking to CRM opportunity and Opportunity line items.
One can use SAP CPM API ‘/CPD/CREATE_MP_FP_FROM_REL_OBJ’. You may want to generate asynchronous web service out of this API for consumption with SAP HANA cloud integration.
This API is an RFC function module which creates a commercial project based on details passed in the following parameters:
(Commercial Project Header)
(Commercial Project Description)
(Commercial Project Reporting Attributes)
(Contact Person of Commercial Project)
(Related Object linked to Commercial Project)
(Related Object line items to create Financial Plans)
This function module also creates one or more commercial(financial) plans for the commercial project, based on the items of the Opportunity passed in the parameter IT_MP_ITEM_REL. In the commercial(financial) plan, a bid structure element is created and mapped to the respective item of the Opportunity linked to the commercial project.
Here, some more information about additional parameters
Type of the reference object, maintained in the Customizing for Commercial Project Management, under Master Data > Commercial Project > Define Object Link. For a CRM Opportunity, the object type is 0OPP.
Header GUID of the reference object = CRM Opportunity
Table of attributes of the reference object linked to the commercial project, in this case CRM opportunity
Header GUID of the reference object
Type of the reference object, maintained in the Customizing for Commercial Project Management, under Master Data > Commercial Project > Define Object Links. For CRM Opportunity, the object type is 0OPI.
Reference object item GUID
Table type for attributes of items of the reference object link (for example, CRM Opportunity item). However, REL_OBJ_ID and REL_OBJ_ITM_DESC are mandatory attributes to be passed. REL_OBJ_ID is used for the reference object ID and REL_OBJ_ITM_DESC is for providing a relevant description for the reference object item. This information is used to form the plan item name in the bid structure of the financial plan.
Financial plan header details (to be passed if there is specific financial plan to be created for an item of a related object link.
Now you may want to update Commercial project Id within CRM system. This can be done using below attributes.
Header GUID of the Commercial Project
Commercial Project ID created in CPM
Financial plan details with the bid structure elements created for opportunity
Messages list(Includes all types of messages)
This data can be used in further APIs to get the data stored or planned in the CPM for the commercial (financial) plans.
What if I would like to default certain attributes based on information from opportunity?
The following business add-ins [extensibility points] can be used
/CPD/PWS_MP_DEFAULTS – To default certain values for Commercial Projects
/CPD/PFP_BADI_FP_DEFAULTS – To default certain values for Commercial Financial Plans
Within standard system, default implementation of /CPD/CL_PFP_FP_DEFAULTS creates one commercial(financial) plan for every opportunity line item. On the other hand, if you want to change the financial plan creation from 1:1 to any other scenario, that is one financial plan for multiple opportunity line items. You must create your own implementation of this BAdI.
You can use importing parameters to set the mandatory information for a financial plan, or allow the implementation to determine these values from the reference object.
Now you may want to show information about commercial plans within CRM system such as costs, revenues & margin or various versions.
You can use following APIs
API /CPD/PFP_RFC_GET_AGGR_COST – Get plan cost and revenue at aggregated level. You would need to pass Commercial Project ID that was stored after successful creation of Commercial project.
API /CPD/PFP_RFC_REFOBJ_TRANSFER – Get detailed commercial plan data for the versions specified in IT_PLAN. The function module reads plan data for a plan version of a financial plan belonging to a commercial project.
What if I would delete the opportunity line item and want to delete the reference in the commercial plan?
The API /CPD/PFP_RFC_DEL_REF_OBJ_LINK - Delete assignments between bid structure elements and opportunity line items, when they are deleted from the opportunity linked to the commercial project. This RFC can be configured in a synchronous way from CRM.