Skip to Content
-1

OK Code greyed out in Module pool

Aug 24, 2017 at 03:12 AM

226

avatar image

Experts,

I am editing an existing custom module pool program that has table control. I see that OK_CODE has not been assigned against OK field in element list

When i do scroll up or scroll down in table control, i see that old function code value is coming in SY_UCOMM. For example, i have added custom buttons to add rows in table control as below,

If i scroll up or down in table control after clicking ADD button, i see that function code has incorrect value ADD mapped for ADD button. This is simply adding more and more rows in table control each time i scroll down.

Please share your valuable inputs.

BR,

Aspire

ok-code.png (7.8 kB)
buttons.png (20.0 kB)
10 |10000 characters needed characters left characters exceeded

SY-UCOMM, not SY_UCOMM.

0
Former Member

Oops. Sorry typo. Thanks Sandra.

0
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Sandra Rossi Aug 24, 2017 at 05:31 AM
2

First, it's protected because the dynpro is of type subscreen, i.e. it will be displayed inside a general dynpro (full screen) or inside a modal popup dynpro. The OK field may be defined only in one of the two latter types of dynpro.

In the ABAP documentation, it's explained why you should use an OK field instead of SY-UCOMM. It's because SY-UCOMM keeps its last value when Enter is pressed, while the OK field is blanked out.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sandra,

Thanks a lot for your valuable reply. Now i understand why OK field in element list is greyed out. You are absolutely correct - My table control is called as part of a subscreen as below,

ADD, DELETE, SELECT ALL & DESELECT ALL are the four buttons that i have added as part of a normal screen(Screen no;100) and table control with title 'Questionnaire' is called as part of subscreen(Screen no: 102). I see that GV_OK has been assigned against OK field in screen 100 as below,

In my code, i am not referring sy-ucomm anymore. I am referring GV_OK as below:

In the end of module user_command input, i am clearing GV_OK variable. I see that GV_OK gets old function code when i scroll up or scroll down. Can you please tell me what i am doing wrong here.

BR,

Aspire

screen1.png (45.3 kB)
okcode.png (39.0 kB)
gv-ok.png (36.3 kB)
0

In fact, you must clear out the OK field during the PAI because the Enter and Scroll keys do not change its latest value.

SAP has invented the OK field because the ABAP programs should not change the System Fields themselves (like SY-UCOMM).

For handling the scrolling, you must use the data object declared using CONTROLS. It's a structure which has for instance CURRENT_LINE and TOP_LINE components. You use them during the LOOP in both the PAI and the PBO of your subscreen to transfer the lines on the screen to your internal table, and vice versa.

See for instance the demo program DEMO_DYNPRO_TABCONT_LOOP.

1

Hi Sandra,

Do we still have points system in SCN? I would like to award points for your answer but do not see an option for the same.

BR,

Aspire

0
avatar image
Former Member Aug 24, 2017 at 10:13 AM
0

Hi Sandra,

I have assigned function code DEL for DELETE button. If user does not choose the checkbox which is 1st column for every record in table control & if they simply click DELETE button, I am raising error message - "Select atleast 1 record to delete" as below,

Step 1: Without choosing a checkbox if i click delete button, i am getting error message as expected. GV_OK has value 'DEL' (Function code for DELETE button).

Step 2: Now i am scrolling down using touchpad area of my laptop. GV_OK still has old function code value 'DEL'. This is incorrectly raising the error message "Select atleast 1 record to delete".

How can i make sure that old function code value is not assigned to GV_OK?

BR,

Aspire


del.png (30.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Aug 24, 2017 at 10:18 AM
0

Hi Chandan,

My initial approach was to assign SY-UCOMM value to a variable GV_OKCODE. I realized this is not required as there is a variable GV_OK which has already been assigned in element list for screen 100 against OK code field. This means that whatever is the ok code from screen 100, it will always be stored in this variable GV_OK. So i am directly accessing this field GV_OK in program rather than refer to SY-UCOMM.

As per your suggestion, I am clearing GV_OK at the end of PAI module. Still old function code is retain in this variable.

BR,

Aspire

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Aug 24, 2017 at 10:36 AM
0

The easiest solution for me is to remove the error message for DELETE button. This way, i will not get the incorrect error message "Select atleast 1 record to delete" when i scroll down. This can be 1 workaround solution.

Let us take ADD button scenario. When i click ADD button, 1 row is added to table control.

Step 1: Click add button. GV_OK has function code as ADD. 1 row is added to table control as expected

Step 2: Scroll down the table control. Now, old function code ADD is retained in GV_OK and it keeps adding records every time i scroll down in table control. This is incorrect. Expected output is that GV_OK should have blank value when we scroll down and no new records should be added when we scroll down in table control.

Can you please help me understand what is missing.

BR,

Aspire

Share
10 |10000 characters needed characters left characters exceeded
Surbjeet Dhillon Aug 24, 2017 at 10:59 AM
0

Hi Aspire,

My suggestion would be to use the Table Control Wizard as it generates most all the code for you.

If you want to continue with your current design then follow thes steps:

1) Declare a global called save_ok of type sy-ucomm

2) in the PAI module where you are checking the ok code add this code to the top:

save_ok = GV_OK.
CLEAR GV_OK.
case save_ok.
when 'DEL'.
...
endcase.

The above code will ensure GV_OK does not keep its previous value which is causing your problem.

Che

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Che,

Thanks for your reply. Tried your suggestion. I created a global variable GV_OKCODE and i am assigning value of GV_OK to this variable as below,

I am clearing the value of GV_OKCODE outside CASE statement as below,

I still see that GV_OK field from screen's element list is having old function code & the same old value is passed on to GV_OKCODE variable.

BR,

Aspire

gvokcode.png (30.3 kB)
clearok.png (31.3 kB)
0
Replace CLEAR gv_okcode.
with CLEAR gv_ok.
0

Hello Bharath,

Have you tried the suggestion from Che Eky to replace CLEAR gv_ok_code with CLEAR gv_ok?

Thanks,

Chandan

0
Chandan Saurav Panda Aug 24, 2017 at 04:09 AM
0

Hello,

I think you can solve this by creating one new variable like gv_okcode and assigning SY-UCOMM to it at start of your PAI block. Then do your all processing based on the value of gv_okcode. At last clear the gv_okcode.

Please try this.

Thanks,

Chandan

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Chandan,

I am doing as you suggested. I see that whenever i use scroll down in my laptop's touchpad area, whatever was the old function code, the same gets assigned. For example, I have added a checkbox as first field in table control so that users can choose multiple records & click delete button. This is working as expected. If user clicks delete button without clicking checkbox, i am raising error message - Choose atleast 1 record to delete.

Assume user deletes a record on screen. Now if we scrolls down, I am incorrect getting error message 'Choose atleast 1 record to delete'. This is happening because old function code for DELETE button gets carried over.

BR,

Aspire

0
Aspire WF Sep 05, 2017 at 01:28 AM
0

All,

Thanks a lot for your valuable help. As suggested by Sandra, I realized that my table control has been embedded in a subscreen & that is why ok code was greyed out. I notice that in main screen where this subscreen is called, ok code is enabled.

Add, select all, delete & deselect all buttons were handled using ucomm from main screen.

BR,

Aspire

Share
10 |10000 characters needed characters left characters exceeded