How BO “pdf summary ” works with Workflow
Usecase: Admin wants to send BO pdf Summary as a part of workflow. He needs to ensure that he has the possibility to select the right template and language for the pdf summary while defining workflow rules to ensure that template and language are suited for end user.
It also provides a posisblilty for customer to write custom code for template & language determination if customer does not want to use standard feature.
Create a Workflow Rule for a BO, say Sales Quote, for which “Form Group Code” is defined.
While defining the workflow rule select the BO object ( say “Sales Quote”) defined in previous step. Select ‘Timing’ as ‘on Create Only’
Under ‘Define Actions’ , Select rule type as ‘email’
Check the checkboxes ‘Always Send E-mail’ and ‘Create Email Activity’.
Enter ‘Sender’ as ‘email@example.com’, Enter any ‘Subject’
Select a template file ( an HTML email template
Select the PDF template from the drop down
PDF Template language: From the drop down list, select the language for selected template
PDF Template Country: From the drop down list, select the Country for the selected language
Add the ‘Employee’, recipient to whom the mail should be sent.
Click on ‘Next’, Click on ‘Activate’, Click on ‘Finish’.
Goto Workcenter View for ‘Sales Quote’, Create a New Sales Quote and click Save.
The ‘Employee’ configured will receive a mail with the PDF document (pdf Summary of Sales Quote, in the language selected by the Admin User) attached.
Go to Workcenter View ‘Activities->Email
Open the activity created for your email, Goto Tab ‘Attachments’, you should see the generated PDF.
Case 2: Form Template Code maintained by Key user, the variant to be picked from PDI BADI.
There is another possibility where Customer can implement a BADI to specify the Form Variant Language and Form Variant Country (Based on BO Attributes). The input to this BADI are:
- BO name
- BO namespace
- UUID of the BO Instance.
- List of valid variant for selected for template, with an ‘index’ generated for each variant.
The BADI specifies the Variant by specifying the ‘Index’. This BADI is called if the Key user , while defining the workflow rule , has defined only the Form Template Code.
For testing this functionality, choose a system which is PDI enabled. Login to the Cloud Studio and create an Enhancement spot. The Details of the BADI are as follows:
Name : ExitForGettingFormTemplateVariant
Namespace : http://sap.com/xi/AP/Workflow/Global.
Filter of the BADI is the name of the ‘Workflow View of Business Object’ you have used while defining the Workflow rule.
Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: ExitForGettingFormTemplateVariant
Script file signature
Parameter: InputData of type InputStructureWorkflowsGetFormTemplateVariant
– To use code completion, press CTRL+J.
var result : OutputStructureForWorkflowsGetFormTemplateVariant;
Once BADI has been implemented and activated, the variant selection screen will look like below
User can choose if they want to go for Manual Selection on UI while creating Workflow Rules or use Custom Implementation to choose pdf summary.
If ‘Custom Implementation’ is chosen, the ‘PDF Variant Language’ and ‘PDF Variant Country’ fields are cleared.
Cointinue with the test by selecting the PDF Form Template, PDF Form Variant Selection as ‘Custom implementation’.
Repeat the above steps, PDF should be generated according to the specified variant in the BADI Implementation.