cancel
Showing results for 
Search instead for 
Did you mean: 

Using multiple technical objects on one script in Personas

babowden
Explorer
0 Kudos
134

Hello,

We are currently trying to create a flavour with a Vendor drop down list (achieved) and then a list of text fields (say 20) for the end user to apply equipment record numbers and then click a `SEND` button.

Upon clicking this send button, how can we have the script apply all the equipment record data to transaction code MIGO (for example) and then check the next text field on the flavour for an entry before posting the material document?

I assume this would be like a `loop` on the script until the next text field is blank, and then it proceeds to the posting step.

I appreciate your support and help in this matter, as this will hopefully resolve a few new flavours to support our end users.

Many Thanks,

Ben

View Entire Topic
kmagons
Advisor
Advisor
0 Kudos

Hi Ben,

I think, I understand your requirement as follows:

You have created a Screen Personas flavor for transaction X that contains n optional inputs and the SEND button that has a script associated. For each non-empty input value go to transaction Y, process data and return back to X. Once the processing of up to n inputs is completed, proceed with further logic of X.

1) Your n text inputs have unique ID's. You can use the scripting inspector to locate the ID value for each input. Create an array of them.

For example,

var aInputs = ["wnd[0]/usr/txtPersonas_16605716415712", "wnd[0]/usr/txtPersonas_166057164659044", "wnd[0]/usr/txtPersonas_166057165734327"];

2) For each input ID, locate the control and check the text value. If it's set add it then to a collection of non-empty values. For example,

var aValues = [];
aInputs.forEach(function(sInputId){
if(!session.idExists(sInputId)){
return;
}
var sValue = session.findById(sInputId).text;
if(sValue){
aValues.push(sValue);
}
});

3) If you have at least one value set, take the values to the transaction Y, process data there and return back to X

if(aValues.length > 0){

session.findById("wnd[0]/tbar[0]/okcd").text = "Y";
session.findById("wnd[0]").sendVKey(0);
aValues.forEach(function(sValue){
//Do stuff...
});
session.findById("wnd[0]/tbar[0]/okcd").text = "X";
session.findById("wnd[0]").sendVKey(0);
}

4) Proceed with the further steps from the SEND logic.

Hope, this helps, however, I am not sure if I correctly understood your struggles! 🙂

Best regards,

Krists Magons

SAP Screen Personas Dev Team