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 does take value

Former Member
0 Likes
1,473

Hi,

I'm learning Dialog programming. I created a Dialog program to get the Details of a Particular plane on a given date. I also created a GUI STATUS.

As far I know, value in OK_CODE field is set automatically during runtime. I have defined it as follows:

DATA ok_code like sy_ucomm.

The problem is : ok_code value is initial during runtime. There is no value in OKCODE field. When I use sy-ucomm directly, the code works fine.

I need to use EXIT, BACK, and CANCEL buttons. Unable to do so due to this problem.

I have no idea how to over come this. Could any one please help me,

Thanks

Ashish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,150

Set the value of OK_CODE field just before, you want to use it. It automatically does not hold any value. So wherever you are performing any operation based on OK_CODE, use this stmt. OK_CODE = SY-UCOMM. and ignore using sy-ucomm directly in your program. And define this OK_CODE field at both places, once in the screen's element list and another in your program.

Edited by: Sujeet Karn on Dec 22, 2009 6:55 PM

8 REPLIES 8
Read only

Former Member
0 Likes
1,150

Hi,

Have you defined OK_CODE in the screen layout - Element list?

Read only

0 Likes
1,150

Hi,

I have defined OK_CODE field in the TOP include of the program.

Read only

Former Member
0 Likes
1,151

Set the value of OK_CODE field just before, you want to use it. It automatically does not hold any value. So wherever you are performing any operation based on OK_CODE, use this stmt. OK_CODE = SY-UCOMM. and ignore using sy-ucomm directly in your program. And define this OK_CODE field at both places, once in the screen's element list and another in your program.

Edited by: Sujeet Karn on Dec 22, 2009 6:55 PM

Read only

0 Likes
1,150

Hi,

Thank you very much for the reply. I'll try that. Could you please tell how to define OK_CODE field in Screen Element list?

I have defined this field only in TOP Include of the dialog program as follows. DATA ok_code like sy-ucomm.

Ashish

Read only

0 Likes
1,150

Go to SE51 and enter your program name and screen number. Dont click on 'Layout' button. There you can see three tabs.. 1. Attributes, 2. Element List, 3. Flow Logic. Click on 2nd Tab.

You need to define this OK_CODE in this under 'General Attributes'.

Read only

0 Likes
1,150

Sujeet already explained the way how it must be done to work. I only would like to add some useful link which I think you should get familiar with

http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dbaa1335c111d1829f0000e829fbfe/frameset.htm

I will help you to uderstand the concept of saving ok_code .

Regards

Marcin

Read only

0 Likes
1,150

Thank you very much. Defining the OK_CODE field in the Screen Element List solved the problem.

Full Points awarded to you. Thanks a lot.

Ashish

Read only

0 Likes
1,150

Hi Marcin,

Thank you very much for the link. Helped me a lot.

There are 2 methods according to TAW12 material:

1) MODULE clear_okcode OUTPUT.

CLEAR OK_CODE.

ENDMODULE.

2) MODULE clear_okcode INPUT.

save_ok = OK_CODE.

CLEAR OK_CODE.

ENDMODULE.

But they failed to mention that OK_CODE had to be defined in SCREEN Element List as well.

Thanks a lot for the help guys.

Ashish