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

okcode concept

Former Member
0 Likes
544

hi experts, can any one give me the details abt that okcode concept with some example, what is the use........

4 REPLIES 4
Read only

Former Member
0 Likes
512

Ok code is system function and which will identify the user what is selecting option.

example : when user click on back button ,then BACK Ok code will trigger.

create one module pool program.

see the ABAPDOCU Transaction to get more examples

Read only

Former Member
Read only

Former Member
0 Likes
512

Hi Arun,

okcode is used to get the user command in the okcode. you can add okcode in the name column of the screen's element list tab to catch the ok code returned

CASE ok_code.

WHEN 'CLEAR'.

PERFORM clear_screen_200.

WHEN 'BACK'.

CALL SCREEN 100.

ENDCASE.

Regards,

George

Read only

Former Member
0 Likes
512

hi,

ok code is the one of the screen element.

<b>OK_CODE field</b>

Every screen has a twenty-character OK_CODE field (also known as the function code field), which is not displayed on the screen.

User actions that trigger the PAI event also place the corresponding function code into this field, from where it is passed to the ABAP program.

You can also use the command field in the standard toolbar to enter the function code.

You must assign a name to the OK_CODE field to be able to use it for a particular screen.

In each PAI event that a user triggers by choosing either a pushbutton on the screen or an element in a GUI status, the corresponding function code is placed into the system field SYST-UCOMM or SY-UCOMM and placed in the OK_CODE field (as long as the function code is not empty). Empty function codes are placed in neither the SY-UCOMM field nor the OK_CODE field.

<b>sample program.</b>

PROGRAM DEMO_DYNPRO_PUSH_BUTTON.

DATA: OK_CODE LIKE SY-UCOMM,

SAVE_OK LIKE OK_CODE,

OUTPUT(8) TYPE C.

CALL SCREEN 100.

MODULE USER_COMMAND_0100 INPUT.

SAVE_OK = OK_CODE.

CLEAR OK_CODE.

CASE SAVE_OK.

WHEN 'BUTTON_EXIT'.

LEAVE PROGRAM.

WHEN 'BUTTON_1'.

OUTPUT = 'Button 1'(001).

WHEN 'BUTTON_2'.

OUTPUT = 'Button 2'(002).

WHEN 'BUTTON_3'.

OUTPUT = 'Button 3'(003).

WHEN 'BUTTON_4'.

OUTPUT = 'Button 4'(004).

WHEN OTHERS.

OUTPUT = SAVE_OK.

ENDCASE.

ENDMODULE.

regards,

Ashokreddy.

Message was edited by:

Ashok Reddy