cancel
Showing results for 
Search instead for 
Did you mean: 

Personas 3.0 SP1 - VA01 - Popup

former_member189862
Participant
0 Kudos

Hi Experts,

In create sales order screen(VA01) -

When I click on the Sales Order Line item and hit the Ext Dtls button - a popup appears for external details. - here I am using only one field Mode of Transport. - See below screen shot.

Is there a way using Personas 3.0 SP1 - I can have the field somewhere in the main screen itself, so that I don't have to hit Ext Details button for multiple lines every time, just for that one field.

Note: there can be multiple line items in a sales order.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Kapil,

You will need to find the row index of the table control that matches the item line number. With the row index, you can set the selectedRows property of the table control and then click on the external details button and then set the value in the popup.

To do this, you will need to find the column name of the item line number column. To do this, you can use opt for one of the following methods:

1. Use the control selector tool from the script editor and select one of the cells from the item line number column. From the parentId value, use the last segment from the column ID and ignore prefixes 'txt' or 'col'. In this example, the parentId will be similar to "wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\03/ssubSUBSCREEN_BODY:SAPMV45A:4490/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/txtVBAP-POSNR[0,0]". From this ID, the last token "txtVBAP-POSNR[0,0]" is what is required - omit the 'txt' and [0,0] and you will get the column name - "VBAP-POSNR".

2. Use the following script to print out the column names to the browser console and then find the one that matches the column index.


/**

* Prints the columns names of the provided table control.

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

*/

var printColumnNames = function(sTableControlId){

  var oTableControl = session.findById(sTableControlId),

  aColumns = oTableControl.columns,

  i;

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

  console.log("Column " + i + ": " + aColumns.elementAt(i).name);

  }

}

printColumnNames("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\03/ssubSUBSCREEN_BODY:SAPMV45A:4490/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG");

Here's some sample code on how you can find the row index of the cell that matches the value of a column. I have used the item detail screen as a basis for this - you will need to change the table control ID from your screen in order to get this to work.


/**

* Returns a table control row index of a cell that matches the value and column name provided.

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

* @param {string} sColumnName - The column name.

* @param {string} sValue - The value to be matched.

* @returns {number} The row index of the cell.

*/

var findTableRowIndex = function(sTableControlId, sColumnName, sValue) {

    // Fetch the table and its columns

    var oTableControl = session.findById(sTableControlId),

    nTopRow,

    sColumnName,

    nRowIndex,

    i,

  sCellValue;

    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++) {

            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;

            }

  sCellValue = oTableControl.getCellValue(nRowIndex, sColumnName);

  // Trim any whitespaces to compare any right aligned columns

  sCellValue = sCellValue ? sCellValue.replace(/ /g, "") : "";

  //console.log("sCellValue:" + sCellValue);

  if(sCellValue === sValue){

  return nRowIndex;

  }

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

            if (sCellValue && !sCellValue.replace(/_/g, "")) {

                break;

            }

        }

    }

    return -1;

};


// Find the table control's row index that matches the copied value with the first column from the table

var nRowIndex = findTableRowIndex("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\03/ssubSUBSCREEN_BODY:SAPMV45A:4490/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG", "VBAP-POSNR", sItemLineNumber);

//console.log(nRowIndex);


// Select the matched row

if(nRowIndex > -1){

  session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\03/ssubSUBSCREEN_BODY:SAPMV45A:4490/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG").selectedRows = String(nRowIndex);

}


// Add the code to click on the external details button and set the value in the popup.

You can add these utility functions into a library and use it across flavors as described in the KB article - Scripting: Including Global Javascript Libraries - SAP Imagineering - SCN Wiki

Regards

Kranthi

former_member189862
Participant
0 Kudos

Dear Kranthi,

Thanks a lot for your suggestion, that certainly resolved the issue.

However I have a additional Issue

I have these custom fields on the Sales A tab , they retain values after the user saves the sales order and does not go out of VA01.

1. So I tried to clear them as soon as user hit Click to Copy Values in the script above, but the problem, is user says they would still like to see them if they go to Sales A tab again.

2. So I tried to clear them using a separate script and put that script on screen events - onLoad or onAfterRefresh and onBeforeRefresh , but it gets called everytime.

Is there an event which only gets called just once - so that I can clear the values just the first time when transaction starts and not everytime I go to Sales A tab.?

Or may be there is any other creative way of doing this?

0 Kudos

1. clear all the custom fields when you enter the flavor using onLoad

2. in your "Copy Values" script, also put the values of custom fields into session.utils.put()

3. For SALES A tab, you can activate the script using onActivate event for this tab.

Your onActivate script will paste the values from session.utils.get() into the custom fields

Scripting Utility Methods - SAP Imagineering - SCN Wiki

former_member189862
Participant
0 Kudos

Thanks Sushant,

Appreciate your support. I am on SP01 can I still use the onActivate event? I was trying to see if I can find a use case on how to use this event. on the actual screen, I don't see this screen event.

