Creating and scheduling MDRs in the SAP Cloud Application Studio

Article by Andrei Matys, Software Engineer at ACBaltica.

In this article, we will continue talking about MDRs in C4C. This is a short guide for creating and scheduling MDRs. You can read about the general structure of MDRs and technical aspects in the previous article.

Task: create multifunctional MDR from the previous guide.

Step 1. Create business object for your future MDR.

I recommend you to create a separate folder for MDRs (picture 1)

Project structure  

Picture 1 – Project structure

 

For my business object custom codelist was created and stored in a separate folder for MDR’s BO codelists (picture 2). 

Codelist for MDR’s BO

Picture 2 – Codelist for MDR’s BO

Business object code:

import AP.Common.GDT as apCommonGDT;

 

businessobject MultifunctionalBO raises MsgInfo_EN {

 

    message MsgInfo_EN text "Message: &1": LANGUAGEINDEPENDENT_EXTENDED_Text;

 

    [Label("Type")] element Action : MDRActionCode;

      

       action Run;

       action ActionOne; // The name is an example

       action ActionTwo; // The name is an example

      

}

Step 2. Create action and query.

Created query is shown in pictures 3. Query is used for retrieving data from DB, when run starts. For custom BO you can’t use standard query and should create your own. 

Query

Picture 3 – Query

 

BO action for MDR will look like:

import ABSL;

 

// Actions

var ACTION_ONE = "001";

var ACTION_TWO = "002";

 

// Start action for MDR

switch(this.Action){

       case ACTION_ONE {

              this.ActionOne();

       }

       case ACTION_TWO {

              this.ActionTwo();

       }

}

 

This action is called after a request to DB. It calls other actions according to the type of the selected row.

 

Step 3. Create MDR.

You can do this in two ways:

-         Right click on the created BO ® Create Mass Data Run. MDR will be created in a folder with a business object

-         Right click on the folder you need ® Add ® New Item ® SAP – Mass Data Run ® Select the created BO. MDR will be created in a folder you need.

Other steps are the same and are shown in pictures 4 - 6.

MDR settings (step 1)

Picture 4 – MDR settings (step 1)

 


MDR settings (step 2)

Picture 5 – MDR settings (step 2)

 

As you see in picture 5, you can select different types of restrictions:

-         None;

-         User Selection – value for query parameter selected by a user in UI;

-         Fixed value – value is set by developer in PDI.

At least one query parameter should be selected (not “None”).

 MDR settings (step 3)

Picture 6 – MDR settings (step 3)

You can select option “Parallel processing” for MDRs, if retrieved data is not intersected. That’s why be careful with this option. Different processes can have an access to the same row in DB and block it.

Parameter “Retention Time” defines logs storing time.

Using parameter “Detail Level”, you can set types of raised messages, which will be stored in logs.

Step 4. Create screens for MDR

MDR screens are used for creating MDR run and scheduling them. You can simply do this: right click on created MDR ® Create Screens. A package of screens will be created (picture 7).

MDR screens

Picture 7 – MDR screens

 

Screens:

-         OWL – displays all the created MDR runs and root logs;

-         QA – creates a new MDR run;

-         WCVIEW – assigns MDR to some work centers (WCF).

In this guide I will assign WCVIEW screen of MDR to WCF screen of the business object (step 5, MultifunctionalBO_WCF). You can assign it to any needed WCF screen.

 

Step 5. Create screens for business object.

This step is additional (if your MDR is based on additional business object and data in BO does not exist and should be created). You can also use web-services to add data into DB.

Create screens: right click on created BO ® Create Screens. You can create screens with Thing-Based or Object-Based navigations, it depends on your requirements. Screens are shown in picture 8. I chose thing-based navigation in this article. 

BO screens

Picture 8 – BO screens

 

Note: For thing-based navigation you should add button “New” on OWL screen.

I also tuned OWL screen and added a remove row button and changed SAP_UUID column (additional, not required).

 

Step 6. Assign MDR and BO screens to your business user (role).

Login to SAP Sales/Service Cloud ® Administrator ® General settings ® Add rights to screens (business role or directly to users for testing). This information is shown in picture 9. 

Assign views to business role

Picture 9 – Assign views to business role

 

Step 7. Crete and schedule MDRs.

Note: rows in custom BO (in general with additional BO) should exist for task in this article. We add rows manually in UI (picture 10). 

Data in BO 

Picture 10 – Data in BO

 

Create run, which will start ActionOne. An example is shown in picture 11.

 

Run settings

Picture 11 – Run settings

 

Only active run can be scheduled. To activate run you can click button “Set to Active”. We can schedule the created run (pictures 12 and 13).

List of runs

Picture 12 – List of runs

 

To schedule the concrete run select record from the list and click button “Schedule”,  in the appeared list choose button “Schedule”. A window like in picture 13 will appear.

Schedule run


Picture 13 – Schedule run

 

Schedule type:

-         Start Immediately – run will be executed now only for one time;

-         Run After Job – current run will be executed every time after selected (specified) run execution. “Parent” run must be specified;

-         Single Run – current run will be executed at specified time once;

-         Recurrence – current run will be executed periodically (Daily, Weekly, Monthly, None). If you select “None” run – the same as “Single Run”.

To plan run “Hourly” just plan 24 times run daily every hour.

 

Every run execution has logs. The log is shown in picture 14.

Run’s log

Picture 14 – Run’s log

 

In picture 14, I highlighted a number of objects which were selected and a number of objects which were changed.

For better understanding how run selects data and works with it, I will advise to write a line (for example, Run) in MDR action which will change data in current row (for example this. Action = "002";) and schedule run two times and compare logs.

 

Let’s sum up:

1.     Create business object (or use the existing one);

2.     Add action and query (or use the existing one);

3.     Create MDR and screens;

4.     Assign rights and schedule.

 

Thanks for attention!


About the author
Andrei Matys
Andrei Matys
Software Engineer at ACBaltica
Subscribe
 * — required fields
On this site, we use cookies to make our service faster and easier for you to use. For details, please review our Privacy Policy.