Application Development and Automation 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: 
Read only

What are OK Codes?

Former Member
0 Likes
17,515

What are OK Codes?

1 ACCEPTED SOLUTION
Read only

h_senden2
Active Contributor
0 Likes
9,801

The function code / variable representing the user command on the screen (see also SY-UCOMM) in dialog programming/

regards,

Hans

Please reward all helpful answers !!!!!

What are OK Codes?

9 REPLIES 9
Read only

Former Member
0 Likes
9,801

Hi

OK codes are nothing but the Function codes what we define for each Buttons on the screen or Menu

OK code is nothing but the SY-UCOMM

reward points if useful

regards,

Anji

Read only

h_senden2
Active Contributor
0 Likes
9,802

The function code / variable representing the user command on the screen (see also SY-UCOMM) in dialog programming/

regards,

Hans

Please reward all helpful answers !!!!!

Read only

Former Member
0 Likes
9,801
Read only

Former Member
0 Likes
9,801

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.

also chk this

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

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
9,801

OK code is like function code. Where u assign the function codes PAI.

e.g: In the GUI Status if u have defined a EXIT button and u have assigned say 'EXT for that.

Then EXT will become ur OK_CODE.

In PAI under this OK_CODE u will execute some code.

when u press the EXIT button in your screen the logic will be executed.

This is the use of OK_CODE.

Thanks & Regards

Santhosh

Read only

Former Member
0 Likes
9,801

Hi,

OK_CODE is nothing but function code for Screen.It Stores Function Code of screen.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

former_member196299
Active Contributor
0 Likes
9,801

hi SaI,

OK Codes are nothing but Function code defined for any click on the screen esp in module pools programs . You capture the function codes / OK Codes in SY-UCOMM . that means the value for any click during runtime is saved in SY-UCOMM .

you can do operations accordingly ....

eg: ok_code = sy-ucomm .

if ok_code EQ 'EXIT' or ok_code EQ 'CANCEL'.

leave program .

endif.

that means when you click on EXIT or Cancel icon the system will leave the current program .

Reward if helpful!

Thanks

Ranjita

Read only

Former Member
0 Likes
9,801

Thank U very much

Read only

0 Likes
9,801

Hi,

OK_CODE is a variable which is used to collect the screen attributes related Function codes. Whenever click on Push buttons or some Action, the Action related function code will be captured into OK_CODE variable. OK_CODE is type of system variable SY-UCOMM. Every button related action will be written basing on this OK_CODE value (Function code).

Regards,

Nasreen