This document helps you add a button on to the ALV grid toolbar of a standard report – CO27 Picking list.
— The initial screen of ‘Picking list’ looks like this:
— On entering input and executing the report, it displays a list of order and material details as shown below :
Follow the steps given below to achieve this :
(1) We will need to write code for button functionality in the method of “handle_toolbar_set” event as we are going to add it on to the toolbar.
(2) Since it is a standard SAP program , we will check for implicit enhancements to add this code in the method shown above.
There exists an implicit enhancement point in the method and we shall create one implementation.
(3) Create an enhancement implementation in the method of “handle_toolbar_set” event.
(4) Name the implementation and enter the short text.
(5) Write the code for adding a button on the toolbar.
In this example, we are adding a function code ‘ZBTN’ for the button and also naming it as “New Custom Button.”
(6) Activate the enhancement and run the report.
And this is it! We can see the new button that we have added on the toolbar.
We have also assigned a function code for this to handle the action.
On clicking this new button, the function code ‘ZBTN’ would be captured and the necessary logic be performed.
(7) Handle the action on button click : We will write the logic for handling the user action in the method of “handler_after_user_command” event.
(8) This method has handled user action for few of the buttons that are already in place.
(9) We will follow the same process from step 2 to 5. Check for implicit enhancement points and create an implementation in this method.
(10) Write logic to perform the necessary action on button click.
We are calling this BADI to get the user command. By checking for its value, we are writing code in the ‘handle_new_custom_button’ subroutine.