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

Why the OKCODE is set automatically?

former_member249594
Participant
0 Likes
2,809

I have a table control in the screen and I set the select column for the table control.The first column of the table control is a button(OKCODE is MSGI) column , we use this button to generate a screen(we call it messages screen) to display the error messages of the corresponding line item in the table control. Actually the program works well as far as I had countered below problem.

The problem is:

when I entry the data in the table control, and then I select one row and the selected row in table control is highlighted(become yellow). And then I press the ENTER key in keyboard, but It is strange that the message screen is displayed. I debug the program and I found that the OK CODE is automatically set to the message button(OKCODE MSGI). But in the whole process I had not click this button.

I was confused by this problem. Please any friends had countered this problem and you can give me some idea to solved this problem.

PS: I clear the okcode and sy-ucomm at last the PAI process.

Thanks in advance.

Joe

Edited by: Gangrong Chen on Jul 2, 2010 1:59 PM

9 REPLIES 9
Read only

Former Member
0 Likes
1,867

Hi Joe,

Could you please try with the below logic,

In the PAI module user_command:

Data: g_save_ok_code type sy-ucomm.

G_save_ok_code = ok_code.

Clear ok_code.

.

.

.

Then check the variable g_save_ok_code instead of ok_code in the block.

I had the same issue and it got solved once I did like above. Hope, your problem is also the similar one.

Regards,

Selva K.

Read only

Former Member
0 Likes
1,867

Hi Joe,

try to clear your ok code while PBO.

regards

rea

Read only

Former Member
0 Likes
1,867

Hi Joe,

Go to GUI status -> Function keys -> Give function code 'ENTER' for first button (previous to SAVE button)

Now execute your program and press ENTER button, henceforth OKCODE will always have function code 'ENTER' so it will never affect your logic.

-Amol

Read only

former_member249594
Participant
0 Likes
1,867

Hi Friends,

Thanks very much for your kindly response. I had tried your idea but I am sorry that my issue is still not solved.

I am afraid that I should give up handling this issue, because I found that the standard SAP program have this problem as well. For example, we change the purchase odrder item through ME22N, if the PO items have error mesage then the Status button column of the table control will show a led-red icon to indicate the status of the line item. Now if you select this line item and press ENTER, the message screen will be shown out.

Thank you.

Joe

Read only

0 Likes
1,867

Joe,

Not sure if I follow, but basically pressing ENTER key triggers empty function code. This means that if there was previous function code value in OK_CODE you would be getting the same value each time after you press ENTER. So I think this is a matter of clearing the OK_CODE each time at the end of PAI and evaluate real function code value in some addtional SAVE_OK data object.

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

Regards

Marcin

Read only

Former Member
0 Likes
1,867

HI,

I think wen u select the row ur cursor might be on the button of table control , so wen u press enter the okcode = msg is triggered

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,867

Its not automatically set, after previous assignment of ok code its not cleared.

Read only

former_member249594
Participant
0 Likes
1,867

I am afraid that I have to agree with Madhukar Shetty 's idea.

Below is my code of user-command modue in PAI.


*PAI*
PROCESS AFTER INPUT.
  CALL SUBSCREEN : left_sel,
                   right_sel,
                   window .
  MODULE user_command_2000.


MODULE user_command_2000 INPUT.
  save_ok_code = ok_code.
  CLEAR ok_code.
  PERFORM user_command_2000.
  CLEAR save_ok_code.
ENDMODULE.                 " USER_COMMAND_2000  INPUT


FORM user_command_2000.
  CASE save_ok_code.
    WHEN zfisc_s_okcode-is_execute OR zfisc_s_okcode-is_re_execute.
      PERFORM select_data.
    WHEN zfisc_s_okcode-is_back OR
         zfisc_s_okcode-is_up   OR
         zfisc_s_okcode-is_cancel.
      PERFORM leave_program.
    WHEN zfisc_s_okcode-is_save.
      PERFORM save_entry.
    WHEN zfisc_s_okcode-is_dbclick.
    WHEN zfisc_s_okcode-is_change_display_shift.
      PERFORM shift_display_change_mode.
    WHEN zfisc_s_okcode-is_check.
      PERFORM check_all_entries.
    WHEN zfisc_s_okcode-is_check_item          OR
         zfisc_s_okcode-is_wbs_range               OR
         zfisc_s_okcode-is_display_item_msg     OR
         zfisc_s_okcode-is_delete_single_item    OR
         zfisc_s_okcode-is_release_single_item.
      PERFORM handle_single_entry.
  ENDCASE.
ENDFORM.                    " USER_COMMAND_2000

The first column in table control is a message button and the function code is zfisc_s_okcode-is_display_item_msg(a constant defined in type-pool ZFISC ). If the item is selected in table control and then you press ENTER in keyboard, the subroutine PERFORM handle_single_entry is triggered. The ok_code is cleared in PAI, so I do not think it is a metter of clearing ok_code.

Read only

former_member249594
Participant
0 Likes
1,867

JUST CLOSE THE THREAD