CRM and CX Blog Posts by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
GopalakrishnanS
Participant
650

Have tried exposing your custom output forms created in SAP C4C Cloud application studio to the external systems. We all used the Standard Sales Quote output forms which can be exposed to the other systems easily via the ODATA APIs of SAP Cloud for Customer. The response for those API calls would be binary data (Base 64 encoded) and can be converted to readable format.

Let’s see how this custom output form had been created in the solution. The custom output form is created against the custom BO which had been associated with the Customer Quote Business object.

We followed the usual routine to create the custom forms as mentioned in many of the SAP SCN forums and custom action ABSL files to generate the values for the output form.

We have a requirement to expose the custom output form created in the solution to the external system. The custom forms are generated anytime by clicking on the custom button embedded into the standard attachment tab.

High level steps to complete this requirement.

  1. Custom BO with required elements and association
  2. Delete all the existing instances and generate the new PDF binary.
  3. The new generation of PDF binary can be achieved via the POST method which return the binary pdf data directly in the response.
  4. Retrieve the OutputRequestFormTemplateCode dynamically based on the solution prefix.
  5. Invoke the GetPDF(BusinessObjectNode, FormTemplateCode, FormTemplateLanguageCode) method of OutputManagementUtilities and assign to the instance pdfBinary.
  6. Create custom ODATA for the custom BO generated in step 1.
  7. Exposing the API URL of the custom ODATA to the external system with the technical user id we can generate the POST method successfully.

PFB the code snippet.

 

Custom BO: ZFormOutput  //BODL defintion
element  quoteID: BusinessTransactionDocumentID
element pdfBinary: BinaryObject
association toSlsQuote: CustomerQuote

 

Actual Logic

In After-Modify event we will delete all the existing output instance as per the quote ID. Then we will create the new PDF binary instance by calling custom action ABSL which is used to generate the output form.

 

foreach (var instance in this)
{
	//Delete existing instance(s) for quote id
	var query = ZFormOutput.QueryByElements;
	var selPara = query.CreateSelectionParams();
	selPara.Add(query.quoteId.content, "I", "EQ", instance.quoteId.content);
	var oldInstanceList = query.ExecuteFromDB(selPara);
	foreach (var oldInstance in oldInstanceList)
	{
		oldInstance.Delete();
	}

	//Create PDF binary for new instance
	var quoteInfo =<CustomBusinessObject>.Retrieve(instance.quoteId);
	quoteInfo.<customActionABSL>(); Used to generate the custom output form
	var ftCode : OutputRequestFormTemplateCode;
	var sn_type = quoteInfo.GetObjectNodeReference().ObjectTypeCode.content.Substring(1,8);
            ftCode.content = sn_type + "_XXXX1";

	instance.pdfBinary = OutputManagementUtilities.GetPDF(quoteInfo, ftCode, "E");
}

 

ODATA reference and testing in postman tool.

CustomODATA.jpg

CustomODATA_POSTMAN.jpg

 

I hope this article will helps you to expose the custom forms from SAP Sales Cloud to external system.
Thanks,

GKS.