Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Contextmenu on a simple List

peter_burgard
Explorer
0 Likes
743

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 ...

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
484

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_request

The 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

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
485

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_request

The 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

Read only

0 Likes
484

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.

Read only

peter_burgard
Explorer
0 Likes
484

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)