2005 Feb 10 5:52 PM
Hello,
This is my fist attempt to use SND so I am hoping for a fast reply that will get me to long on more often. Here goes.
I want to be able to print the word documents that are attached to an equipment that is used in the PM order. When the order is printed a SAP Script form is automatically output. I want to be able to print the documents attached to the equipment at the same time. Is that possible. I have tried the OLE classes but I get a short dump when I try to print the order through the menu Order->Print Order.
Any help would be appreciated.
Thanks
2005 Sep 09 8:29 PM
Hello Everybody,
There is an SAP certified solution for the printing of Word Doc Attachments to the Equipment from SEAL System.
dependent upon where you live
Regards
Robert Bruns
2005 Feb 10 6:02 PM
Yes, its possible thru OLE, first, if not already done, you must in configuration, make it so that the printing happens in the foreground as opposed to the background, then in you print program, you need to retrieve the attached documents. Here is a routine that is working for us in production now.
This is the call of the subroutine, send thru the business object id, and the BO key, along with a flag
for print preview on/off.
perform retrieve_and_print_documents
using 'BUS1019'
your_object_key " Probably Equipment Number
device.
Here is the routine. It handles .Doc and .Xls attachments only.
*********************************************************************
* Form RETRIEVE_AND_PRINT_DOCUMENTS
*********************************************************************
form retrieve_and_print_documents using objtyp
objkey
device.
tables: plko, sood.
type-pools ole2 .
data: documents type standard table of neighbor.
data: document type neighbor.
data: docs like line of documents.
data: xobject like borident.
data: objects type standard table of sood4.
data: object type sood4.
data: word type ole2_object.
data: excel type ole2_object.
data: workbooks type ole2_object.
data: app type ole2_object.
data: filename(200) type c.
* If background, then do even try it!
check sy-batch <> 'X'.
* Retrieve Documents
xobject-objtype = objtyp.
xobject-objkey = objkey.
clear document. refresh documents.
call function 'SREL_GET_NEXT_NEIGHBORS'
EXPORTING
object = xobject
roletype = 'APPLOBJ'
relationtype = 'ATTA'
TABLES
neighbors = documents.
* If no documents, then exit.
if documents[] is initial.
exit.
endif.
loop at documents into docs.
select single * from sood
where objtp = docs-objkey+17(3)
and objyr = docs-objkey+20(2)
and objno = docs-objkey+22(12).
if sy-subrc <> 0.
continue.
endif.
* Create the Microsoft Application Object
case sood-file_ext.
when 'DOC'.
create object word 'WORD.BASIC'.
when 'XLS'.
create object excel 'EXCEL.APPLICATION'.
endcase.
* Open Document.....
clear object.
clear objects. refresh objects.
object = docs-objkey. append object to objects.
call function 'SO_DOCUMENT_DISPATCH_MANAGER'
EXPORTING
activity = 'DISP'
TABLES
objects = objects.
if device <> c_preview.
* Hide Microsoft Application
case sood-file_ext.
when 'DOC'.
call method of word 'APPHIDE'.
when 'XLS'.
set property of excel 'VISIBLE' = 0.
endcase.
wait up to 2 seconds.
* Print the Document
case sood-file_ext.
when 'DOC'.
call method of word 'FILEPRINT'.
when 'XLS'.
get property of excel 'ACTIVEWORKBOOK' = workbooks.
call method of workbooks 'PRINTOUT'.
endcase.
wait up to 8 seconds.
* Close Microsoft Application
case sood-file_ext.
when 'DOC'.
call method of word 'APPCLOSE'.
when 'XLS'.
call method of excel 'QUIT'.
endcase.
else.
* Minimize Microsoft Application
case sood-file_ext.
when 'DOC'.
call method of word 'APPMINIMIZE'.
when 'XLS'.
get property of excel 'APPLICATION' = app.
set property of app 'WINDOWSTATE' = 2.
endcase.
endif.
* Free the Object
case sood-file_ext.
when 'DOC'.
free object word.
when 'XLS'.
free object excel.
endcase.
endloop.
endform.
Regards,
Rich Heilman
2005 Feb 10 6:25 PM
Thanks For the help. But I forgot to mention that I am still working in the 4.0b environment. We are upgrading to 4.7 so I was able to check to ensure that this object was in 4.7 and it is. Would you have a 4.0b solution by any chance?
2005 Feb 10 6:28 PM
2005 Feb 10 8:58 PM
Thanks Rich.
Hopefully I can get some help from some on 4.0.
I am very thankful for your prompt replies.
2005 Jul 01 11:06 AM
Hi Rashid,
there is a solution certified by SAP for the printing of documents with maintenance orders. It is server side processing and works wether the documents are management by KPRO or on a file system.
Please see
Regards
Andrew
Message was edited by: Andrew Barnard
2005 Sep 09 8:29 PM
Hello Everybody,
There is an SAP certified solution for the printing of Word Doc Attachments to the Equipment from SEAL System.
dependent upon where you live
Regards
Robert Bruns
2005 Sep 09 8:30 PM
2005 Sep 09 8:31 PM