‎2007 Jan 03 3:59 PM
Hi there,
I want to add a own Contextmenu on a "List" (List = with the command 'write' you put text on a "List").
I found in the SAP Bibliothek an Instruction how to do this.
so
1) I create a PF-Status with the Function Code %CTX and aktivated the PF-Status
2) Set PF-Status to this new created PF-Status.
3) Implemented a so call CALLBACK-Function
FORM on_ctmenu_request USING l_menu TYPE REF TO cl_ctmenu.
CALL METHOD l_menu->add_function
EXPORTING fcode = 'ENTRY'
text = 'ENTRY'.
endform
after starting the programm, just the standard Contextmenu from SAP appears as i press the right mouse-button or use shift-f10.
what is wrong ???
thanks for your reply ...
‎2007 Jan 04 8:58 PM
Hello Peter
I had the very same problem like you with my sample report (copied from the SAP documentation):
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_WRITELIST_CTXMENU
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_writelist_ctxmenu.
*REPORT demo_list_context_menu .
DATA: wa_spfli TYPE spfli,
wa_sflight TYPE sflight.
START-OF-SELECTION.
SET PF-STATUS 'BASIC'.
SELECT * FROM spfli INTO wa_spfli.
WRITE: / wa_spfli-carrid,
wa_spfli-connid,
wa_spfli-cityfrom,
wa_spfli-cityto.
HIDE: wa_spfli-carrid, wa_spfli-connid.
ENDSELECT.
CLEAR wa_spfli.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'DETAIL'.
CHECK NOT wa_spfli IS INITIAL.
WRITE sy-lisel COLOR COL_HEADING.
SELECT * FROM sflight INTO wa_sflight
WHERE carrid = wa_spfli-carrid
AND connid = wa_spfli-connid.
WRITE / wa_sflight-fldate.
ENDSELECT.
ENDCASE.
*&--------------------------------------------------------------------*
*& Form on_ctmenu_request
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->L_MENU text
*---------------------------------------------------------------------*
FORM on_ctmenu_request USING l_menu TYPE REF TO cl_ctmenu.
DATA lin TYPE i.
IF sy-listi = 0.
* GET CURSOR LINE lin.
* IF lin > 2.
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'DETAIL'
text = text-001.
* ENDIF.
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'BACK'
text = text-002.
ENDIF.
ENDFORM. "on_ctmenu_requestThe GUI status had the following function keys defined:
Reserved Function Keys:
F4 <..> Possible entries
Shift-F10 %CTX Context menu
What was wrong? The function key <b>%CTX is disabled by default</b> !!!
When I activated it I got a nice context menu.
Regards
Uwe
‎2007 Jan 04 8:58 PM
Hello Peter
I had the very same problem like you with my sample report (copied from the SAP documentation):
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_WRITELIST_CTXMENU
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_writelist_ctxmenu.
*REPORT demo_list_context_menu .
DATA: wa_spfli TYPE spfli,
wa_sflight TYPE sflight.
START-OF-SELECTION.
SET PF-STATUS 'BASIC'.
SELECT * FROM spfli INTO wa_spfli.
WRITE: / wa_spfli-carrid,
wa_spfli-connid,
wa_spfli-cityfrom,
wa_spfli-cityto.
HIDE: wa_spfli-carrid, wa_spfli-connid.
ENDSELECT.
CLEAR wa_spfli.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'DETAIL'.
CHECK NOT wa_spfli IS INITIAL.
WRITE sy-lisel COLOR COL_HEADING.
SELECT * FROM sflight INTO wa_sflight
WHERE carrid = wa_spfli-carrid
AND connid = wa_spfli-connid.
WRITE / wa_sflight-fldate.
ENDSELECT.
ENDCASE.
*&--------------------------------------------------------------------*
*& Form on_ctmenu_request
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->L_MENU text
*---------------------------------------------------------------------*
FORM on_ctmenu_request USING l_menu TYPE REF TO cl_ctmenu.
DATA lin TYPE i.
IF sy-listi = 0.
* GET CURSOR LINE lin.
* IF lin > 2.
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'DETAIL'
text = text-001.
* ENDIF.
CALL METHOD l_menu->add_function
EXPORTING
fcode = 'BACK'
text = text-002.
ENDIF.
ENDFORM. "on_ctmenu_requestThe GUI status had the following function keys defined:
Reserved Function Keys:
F4 <..> Possible entries
Shift-F10 %CTX Context menu
What was wrong? The function key <b>%CTX is disabled by default</b> !!!
When I activated it I got a nice context menu.
Regards
Uwe
‎2010 Dec 04 7:11 AM
I guess there is something more than just creating a status and assigning the function code %CTX.
Else then why is that "on_ctmenu_request" not being called and why text-001 and text-002 not being displayed in the context menu?
For once I was able to bring the text-001 and text-002 on the context menu without the default F1 and F4 options along with it. But then, I could not reproduce it again.
‎2007 Jan 05 8:32 AM
Thanks, the answer helps me !!!!
(Das muss man erst mal wissen, das die F-Codes per Default inaktiv sind, manchmal ist es echt zum Haare raufen mit SAP *g)