且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SAP ABAP Webdynpro ALV的link to action的实现方法

更新时间:2022-09-05 23:17:38

If you include the standard webdynpro ALV component SALV_WD_TABLE into your own component, you could not directly change the ALV table column as usual. In ABAP Webdynpro an example of link to action element used in ALV looks like below. Once the column “Social Media Post ID” is clicked, it is expected our application could catch the event and implement our own event handling logic.


SAP ABAP Webdynpro ALV的link to action的实现方法

You could follow the steps below:


(1) Define the component usage to ALV component by double clicking your webdynpro component in SE80 and maintain the component usage in tab “Used Web Dynpro Components”


SAP ABAP Webdynpro ALV的link to action的实现方法

(2) Double click the INTERFACECONTROLLER_USAGE,add your own component for ALVcomponent usage. The reason for this is you need to map the context node of your own component to ALV component, so that it can know which data from your application should display.


SAP ABAP Webdynpro ALV的link to action的实现方法

After that it is ready for mapping the context node of your component to the context node DATA of ALV component. You can achieve it via drag and drop or right click on DATA node, and choose “Define External Mapping” from context menu. After mapping is done, you could see the mapping path displayed below.

SAP ABAP Webdynpro ALV的link to action的实现方法

(3) double click on your view, and insert a new element “ViewContainerUIElement”, which acts as the container for ALV interface view to be embedded.

SAP ABAP Webdynpro ALV的link to action的实现方法

then double click on window, right click the ViewContainerUIElement and choose “Embed View”, include the ALV interface view from drop down list.


SAP ABAP Webdynpro ALV的link to action的实现方法

The final settings looks like below. Now you should already see the ALV in your application UI.

SAP ABAP Webdynpro ALV的link to action的实现方法

Create a new method in view controller and implement the code below:

SAP ABAP Webdynpro ALV的link to action的实现方法

And call it in wddomodifyview of view controller:

SAP ABAP Webdynpro ALV的link to action的实现方法

Note: according to sap help, the event ON_CLICK is only triggered if the method

IF_SALV_WD_TABLE_SETTINGS~SET_CELL_ACTION_EVENT_ENABLED is set to FALSE Otherwise, the event ON_CELL_ACTION is triggered.

(4) Create a event handler in view controller Methods tab. Choose the event name ON_CLICK from drop down list.

SAP ABAP Webdynpro ALV的link to action的实现方法

In the runtime, the selected item index and item value could be found in importing parameter R_PARAM:

SAP ABAP Webdynpro ALV的link to action的实现方法