Where do OK codes come from?

By James Lofgren on Apr 1, 2020

Hey, do you have a minute to talk?

Now that you’re growing up as a Winshuttle user, we think you’re mature enough to have this conversation. Your Winshuttle scripts are going through some changes, and sometimes that can be a bit confusing. We want you to know that we’re here to help you navigate those changes. You probably have some questions and we want to make sure you’re getting the right answers. Go ahead and take a seat… We think it’s time we finally have the talk, so you understand, “Where do OK codes come from?”

What is an OK code?

Before we go into the details of OK codes and where they come from, it’s helpful to make sure we understand exactly what their role is in a script. An OK code is a specific command within SAP to perform certain actions. This can be anything from pressing enter, clicking a button, selecting a menu item, or scrolling down a page. It’s important to know that OK codes are a function within SAP rather than being unique to Winshuttle.

Why would I edit an OK code?

When a script is first created, all the fields that you interacted with and the OK codes you executed are captured together and delivered into the world as a brand new Winshuttle script. These little bundles of joy are sweet, innocent, full of boundless potential! Within them resides the possibility of making the world a better place… and they also smell nice. As you map your fields and watch your script take its first steps, you feel that sense of pride only a Winshuttle Developer can know. Before you know it, the day comes when you’re ready to send your script out into the world.

But the real world can sometimes be a tough place.

The script that grew up before your eyes now needs to navigate the awkward teen phase of new requirements, changing business processes, or changes to SAP. This is where an understanding of OK codes can help your script overcome these challenges and become a functioning, productive member of society. By changing OK codes from within Winshuttle Studio, you can modify the actions of that script to take new actions, handle new screens, or navigate through different data processes.

Where are OK codes in a script?

To view or edit these in Winshuttle Studio, we’ll need go into the Expert View of your script. Within each screen container, which is the group of fields under each blue Screen line, there should be a line with the technical name of BDC_OKCODE and the value of that field is the OK code being sent to SAP. To modify this value, just double-click into the value field and you can change the OK code for that screen.

In this example, I have highlighted the OK codes from each of the first two screen containers.

The first OK code, =ENTR is the command to click the Green Check in the SAPMF02D-7101 screen.

The second OK code, =FISEG is the command to click on the Company Code Data button within the SAPMF02D-7000 screen.

When modifying OK codes, it is important to make the modification within the correct screen container in your script. The “correct” screen container depends entirely on which step in your script you are trying to change, and it is often helpful to walk through your script in Debug Mode a few times to determine where exactly the change needs to occur.

Where do OK codes come from?

Now that we understand how important OK codes are in a script, why we would want to edit them, and where we can edit them, let’s see how we can determine the OK code for new actions we would like the script to perform.

There are typically four ways this can be done, and the method chosen is often determined by which type of action you are trying to take within SAP.

Clicking a button within the screen

If you would like to select a new button in the SAP screen, the first step will be navigating to the screen where you would like to make the change directly through the SAP GUI. In many cases, you won’t need to walk through the same steps that your script is performing in order to get to the OK code you want to change. Feel free to go directly to the screen to be changed, rather than walking through every step in your script, if possible.

Once you are on the screen that contains the button that you would like to change your OK code to follow these steps to see the OK code associated to a button:

  1. Click down on the button, but DO NOT release the mouse click.
  2. Drag your cursor off the button, then release the mouse click. This should place a red rectangle around the button.
  3. Press F1 on your keyboard. (If nothing appears, check that Function Lock on your keyboard is enabled and press F1 again)
  4. The Technical Information screen appears, and the OK code is displayed in the Function field.


In this example, if we want our script to now select the Product Attributes button, we find the step in our script where we are in the Sales Tab of the Sales Area Data and change the OK code to “PRAT”.

Hover over a Menu Item

The steps to see the OK code for items selected through the Menu are more straightforward. Simply hover over the item you would like to select and press F1 to see the Technical Information.


Selecting a Tool Bar item or using a keyboard command

If the change you want to make is selecting an item on the SAP Tool Bar or using a keyboard shortcut, the click and drag option won’t be available. For example, if I now want my script to select the Save button on the Standard Tool Bar, I am not able to use the F1 key to capture the OK code.

For these actions, you’ll want to again navigate to the screen where you would like to make the change directly in the SAP GUI. Once you’re in the right place, click into any field on the screen and press F1. The Performance Assistant should appear, and from there you can click the Technical Information icon to see the details.


From here, double-click into the Status field, and it will take you to the Interface Display for that screen.

Please note, the Interface Display may require higher level authorizations to view, but you can always use the Interim Recording method, which is explained below, to capture any OK code.

Once inside this screen, there are typically three groups that can be expanded—Menu Bar, Application Toolbar, and Function Keys.

From here you can see the full list of items in the Menu Bar by clicking the Expand icon on that group. As you double-click through each of the menu items and sub-menu items SAP will display both the OK code and Text of the items.

For comparison to the hovering method, we can expand the Menu Bar, double-click on Extras, and see that the OK code for the Additional Data menu item is “ZUDA”, along with the OK codes of the other items in that menu list.

If the action you would like to take is in the Standard Toolbar, or using a Keyboard Shortcut, you can expand the Function Keys group to see the list of OK codes.

In this example, the Function Keys are expanded, and we can see the OK code for Save is “UPDA”. Note that some keys do not have OK codes assigned which means they are not activated in that screen.

Any other actions

If either of the above methods can’t capture an OK code, I recommend using an interim recording in Winshuttle to find the OK code. A common example of this would be the OK code to move between tabs on a screen as they are neither buttons nor menu items. With this method, you’ll start a new Winshuttle recording, and go directly to the action you would like to take in SAP. You likely won’t be using this script for anything else, so don’t feel the need to capture all your requirements here. Instead, go directly to the screen you need in SAP and execute that new action. If this will prompt new screens or fields in SAP, it may be a good idea to record the portions of SAP that were not in your original recording, so you can copy the screens and actions from your interim script along with your new OK code. Once you have copied what you need from the interim script, and pasted that into your original script, feel free to close the interim script without saving.

For example, if your modified action will be taking you to a new tab, you’ll need to modify the OK code of the screen container where you will take the action (Line 34), and include any new screens or fields in screen containers AFTER the modified OK code (Lines 37-39).

What is the impact of changing OK codes?

Any time a script is being modified, but especially when changing OK codes, it is critical to understand the impact that the change will have on the direction of your script. Some changes may keep you within the same screen in SAP, such as adding a command to click New Line or Last Page and may not require other changes to your script. However, with other changes, screens that had been previously not encountered may appear during execution, and you would need to make more modifications to your script such as adding new screens and fields to execute properly.

It is a good idea to run scripts in Debug mode after OK codes have been modified to make sure that your script is still able to execute the remainder of the actions in SAP. If screens or fields need to be added to your script, you can use the steps found here to modify your script further: https://support.winshuttle.com/hc/en-us/articles/360023688611-How-to-Find-SAP-Screen-and-Field-Information-

Conclusion

We hope this helps clear up any confusion that you might have had and know that your changing requirements are completely normal. We hope you know that we love you very much and we’re always here to talk or answer any additional questions you might have. Feel free to reach out to us at https://support.winshuttle.com/hc/en-us

About the author

James Lofgren

James has been helping companies make the most of their SAP investment since 2008. He has worked on multiple implementation projects, provided hundreds of end-user trainings, developed technical solutions and enhancements, and broken many features previously considered "idiot-proof". Now he’s helping customers find solutions for their data and business process challenges.

Questions or comments about this article?

Tweet @Winshuttle to continue the conversation!