cancel
Showing results for 
Search instead for 
Did you mean: 

Mass data run-Custom field update with system date on daily basis

Former Member
0 Kudos

Hi Experts,

I am trying to make a custom field in customer's screen and field will be updated daily automatically with current date of the system. But I am not aware of the process how can I do this and process of mass data run so that field can be updated automatically on daily basis? .

Best Regards,

Pragati

Accepted Solutions (1)

Accepted Solutions (1)

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragati Verma and Saurabh Sharm,

I have created a document similar to your requirement explaining how to: Update standard BO with MDR.

Follow the steps mentioned in it.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Sorry for delay in replying and marking your answer correct. Thank you  so much for this awesome blog.

Thanks and regards,

Pragati

Former Member
0 Kudos

Hi Sunil,

Can you plz. help me here one more time? Actually the purpose of this type of approach regarding MDR was to send birthday notification to customers, individual customers. When I tried to make a work flow rule for e.g. when current date of system= DOB of customer send a email notification to customer. But unfortunately I can't find customer as recipient in workflow. Plz. help show should I do this? Is there any customization  that can be done with workflow? 

Regards,

Pragati

Answers (3)

Answers (3)

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragti,

I have just typed code as an example, so you can understand how to query. You should write your own logic for filtering query result. I would suggest you to read ABSL script.

Now let me explain how to this filter works, If you are aware about the filter, this below code is here in ABSL works as filter. You first define variable for selection parameter then you add all the condition(filter condition)


selParams = query.CreateSelectionParams();   // define selection parameter

selParams.Add(query.InternalID, "I", "EQ", "11012345") // here 11012345 is a customer internal ID if you execute this query with selection parameter then it will  return only one customer BO instance.

So the point is to use of selection parameter to fetched required customer instance which you want to update, for example if you want to update customer who has role as Prospect then use code like below

selParams.Add(query.Role,"I","EQ", “Prospect") // please syntax after query ctrl+space


if you execute query with this parameter then it will return only customer who has role as prospect.


You can use multiple condition to get more precise result, the way I have used above.


Note: above code is just for example.


Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Like you mentioned that here 11012345 is a customer internal ID,


1) it means that our mass data run will work for only this ID? What if we want to run mass data for all of the customers existing in the system then how should I do?

2) You also mentioned here that I have to create a record in our custom BO as well. It means I have to create a custom field in that BO and then generate screens(might be QC), Right?

Plz. help!

Regards,

Pragti



sunil1101
Advisor
Advisor
0 Kudos

Hi

Answers

1. Yes, if query with unique ID it will return only instance mean one record, that is why I mentioned you can use your own selection parameter, you can also avoid selection parameter.

Selection parameter is just like a filtering condition

for example SQL statement

Select * From table into It_table where var1 eq "some value", here you get records which match this condition.

Similarly statement selParams.Add(condition) used for filtering the BO records in ABSL.

You do one thing do not use conditon just execute it, you just write below line

query = Customer.QueryByIdentification.Execute(), it will return all customer instances.


2.  Yes you have to crete an instance of custom bo to run MDR, I would suggest first complete the SDK documentation and complete the example

In document search below topic and follow the step by step document

Example: Changing the Status of a Price Request (Mass Data Run)

help.sap.com/sdk

Regards

Sunil

former_member186648
Active Contributor
0 Kudos

Hi Pragti,

1) Which query parameters to have depends on what data you want to retrieve and update.
If your requirement is to update all the customers, then you need not have any query parameter

2)You need to have QA on BusinessObject1 to create data

Thanks, Pradeep.

Former Member
0 Kudos

Hi Sunil,

Thanks a ton for all these nice explanations. I'm getting the things cleared now. Actually I'm working on functional part and very much new to trchnical part but as this requirement is very urgent and had to take the initiative so I could not read the documentation properly earlier but will surely do ASAP.

I have read the MDR creation process. Two things I am not getting:-

1) Why do we need an instance in our custom BO as we are not supposed to work on Custom BO we     are doing this process for our customer BO.?

2) Now to create an instance I have created an element like this:-

import AP.Common.GDT as apCommonGDT;

businessobject BusinessObject1 {


  [Label("Testing")]element Test :Date;  // (if this is correct? if not then what type and how                                                                        should I create a record?)

  action Refresh;

}

Can you plz. help if I am doing with this code correctly or not ?

Many Thanks!

Pragati

sunil1101
Advisor
Advisor
0 Kudos

Hi

1. You can not create MDR object for XBO, You can only create MDR on custom BO. So how will update standard BO with JOB run yes here is the workarround you can read/edit stadnard BO in custom Action so they way we are updating every standard bo instance in a loop.

Execution of MDR->find custom bo instance->execute custom action for all custom bo instance

