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

sy-ucomm and okcode

Former Member
0 Likes
2,396

Hi friends,

Can any one tell me what is the difference between

sy-ucomm and okcode.

cheers,

uday

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,600

sy-ucomm is for doing the functions what the user wishes to do at that particular

event.You use it in menus and other place . this mainly in using <pfstatus>

ok_code is generally used in screen as of I have used.

You will define the function in the screen. and you can use it in the main program.

ok_code acts just as a temporary variable that stores the value of sy-ucomm.

When user interacts with the screen elements, the function code that you have

assigned is filled in the sy-ucomm field which is turn gets reflected in OK_CODE.

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 PAIevent,

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.

5 REPLIES 5
Read only

Former Member
0 Likes
1,601

sy-ucomm is for doing the functions what the user wishes to do at that particular

event.You use it in menus and other place . this mainly in using <pfstatus>

ok_code is generally used in screen as of I have used.

You will define the function in the screen. and you can use it in the main program.

ok_code acts just as a temporary variable that stores the value of sy-ucomm.

When user interacts with the screen elements, the function code that you have

assigned is filled in the sy-ucomm field which is turn gets reflected in OK_CODE.

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 PAIevent,

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.

Read only

Former Member
0 Likes
1,600

Hi,

the sy-ucomm value of the screen is placed in the okcode of that screen.

rgds,

bharat.

Read only

Former Member
0 Likes
1,600

OK_CODE is for Batch input session to enter the key strokes that simulate actions to move from once screen to another.

SY-UCOMM - is the user input value/key pressed by user used in Interactive reporting...

Sy-ucomm, Ok_code and local variable. They must be used in the reverse order. I mean declare a local variable like

codedata : save_ok type sy-ucomm.[/code]

and transfer the contents of ok_code to save_ok. Use save_ok in your code.

The reason save_ok is your variable there is no chance of system automatically resetting it. Where as if you use Ok_code which is global to the entire module pool program system may automatically change the variable in another screen and you may get un-known result.

Now coming to Sy-ucomm its system variable global to all programs. Hence system may change it any time in any program.

Hence to avoid confusion we must use these in the order of preference given below.

local variable (Save_ok) ---> Ok_code -


> sy-ucomm.

Check the following links for the difference between ok-code and sy-ucomm

http://www.sap-img.com/abap/sy-ucomm-and-ok-code-in-dialog-program.htm

http://www.saptechies.com/difference-between-sy-ucomm-and-ok_code-in-dialog-program/

http://www.geekinterview.com/question_details/46351

Reward points if helpful.

Read only

Former Member
0 Likes
1,600

Hi,

sy-ucomm is nothing but it 'll get user command for a particular object from screen that u hav declared in okcode.

it is used in progarm level.

okcode. it is the field tht gets value from the screen which action has selected... then u have to transfer the value to sy_ucomm to process next task.

it is used in screen level

Thanks.

Reward if useful.

Arunprasad.P

Read only

p291102
Active Contributor
0 Likes
1,600

Hi Uday and srinivaalu,

This is not the correct place for showign your friendship's and all. I am seeing 3 threads uday u r asking the question srinivasalu giviing the answers. Uday u r putting the mark as like 10 . U r not concentrating other experts answers also.

So dont cheat others valuable informations and their timings.

Really if u r having the doubts ask properly and validate the answers given by all.

This forum is not showing your friendship's.

Thanks,

Sankar M