‎2014 Mar 25 4:45 PM
Hi
I have a ALV custom container and I have Print Button in the standard ALV screen . I need to add a Function code /Ok code to the print button .
As function codes are not allowed to standard alv screens( as I checked in the forums ) . I have created a new button as "print " and Now I need to implement the same print functionality to this custom Print Button.
Can we assign function codes to the ALV buttons?
Please suggest a better way of doing this.
‎2014 Mar 25 5:08 PM
Hi,
You mean to say you want to assign a custom button 'PRINT' to standard ALV container in some standard tcode?
Yes you can do that. Create PF status for the same assign function code and with the help,of sy-ucomm perform your functionality.
BR
Sumeet
‎2014 Mar 25 5:10 PM
Can we assign a function code to ALV tool bar? I want to assign F8 function code for Print button , Is it possible?
‎2014 Mar 25 5:18 PM
Yes in PF status there is function code known as 'Execute' with icon . You can assign it to the same and in code give as below.
Case sy-ucomm.
when 'EXECUTE'.
ur code.
endcase.
BR
Sumeet
‎2014 Mar 25 5:35 PM
Case sy-ucomm.
when 'EXECUTE'.
ur code. -> There is no custom functionality , It should work as the same way when standard print button is clicked , So Do we need to call any standard program and submit.
endcase.
‎2014 Mar 26 12:09 PM
Yes copy the same standard code for print and run it for 'EXECUTE' also and deactivate the code for standard print functionality.
Just debug the standard functionalty for 'PRINT' and run the same for execute also.
‎2014 Mar 25 6:32 PM
Hello Cherry,
Goto the newly created PF status copied from the standard.
goto SE41, give your program and status and in the application toolbar list, deactivate the standard print button and assign the standard function code to your custom button.
now in your code, under the user command, do a sy-ucomm check and if the function code is same as the one which you assigned to the custom button, do your printing.
Regards,
TP
‎2014 Mar 25 7:16 PM
Hi Cherry,
Follow Sumeet's Post.It is Correct.
OR
You can take one Screen .
Use CL_GUI_CUSTOM_CONTAINER class ( using OOPS concepts) and on that screen Take a Button and write down the functionality for that button.
e.g if you taken the two buttons say Exit and Display.
Code would be:
Case Sy-Ucomm.
When 'Display'.
your code:(Means You can also call the screen and on that screen Put print functionality Like alv Container.If you use CL_GUI_CUSTOM_CONTAINER class then you can call the method SET_TABLE_FOR_FIRST_DISPLAY.It will display the table)
When 'Exit'.
Leave Program.
Endcase.
I hope you got it.
Regards,
Abhishek K.
‎2014 Mar 25 8:44 PM
Hi,
We can add custom function code to standard button as follows.
Define TOOLBAR event handler,and raise that event by calling set_toolbar_Interactive( ).
In that event handler write
LOOP AT e_object->mt_toolbar INTO ls_toolbar.
CASE ls_toolbar-function.
WHEN cl_gui_alv_grid=><name of standard-ok-code for print>.
ls_toolbar-function = 'Custom function code'.
WHEN OTHERS.
CONTINUE.
ENDCASE.
MODIFY e_object->mt_toolbar FROM ls_toolbar INDEX syst-tabix.
ENDLOOP.
ENDMETHOD.
After this when user click on print it raises custom function code and trigger USER_COMMAND.
So write your code in USER_COMMAND.
Regards,
Sreenivas.