Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Print Functionality in ALV container

Former Member
0 Likes
2,057

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.

8 REPLIES 8
Read only

former_member226419
Contributor
0 Likes
1,580

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

Read only

0 Likes
1,580

Can we assign a function code to ALV tool bar? I want to assign F8 function code for Print button , Is it possible?

Read only

0 Likes
1,580

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

Read only

0 Likes
1,580

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.

Read only

0 Likes
1,580

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.


Read only

ThangaPrakash
Active Contributor
0 Likes
1,580

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

Read only

0 Likes
1,580

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.

Read only

former_member219762
Contributor
0 Likes
1,580

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.