‎2007 Oct 31 12:00 PM
Hi,
Can any one tell me the difference between ok_code and sy-ucomm
‎2007 Oct 31 1:50 PM
Hi,
Actually OK_CODE and SY-Ucomm are the same. But experts suggest use of OK code for following reason:
In each PAI event that a user triggers by choosing either a pushbutton on the screen or an element in a GUI status, the corresponding function code is placed into the system field SYST-UCOMM or SY-UCOMM and placed in the OK_CODE field (as long as the function code is not empty). Empty function codes are placed in neither the SY-UCOMM field nor the OK_CODE field.
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.
‎2007 Oct 31 1:50 PM
Hi,
Actually OK_CODE and SY-Ucomm are the same. But experts suggest use of OK code for following reason:
In each PAI event that a user triggers by choosing either a pushbutton on the screen or an element in a GUI status, the corresponding function code is placed into the system field SYST-UCOMM or SY-UCOMM and placed in the OK_CODE field (as long as the function code is not empty). Empty function codes are placed in neither the SY-UCOMM field nor the OK_CODE field.
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.
‎2007 Nov 01 5:18 AM
both are same (ok_code and sy-ucomm )
we will actually store ok_code = sy-ucomm
As actual programing std we should not compare system variables direclty
so we need to store it in some local variable and compare the user command so ok_code we need to compare.
There is no diffrence in ok_code and sy-ucomm.
‎2007 Nov 01 5:22 AM
Hi Pavani,
Check the following links for the difference between ok-code and sy-ucomm
Reward points if helpful.
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/
‎2007 Nov 01 8:02 AM
Hi Pavani,
Sy-ucomm, Ok_code and local variable. They must be used in the reverse order. I mean declare a local variable like
data : save_ok type sy-ucomm.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.
Reward points if useful,
Aleem.
‎2008 Feb 28 10:23 AM
Hi,
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...
Reward points if usefull to u,
Regards
fareedas
‎2008 Feb 28 10:28 AM
hI
Difference between sy-ucomm Vs OKcode
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