Skip to Content
Author's profile photo Former Member

How to read Function code from %GC_

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.


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


        control           = lo_control


        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


          pid   = ‘0’


          value = lv_event.



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

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi
      Hi Kothand, I always wondered how it worked, thanks a lot for your finding!
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Some customers always get what they want, at any cost 🙂
      Author's profile photo Clemens Li
      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.

      Author's profile photo Amit Gujargoud
      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


      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Amit,

      True. The warning inside this static method is BOLD :). Thanks a lot


      Author's profile photo Alejiandro Sensejl
      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...


      Author's profile photo Former Member
      Former Member
      Blog 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