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

OK_CODE

Former Member
0 Likes
3,408

Hi Gurus,

What is OK_CODE? What is the different types of OK_CODES and their values?

Marks will be rewarded

Thanks in advance

Ravi

1 ACCEPTED SOLUTION
Read only

Former Member
2,526

Hi,

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.

Reward if useful.

Regards,

Anji

11 REPLIES 11
Read only

Former Member
2,527

Hi,

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.

Reward if useful.

Regards,

Anji

Read only

satykumar
Product and Topic Expert
Product and Topic Expert
0 Likes
2,526

Hi Ravi,

Please go through this thread

Regards,

Satyendra.

Read only

Former Member
0 Likes
2,526

Hi ,

In dialog programming or in the reports sy-ucomm keeps a track of FCODES of the pushbutton or any event wbeing clicked on application toolbar or menu or function keys.

In the Dialog programming you set a variable as OK_CODE in the element list if you have created own pushbuuton which have FCODE .

so the system variable sy-ucomm has the values .

Please rewards if useful.

Read only

Former Member
0 Likes
2,526

Hi Ravi Kanth,

In your ABAP programs, you should work with the OK_CODE field instead of SY-UCOMM. There are <b>two reasons</b> for this: <b>Firstly</b>, the ABAP program has full control over fields declared within it, and <b>secondly</b>, 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.

In your application programs, the first step in PAI processing should be to save the function code in an auxiliary variable and then initialize the OK_CODE field. You can then read the function code from the auxiliary variable (for example, using a CASE structure), and control the program flow from there.

Reward if helpful.

Regards,

Sandhya

Read only

Former Member
0 Likes
2,526

Hi ravi,

see the link beow..

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

i hope it will help ful..

Thanks & Regards,

Mahendar

Read only

Former Member
0 Likes
2,526

OK_CODE is function code, like in module pool prog if u create a button on screen and assign fun code to it, then on click of that button OK_CODE will contain the fun code assigned to that button.

reward if useful

Read only

Former Member
0 Likes
2,526

hi

ok_code is of type sy-ucomm.

during runtime u get values in it corresponding to function code.

for example u create a save button,then give function code as save.

then when u press save the corresponding function code is obtained in ok

_code and action can be triggered.

.For each screens element list u should give ok_code.

Regards

shinu

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
2,526

Hi

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

Suppose for better explanation sake take the example of recording the Transaction.

At the time of Transaction Recording we use Enter and Save buttons normally.

When you press SAVE your every action is recorded by using the OK_COde.

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

Like that to recognise every user action on the screen Function codes are there for each user action.

Regards,

kumar

Read only

Former Member
0 Likes
2,526

Hi Ravi,

OK_CODE helps you to capture which button was clicked in your module pool screen. The OK_CODE is listed in the element list of you screen. The button can be in the application tool bar/one of the function keys/button on the screen layout. In the data declaration of your module pool ok_code must be declared as type sy-ucomm.

Now, in the PAI of you module pool you can do something like this....

if OK_CODE eq 'BACK'.

leave program.

endif.

*******************Reward if found useful************************

Regards,

Kriththika.

Read only

Former Member
0 Likes
2,526

HAI,

ok code is equal to sy-ucomm.it stores the temerory values which u r clicked

in some event.

Read only

Former Member
0 Likes
2,526

Ravi,

As ABAP is event driven programming, whenever user generates an event using key stroke, menu option,mouse click, system assigns a code to a system variable called SY-UCOMM,can also be called ok_code.

respective actions can be taken under respective ok_codes.

Regards,

Sujatha.