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

OK_Code?

Former Member
0 Likes
1,214

hi,

I'm am just looking for confirmation and clarification - is an OK_CODE simiilar to a specialized return code

thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
707

OK_Code is a variable used to keep the system user command values , which is nothing but sy-comm.

Chk this for more.

http://help.sap.com/saphelp_47x200/helpdata/en/d1/801e61454211d189710000e8322d00/frameset.htm

Read only

Former Member
0 Likes
707

hi,

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.

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.

Global data declarations:

DATA: OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE SY-UCOMM.

Your ABAP program must contain a field with the same name as the OK_CODE field on the screen. To specify the type, you should refer to the system field SY-UCOMM, since this always corresponds to the type of the OK_CODE field on the screen. At the same time, you should declare an appropriate auxiliary variable.

PAI module:

MODULE USER_COMMAND_100 INPUT.

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

CASE SAVE_OK.

WHEN...

...

ENDCASE.

ENDMODULE.

In the first PAI module, you should assign the contents of the OK_FIELD to the auxiliary variable and then clear the OK_CODE field and carry on working with the auxiliary variable.

OK_CODE is for Batch input session to enter the key strokes that simulate actions to move from once screen to another.

I hope it will be helpful for you.

Regards,

Arunsri

Read only

Former Member
0 Likes
707

HI,

OK_CODE is nothing else as standard element on screen (like input/output), but it's hidden...

This elelements value is populated with System Code (event code, let's say from button click).

OK_CODES are for programs to process after input from the user and are defined in the GUI Status of a program.

However /$sync is an SAP command and although they both can go in the command box they are not the same as each other (as I understand it)

Cheers,

Chandra Sekhar.