Context Menu In Module pool
Hi All Creation of Context Menu For Customized Transaction.
- Create a Z MODULE POOL program in SE38.
2. Right click the left hand side program name and create new screen.
3. Now create an input/output field ‘TEXT1’ and create a text element name it ‘TEXT1’.
4. Similarly perform the step above for input/output field ‘TEXT2’ the attribute screen of input/output field ‘TEXT2’ is shown below.
5. Go back to element list and add ‘OK_CODE’ in the last empty field.
6. Now go to the flow logic tab and un-comment those lines.
7. Come back to program and now Right click the left hand side program name and create new transaction code ZCNTMENU for execution.
8. Define these variables.
9. Add this Code In PAI of MODULE USER_COMMAND_1000.
MODULE USER_COMMAND_1000 INPUT.
CLEAR OK_CODE.
OK_CODE = SY–UCOMM.
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.
12. OUTPUT:Run Transaction ZCNTMENU
Type something in text1 input field and SHIFT + Right click that field
Note:
- 1. When the GUI setting “Quick cut and paste” is active, the Right click cannot work .
- 2. You can still open context menu by pressing Shift + Right click button or SHIFT+F10.
Thanks and Regard’s
Hiriyappa Myageri
Good one
Thanks for writing but we alredy have demo report for the same. Please check DEMO_DYNPRO_CONTEXT_MENU
Good work...Thanks for this
Good one it is very useful 🙂
nice jobs .. 🙂