08-11-2015 9:57 AM
Hello,
I got a problem that I want to fill (not create!) a word template with a custom report. This means I have a prepared Word template which already exists. I placed some fields there just like the address etc. that should be filled dynamically by SAP values. I was looking for SAP office integration that can maybe handle this, but I did not find any coding snippet that could help. All the snippets I found were for creating a new word file which I do not need. I "just" want to have 3 things.
(1) Use/ Upload a custom Word template with fields in it.
(2) Use this template in a custom report and fill the fields from the report.
(3) Save the filled template in SAP or workspace
Any hints for this?
Regards
Michael
08-11-2015 10:33 AM
08-11-2015 10:41 AM
Hey Praveer,
thanks for the link but I know this one. It is completely filled with SAP values from a table.
I do not need something like this, I need a method or function which allows me to transfer in a word template prepared fields from SAP to MS word.
Regards
Michael
08-11-2015 11:55 AM
HI Michael,
As per you requirement, you have to update the already defined fields from WORD file.
for this, you can refer below program.
Program Name: SAPRDEMO_FORM_INTERFACE.
Here, some already define value or fields are exist in WORD file. and by the selection of respective event, the entered or selected value from SAP screen, will transfer to respective fields of WORD file.
Select Run application in place to open WORD file in SAP screen.
Regards,
Praveer.
08-11-2015 12:53 PM
Yes I know that too and tried to work with it. It looks similar to my request. But I tried to copy it into my custom report and was not able to replace it. There are many factors in this report which I do not need. I just need the coding snippet which opens the word file and replaces the fields, but I was not able to find them in the report.
Regards
Michael
08-11-2015 1:11 PM
Hi Michael,
Open the WORD file in SAP screen is in MODULE CREATE_BASIC_OBJECTS OUTPUT of the program, only you have to pass inplace eq 'X'.
and to set the data to respective information in WORD file you can follow the MODULE USER_COMMAND_0100 INPUT.
inside this module, a method has been called to set the data.
CALL METHOD HANDLE->SET_DATA
EXPORTING FIELDS = TABEL2
CLEAR = 'X'.
I would suggest, don't copy the whole program, debug as per your requirement and create another program.
Regards,
Praveer.
08-11-2015 1:26 PM
And where can I put or read the word file?
I have a docx file on my computer which should be used for this.
08-11-2015 1:29 PM
Did you try ZWWW? It's not standard but very good module to create reports in word and excel.
08-11-2015 1:59 PM
Similar to XLSX, DOCX is an open source Microsoft Word document. Which means that, you will be able to use XML, to play around with the DOCX document.
I would suggest you to do the following steps.
This should give you an idea on how to create your document template. You may load that document to mime repository and retrieve that in your program. You can use CL_ABAP_ZIP to perform zip/unzip within SAP. You can use XML classes in SAP to edit the XML values.
Thanks,
Juwin