Let’s Web Dynpro. Part VI

In Part V, we learnt how we can display the tabular output in ALV with Component Usage. In this post we would see how to add custom buttons programmatically to the ALV output tool bar/header.

It is a very common requirement as shown below (please note these buttons are not standard UI elements).

In the above figure: SELECTALL, DESELECTALL and RETRIEVEINFO are buttons which we have added at run time, programatically. They are not standard UI buttons.

How to achieve this functionality?

Once you have determined the data for the output, you bind it to the context node and call the method to SET the ALV Properties (for our example the method is “ALV_SET_AVAIL_PLANT”. This is the place where you define the button name and function code.

Let us check the important lines related to the custom buttons in this method.

Create object, provide the image source (optional), Set the text of the button (optional), provide the function code and add/set the button.

Please click the link for complete code snippet for the ALV_SET_AVAIL_PLANT. You can use this as your template for all ALV properties. Just change the field names of your table and you may or may not need the button parts (shown in the above figure).

Give special emphasis to the function code. Make sure of the case of the alphabets. You need to give the exact function code to the Event Handler method as stated below.

Once the ALV Property is set, we need to declare another Event Handler method to capture the clicks on the ALV; for our example it is SELECT_DESELECT method.

In this method we need to identify the function code and call corresponding method for action/activity you want to perform. Please see the function code in the event handler method and the ALV property method. They are exactly the same.

Say for action ‘DESELECTALL’ we want to call method deselectall( ) to deselect all the check boxes. Similarly ‘RETRIEVEINFO’ action would fetch you the plant details.

Please note, the method name can be different than the BUTTON or FUNCTION code name. In our example we have the same name for all three for simplicity.

Rating: 0 / 5 (0 votes)