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.
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.
I hope this article will helps you to expose the custom forms from SAP Sales Cloud to external system.
Thanks,
GKS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.