cancel
Showing results for 
Search instead for 
Did you mean: 

Add new function in RIGHT CLICK MENU...

Former Member
0 Kudos

I reuse the component ALV Grid, but i'd like to add a specific entry the the right click menu...

is it wdoncontextmenu ? Do you have any example ?

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You might find this help document useful as well:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/45/180c60c2e927d0e10000000a155369/frameset.htm

The only thing I am not sure if is the fact that you want to do this with an ALV. The ALV is acutally another component. I'm not sure you can trap the context menu in the WDDOONCONTEXTMENU of the parent component. There are many other ways to extend the ALV using the Toolbar however.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hey.

Why did not you add new function in standard toolbar of ALV ?

You can create your own context menus for user interfaces elements in Web Dynpro for ABAP.

First,you need to add code in order to create your own context menus in WDDOONCONTEXTMENU hook method .

Second,you need to create acction for your own context menus item. At one time,you need to add code in action method. When context menus item will be click,this method will be called and respond

your handle.

Below are test code of sample. Hope that these are helpful.

-


method WDDOONCONTEXTMENU .

DATA: LR_CONTEXT_ELEMENT TYPE REF TO IF_WD_CONTEXT_ELEMENT,

LR_MENU TYPE REF TO CL_WD_MENU,

LR_MENU_ITEM TYPE REF TO CL_WD_MENU_ACTION_ITEM.

CASE CONTEXT_MENU_EVENT->ORIGINATOR->ID.

WHEN 'GROUP01'.

CALL METHOD CL_WD_MENU=>NEW_MENU

EXPORTING

ID = 'ZHANGWH'

TITLE = 'Zhang wei hong test context menu'

RECEIVING

CONTROL = MENU.

CALL METHOD CL_WD_MENU_ACTION_ITEM=>NEW_MENU_ACTION_ITEM

EXPORTING

ID = 'CHECK'

ON_ACTION = 'CHECK_DATA'

TEXT = 'Check input data'

RECEIVING

CONTROL = LR_MENU_ITEM.

CALL METHOD MENU->ADD_ITEM

EXPORTING

THE_ITEM = LR_MENU_ITEM.

WHEN OTHERS.

ENDCASE.

endmethod.

-


Action Action type

CHECK_DATA Standard

-


method ONACTIONCHECK_DATA .

  • Define local variables

DATA: LR_API TYPE REF TO IF_WD_VIEW_CONTROLLER,

LR_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER,

RT_CARRID TYPE REF TO DATA,

R_CARRID TYPE RANGE OF S_CARRID,

LS_CARRID LIKE LINE OF R_CARRID,

LV_MESSAGE_TEXT TYPE STRING,

LV_LOW TYPE S_CARRID,

LV_HIGH TYPE S_CARRID.

FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE.

  • Check airline id

CALL METHOD WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD

EXPORTING

I_ID = 'CARRID'

RECEIVING

RT_RANGE_TABLE = RT_CARRID.

ASSIGN RT_CARRID->* TO <FS_CARRID>.

READ TABLE <FS_CARRID> INTO LS_CARRID INDEX 1.

LV_LOW = LS_CARRID-LOW.

LV_HIGH = LS_CARRID-HIGH.

IF LV_LOW IS NOT INITIAL.

SELECT COUNT(*)

FROM SCARR

WHERE CARRID = LV_LOW.

IF SY-SUBRC 0.

LR_API = WD_THIS->WD_GET_API( ).

LR_MESSAGE_MANAGER = LR_API->GET_MESSAGE_MANAGER( ).

CONCATENATE 'Inputed Airline ID' LV_LOW 'is not exist!'

INTO LV_MESSAGE_TEXT SEPARATED BY SPACE.

CALL METHOD LR_MESSAGE_MANAGER->REPORT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = LV_MESSAGE_TEXT.

ENDIF.

ENDIF.

IF LV_HIGH IS NOT INITIAL.

SELECT COUNT(*)

FROM SCARR

WHERE CARRID = LV_HIGH.

IF SY-SUBRC 0.

LR_API = WD_THIS->WD_GET_API( ).

LR_MESSAGE_MANAGER = LR_API->GET_MESSAGE_MANAGER( ).

CONCATENATE 'Inputed Airline ID' LV_HIGH 'is not exist!'

INTO LV_MESSAGE_TEXT SEPARATED BY SPACE.

CALL METHOD LR_MESSAGE_MANAGER->REPORT_ERROR_MESSAGE

EXPORTING

MESSAGE_TEXT = LV_MESSAGE_TEXT.

ENDIF.

ENDIF.

endmethod.