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: 

hai all

Former Member
0 Kudos
95

What is ok_code in BDC? ok_code referes what command in bdc?

4 REPLIES 4

Former Member
0 Kudos
60

hi,

SAP recommends that in dialog program always use OK_Code instead of sy-ucomm. Here is what the help says

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.

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba99935c111d1829f0000e829fbfe/content.htm

This is a long standing issue dating back many years. The general answer is that you control the OK_CODE field while SAP controls the SY-UCOMM field. You assign field OK_CODE to the OK code field in the screen painter and SAP copies SY-UCOMM to your OK_CODE field. Now you have control over the value. If you start invoking other code, like SAP utilities that display screens, you can be guaranteed that the value in OK_CODE will still be there, while you have no idea what SAP might be doing with SY-UCOMM.

This is a design decision that was probably made about 20 years ago when screen processing was introduced. In most cases, you can probably use SY-UCOMM and not have any problems but there are probably cases out there where SAP has done something tricky and you will have a problem.

Because there are unknowns out there, I always define an OK_CODE and do not use SY-UCOMM for standard screen processing. For me this is a long standing habit.

OK_Codes are like function code for each button or for any action on the screen.

When you press SAVE or when you Press some Button on the screen, your every action is recorded by using the OK_COde.

for example for ENTER button it is '/00'.

While you record BDC's using SHDB you will come to know all these OK codes.

Former Member
0 Kudos
60

Hi,

BDC_OKCODE: It is the Function Code , Sap provide Function code for every user action, like when user click any button or menu item each and every thing having Function code, that is called OK-Code.

u can see okcode Like:

1. single click on one button on screen & drake

ur mouse cursor down (out of sap screen) then press F1

2. U can see Function code

BDC_OKCODE will store all the ok codes in the BDC program, when you pass the Fields to a scrren after filling the fields we need to click any button to move other screens, so here the Button will be have a OK_CODE internally to know this we do the recording of the Program, after that we will store this OK code in the BDC_OKCODE field to trigger the next operation

Few lines to understand what is BDC-OK code:

In BDC recording/program processing we pass OK Code for the User actions like ENTER or SAVE or pressing some button on screen.

so these actions will be stored in some function codes and we use them in BDC

like the sy-ucomm of ABAP programs.

You should also always initialize the OK_CODE field in an ABAP program .

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.

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.

BDC_OKCODE identifies the command field

it can use function key number or function code

/ for function key number and = for function code

'/00'-->Enter

'/3' -->Back function key

'/15'-->Quit function key

'/11'--> save

All functions in menus and buttons are identified by function codes

Regards,

Padmam.

Former Member
0 Kudos
60

Hi,

Reward Helpful Answers & Close the Thread if it resolves ur Query.

Thanks & Regards,

Padmam.

Former Member
0 Kudos
60

BDC_OKCODE identifies the command field

it can use function key number or function code

/ for function key number and = for function code

'/00'-->Enter

'/3' -->Back function key

'/15'-->Quit function key

'/11'--> save

All functions in menus and buttons are identified by function codes

Refer this link:

Pls reward points.

BDC_OKCODE: It is the Function Code , Sap provide Function code for every user action, like when user clike any button or menu item each and every thing having Function code, that is called OKcode.

u can see okcode Like: 1 single click on one button on screen & drake

ur mouse cursor down (out of sap screen) then press F1

2. U can see Function code

BDC_OKCIDE will store all the ok codes in the BDC program, when you pass the Fields to a scrren after filling the fields we need to click any button to move other screens, so here the Button will be have a OK_CODE internally to know this we do the recording of the Program, after that we will store this OK code in the BDC_OKCODE field to trigger the next operation

BDC_OKCODE identifies the command field

it can use function key number or function code

/ for function key number and = for function code

'/3' -->Back function key

'/15'-->Quit function key

'/11'--> save

All functions in menus and buttons are identified by function codes

Few lines to understand what is BDC-OK code:

In BDC recording/program processing we pass OK Code for the User actions like ENTER or SAVE or pressing some button on screen.

so these actions will be stored in some function codes and we use them in BDC

like the sy-ucomm of ABAP programs.

You should also always initialize the OK_CODE field in an ABAP program .

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.

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.