That is why here you should have one dummy custom BO instance and action will execute for one dummy custom bo instance but in that action you will edit all stadard bo instnace.

2. Yes this is correct, you can create your custom BO as you want,  create a UI, (activate BO -> right click -> create screens ->select screen scenario either OBN or Thing type, you can alos create induvidual screen)

Point to be noted : MDR should read only one instance of custom BO

Former Member
0 Kudos

Hi Sunil,

Thanks a lot. I have created screen scenario but unfortunately new button to create a new entry is not working. Can you plz. help here and correct what wrong am I doing here?

1) custom Business object

2) OWL and new button

3) New button created but not working on clicking shows nothing.

Plz. help!!

Regards,

Pragti

former_member186648
Active Contributor
0 Kudos

Hi Pragti,

You need to assign the above UI to a Work centre view, and this work centre view to a Work Centre, and this work centre to your user.

Thanks, Pradeep.

sunil1101
Advisor
Advisor
0 Kudos

Hi

when you test you should login with sdk user.

From solution exploerer right click on OWL->Preview screen

Login with current SDK user (same user you have current logined in sdk).

In QAF preview tab you can also create record

Regards

Sunil

former_member189296
Active Participant
0 Kudos

Hi Sunil,

Still it is not working. I am logged in wit sdk user using preview in sdk. Clicking new button doesn't work. Can you plz, check in the above screenshots I have uploaded in previous comments whether I am doing screens configuration properly? and also the screenshots below:-

OWL screen

Data model

Regards,

Saurabh

Former Member
0 Kudos

Hi Sunil and Pradeep,

Yes this is still not working.

sunil1101
Advisor
Advisor
0 Kudos

Hi

I can you have created both type of UI thing based and OBN based. I would suggest create one type UI at a time.

If you only want to create a record you can enter data from preview

In UI designer(QC or QAF)-> click on Preview Tab.

For bettre understaning to create UI on BO, please follow this video link

SAP Cloud Dev: 04 - Creating a Basic Cloud Application - YouTube

SAP Cloud Dev: 05- Creating Business Logic - YouTube

SAP Cloud Dev: 06 - Enhancing the User Interface - YouTube

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

My apologies that my colleague replied simultaneously as we are working together. Anyway we have created OBN screens and also created one record. 

Below are the screenshots

Can you please tell if this is correct? Is it what we need and sufficient as this is a record.?

Many regards,

Pragati

former_member186648
Active Contributor
0 Kudos

Yes, this should be fine.

sunil1101
Advisor
Advisor
0 Kudos

Hi

Yes, you can create a record.

Enter date and click on Save.

Regards

Sunil

former_member186648
Active Contributor
0 Kudos

Hi Pragati,

search for "Mass Data Run" at http://help.sap.com/saphelpiis_studio_1508/studio_od_1508.pdf

Thanks, Pradeep.

sunil1101
Advisor
Advisor
0 Kudos

Hi,

Creating a MDR is one option which will definitely work for extension field, But this update will run for all customer or customer which you select in your query.

Another option you can use embedded component. create a BO with one field of type date and then create embedded component and an action

in action write logic

this.today =  Context.GetCurrentSystemDate();

use this event handler of action in on fire in-port of embedded component, whenever you open Customer screen embedded component will be loaded with current date.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Thank you for your reply. Actually I want that date should be updated automatically daily without opening customer screenfor all customers. So MDR is the good choice for this.

But unfortunately I don't know how to do the MDR process/development. Can you please help me with the entire process? Is it possible for you to upload screenshots?

Best regards,

Pragati

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragti,

As per your requirement you want to create MDR for standard BO, which is not possible. You can only create MDR for custom BO but there is workaround to update standard BO.

First you should read the details of MDR , as pradeep suggested go through this link.

then for standard BO you should first create custom BO with query and action.

then in action you should write a logic to update customer BO. This below link has used similar use case. How to create an hourly mass data run in C4C | SCN

Let us know if you face any difficulty.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Thanks for replying. I have read the process of mass data run creation.

And this is what I did.

1. Created a BO with a field CurDate and action refresh

2. Created a query Overview01.qry

As mentioned by you that I should create an action (that I have already created) on that custom BO with a logic. Can you plz. help and tell me how to code this action for logic so that it can  update the standard BO.

Regards,

Pragati

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragti,

1. First query you customer BO and returns required instance which you want to update, then inside the loop update the fields.

for example if you want to update customer on basis of role or status or both then write a query like below logic

import import ABSL;

import AP.FO.BusinessPartner.Global;


// Define variables

var query;

var selParams;

var queryResult;

// define query and selection parameter

query = Customer.QueryByIdentification;

selParams = query.CreateSelectionParams();

// Retrieve customer by query identification

selParams.Add(query.Role,"I","EQ", “Prospect");// Check relevant parameter for selection parameter

selParams.Add(query.Status,"I","EQ", “Active"); // there may be some other status, I given just an example

queryResult = query.Execute(selParams);

// Inside the loop you should update the field which you want to update by MDR

foreach (CustIns in queryResult) {

CustIns.Common.Person.Name.FamilyName = this.PersonFamilyName ;

CustIns.Common.ContactAllowedCode = "XYZ";}

When MDR will trigger it will trigger this logic which update the customer BO.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Still there is some confusion with me. Ok So what I can understand is:-

1) Create an XBO for customer BO and action        this.MyCustomField=Context.GetCurrentSystemDate();

2) Now create a custom BO with some custom action like this

  1. // Define variables 
  2. var query; 
  3. var selParams; 
  4. var queryResult; 
  5. // define query and selection parameter 
  6. query = Customer.QueryByIdentification; 
  7. selParams = query.CreateSelectionParams(); 
  8. // Retrieve customer by query identification 
  9. selParams.Add(query.Role,"I","EQ", “Prospect");// Check relevant parameter for selection parameter 
  10. selParams.Add(query.Status,"I","EQ", “Active"); // there may be some other status, I given just an example 
  11. queryResult = query.Execute(selParams); 
  12. // Inside the loop you should update the field which you want to update by MDR 
  13. foreach (CustIns in queryResult) { 
  14. CustIns.Common.MyCustomField = Context.GetCurrentSystemDate();//  I have doubt here, plz. correct

                15.  CustIns.Common.ContactAllowedCode = "XYZ";} 

Here MyCustomField is an element declared in XBO and is a custom field defined in standard action beforesave that will be filled with current system date.

3) Now create an MDR that will trigger this custom action and it will update that custom field  in standard BO.

Can you plz. correct this code and rectify me where am I doing wrong? which steps am I missing?

Regards,

Pragti

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragti,

This is correct, what is your dobut in below line.

custIns.CommonMyCustomField = context.GetCurentSystemDate();.

you have to create an instance of Custom BO which needs to be schedule (this instance always be picked up by query used in MDR)

MDR fetched one instance of Custom BO and execute it's action, this action query required Customer BO instance and will update as per the logic.

If you are facing any issue let us know.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

Thanks for replying. We have now queried the customer BO. Now is there anything that we need to do before we create MDR? If yes then how can I do that with coding? Because I have confusion with the term "instance". Like how can I create the instance of Custom BO now? What is the use of creating the instance?

Plz. help!

many Regards,

Pragti

sunil1101
Advisor
Advisor
0 Kudos

Hi Pragti,

Instance means record in Custom BO, so you have to create a record for your custom BO.

You can create it by UI, Click on OWL new button either on Quick Create or Quick Activity floorplan enter the data and save it will save one record, which you need to schedule.

Concept is : you will setup a MDR for custom BO just like changing the status price request  example in document. In your case in ABSL logic you are changing Customer BO records instead of custom BO.

When MDR execute it execute for custom BO first it will search for relevant record need to change then it run the absl logic to change, in your case there will be only one record of custom bo for one record absl script will run and it will query all relevant instance of customer.

Regards

Sunil

Former Member
0 Kudos

Hi Sunil,

This is what I am trying.

1) created XBO for customer BO

2) Created an event for XBO, beforesave with a field in it

 

3)Then created a custom BO

4) Defined that custom action refresh as you suggested


import ABSL;

import AP.FO.BusinessPartner.Global;

import AP.FO.BusinessPartnerRelationship.Global;

import AP.CRM.Global;

import AP.Common.GDT;

import AP.Common.Global;

var queryResult;

var CustIns;

// define query and selection parameter

query = Customer.QueryByIdentification;

selParams = query.CreateSelectionParams();

// Retrieve customer by query identification

selParams.Add(query.InternalID, "I", "EQ",""); //It is not showing error here but what should I insert the value?

selParams.Add(query.Status,"I","EQ", "Active);// It is not identifying status saying identifier status doesn't exist

queryResult = query.Execute(selParams);

foreach (CustIns in queryResult) {

CustIns.Common.GetFirst().CurrDate=Context.GetCurrentSystemDate();

              CustIns.Common.GetFirst().ContactAllowedCode="XYZ";

   }

Now in ,


selParams.Add(query.InternalID, "I", "EQ", "") What should I mention in quotes?

selParams.Add(query.Status,"I","EQ", "Active); Shows error that identifier status doesn't exist.

I don't know why status identifier is not getting recognized. Plz. help

Regards,

Pragati

former_member186648
Active Contributor
0 Kudos

Hi Pragati,

There is no parameter on Customer.QueryByIdentification with name "Status".

Thanks, Pradeep.