0
votes

Is it possible to call the function MAT1_F4_HELP_EXIT in the PBO module of the screen to trigger search help for a material field on a custom screen (assigning the search help using se11 and search help exit is not working).

I am confused regarding the parameters that are being passed in the function.

Edit (taken from discussion)

I have a field called material, and I want to trigger a search help (MAT1). I have assigned it the table field and it is not letting the user do it automatically. So, I want to call it explicitly.

screenshot of the field properties in the screen painter

1
What is your exact requirement? You simply want a search help to trigger on a field of type MATNR? - Laurens Deprost
@LaurensDeprost I have a field called material, i want to trigger a search help (MAT1). I have assigned it the table field and it is not letting the user do it automatically. So, I want to call it explicitly. For your knowledge, when i try to hit f4 the debugger records sy-ucomm as '&F4'. Is this correct? - Rahul
Have you built the screen using the screen painter? - Laurens Deprost
@LaurensDeprost yes - Rahul
@SandraRossi I deleted it because we did not get anywhere with the question. Although your point is well noted and i will be take it into consideration the next time, thank you. - Rahul

1 Answers

1
votes

I have reproduced the issue (cf minimal code and screen at the bottom).

Steps to reproduce :

  • start the program (-> ALV displayed)
  • double click one line of the ALV (-> screen 0100 displayed)
  • press F4 on screen field defined with search help (-> popup 'abnormal situation' instead of search help!)

Reason: the active GUI status reassigns the F4 function key a classic function key behavior instead of calling the search help and as you didn't set a GUI status in your screen, the one of the previous screen is used again.

Solution: define your own GUI status and set it in the PBO of the screen (and don't redefine F4 of course!)

Rule of thumb : always define your own buttons and menus for every screen (why would you display buttons and menus from other screens which make no sense).

Minimal code:

REPORT.
SELECT * FROM sflight INTO TABLE @DATA(flights).
" does a CALL SCREEN which does SET PF-STATUS 'STANDARD_FULLSCREEN' (in program SAPLKKBL)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_callback_program      = sy-repid
    i_callback_user_command = 'USER_COMMAND'
    i_structure_name        = 'SFLIGHT'
  TABLES
    t_outtab                = flights
  EXCEPTIONS
    OTHERS                  = 2.
FORM user_command
      USING
        r_ucomm     LIKE sy-ucomm
        rs_selfield TYPE slis_selfield.
  IF r_ucomm = '&IC1'.
    CALL SCREEN 100.
  ENDIF.
ENDFORM.
MODULE pbo OUTPUT.
  " missing part !! ==> create GUI status 0100 and do SET PF-STATUS '0100'
ENDMODULE.
MODULE pai INPUT.
  CASE sy-ucomm.
    WHEN '&F03'.
      SET SCREEN 0.
    WHEN '&F4'.
      " corresponds to F4 key inherited from ALV GUI status 'STANDARD_FULLSCREEN'
      MESSAGE 'abnormal situation -> define your own GUI status !' TYPE 'I'.
  ENDCASE.
ENDMODULE.

Screen 0100 :

  • Any field with search help (same as you did)

Flow logic of screen 0100 :

PROCESS BEFORE OUTPUT.
  MODULE pbo.
PROCESS AFTER INPUT.
  MODULE pai.