Hi All Creation of Context Menu For Customized  Transaction.

  1. Create a Z MODULE POOL program in SE38.

         

       I1.png

2. Right click the left hand side program name and create new screen.

     I2.png

       I3.png

         I4.png

3. Now create an input/output field ‘TEXT1’ and create a text element name it ‘TEXT1’.

   I5.png

4. Similarly perform the step above for input/output field ‘TEXT2’ the attribute screen of input/output field ‘TEXT2’ is shown below.

    

   I6.png

5. Go back to element list and add ‘OK_CODE’ in the last empty field.

    

    I7.png

6. Now go to the flow logic tab and un-comment those lines.

   /wp-content/uploads/2013/10/i17_300513.png

7. Come back to program and now Right click the left hand side program name and create new transaction code ZCNTMENU for execution.

    I8.png

       I9.png

         I10.png

8. Define these variables.

   

    I11.png

9. Add this Code In PAI of MODULE USER_COMMAND_1000.

   

MODULE USER_COMMAND_1000 INPUT.
CLEAR OK_CODE.
OK_CODE
= SYUCOMM.
CASE OK_CODE.
WHEN ‘OPEN’.
MESSAGE ‘OPEN IS CLICKED’ TYPE ‘I’.
WHEN ‘CUT’.
text_CUT
= text1. “storing in some temp variable
CLEAR text1.
WHEN ‘PASTE’.
GET CURSOR FIELD fld VALUE val.“to find out in which i/o field the cursor is in
if fld = ‘TEXT2’.
text2
= TEXT_CUT.
ELSEIF fld = ‘TEXT1’.
text1
= TEXT_CUT.
ENDIF.
when ‘CLEAR’.
CLEAR : text1 ,TEXT2,TEXT_CUT.
WHEN ‘BACK’.

LEAVE PROGRAM.
ENDCASE.
ENDMODULE.                 ” USER_COMMAND_1000  INPUT

10. Finally Add Standard Call back routines After MODULE USER_COMMAND_1000 INPUT.

     

“RIGHT CLICK on text 1 input/ouput field
FORM on_ctmenu_text1 USING l_menu TYPE REF TO cl_ctmenu.
CREATE OBJECT right_clk.
CALL METHOD: right_clk->add_function
EXPORTING fcode = ‘OPEN’
text  = ‘Open’,
right_clk
->add_function
EXPORTING fcode = ‘CUT’
text  = ‘Cut’,
right_clk
->add_function
EXPORTING fcode = ‘PASTE’
text  = ‘Paste’,
right_clk
->add_function
EXPORTING fcode = ‘MOVE’
text  = ‘Move’,
l_menu
->add_submenu
EXPORTING menu = right_clk
text = ‘OPTIONS’.
ENDFORM.“RIGHT CLICK on text 2 input/ouput field


FORM on_ctmenu_text2 USING l_menu TYPE REF TO cl_ctmenu.
CREATE OBJECT right_clk.
CALL METHOD: right_clk->add_function
EXPORTING fcode = ‘OPEN’
text  = ‘Open’,
right_clk
->add_function
EXPORTING fcode = ‘CUT’
text  = ‘Cut’,
right_clk
->add_function
EXPORTING fcode = ‘PASTE’
text  = ‘Paste’,
right_clk
->add_function
EXPORTING fcode = ‘MOVE’
text  = ‘Move’,
l_menu
->add_submenu
EXPORTING menu = right_clk
text = ‘OPTIONS’.
ENDFORM.

11. Activate and execute the program.

     

     I12.png

12. OUTPUT:Run Transaction  ZCNTMENU

    I13.png   

      Type something in text1 input field and SHIFT + Right click that field

      

      I14.png

        I15.png

           I16.png

      

Note:

  1. 1. When the GUI setting “Quick cut and paste” is active, the Right click cannot  work .
  2. 2. You can still open context menu by pressing Shift + Right click button or SHIFT+F10.



Thanks and Regard’s

Hiriyappa Myageri











To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply