on 05-30-2018 1:40 PM
Hi,
Based on this article (https://archive.sap.com/discussions/thread/3925665) I tried to create my own MDR from ABSL. This is working fine for the most part, except for the query parameters. They don't get applied in the MDR that is created.
Does anyone know how to do this exactly? Please review my code below and tell me where I went wrong.
var QueryParam : QueryParameter;
var MDRO_ID : XPEString;
var MessageList : MessageList;
MDRO_ID = "PRS_" + this.ID.content.RemoveLeadingZeros() + "_" + Context.GetCurrentSystemDate().GetDay() + "." + Context.GetCurrentSystemDate().GetMonth() + "." + Context.GetCurrentSystemDate().GetYear() + "_" + Context.GetCurrentSystemTime().GetHour() + ":" + Context.GetCurrentSystemTime().GetMinute();
MDRO.CreateInstance("MDR_MD_Create", "", MDRO_ID);
QueryParam.ParameterName = "RequirementSpecificationID";
QueryParam.Sign = "I";
QueryParam.Option = "EQ";
QueryParam.Low = this.ID.content.RemoveLeadingZeros();
MessageList = MDRO.AddSelectionParameter("MDR_MD_Create", "", "QueryByReleaseStatus", MDRO_ID, QueryParam);
MDRO.Activate("MDR_MD_Create","",MDRO_ID);
var currentTime = Context.GetCurrentGlobalDateTime();
var StartDuration = Library::Duration.Create(0,0,0,0,0,30);
var startTime = currentTime.AddDuration(StartDuration);
MDRO.ExecuteDateTime("MDR_MD_Create", "", startTime, MDRO_ID);
Hi Michiel,
please have a look at the sample code below, I am sure you will be able to solve your problems with it.
Imports
import ABSL;
import AP.PlatinumEngineering;
MDR Configuration
var MDRName = "MDR_StackProcessor";
var RunDescription = "Run for " + obj.ObjectType.GetDescription() + ", session
(" + obj.SessionUUID.content.ToString() + ")";
var NumberRangeName = "MDR_Stack_ID";
var SelectionParam1 = "SelectByObjectTypeContent";
var SelectionParam2 = "SelectBySessionUUIDContent";
var SelectionParam1content = obj.ObjectType.content;
var SelectionParam2content = obj.SessionUUID.content;
Selection Parameters
var queryParameter : QueryParameter;
var parameterName = SelectionParam1;
queryParameter.Option = "EQ";queryParameter.ParameterName = parameterName;
queryParameter.Low = SelectionParam1content;
var queryParameter2 : QueryParameter;var parameterName2 = SelectionParam2;
queryParameter2.Option = "EQ";queryParameter2.ParameterName = parameterName2;
queryParameter2.Low = SelectionParam2content;
Instanciation
var MDRO_ID : XPEString;
MDRO_ID = NumberRange.DrawNumber(NumberRangeName);
MDRO.CreateInstance(MDRName, "", MDRO_ID, RunDescription);
//do AddSelectionParameter only once per instance (otherwise you will have multiple entries with the same selection parameters)
MDRO.AddSelectionParameter(MDRName, "", parameterName, MDRO_ID, queryParameter);
MDRO.AddSelectionParameter(MDRName, "", parameterName2, MDRO_ID, queryParameter2);
// If you use selection criteria between, you do not need the following line
MDRO.SetSelectionLowParameter(MDRName, "", parameterName, "LowerBoundaryID", "2", MDRO_ID);
Scheduling & Execution
var currentTime = Context.GetCurrentGlobalDateTime();
var StartDuration = Library::Duration.Create(0, 0, 0, 0, 0, 10); // Years, Months, Days, Hours, Minutes, Seconds
var startTime = currentTime.AddDuration(StartDuration);
MDRO.ExecuteDateTime(MDRName, "", startTime, MDRO_ID);
From testing we can confirm that the 10 sec interval works best. Other durations don't seem to work seamless.
Sample Implementation
import ABSL;
import AP.PlatinumEngineering;
var mdrName = "MDR_Schedule";
var mdrDescription : MDRO.CreateInstance.Description = "Schedule Run for Object XY";
var mdrID = "[MDR_ID]";
MDRO.CreateInstance(mdrName, "", mdrID, mdrDescription);
var queryParameter : QueryParameter;
queryParameter.Option = "EQ";
queryParameter.ParameterName = "SelectByID";
queryParameter.Low = "4711";
MDRO.AddSelectionParameter(mdrName, "", queryParameter.ParameterName, mdrID, queryParameter);
var now = Context.GetCurrentGlobalDateTime();
var startDuration = ABSL:Duration.Create(0, 0, 0, 0, 0, 10);
var startTime = now.AddDuration(startDuration);
MDRO.ExecuteDateTime(mdrName, "", startTime, mdrID);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for taking the time. I suspect that the problem lies in the query itself. In your example you use the following:
queryParameter.ParameterName = "SelectByID";
How would you define the actual query itself? Where does this "SelectByID" come from exactly? So basically what I want to know is how these two are linked.
This is my query:
Hi Michiel,
the query may be your problem. One way - the one I am aware of - to find the name of the query parameters is to generate the screens for the MDR and open the quick activity (QA). There you'll find all parameters which you have selected while creating the MDR itself. Like it is here:
This does depict the structure you would see in the UI component if you opened it in SAP. If you have the correct name you should be able to use the code included in the first comment.
Best regards,
Jürgen
Hi Jürgen,
Were you able to find this in the code ? I am looking for the same. I need to access the low and high value that the user has entered and scheduled the MDR from UI. Only way I can find now is via the QA screen. I am unable to access the structure highlighted by you in the code. Did you get a way to access it ?
Best Regards,
Srikanth Rathod
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.