It is the third parameter (#3) which passes read-only option. It must be set to '1' if you want to open the document in 'Read-only' mode.
Check these following SAP programs
This ABAP code needs a Word file in somewhere in local PC directory tree. The word file must be already configured as a mail merge template. The data source is not controlled by this ABAP code, so the Word file must have it.
REPORT zyamagi_wordprint MESSAGE-ID sy.
*Working directory such as SapWorkDir
PARAMETERS : p_file LIKE rlgrap-filename.
DATA: h_word TYPE ole2_object,
h_docs TYPE ole2_object,
h_doc TYPE ole2_object,
h_merge TYPE ole2_object.
CALL FUNCTION 'WS_QUERY'
query = 'CD'
return = p_file.
CONCATENATE p_file 'Merge.DOC' INTO p_file.
* Create Word Application object
IF h_word-header = space OR h_word-handle EQ -1.
CREATE OBJECT h_word 'WORD.APPLICATION'.
IF sy-subrc NE 0.
MESSAGE i002 WITH sy-msgli.
SET PROPERTY OF h_word 'VISIBLE' = 1.
* Get Documsnts collection as property of Application object
GET PROPERTY OF h_word 'DOCUMENTS' = h_docs.
* Open a word file
CALL METHOD OF h_docs 'OPEN' = h_doc
EXPORTING #1 = p_file.
* Invoke mail merge
* The Word windows will be visible
GET PROPERTY OF h_doc 'MAILMERGE' = h_merge.
SET PROPERTY OF h_merge 'DESTINATION' = 1.
CALL METHOD OF h_merge 'EXECUTE'.
* Terminate Word
CALL METHOD OF h_word 'QUIT' EXPORTING #1 = 0.
* Free objects
FREE OBJECT : h_merge,
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.