10-28-2021 7:25 AM
Hi,
We have a requirement where the user should be able to open a word document from an SAP transaction with a pre defined template. Some fields should be pre-populated from the ABAP program and the others the user will enter. Now I have an issue with defining these fields in the template and retrieving the data back to the ABAP program.
Below are the steps that I followed.
The problem is when I try to retrieve data from the document to the program. Need help in understanding how we define fields in the template and read it in our programs. I have tried using the form interface (I_OI_FORM) and link server (I_OI_LINK_SERVER) but in either case I am not able to define the fields and transfer data.
Any pointers on this will be really helpful.
Thanks in Advance.
Rincy
10-28-2021 7:52 AM
I don't know much about I_OI_FORM, but for information the templates are used in the Business Workflow component ("document from template") and maybe you can find some hints in the function module SWUO_OPEN_DOCUMENT_API which calls OPEN > FILL_LINKITEMS_FROM_WF > GET_LINK_ITEMS > P_GET_FORM_DATA, that gets the fields from the template. I guess it should use GET_DATA from I_OI_FORM, I don't know why it doesn't work for you (did you flush?)
Concerning I_OI_LINK_SERVER, if I have understood well, it's only to improve performance, by downloading something once to the laptop, and reuse it several times with DOI.
EDIT: SAP Library: The Form Interface saying "The data table is passed separately from the link server and table collection using the SAP Data Provider."
10-28-2021 8:14 AM
Hi Sandra,
Thank you for your reply.
Regarding the GET_DATA method of I_OI_FORM, in my program if I use the sample template provided in SAPRDEMO_FORM_INTERFACE 'FORMEXAMPLE', the GET_DATA method returns the fields. But if I use my custom template uploaded similarly in BDS, the GET_DATA method does not return the fields.
So I am assuming I am missing something while building the template. (note: the display of the custom template works fine though). Any idea how to define the fields in the word template like context control or something. Is there any other step that I am missing?
Thanks.
Rincy.
10-28-2021 8:15 PM
To insert your fields manually in MS Word > Developer tab > Controls > Legacy form > Text field, Check box, Drop down list.
Right-click on a given field > Properties, to change the default value.
The property fields are to be defined first in File > Info > Properties > Advanced properties > Custom tab, then to be inserted via menu Insert > Text > Quick parts > Fields > DocProperty.
For information, I have just tested ADD_FIELD of I_OI_FORM for properties, it works only if the property is already set in the document (see above), and impossible to set an initial value for all types of fields. The other commands demonstrated in SAPRDEMO_FORM_INTERFACE work, but it seems only in this demo configuration, because using SET_DATA before the document is displayed seems to not work (*).
Test with Office 365.
(*) EDIT right after Rincy comment Nov 1st : my comment about SET_DATA not working is that I tried to set a value for a text field/checkbox I have added using ADD_FIELD (i.e. the MS Word document was created from scratch, i.e. not loaded from an existing document with a field added manually, i.e. probably the reason is because of ADD_FIELD not working well).
11-01-2021 7:34 AM
Hi Sandra,
Thank you very much for your response. It really helped.
The property fields are to be defined first in File > Info > Properties > Advanced properties > Custom tab, then to be inserted via menu Insert > Text > Quick parts > Fields > DocProperty.
This is what I was missing. Few other things that I noticed are:
Once again thanks for your valuable inputs.
11-29-2021 7:59 AM
Hi,
I have a couple of questions in continuation to the above.
I'm trying to explore the best ways of maintaining the template.
Thanks in advance,
Rincy
11-29-2021 2:25 PM
Hi. 1. "best" depends on context, what is important for your company, etc. If BDS (your current solution) works, then it's fine.
2. Depends on the strategy of your company. I can't answer for them.