Sap DMS – direct print of pdf drawings on Windows frontend

My problem was to print a pdf from SAP document management system automatically, without user actions needed;
I solved this using the classic function cl_gui_frontend_services=>execute giving as parameter not only the path of the file to open, but the concatenation of the specific Adobe Reader call parameters to print and hide the main window (simply: /p /h ).
Here it is the entire code of my function:

FUNCTION z_print_pdf_draw.
*”  IMPORTING
*”     VALUE(PDOKAR) TYPE  DRAW-DOKAR
*”     VALUE(PDOKNR) TYPE  DRAW-DOKNR
*”     VALUE(PDOKVR) TYPE  DRAW-DOKVR
*Direct Print of pdf drawings, Windows Frontend only
TABLES: draw.
SELECT SINGLE * FROM draw INTO draw
WHERE  dokar = pdokar AND
doknr = pdoknr AND
dokvr = pdokvr.
IF sy-subrc = 0.
DATA: sourcef TYPE string,
targetf TYPE string,
printcommand TYPE string,
dms_file TYPE dms_doc_file.
CONCATENATE ‘C:\Temp\’ draw-mrk_filep INTO targetf.
CONCATENATE ‘/p /h ‘ targetf INTO printcommand.
“P = Print, h = Hide Window
dms_file-fileno = 1.
MOVE targetf TO dms_file-filename.
dms_file-dappl = ‘PDF’.
dms_file-dttrg = draw-dttrg.
*save the pdf file locally
CALL FUNCTION ‘CV120_DOC_CHECKOUT_TO_CLIENT’
EXPORTING
ps_draw           = draw
ps_doc_file       = dms_file
.
IF sy-subrc = 0.
* print the pdf!
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
application = ‘AcroRd32.exe’
*application = ‘Acrobat.exe’
parameter = printcommand
minimized = ‘X’
operation = ”
EXCEPTIONS
*…
OTHERS = 10 .
ENDIF.
ELSE.
* file not found…
ENDIF.
ENDFUNCTION.
Share this post:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Twitter
  • Google Buzz
  • LinkedIn
  • Tumblr
Posted domenica, luglio 11th, 2010 under Sap.

Tags: , ,

Leave a Reply