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

DIFFERENCE BET 'SY-UCOMM' AND 'OK-CODE'..?

Former Member
0 Likes
2,661

HI,

I AM SIVA,

I AM NEW FOR ABAP,

I AM LITTLE BIT NOT UNAWARE OF DIFFERENCE BET SY-UCOMM AND

OK-CODE..

PLEASE SEND ME ANSWER ...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,092

Hi Siva Reddy,

Hello,

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 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.

Reword some points.

Rgds,

P.Naganjana Reddy

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,092

Use SY-UCOMM when dealing with regular report programs. USe OK_CODE in your screen(dynpro) programming. Every dynpro allows you do specify the OKCODE for the screen, it is the field type "OK", usually ABAPERs will name this field in the screen as OK_CODE.

They do the same thing, SY-UCOMM is the system field which is to be used in interactive reporting, OK_CODE more used for module pool programming or dialog programming.

Regards,

Rich HEilman

Read only

Former Member
0 Likes
1,092

<b>OK-CODE FIELD:</b> :

Also called function code field.

Internal work field for storing a defined function code.

When the user triggers a function in a transaction, the system copies the function code into the OK code field OK_CODE.

The contents of the field are evaluated in the corresponding PAI module.

<b>SY-UCOMM</b>

Is the system field.

Used to access the function code.

Regards,

Shobana.

Read only

Former Member
0 Likes
1,093

Hi Siva Reddy,

Hello,

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 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.

Reword some points.

Rgds,

P.Naganjana Reddy

Read only

0 Likes
1,092

hi,

thanks for clarifying my doubt,

thank you,

yours,

siva.