‎2005 May 03 7:28 AM
Hi,
I need to print several word documents one after another, but not to the default printer. Todo that, I open each document, print it and closing it.
I use the Interface I_OI_DOCUMENT_PROXY methods:
- OPEN_DOCUMENT_FROM_TABLE
- PRINT_DOCUMENT
- CLOSE_DOCUMENT
The problem is that I only succeeded to print my documents to the fronted (user windows) default printer.
Is there a way to change the windows default printer for my application before printing?
I looked for a method in class CL_GUI_FRONTEND_SERVICES
but didn't find one.
Thanks from your time,
Eyal.
‎2005 May 03 7:38 AM
Hi Eyal,
Go to the menu option <i>System>User Profile>Own Data</i>. On the screen that follows, go to the <i>Defaults</i> tab and specify the Output Device to the value that you like.
Is that what you're looking for ?
Regards,
Anand Mandalika.
‎2005 May 03 7:38 AM
Hi Eyal,
Go to the menu option <i>System>User Profile>Own Data</i>. On the screen that follows, go to the <i>Defaults</i> tab and specify the Output Device to the value that you like.
Is that what you're looking for ?
Regards,
Anand Mandalika.
‎2005 May 03 7:45 AM
If the printer is defined in the SAP system you can get the same from table
TSP03
and then you can direct your prints to that particular printer.
also check out this FM
RSPO_FRONTEND_PRINTERS_FOR_DEV
Regards
Raja
‎2005 May 03 7:57 AM
Hi,
Thanks but I required that the user will select the printer at runtime,
before the documents send to the printer.
Because I open a Word document and print it the selected printer is taken from the Windows printer definition, like when I open my Word application from the desktop, regardless the printer defined in the SAP system (in my opinion).
‎2005 May 03 8:20 AM
can you explain the process bit more clearly.
my understanding is that you thru an abap program you open documents and print it right?
Where does the user interaction comes here?
or do you want the ability for the user to choose a front end printer before they run the abap (as selection value)
Regards
Raja
‎2005 May 03 8:37 AM
Hi Eyal,
Like Raja, even I'm a bit not clear with your description of the requirement. But as far as I know, you will not be (and should not be) able to change the default printer for Windows for any user. Don't you think that is going a bit too far ?
But if the user wants to be able to select the printer which has to print the word document, then instead of using the print button on the toolbar in the word document, the user will have to choose the menu option <i>File-->Print</i> from his word document. That will give him a pop-up which has got the printers defined in Windows. He can choose any printer from there. The toolbar button for print in Ms-Word does not give this pop-up, it automatically prints at the default printer.
Regards,
Anand Mandalika.
‎2005 May 03 9:14 AM
Eyal,
Are you trying to print to the Windows default printer ?
If this is what you want to do, you can specify the output device as LOCL. This will print it on which ever printer is set as the default printer for that user.
PS: Remember 2 Reward the answer that helped u solve your problem.
Regards,
PP.
‎2005 May 03 9:34 AM
Thanks,
The process is should be as follow:
- The user gives a range of documents number in the select option and has a parameter to choose a printer to print them.
- For each document I:
- fill an Internal table in 'RTF' format ( the document content ).
- Open the document from the internal table,
- Set the printer in the user fronted ( like in the printer dialog ) - This my problem,
- Print the document,
- Close the document.
- Next document.
Because I am Opening and Closing the document in the screen PBO the user doesn't see the documents on screen so he can't choose the printer himself in the print dialog.
Hope it is better now,
Eyal.
‎2005 May 03 10:01 AM
did you try setting the prompt_user parameter of PRINT_DOCUMENT method?
to get the list of front end printers installed you can use the following code.
CALL FUNCTION 'RSPO_LIST_FRONTEND_PRINTERS'
destination 'LOCAL_PRINT'
TABLES
list = list
exceptions
others = 1.
Regards
Raja
‎2005 May 03 10:38 AM
Thanks Raja,
Unfortunately it does not work. The prompt_user
parameter opens the dialog printing before the document is sending to the printer.
It does not good for me because the user need to choose the printer once at the selection screen and not for each document.
Eyal.
‎2005 May 03 10:51 AM
Can we see the implementation of print_document method.
Please paste the code here.
Regards
Raja
Also have a look at the following weblog
/people/mark.finnern/blog/2004/08/10/spread-the-love
‎2005 May 03 11:51 AM
Hi,
Members of my class:
mref_control TYPE REF TO i_oi_container_control
mref_document TYPE REF TO i_oi_document_proxy.
The open method code:
METHOD show_document.
CONSTANTS:
lc_doc_type TYPE soi_document_type VALUE 'Word.Document.8'.
DATA: lref_error TYPE REF TO i_oi_error,
lv_retcode TYPE soi_ret_string.
DATA: lv_num_of_lines TYPE i,
lv_document_size TYPE i.
CALL METHOD mref_control->get_document_proxy
EXPORTING
document_type = lc_doc_type
document_format = 'RTF'
IMPORTING
document_proxy = mref_document
error = lref_error
retcode = lv_retcode.
CALL METHOD lref_error->raise_message
EXPORTING
type = 'E'.
DESCRIBE TABLE mt_text LINES lv_num_of_lines.
COMPUTE lv_document_size = lv_num_of_lines * 132.
CALL METHOD mref_document->open_document_from_table
EXPORTING
document_size = lv_document_size
document_table = mt_text
open_inplace = 'X'
open_readonly = pv_disp_only
protect_document = pv_disp_only
IMPORTING
error = lref_error
retcode = lv_retcode.
CALL METHOD lref_error->raise_message
EXPORTING
type = 'E'.
ENDMETHOD. "show_document
The print method code:
METHOD print_document.
DATA: lref_error TYPE REF TO i_oi_error,
lv_retcode TYPE soi_ret_string.
CALL METHOD mref_document->print_document
EXPORTING
prompt_user = ' '
IMPORTING
error = lref_error
retcode = lv_retcode.
CALL METHOD lref_error->raise_message
EXPORTING
type = 'E'.
ENDMETHOD. "print_document
Thanks,
Eyal.