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

Printing files from Presentation Server

Former Member
0 Likes
2,569

Hi experts,

I need a recomendation :

I have documents in presentation server (.xls, .doc, .jpg, .msg) and I need to print it in a specific printer.

I was searching for a method or FM and I found METHOD cl_gui_frontend_services=>execute, but this method prints to my Windows default printer

and I need to set a printer name, because the users have many printers and they need to chose one.

If you know another method or FM in which I can set the printer name, please help me with that.

Thanks!!

1 ACCEPTED SOLUTION
Read only

Juwin
Active Contributor
0 Likes
2,168

Have a look at this thread please:

Thanks,

Juwin

Have a look at this thread please:

Thanks,

Juwin

10 REPLIES 10
Read only

Juwin
Active Contributor
0 Likes
2,169

Have a look at this thread please:

Thanks,

Juwin

Read only

Former Member
0 Likes
2,168

Thanks so much for your answer,

The thread is so helpful, but what happen with the others types of documents?

(Like .xls, .pdf, .msg)

CREATE OBJECT gs_word 'WORD.APPLICATION'.


Thanks Juwin.

Read only

Juwin
Active Contributor
0 Likes
2,168

I thought you already had a method to print the documents.


You may use the thread I suggested, to set the active printer and then use your current logic to print out the documents.

Thanks,

Juwin

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
2,168

Hmm, a trick could be to exploit the printing capabilities of the browser control. It should be able to consume these file types. The encapsulation CL_ABAP_BROWSER  shows how to add a print button that allows to select a printer (printing = abap_true), see program DEMO_HTML_BROWSER.

Read only

Former Member
0 Likes
2,168

Yes Juwin, I´ve already have the logic for printing differents document using  method METHOD cl_gui_frontend_services=>execute, but my doubt is related to how to create the object, because it make reference only to word document.

Sorry, I got confused.

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,168

OLE and cl_gui_frontend_services=>execute arecompletely different. Again, could you give the command you execute, so that we can answer/search whether there's a solution to select the printer?

Read only

Former Member
0 Likes
2,168

Thanks so much for your help Juwin and Sandra, I´m going to explain the complete process:

As I explained, the user has to chose an specific printer because they have many in their work place.

They have to print smartforms and presentation server document like (.xls, .doc, .jpg, .msg).

In a popup, they write a printer name,  and I set it in smartform FM :

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

          EXPORTING  formname           = 'XXXXXXXX'

          IMPORTING  fm_name            = lf_fm_name

          EXCEPTIONS no_form            = 1

                     no_function_module = 2

                     OTHERS             = 3.

       ls_control_param-device      = 'PRINTER'.

       ls_control_param-no_dialog   = 'X'.

       ls_control_param-preview     = ' '.

       ls_control_param-getotf      = ' '.

       ls_control_param-langu       = 'S'.

       ls_composer_param-tddest     = PRINTER NAME FROM THE POPUP.

       ls_composer_param-tdcopies   = wa_zsdoc_status_n-cant_documentos.

       ls_composer_param-tdimmed    = 'X'.

       ls_composer_param-tddelete   = 'X'.

       ls_composer_param-tdnoprint  = ' '.

       CALL FUNCTION lf_fm_name

            EXPORTING

                       archive_index        = toa_dara

                       archive_parameters   = arc_params

                       control_parameters   = ls_control_param

                       mail_recipient       = ls_recipient

                       mail_sender          = ls_sender

                       output_options       = ls_composer_param

                       user_settings        = space

                       XML                  = it_xml

            IMPORTING  job_output_info      = ls_job_info

            EXCEPTIONS formatting_error     = 1

                       internal_error       = 2

                       send_error           = 3

                       user_canceled        = 4

                       OTHERS               = 5.

And it´s works

The problem is when I try to print documents from presentation server. I used the method:

    CALL METHOD cl_gui_frontend_services=>execute

     EXPORTING

       operation               = 'PRINT'

       document                = path where the documet is located

     EXCEPTIONS

       cntl_error              = 1

       error_no_gui            = 2

       bad_parameter           = 3

       file_not_found          = 4

       path_not_found          = 5

       file_extension_unknown  = 6

       error_execute_failed    = 7

       synchronous_failed      = 8

       not_supported_by_gui    = 9

       OTHERS                  = 10.


It´s works, But it takes Windows default printer and I do not need it.

I do not know if I´m clear in my request, could you help me with my problem?


Thanks so much for your help!!

Read only

Juwin
Active Contributor
0 Likes
2,168

You can just create the Word object and make it not visible and use that object to set the default printer. You needn't use that object for anything else.

Thanks,

Juwin

Read only

Former Member
0 Likes
2,168

Juwin, It doesn´t works :s

CREATE OBJECT gs_word 'PDF.APPLICATION'.

   SET PROPERTY OF gs_word 'Visible' = 0.

   CALL METHOD OF gs_word 'Documents' = gs_documents.

   CALL METHOD OF gs_documents 'Open' = gs_newdoc

   EXPORTING #1 = '\\folder\public\document\file.pdf'.

   CALL METHOD OF gs_word 'ActiveDocument' = gs_actdoc .

   SET PROPERTY OF gs_word 'ActivePrinter' = 'LPS3'.

   CALL METHOD OF gs_actdoc 'PrintOut' .

   CALL METHOD OF gs_word 'Quit'.

   FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc .



It´s the same source code from thread you share me.

Read only

Juwin
Active Contributor
0 Likes
2,168

No, what I meant was:

CREATE OBJECT gs_word 'WORD.APPLICATION'.

SET PROPERTY OF gs_word 'Visible' = '0' .

get property of gs_word 'ActivePrinter' = current_printername.


If you want user to have the option to choose the printer, then you can give a popup with a dropdown of printer names. List of printer names can be retrieved using  RSPO_LIST_FRONTEND_PRINTERS function module. Check RSPO_FRONTEND_PRINTERS_FOR_DEV for example. Once the user chooses the printer from the dropdown, pass that selected value to the ActivePrinter name.


set property of gs_word 'ActivePrinter' = new_printername.

CALL METHOD cl_gui_frontend_services=>execute

     EXPORTING

       operation               = 'PRINT'

       document               = path where the pdf document is located

set property of gs_word 'ActivePrinter' = current_printername.

CALL METHOD OF gs_word 'Quit' .

Thanks,

Juwin