This document covers how to schedule a batch job using MDR in SAP Cloud Application Studio and usage of Adobe LiveCycle Designer in generating PDF Form to use in CAS.
Thanks to my colleagues vaibhav.kwatra,kartik.saini,bhupinder.sharma2 ,dpksghl , jayant.saini , atul.malhotra ,ajay_salwahan as they have helped and contributed in preparation of this document.
Table of Contents
1. Problem Statement
Sometimes it is required to broadcast the information (reports) related to the business transactions to the business users in periodic manner.
For example: - User would be interested in getting the information for the opportunities getting expired in next four weeks/one month.
2. Solution
MDR:
A MDR (mass data run) is the automatic mass processing of a task or a business transaction. Mass data runs enable mass processing of business data and are used in business processes, for example, invoice runs, payment authorization runs, or balance confirmation runs. When a user schedules a mass data run, the system executes it as a background job. As part of this document, we shall be sending the notification via email having report attachment. Detail about the solution is described in the section 3 of the document.
- In the SAP cloud solution, customer uses the mass data run to schedule an action for many instances of a custom business object.
- We can schedule a MDR on daily basis or at a particular time.
- Multiple MDR’s can be scheduled at a time.
- MDR runs in the background independent of the current processes.
3. Detailed Solution
3.1 Custom Object and MDR Creation
Following are the initial steps for our solution:-
- Create a custom object.
- Create a query.
- Create Script file and define Action.
- Create Screen for Custom Object.
- Create PDF for email Attachment.
- Assigning Solution to work center.
3.1.1. Create a custom object
- First we need to build a solution which will contain our custom business object.
- Enter the description and select Customer Relationship Management as deployment unit from the dropdown.
- Create a custom business object on which our MDR will run.
- Right click on the solution you created and go to ADD -> New Item -> Business Object.
- Enter the business object name and click on ADD.
- Add an element dummy with data type “ID”, OpptID, OppEndDate and an action named “SendMail”.
- Save & Activate the solution.
3.1.2. Create a query
- In order to design an MDR we need to create a query in which we select the elements of the business object based on who's the query will run, later these elements are accessed by MDR to run on particular user defined conditions.
- Right click on the business object and click on “Create Query”.
- Enter the query name and description.
- Select the elements based on which the query will run.
- Select the selection and result parameters.
3.1.3. Create Script files
- Save & Activate, Right click on BO and go to “Create Script Files”.
- Action “SendMail” will be auto selected, click OK.
- A new script will get added in solution with the action name.
- In action we have to search the records of the standard object (Opportunity) and then select only those record which are going to expire in the next 30 days. Then we need to retrieve the selected elements from those record according to the business requirement. Here we need to fetch the Email address, Opportunity Id, and the End date of the particular Opportunity and then we have to send them the mail with the pdf attachment.
- Below are the steps followed for writing the Action Code:-
1. Fetch the data of Standard Object using query.
2. Select only those record which are going to expire in next 30 days.
3. Create an E-mail Instance for those records.
4. Fetch the respective E-mail ID from the query result.
5. Create a PDF attachment for E-mail.
6. Fire E-mail(s).
3.1.4. Create Screen for Custom Object
- Create the screens for BO.
- Right click on the business object and click on “Create Screens”.
- Select object based screens and enter a short id and click ok.
3.1.5. Creating PDF for Email Attachment
- Follow the steps given below to add PDF form to the solution.
- Open .xdp file with the help of adobe LiveCycle designer (must be installed on system)
- Place fields from our object on the form, to show details related to opportunity as shown in below screenshot:
3.1.6. Assigning Solution to Work Centre
- We need to assign this solution to a business user in the work center via system admin.
- Open the application in the internet explorer and enter the credentials of system admin.
- Launch the application in Silverlight.
- Go to Administrator -> Business Users.
- Search specific business user to which work center needs to be assigned.
- Select Edit -> Access Rights.
- Click on find and enter the name of your business object.
- Click on “Locate” to find it.
- Check the work center and click save.
- A pop up will appear, Click OK.
3.1.7. Creation of MDR
Following are the steps for the creation of the MDR:-
a. Create MDR.
b. Create screens for MDR.
c. Assigning the OWL screen of MDR to the WCF screen of custom object.
d. Assign MDR to the work center.
e. Creating a MDR element and scheduling it.
a. Create MDR
- Right click the business object and click on “Create Mass Data Run”.
- A mass data run wizard will open.
- Enter the MDR name, business object and node will be preselected as of the current solution.
- If you have multiple actions in the business object then select the action which should get triggered when the MDR will run.
- On the next screen the elements we selected in the query will appear.
- Select the elements to include them as conditions in MDR.
- Select the restriction as user selection so that a custom value can be assigned to it during MDR creation.
- Let the control parameters remain as it is, Click Next.
- Review the MDR and click finish.
b. Create screen for MDR
- Create screens for the MDR.
- 3 screens will be created for the MDR.
c. Assigning the OWL screen of MDR to the WCF screen of custom object
- Now we need to embed the WC_View screen of our MDR to the business object.WCF.uiwoc screen so that the user is able to see the MDR scheduling tab inside our custom object tab.
- Open the business object.WCF.uiwoc screen in UI Designer.
- Click on Test View.
- Go to Configuration Explorer[Your Solution]_MAIN - >SRC - > [your mass data run work center view] _WCView and drag and drop it onto the empty space on the screen.
- A warning message will appear, Click Yes.
- Save & Activate and close the UI designer.
- Double click on _WCF.WCF.uiwoc file of the custom business object.
- On the Designer tab, the TestView work center view should now have changed its name to the name of your MDR.
d. Assign MDR to the work center
e. Creating a MDR element and scheduling it
- Create an element of MDR which will be scheduled as per our requirement from OWL Screen of MDR.
- Create new record in MDR.
- Click on ‘Set to Active’ to activate the MDR element.
- Click on ‘Schedule’ to schedule the MDR.
- Schedule job on daily basis by checking the option of ‘Recurrence’.
- Now open the OWL screen of the MDR.
- Click on refresh to see the recently created MDR element.
- In order to create an MDR element or to schedule a MDR via UI we have to assign the work center to both business object and MDR to the particular business user like we have previously done in section Assigning Solution to Work Centre.
- Login into the application via the particular business user and Select the Custom BO tab.
- Select the MDR work center and then the MDR OWL screen will open where you can schedule a predefined MDR or create a new MDR element.
- Below are the screenshot for the Email confirmation after scheduling the MDR.