Skip to Content
avatar image
Former Member

SAP Screen Personas 3.0 Hiding screen elements via OnLoad screen event

I would like to hide (or show) some screen elements depending on the order type via a script. The script should be triggered when a user starts transaction VA02 (after entering the order number and pressing ‘Enter’. Therfore I created a script and attached it to the screen event ‘OnLoad’. While I can read field values during ‘OnLoad’ it seems to be impossible to hide fields. Does anybody know how to achieve this?

Thanks in advance

Jan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Oct 31, 2016 at 04:01 PM

    I use this functionality in work orders. The below code should help you, assign it to onLoad. (not in the code is defining variable orderType, make sure to do this)

    if (orderType === 'Z400'){

    session.utils.log (orderType)

    session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/tabsTS_1100/tabpIHKZ/ssubSUB_AUFTRAG:SAPLCOIH:1120/boxPersonas_146964646030946/lblPersonas_146964660474297").hide() ;
    session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/tabsTS_1100/tabpIHKZ/ssubSUB_AUFTRAG:SAPLCOIH:1120/boxPersonas_146964646030946/txtPersonas_146964662395271").hide() ;
    }

    Thanks,

    Andrew McGrath


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 01, 2016 at 10:02 AM

    Hi Andrew,

    thank you very much for your answer. Unfortunately this does not work in our system. The script reacts only after the user has started to work within the screen (for example clicking on a button or pressing ‘Enter’). This is not very useful. The screen elements should be hidden when the transaction has been started. Does your system react differently?

    (Within the OnLoad event I can read values and show them within a message box but I cannot fill in values to text elements or hiding elements.)

    Jan
    Add comment
    10|10000 characters needed characters exceeded

    • This (nonsensical) script works for me in VA02. It looks at the order number, and if it is "102" it hides the gross amount field!

      var order = session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/ctxtVBAK-VBELN").text;
      if(order == "102") {
          session.findById("wnd[0]/usr/subSUBSCREEN_HEADER:SAPMV45A:4021/txtVBAK-NETWR").hide();
      }

      Set this as the "onLoad" event handler on the second screen of VA02 and it should do what you want. It certainly works for me.

      Perhaps if you post more details of what you've done, including your script, we might be able to help more?

  • Nov 01, 2016 at 11:40 AM

    Hi Jan,

    I think screen refresh might be the problem try adding the below code inside if condition at the last.

    sap.personas.scripting.executeScriptInternal({src:''});  
    Add comment
    10|10000 characters needed characters exceeded