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
3,028

whats the function of ok_codE?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,158

Hi,

when ever u press a button in a screen the function code of that button will be stoored in okcode of the screen.

okcode is individual for each screen.

rgds,

bharat.

10 REPLIES 10
Read only

Former Member
0 Likes
2,158

OK_CODE is used to temporarily store the value of SY-UCOMM

Read only

Former Member
0 Likes
2,158

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.

In your application programs, the first step in PAI processing should be to save the function code in an auxiliary variable and then initialize the OK_CODE field. You can then read the function code from the auxiliary variable (for example, using a CASE structure), and control the program flow from there.

The OK_CODE field can have a different name on each screen. However, common practice is to use the same name for the field on each screen of an ABAP program. You then only need one field in the ABAP program, with the same name, into which the function code is placed, and from which you can read it.

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
2,159

Hi,

when ever u press a button in a screen the function code of that button will be stoored in okcode of the screen.

okcode is individual for each screen.

rgds,

bharat.

Read only

Former Member
0 Likes
2,158

Hi,

<b>ok_code</b> 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

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:

Regards

Sudheer

Read only

Former Member
0 Likes
2,158

Vijay Kumar,

OK_CODE is used to store the Action codes, it is similar to SY-UCOMM, but it is local to the screen. This OK_CODE will hold the ACTION code.

Regards

Vijay

Read only

Former Member
0 Likes
2,158

Hi Vijay,

The ok_code is of the type sy-ucomm.. Any interaction, which the user does with the screen, the function code gets returned in the system variable sy-ucomm. Even if you double click, it has a function code assigned to it. You capture these function codes and then depending on your requirement, you do further processing.

For example, you are displying a standard sales order details. on double clicking on any of the order no. you wish to show the item details in the next screen. In this case, as soon as the user double clicks, the function code &IC1 (can be found out by debugging ) is returned in the system variable sy-ucomm (or you declare variable ok_code type sy-ucomm). nOw check this variable and do further processing.

Hope this helps,

Reward points if useful.

Karan

Read only

Former Member
0 Likes
2,158

Page 6 of 13

Define the Screen Layout

Use the various options of the screen painter to place the text fields, input/output fields, pushbuttons required for the 2 screens.

Define the Screen Element Attributes

As far as possible, use dictionary data elements for the input/output fields so that the required attributes will be automatically set by SAP and the basic automatic validations checks will also be done by SAP.

To set the attributes of each field, select the field and double click on it to open the Attributes Screen.

Define the ok code field in the field list for the Screens

Whenever user does any interaction with the screens, a field is required to trap the action that the user is trying to perform. To do this, define 4 character variable by the name v_okcode_screennumber.

Assign function codes to the various buttons on the screen that the user is likely to press.

These function codes are then transferred via the variable to the flow logic of the screen, to decide the path to be taken by the flow of the transaction.

girish

Read only

Former Member
0 Likes
2,158

The main purpose of ok_code is to communicate in between abap program and screen program. When one press a push button on the screen the fct code of that is stored in the ok_code like sy-ucomm.

when program call the ok_code field it supplie fct code of the push button. Consequently it performs the function of the push button.

Regards

Read only

Former Member
0 Likes
2,158

thanks

Read only

Former Member
0 Likes
2,158

hi vinay,

OK_CODE is used to temporarily store the value of SY-UCOMM

if helpful reward some points.

with regards,

suresh babu aluri.