Question

I want to overwrite some function in an ALV grid. But I can't manage to do it with a callback usercommand. this is just for non-standard functions. any idea? should I use a event exit? I tried something with it but couldn't do it either :P

FORM event_exits.

  CLEAR wa_eventexit.
  wa_eventexit-ucomm = '&OUP'.
  wa_eventexit-before = 'X'.
  APPEND wa_eventexit TO it_eventexit.
  CLEAR wa_eventexit.
  wa_eventexit-ucomm = '&ODN'.
  wa_eventexit-before = 'X'.
  APPEND wa_eventexit TO it_eventexit.

ENDFORM.                     "event_exits

FORM user_command Using r_ucomm LIKE sy-ucomm
                    rs_selfield TYPE slis_selfield.
 CASE r_ucomm.
    WHEN '&OUP'.
      IF ck_del = 'X'.
        SORT gt_salord BY audat vbeln lfimg ASCENDING.
      ELSE.
        SORT gt_salord BY audat vbeln kwmeng ASCENDING.
      ENDIF.
    WHEN '&ODN'.
      IF ck_del = 'X'.
        SORT gt_salord BY audat vbeln lfimg DESCENDING.
      ELSE.
        SORT gt_salord BY audat vbeln kwmeng DESCENDING.
      ENDIF.
    WHEN 'D01'.
      BREAK-POINT.
  ENDCASE.
   CLEAR sy-ucomm.
ENDFORM.    "user_command

The D01 function is just for testing so i can see it enters the user_command when i access it. But when i access the function &OUP it doesn't enter anymore in the CASE ( i test it with debugging )

Was it helpful?

Solution

I don't know whether that's an option for you, but you might want to the ALV Object Model - it's better documented - see for example this chapter about handling functions and events. What's more, it's officially supported - if you use it and it doesn't work as it should, you get help instead of the customary "you're using unreleased internal classes/function modules" remark. Take a look at the demo programs (SALV_DEMO_* or DEMO_SALV_*, can't remember.)

Then again, if you want to define a custom sorting mechanism, you should probably just hude the default buttons and insert your own buttons with different function codes. Who knows, in version 42 someone might come up with the idea to enable the default sorting again and then you won't have to adapt everything again...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top