Skip to Content
author's profile photo Former Member
Former Member

onF4 scripting resulting in endless loop, advice welcome :)

Hi,

I've been playing around with the script event onF4 for the work center field. The idea is that if user has already filled in plant the onF4 script would open up all the possible work centers for that plant.

I started by copying the plant value and checking the length of the variable, if length is greater than 0 the script would continue to paste the plant value in the plant field in the work center popup where a search for work centers can be done.

But doing this way will result in a endless loop where the script is triggering the F4 on the work center and then start the script all over again. Do anyone know of a better way of accomplishing this?

Best Regards,

Oskar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Aug 23, 2016 at 02:11 PM

    Hi Oskar,

    I am assuming you used the pressF4 function in your script. The pressF4 function of a GuiTextField control executes any onF4 scripts that are assigned. Hence, the endless loop.

    One way to solve this issue is to use the setFocus function on the field and then sending an 'F4' key to the main window control. In the following example, I used the transaction CR01 and assigned the script to the onF4 event. It populates the plant field with 0001 in the F4 criteria popup. You may need to change the F4 help settings to 'modal' (fully supported compared to limited support of 'amodal' F4 popups).

    session.findById("wnd[0]/usr/ctxtRC68A-ARBPL").setFocus();
    session.findById("wnd[0]").sendVKey(4);
    session.findById("wnd[1]/usr/tabsG_SELONETABSTRIP/tabpTAB001/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/ctxtG_SELFLD_TAB-LOW[1,24]").text = "0001";
    

    Best regards

    Kranthi

    SAP Screen Personas Team

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.