Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OK code in BDC recording

Former Member
0 Kudos

Hi,

please let me know , what is the use/importance of OK code in BDC recording/screens?

Thanks in advance

Jana

3 REPLIES 3

Former Member
0 Kudos

Hi Reddy,

In BDC OK codes are useful which functionality we used means we clikced save button or cancel button etc., or we used the enter key or f1 key etc., for all these functionalities have some code. that code is nothing but OK codes. so that we can check in our program whether the user clicked the specific button or not.

Thanks

Ravi

Former Member
0 Kudos

Hi Janardhan,

Check this info.

SAP recommends that in dialog program always use OK_Code instead of sy-ucomm. Here is what the help says

In your ABAP programs, you should work with the OK_CODE field instead of SY-UCOMM. There are two reasons for this: Firstly, the ABAP program has full control over fields declared within it, and secondly, you should never change the value of an ABAP system field. However, you should also always initialize the OK_CODE field in an ABAP program for the following reason:

In the same way that the OK_CODE field in the ABAP program and the system field SY-UCOMM receive the contents of the corresponding screen fields in the PAI event, their contents are also assigned to the OK_CODE screen field and system field SYST-UCOMM in the PBO event. Therefore, you must clear the OK_CODE field in the ABAP program to ensure that the function code of a screen is not already filled in the PBO event with an unwanted value. This is particularly important when the next PAI event can be triggered with an empty function code (for example, using ENTER). Empty function codes do not affect SY-UCOMM or the OK_CODE field, and consequently, the old field contents are transported.

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba99935c111d1829f0000e829fbfe/content.htm

This is a long standing issue dating back many years. The general answer is that you control the OK_CODE field while SAP controls the SY-UCOMM field. You assign field OK_CODE to the OK code field in the screen painter and SAP copies SY-UCOMM to your OK_CODE field. Now you have control over the value. If you start invoking other code, like SAP utilities that display screens, you can be guaranteed that the value in OK_CODE will still be there, while you have no idea what SAP might be doing with SY-UCOMM.

This is a design decision that was probably made about 20 years ago when screen processing was introduced. In most cases, you can probably use SY-UCOMM and not have any problems but there are probably cases out there where SAP has done something tricky and you will have a problem.

Because there are unknowns out there, I always define an OK_CODE and do not use SY-UCOMM for standard screen processing. For me this is a long standing habit.

OK_Codes are like function code for each button or for any action on the screen.

When you press SAVE or when you Press some Button on the screen, your every action is recorded by using the OK_COde.

for example for ENTER button it is '/00'.

While you record BDC's using SHDB you will come to know all these OK codes.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Former Member
0 Kudos

HI janardhan,

When you run a transaction manually, you wil press some buttons to run some fucntionality, if you run the same in the background, you can not click tose function manually, so we use the OK_CODES to trigger those functionality

regards

Sudheer