Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Gayatri_Bagde
Active Participant
Communication with customers is a key factor in growth of any business, specially in sales scenarios. Sales representatives spend most of the their time in collecting the required information , documents , drafting and sending mails to win a deal. Automating such processes can save a lot of time and can improve customer & Employee experience. In this blog post, I will be demonstrating how such processes can be automated in SAP C4C.

Let's consider a scenario, where sales representative has to send an e-mail containing all the product related information to customer whenever a quote is won. With SAP C4C , such processes can be automated using workflows. In order to add attachments to an email generated via workflow, SAP C4C provides an enhancement option where this process can be extended to get the required documents.

In this scenario, we will be retrieving all the documents which are stored in Product and will be sending them to customer's Primary Contact Person.

For this scenario we will be considering below setup –

  1. All Product related information / documents are attached to Product under attachments section.

  2. Automatic email will be sent to the primary contact person of an Sales quote's Account. We will be using Workflow for sending such emails.

  3. This email should contain all attachments (irrespective of type like docx, pdf, jpeg etc.) available under all products added in a quote


Let's consider a quote Q1 containing products P1 and P2. P1 has 3 documents attached under its attachments section as P1.docx, p1.PDF , P1.jpeg and P2 has P2.docx. So whenever an email is getting triggered for this quote, all of these 4 docs should be attached to the email.

To achieve this, we need to create one workflow which will send an email and then implement an Enhancement Option - "ExitForGettingWorkflowAttachment" using cloud application studio.

A) Workflow Implementation:


Step 1: Go to Administrator --> Workflow Rules

Step 2: In the first step, select business object as "Sales Quote"



Step 3: In the second step, specify condition when this workflow should be triggered. In this case, We are sending an email only when Sales Quote is Won.

Step 4: In the next step "Define actions", fill in the details as below:

Make sure that checkbox "Add Attachment" is ticked.



E-mail Recipient determination should be done in this step.

B) Workflow Enhancement BADI


Step 1 :To implement the workflow enhancement option - "ExitForGettingWorkflowAttachment" ,login to cloud application studio.

Step 2 : Create a new solution and click on "Add item", Select "Enhancement Implementation" option, give relevant name to it and click on Add.



 

Step 3 : Select namespace and enhancement option, as highlighted in below screenshot.



Step 4 – This Enhancement option has two sub-items - ABSL script and Enhancement filter as highlighted below



Step 5 : There are three places where we can provide filters for this scenario :

  1. Adding filter conditions in workflow configuration in step 2 in configuration of workflow .(Workflow configuration is provided above)

  2. Adding filter in BADI (Enhancement option) implementation.

  3. Adding filter condition in ABSL scripting.


Step 6 : Below is the input and output parameter of this BADI

Input – Triggered object namespace and UUID of the object.

Return – Binary Object of attachment and its related name.

Step 7 : We’ll be adding our logic in ABSL script. Below is the code to extract all attachments available under all products in sales quotes.
/*
Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: ExitForGettingWorkflowAttachment
Operation: GET_EXT_ATTACHMENT

Script file signature
----------------------------
Parameter: InputData of type InputStructureWorkflowsGetPdiAttachment
Returns: OutputStructureforWorkflowGetAttachment

Note:
- To use code completion, press CTRL+J.
*/
import AP.Workflow.Global;
import AP.Common.GDT;
import AP.CRM.Global;
import AP.FO.ProductDataMaintenance.Global;


//Declaration
var result : OutputStructureforWorkflowGetAttachment;
var BOUUID: UUID ; // Declare UUID object to retrieve the quote details using Quote.Retrieve method.

//Implementation
//Below if condition is required to check or to make sure that our enhacement is getting executed fot Quote workflow.
//We can add multiple namespaces if we have a complex implementation for multiple objects.
if(InputData.TriggerBOESRName.Name == "CustomerQuote" && InputData.TriggerBOESRName.Namespace == "http://sap.com/xi/AP/CRM/Global")
{
if(! (InputData.TriggerBOUUID.IsInitial()))
{
//Copy input Data's UUID to retreive the Quote details
BOUUID.content = InputData.TriggerBOUUID.content;

//Retrieve Quote Details.
var Quoteinst : CustomerQuote;
Quoteinst = CustomerQuote.Retrieve(BOUUID);

//Checking whether quote is successfully retrieved or not.
if(Quoteinst.IsSet())
{
//Get All Product Details available in current quote.

var Productscoll = Quoteinst.Item;

//Check if products exist then proceed else exit the code
if(Productscoll.Count() > 0)
{
//Get attachment for each product

foreach (var ZProduct in Productscoll)
{
//Retrieve complete product to find its related attachments.
var matUUID : UUID; // Declare UUID object to retrieve the product details using Material.Retrieve method.
matUUID.content = ZProduct.ItemProduct.OriginalProductUUID.content;
var ProdInst = Material.Retrieve(matUUID) ;

//Check whether attachments are there or not.
if(ProdInst.AttachmentFolder.IsSet())
{
//Here you can also use ProdInst.AttachmentFolder.AttachmentExistsIndicator instead of count method.
if(ProdInst.AttachmentFolder.DocumentList.Count() > 0 )
{
//Retrieve all attachments for that specific product.
var attachments = ProdInst.AttachmentFolder.DocumentList;
foreach ( var attachment in attachments )
{
//Here we need to take care of only these two contents, rest system will take care internally
//like file type, size, extension etc etc.
result.AttachmentContent.Add(attachment.FileContent.BinaryObject);
result.AttachmentName.Add(attachment.Name);
}
}
}
}

}

}

}

}

//Return the result
return result;

 

With this, all the configurations and enhancements are in place.

Now, whenever a quote is set to "Won" email will be triggered with all the attachments as below.



In this way, with a simple configuration of workflow and BADI enhancement , we can automate the processes of sending an email and can improve customer experience.

Thanks,

Gayatri

 
1 Comment
Labels in this area