Showing results for 
Search instead for 
Did you mean: 

SAP Personas. How to create a script that takes a work order number and retrieves operations

0 Kudos


Can someone please help me? We have a current SMEN flavour to simplify the Work Order confirmation process, and we would like the user to be able to enter a Work Order number, click a search button and SAP personas automatically goes and obtains the available operations on that work order and then populates a existing dropdown list on the SMEN flavour, available for them to select.

Is this possible? And if so, i would greatly appreciate guidance on the JavaScript required to perform this.

Many Thanks,


View Entire Topic
Product and Topic Expert
Product and Topic Expert

Yes, you can do this.

To get the list of operations, I would use an RFC which retrieves the data for the entered work order number. You could do this in an easy way by calling function module BAPI_ALM_ORDER_GET_DETAIL. This returns a ton of details about the order, most of which you don't need - but among them there is a table called ET_OPERATIONS, containing everything you may need, like the operation number, description and much more.

Since calling this FM may be a little heavy, you could also write your own RFC that reads only what is necessary. For this, you'd first read table AFKO with the entered order number and get the value of field AUFPL from the order header record. Then, read table AFVC with this AUFPL value and this will provide you the list of order operations, with all their info. This method is certainly faster than reading all unnecessary stuff the BAPI gives you but requires some ABAP development.

Once you have the list of operations, you can refer to this KB article which explains how to code the script to change the values of a dropdown (combo box). The Script that creates new entries section does what you need. The dropdown key could be the operation number and the label the description of the operation, for instance. You would run this script tied to a script button or the onChange event of the order number field, and pronto 🙂

0 Kudos

Hi Tamas,

Thank you for this detailed answer, much appreciated. I was hoping for something i could do within Java, without the need for RFC. But i can still investigate. Also, can you share the link to the `KB` article you have mentioned around `Script that creates new entries`?

Many Thanks,


Product and Topic Expert
Product and Topic Expert

The link to the KB article is there in my previous post - just click on the word "this" 🙂

If you don't want to use RFC and wish to stay within JavaScript, then to start your script you could take the order number input and record navigation in IW33 to the Operations tab. At that point, you would enhance the script to copy the table content into a variable as described here, parse it to extract the necessary information and then follow the previously linked article to set the dropdown values. May be a little slower than the RFC method and will require more elaborate Personas scripting, but it should work.

0 Kudos

Thank you. Apologies, but how do you `parse` it to extract the necessary information (Operation number and Operation Short Text)?

Please see bellow my current Java script,

// Define the text field and drop-down list variables

var workOrder = session.findById("wnd[0]/usr/txtPersonas_16836377669202").text

var operationList = session.findById("wnd[0]/usr/cmbPersonas_168363900212128").entries

// Get the work order number from the field on the SMEN screen

var workOrder = session.findById("wnd[0]/usr/txtPersonas_16836377669202").Text;

//Goto transaction code IW33

session.findById("wnd[0]/tbar[0]/okcd").text = "IW33";


session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").text = workOrder;



// An OnLoad or OnAfterRefresh script was executed.




* Returns an array of rows containing information from the table control.

* @param {string} sTableControlId - The ID of the table control.

* @returns {Array[Object]} The contents array.


copyTableContents = function(sTableControlId) {

// Fetch the table and its columns

var oTableControl = session.findById(sTableControlId),

aColumns = oTableControl.columns,

aContents = [],






if (oTableControl.rowCount > 0) {

//Set the visible row to 0

oTableControl.firstVisibleRow = 0;

//Get the Max visible row number

nTopRow = oTableControl.visibleRowCount - 1;

//Loop through all the rows

for (nRowIndex = 0; nRowIndex < oTableControl.rowCount; nRowIndex++) {

oRow = {};

if (nRowIndex > nTopRow) {

// Set the first visible row to the next set of rows. If the next set goes beyond the maximum rows,

// adjust it so that the set's last row is the table's last row.

if (nTopRow + oTableControl.visibleRowCount > oTableControl.rowCount) {

oTableControl.firstVisibleRow = oTableControl.rowCount - oTableControl.visibleRowCount;

} else {

oTableControl.firstVisibleRow = nTopRow + 1;


nTopRow += oTableControl.visibleRowCount;


// Populate the row information.

for (i = 0; i < aColumns.length; i++) {

sColumnName = aColumns.elementAt(i).name;

oRow[sColumnName] = oTableControl.getCellValue(nRowIndex, sColumnName);


// Break after the first blank row - the values usually contain all underscores like "____" for a 4 character column.

if (oRow[aColumns.elementAt(0).name] && !oRow[aColumns.elementAt(0).name].replace(/_/g, "")) {






return aContents;


0 Kudos

Hi Tamas,

I think i have this working to a point. I have included the following java from the link you sent me (along with the rest), but it just applies the `LH` and `AA` values. How do i adjust this to apply the fields `VORNR` (Operation) and `LTXAI` (Operation Text) from the `copyTablecontents` part of the script?

var oCombo = session.findById("wnd[0]/usr/cmbPersonas_168363900212128");

var oEntries =oCombo.entries;


var oEntry1 = oEntries.createComboBoxEntry("LH", "Lufthansa");


var oEntry2 = oEntries.createComboBoxEntry("AA", "American Airlines");


oCombo.entries = oEntries; // this will work even for a standard combo box if the original had entries with keys "LH" and "AA"

Once again, i really appreciate your support on this 🙂

Many Thanks,