Skip to Content

This is my first blog, please feel free to point out the mistakes.

It’s always tedious to find out the function code in standard screens e.g. a pushbutton inside a custom control. In this case, say a button click event cannot be captured throughout the flow of the standard program on all places.

When we want to know the function code on our exact part of code it will be dynamically assigned like ‘%_GC 178 10’ and it cannot be used directly to know what the user function is. This might be the case we may face when we do any enhancement to the standard program.

I’ve searched through out the community network and couldn’t find a convincing way of knowing the function code. Any reference to the GUI is a private attribute (I don’t know why SAP wants to hid the function code)

After extensive analysis I found out a way to know the function code. I think it may help someone who is in search of such a scenario and so I am sharing the idea.

It’s a simple way of two method calls as explained below.

Scenario – I want to change the standard ‘PRINT’ (the one marked) for a supplementary customs declaration page. This subscreen is a custom control tab and buttons get dynamic function codes which are processed to know the actual function code (here it is ‘&PRINT_BACK’) when it’s necessary.

sdnimage.JPG

I have to capture the Print function code and insert our business logic instead of standard printing.

Inside the USER_COMMAND for the custom control, I’ve created an Implicit enhancement where the OK_CODE for this Print button is this junk ‘%_GC 178 10’.

There are no attribute to give the correct OK_CODE and so I have used the following logic to fetch the same

  DATA: lo_control TYPE REF TO cl_gui_control,

        lv_event TYPE string.

  FIELD-SYMBOLS: <lo_event> TYPE REF TO cl_gui_event.

  IF ok_code+0(4) EQ ‘%_GC’.

    CALL METHOD cl_gui_control=>get_focus

      IMPORTING

        control           = lo_control

      EXCEPTIONS

        cntl_error        = 1

        cntl_system_error = 2

        OTHERS            = 3.

    IF NOT lo_control IS INITIAL.

      ASSIGN lo_control->cur_event TO <lo_event>.

      CALL METHOD <lo_event>->get_event_param

        EXPORTING

          pid   = ‘0’

        IMPORTING

          value = lv_event.

    ENDIF.

ENDIF.

LV_EVENT carries the current function code. Here in this case, it contains &PRINT_BACK.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Clemens Li
    Thanks a lot – I always wondered how the cryptic ucomms were related to event codes.

    On the other hand, I’m happy I can register events so that there is no need to care about internal handling.

    (0) 
  2. Amit Gujargoud
    Hi Kothand,

    Thanks for the sharing this info! Adding to your blog please do not forget to cal FLUSH command right after method GET_FOCUS.
    CALL METHOD cl_gui_cfw=>flush

    Cheers
    Amit

    (0) 
  3. Alejiandro Sensejl
    Wouldn’t it have been much easier to replace the print button with a custom one and do a proper event handling? It looks a little bit insane to me to enhance the standard implementation…

    Regards,
    Alej

    (0) 
    1. Kothand Murugan Post author
      Hi Alej,

      Well, its conditional. Not in all cases, the business needs different way of processing. Only for very specific type, they need to have different processing way. For other types of SCD, the standard should be functional

      Regards,
      Kothand

      (0) 

Leave a Reply