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: 

difference b/w ok_code and sy-ucomm in module pool ?

Former Member
0 Kudos

hai abap gurus,

ok_code and sy-ucomm store the function code of the element.. then y do v use ok-code in the program. y dont v use sy-ucomm... pls clear my doubt...

1 ACCEPTED SOLUTION

Former Member

Both are same and contains function code

diff:

1) OK_CODE is of type SY-UCOMM created with screen by default.

but SY-UCOMM is present in the DDIC structure (SYST structure)

2) when some even occurs, SY-UCOMM is set with the value and we need to explicitly assign the value to the OK_CODE.

so in short ..

OK_CODE is a screen element and SY-UCOMM is present inthe general DDIC structure SYST which is also called system field table

reward points if useful

Edited by: Reji Prabhakaran Konnasseri on May 29, 2008 8:40 AM

7 REPLIES 7

Former Member
0 Kudos

Hi

During internal processing value of sy-ucomm may change. So we store its value in ok_code.

Aditya

prasanth_kasturi
Active Contributor
0 Kudos

hi,

both are the same. they contain fct code.

as sy-ucomm is a system variable its value keeps on changing

so if its a push button sysytem places the fct code in ok_code(screen specific) for further usage

regards

prasanth

krishnendu_laha
Active Contributor
0 Kudos

Hi Friend,

SY-UCOMM and OK_CODE both stored function code.

OK_CODE is screen specific; if you have declared in a screen it will contain values for that screen. And if screen changes the value will not change or does not conatin next screen's function code.

SY_UCOMM contains both screen's fcode and does not depend on screen or any other object.

Regards

Krishnendu

0 Kudos

what will happen if v use sy-ucomm instead of ok_code ?

0 Kudos

hi,

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.

Former Member
0 Kudos

Difference b/w ok_code and sy-ucomm

It is not obligatory that you write OK_CODE, it is just a denomination from SAP. You can declare any name for the variable in your code that is going to trap the transaction code of the button that the user pressed.

OK_CODE is used in SAP Dialog Programming, while SY-UCOMM is used all around SAP (classes, SAP Dialog Programming, ABAP, forms, and a long etc.).

receive the contents of the corresponding screen fields means the transaction code that you assign at development time to the objects on the screen, which should trigger an event (buttons tipically or folders in a folder control).

Regards,

Raj.

Former Member

Both are same and contains function code

diff:

1) OK_CODE is of type SY-UCOMM created with screen by default.

but SY-UCOMM is present in the DDIC structure (SYST structure)

2) when some even occurs, SY-UCOMM is set with the value and we need to explicitly assign the value to the OK_CODE.

so in short ..

OK_CODE is a screen element and SY-UCOMM is present inthe general DDIC structure SYST which is also called system field table

reward points if useful

Edited by: Reji Prabhakaran Konnasseri on May 29, 2008 8:40 AM