Recently I created a solution to automate pricing calls an external ERP for service tickets in C4C I’d like to share with other Cloud for Customer users.
The following solution is motivated by a customer having long running external pricing runs resulting in a timeout of the C4C UI front end.
To circumvent the UI timeout I investigated whether and how external pricing calls can automatically be run in the background using the SAP Cloud Application Studio.
First I will provide installation instructions how to install the solution on their C4C system.
Afterwards a short technical description how it is working is following.
DISCLAIMER: Please use at your own responsibility. I most likely will not be able to support this solution (especially in the future) beyond the original intention (or the customer) it was created for.
I enhanced the solution to also cover external pricing for sales quotes.
Furthermore I added query parameters to the pricing runs to optionally provide a document type or a document ID for which the pricing calls shall be performed.
The solution has the following properties:
- background automated calls in regular intervals of external pricing for service tickets in C4C requiring external pricing
Since Version 2:
- background automated calls also for service tickets in C4C
- restrict query of documents where pricing is to be perfomred to a given document type and/or document ID.
The solution has a few drawbacks:
- The external pricing will only work for tickets/quotes edited on root level at least once after solution installation (creation of a new ticket/quote covers this).
Thus, already existing tickets/quotes need to be touched by editing e.g. the description (add a space or so).
- The framework used only supports daily scheduled background runs. To have more than one background run per day one needs to create multiple runs per day.
While it might be possible to create one run for every ten minutes (24*6=144 runs) I do not recommend this – especially if your pricing calls tend to be longer running (though I haven’t tried this).
How to install the solution template:
- Download the Asynchronous External Pricing solution template file for SAP Cloud Application Studio from SAP Note 2497035.
- Start the SAP Cloud Application Studio and log in to your C4C test/development tenant.
- Create a new customer specific solution or solution template
- Please fill in the customer specific solution details.
Important: deployment unit has to “Customer Relationship Management” and press “OK”.
- Open the Implementation Manager (Menu: Administration -> Implementation Manager)
- Click the “Import Solution Template” button (second button from the right, next to the Refresh button). Don’t use the “Upload” button (second from the left).
- Select the downloaded solution template file in the file selection dialog and press “Open” (this might take a few seconds).
- Activate the Solution:
In the “Solution Explorer” open the context menu (right click) on the solution itself and select “Activate -> All Items”.
- Now once the solution is activated, a new work center “External Pricing” is available.
Add the authorization rights to access this work center to your user or your user role using the Administration work center, Business User view. If required, update your user access rights by logging out and in again in the C4C UI.
- Enter the work center view “External Pricing” -> “Ticket Pricing Runs” or “Quote Pricing Runs”.
- Add a new external pricing background run to be triggered on a regular schedule.
- Optionally add document ID or document typ selection criterias.
Leaving them empty selects all documents.
- “Save” the run then “Set to Activate”.
- For testing purposes “Schedule Directly” and leave the start time empty.
If everything works as expected:
- Finally “Schedule” the run:
Select “Recurrence” as “daily”,
Start Date/Time must be in the future (e.g. tomorrow 2 am)
Repeat period is “every 1 Day(s)” with “No End Date”
then: “Save and Close”
- You can repeat the previous steps 11-13 to have multiple runs be scheduled per day.
However then the execution log is spread over multiple separate run instances.
My personal recommendation is to create at least one “daily” run and add another run called “Immediate”. This instance can then be used by the (key) user to “Start Directly” a run on demand.
Re-scheduling an existing regular recurring run is a pit-fall: then the recurring schedule will be eliminated and the background run will only be executed once – though immediately.
Technical Implementation Details:
The solution template uses the partner development infrastructure (SAP Cloud Application Studio) to call external pricing on all un-priced service tickets.
To do so, a Mass Data Run is created calling an action on a custom Business Object ServiceTicketReference.
Rationale behind this is that Mass Data Runs can only be called on custom business objects and not on SAP standard objects.
Upon saving a Service Ticket (ServiceRequest) it is checked whether there is one instance of this custom BO ServiceTicketReference and if not one will be created ensuring there exists one per Service Ticket (thus the requirement to “touch” a service ticket once before pricing will work).
A query and selection parameters ensure the run is only performed on service tickets with external pricing without up-to-date pricing data.