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: 

Regarding OKCODE

Former Member
0 Kudos
121

Hi

Can you please tell me what is the purpose of OKCODE in Module Pool Programming.

Why Can't We use SY-UCOMM directly.

Is there any diffreence in performance because of sy-ucomm usage.

Regards

Sandeep.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
77

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.

Reward if you are convinced,

Regards,

Ram.

2 REPLIES 2

Former Member
0 Kudos
78

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.

Reward if you are convinced,

Regards,

Ram.

Former Member
0 Kudos
77

okcode is a temporary variable storing a value of sy-ucommwhich is triggered in pai when ever we press a button or scroll,the function code associated is assigned to okcode.

we can use sy-ucomm instead of okcode but performance reasons, like

1.we cannot change the value of system variables,and if

2.we use sy-ucomm many times there is a chance of mis interpretation there by increasing system time.

therefore,we generally use okcode for every screen element which has a function code and we must initialise it,else may give a warning..

reward if helps.