Skip to Content
-1

OK Code greyed out in Module pool

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Aug 24, 2017 at 05:31 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

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

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 24, 2017 at 10:18 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 24, 2017 at 10:36 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 24, 2017 at 10:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 24, 2017 at 04:09 AM

    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

    Add comment
    10|10000 characters needed 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

  • Sep 05, 2017 at 01:28 AM

    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

    Add comment
    10|10000 characters needed characters exceeded