I went thru the blog Available Events for Scripting - SAP Imagineering - SCN Wiki - it says its there in SP01, but I am not sure where I can look for it to be able to use it.

On the actual screen I don't see event onActivate ? Any further guidance is much appreciated.

0 Kudos

hi kapil,

thats because no control has been selected by you..see top right message.

Click on the tab (where its written "Sales A" and you would notice that Script Event gets activated. Click there and you will see onActivate

Former Member
0 Kudos

Hi Kapil,

what about replacing the save button with a script button. The script button saves the sales order and if session.findById("wnd[0]/sbar").text contains the new sales order number, the script sets the values of the custom fields to blank. Copy the value of session.findById("wnd[0]/sbar").text to a variable, for example message, and check if( message.indexOf('frag') > 0 ) with frag being a fragment of the message shown after saving a sales order succesfully.

Regards

Björn

former_member189862
Participant
0 Kudos

Thanks Sushant,

I found out the onActivate event.

Now when I am doing the step 2 session.utils.put in the copy script.

So my value is in ZMOD = which is moved from text field.

I added one more variable ZMODG, which will become my  key in session.utils.put.

However I don't seem to be able to pass the value to ZMODG.

I tried to use double quotes with session.utils.put like session.utils.put("ZMODG","ZMOD");

but that also did not work. So with or without quotes its not working.

Do you think I should change something to be able to pass value while using this method?

Also when I use the get method, I assume there needs to be a variable which can accept the value, but again, I don't see the value getting passed correctly.

Sorry for the long post, but I am really confused how to use these methods, I think these are my best option, if we can make them work.

Thanks for your support

former_member189862
Participant
0 Kudos

Hi Bjorn,

That's a good suggestion, however we can get lot error messages, incompletion logs etc.

and then once you have a incompletion log - I even tried to hit the button save in the incompletion popup and catch that in another script and replaced it with a new custom button, but system keeps just hanging in that popup.

So now my last hope is the put and get functions, but as I replied above to Sushant that I am getting into some issues while trying to use those functions.

Thanks for your help.

0 Kudos

hi kapil,

your script is wrong. In utils.put you are passing a variable as key with no value...

Do this:

var zmod = your code;

var bloc = your code;

var cid = your code;

session.utils.put("zmodg",zmod);

alert(session.utils.get("zmodg"));

Regards,

Sushant


Answers (1)

Answers (1)

Carifaine
Active Participant
0 Kudos

Hi Kapil,

if i understand you right, you want to show the value directly on the main screen when you select an item in the table? I think you can add a custom field on your main screen and create a script which performs the steps:

- Click on the Ext Details button

- Copy value for Mode of Transport

- Close the popup

- Paste value in your custom field

You can try to bind this script to the event "onSelect" of your table. I didn't try it, but i think this should be the one triggered as soon as you select a row.

Please try this out. If you have any questions, feel free to ask.

Regards,
Christoph

former_member189862
Participant
0 Kudos

Hi Christoph,

Thanks for your reply.

I want to do it the other way while creating the data for the first time in VA01, have some field may be in the item Data (Sales A), and from here copy the value and store it in the External Details of that Particular line item.

So I also added a new field in the Sales A-

Wrote a script to copy this value to the External Details popup.

It works great until I only have one line item in the sales order- because the way script works is, it selects the particular line from the sale order screen and then click on the External Details Button for that line item.

Now since the script is only have 01 - it always inputs the value in 1st line item only.

The challenge here is to actually link the line item user is handling in the SALES A - because here we see SAP line item numbers = 10,20 etc. but in Java Script on the screen we see table control line item numbers 01,02 etc - need to find a way to link these two now, so that my script can select the correct line.

Any more suggestions will be appreciated.

Carifaine
Active Participant
0 Kudos

Hi Kapil,

i think the "01" represents the tab "01" = the first tap of the tabstrip, not the selected line. The position table comes with a property "selectedRows". You can find that in the scripting properties. You can use this to specify which line should be selected to enter the value in the external properties. The matching has to be done manually maybe.

Regards,

Christoph

former_member189862
Participant
0 Kudos

Thanks Christoph,

Appreciate your support,

  • When I select the first line(item 10) and press external details my script looks like below

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\01/ssubSUBSCREEN_BODY:SAPMV45A:8083/subSUBSCREEN_TC:SAPMV45A:8086/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnEXT_DTLS_PB").press();

  • When I select the second line in sales order (item 20) - and press the external details button, my script looks like below

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\\01/ssubSUBSCREEN_BODY:SAPMV45A:8083/subSUBSCREEN_TC:SAPMV45A:8086/subSUBSCREEN_BUTTONS:SAPMV45A:4050/btnEXT_DTLS_PB").press();

There is absolutely no difference, in script depending on what line I selected on sales order - do you think its a bug in system?

Regards

Kapil