Skip to Content
avatar image
Former Member

Difference Between SY-UCOMM and OK_CODE

Hello ,

What is the Exact difference between <b>SY-UCOMM and Ok-Code</b>?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2006 at 12:12 PM

    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.

    Regs,

    Venkat Ramanan N

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      SY-UCOMM is, a system field in SYST structure which holds Function Codes.

      OK_CODE is a variable. It Generally using for to be a copy of SY-UCOMM in screens. sometimes there are some problems in screens. this is why OK_CODE is using instead of SY-UCOMM in screens.

      ibrahim

  • avatar image
    Former Member
    Sep 04, 2006 at 12:12 PM

    Hello,

    sy-ucomm is a system field, contains the code of the buttom or the menu that was cliked in the screen.

    OK_code is a variable of the screen defined like sy-ucomm. Contains the value of sy-ucomm.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 04, 2016 at 07:05 AM

    Hello,

    sy-ucomm is system field. sy-ucomm is basicaaly used for doing the functions what the user wishes to to do at that particular event while Ok_code is user defined temporary variable which is used in screens.
    It stores the value of sy-ucomm. Whenever there is a user interaction on the sceen the function code assigned is filled in the sy-ucomm which further changes the value of ok_code. Now using ok_code we can do manipulations in our main program.

    Add comment
    10|10000 characters needed characters exceeded