现在的位置: 首页 > 综合 > 正文

SAP PRINT WORD/DOC DIRECTLY

2013年09月07日 ⁄ 综合 ⁄ 共 4269字 ⁄ 字号 评论关闭

https://forums.sdn.sap.com/thread.jspa?threadID=15554&tstart=57645

 

How to print a word document directly from ABAP?   
want to send word documents to printer. I found a FM CV150_PRINT_DOC

 

If your functionality allows you to open the doc first and then print it from there, then you can use the FM 'WS_EXECUTE'/ 'GUI_EXEC' to open the file (you should pass the full path of the winword.exe file/WORD prg name and your file path to this FM), and then print it from there

 

----------------------------------------------------

 

You can find some examples using transaction SE83 (Reuse Library): SAP Basis -> Controls -> Desktop Office Integration

 

----------------------------------------------------

I have another question. I could not get the idea of addressing the documents. I mean, when I debug the examples, I found out that the content of the documents are carried out to the internal tables. But where do we define the directory and the name of the files?

Best Regards,
Didem

ps: I think the best way is to use ws_execute, but unfortunately printers we use are not MS DOS compatible. I could not print anything from the command prompt.

 

 

----------------------------------------------------

 

To open a document you can use the following method:

CALL METHOD document->open_document
EXPORTING document_url = p_fname
IMPORTING retcode = retcode.

Where p_fname stands for the filename on your fileserver (use 'FILE://' + <directory name> + '/' + <name of the file> for local files).

 

 

 

----------------------------------------------------

Here is an example code utilizing OLE2.

REPORT print_via_ole_example .

INCLUDE ole2incl .

DATA: gs_word TYPE ole2_object ,
gs_documents TYPE ole2_object ,
gs_newdoc TYPE ole2_object ,
gs_actdoc TYPE ole2_object .

START-OF-SELECTION .
CREATE OBJECT gs_word 'WORD.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 = 'D:/my_doc.doc' .

CALL METHOD OF gs_word 'ActiveDocument' = gs_actdoc .

CALL METHOD OF gs_actdoc 'PrintOut' .

CALL METHOD OF gs_word 'Quit' .

END-OF-SELECTION.
FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc .

 

 

 

----------------------------------------------------

First of all, the requirement is not clear. What exactly do you want? Do you want to print a word document, which is stored in SAP Document Management System or you just want to print a document using ABAP code, which is stored on your local machine ?

CV150_PRINT_DOC can only be used when the word document is stored in SAP DMS. You must have a Document Info Record created in SAP for it.

If you want to print a word document from your PC, you may think of using office integration. You may open the document as an OLE object and print using method PRINT_DOCUMENT of I_OI_DOCUMENT_PROXY.

 

 

 

https://forums.sdn.sap.com/thread.jspa?threadID=15554&tstart=57645

 

http://forums.sdn.sap.com/thread.jspa?threadID=1064038&tstart=26234

 

 

Print a PDF document from ABAP  

Could you pls. help me with the following requirement:

We need to print a PDF document on the local desktop to the local (default) printer:
On executing the program the document should open, get printed and get closed.

There are some OLE commands (for instantiating the OLE object and printing). We have got the code for word document:
CREATE OBJECT h_word 'WORD.BASIC'.
call method of h_word 'AppShow'.
call method of h_word 'FILEOPEN' exporting #1 = e_filename1.
call method of h_word 'FILEPRINT'.
call method of h_word 'FILECLOSE'.
call method of h_word 'FILEEXIT'.
free object h_word.

The above code print the word document. We need similar code for PDF document.
For this the PDF document needs to be registered in SOLE transaction. What should be the entry in SOLE transaction to register the PDF document?

Any inputs in this regard will help us a lot.

 

 

we have standard report RSTXPDFT4 to convert to pdf use this and download it .

 

 

 

First see in transaction SOLE whether PDF OLE application is maintained.
You can have a look at OLE for demo for excel and word.
If you debug it then you will get the clear picture what to do.

 

 

 

 

 

  REPORT  ZTEST_PRINT_DOC.

*REPORT print_via_ole_example .

INCLUDE ole2incl .

DATA: gs_word TYPE ole2_object ,
gs_documents TYPE ole2_object ,
gs_newdoc TYPE ole2_object ,
gs_actdoc TYPE ole2_object .

START-OF-SELECTION .
CREATE OBJECT gs_word 'WORD.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 = 'E:/US-M-TERMS-20110126.doc' .
 #1 = '/tmp/US-M-TERMS-20110126.doc' .

CALL METHOD OF gs_word 'ActiveDocument' = gs_actdoc .

CALL METHOD OF gs_actdoc 'PrintOut' .

CALL METHOD OF gs_word 'Quit' .

END-OF-SELECTION.
FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc .

 

 

 

SMW0/

OAOR/

CG3Z/AL11  文件采用这种方式直接上传服务器

 

这几天还没弄清楚文件传到FTP服务器/SAP DMS/SAP的服务器 处理文件时有什么区别

 

 

 

抱歉!评论已关闭.