06-20-2011 9:48 PM
Hi Experts,
I want to send the output to Word document instead of Smartforms/SAP Script I'm using Mail Merge OLE methods...I have created Template.doc(Mail Merge) and uploaded using class : WORD and type OT. I have used same class and methods of program : SAPRDEMO_MAILMERGE_INTERFACE. I have problem in populating the Mail Merge field values..Any one worked on SAP Mail Merge. Please help me in resolving this issue ?
Thanks,
Kumar
06-21-2011 7:35 AM
docu on mail merge can be found here: http://help.sap.com/saphelp_nw73/helpdata/en/49/321b1ce8d85aa9e10000000a42189d/frameset.htm
06-21-2011 7:35 AM
docu on mail merge can be found here: http://help.sap.com/saphelp_nw73/helpdata/en/49/321b1ce8d85aa9e10000000a42189d/frameset.htm
06-27-2011 5:04 PM
I have issue with method : get_fields it is returning 1 field name ITEM_NAME = " (not field name). I think i'm missing some setting in word. Please suggest me i'm using office - 2007 and ecc 6.0...
Thanks,
Kumar
06-27-2011 10:11 PM
have you seen this wiki, maybe it can help you further
http://wiki.sdn.sap.com/wiki/display/Snippets/PERFORMMAILMERGEDATATOMSWORD
06-28-2011 2:19 PM
Already I used wiki solution also...Not working.
-Kumar
06-30-2011 3:14 PM
Hi Kumar,
Mail merge functionality of Word called from SAP has certain restrictions when the word document is placed in SAP Container(In place).if this is the case you can only merge data into Merge fields and other mail merge rules such as IF,ASK etc will not function if the mail merge is done from SAP using I_OI_MAIL_MERGE interface. please refer SAP note 495627 which explains the differences between inplace/outplace display.
If you are opening word document outside(inplace = ' '),then the mail merge will be proper.
Normally to perform mail merge you should have a datasource(this should contain mail merge fields and their values) which will be used as reference to merge data into mail merge fields.
For performing Mail merge through SAP's I_OI_MAIL_MERGE interface, you have to obtain the mail merge interface instance from the I_OI_DOCUMENT_PROXY interface and then using this Mail merge instance set a data source using SET_DATA_SOURCE method, merge the records set in the data source using MERGE_ONE or MERGE_RANGE methods. After the data source is prepared and merge records are passed, to view the mail merge in word document, call VIEW method. Following this procedure should display data in merge fields.
I had a similar requirement with IF mail merge rules and also have some issues with mail merge functionality of Word document opened in SAP container.
06-30-2011 6:51 PM
It is problem with word..I resolved it..Thank you for replying..
01-02-2015 4:16 AM
Hi,
Here I want to explain problem with merge fields in word for getting list of merge fields used in given document using method I_OI_MAIL_MERGE-get_fields
Merge fields Tags (with Problem) | Merge fields Tags(correct) |
{MERGEFIELD "TAG1"} | {MERGEFIELD TAG1} |
{MERGEFIELD TAG_H1} | {MERGEFIELD TAGH1} |
*******
CLEAR RETCODE. CLEAR ERROR.
CALL METHOD MM_INTERFACE->GET_FIELDS
EXPORTING
NO_FLUSH = ' '
IMPORTING
DESCR_LIST = LIST
ERROR = ERROR
RETCODE = RETCODE.
LOOP AT TDD03L.
LOOP AT LIST INTO WLIST WHERE ITEM_NAME = TDD03L-FIELDNAME.
WFIELD-TABNAME = TDD03L-TABNAME.
WFIELD-FIELDNAME = TDD03L-FIELDNAME.
WFIELD-POSITION = TDD03L-POSITION.
WFIELD-INTLENGTH = TDD03L-LENG.
WFIELD-EXID = TDD03L-INTTYPE.
WFIELD-OFFSET = T_OFFSET.
APPEND WFIELD TO TFIELD.
ENDLOOP.
T_OFFSET = T_OFFSET + TDD03L-LENG.
ENDLOOP.
*****
CLEAR ERROR.
CALL METHOD MM_INTERFACE->SET_DATA_SOURCE
** EXPORTING
** DDIC_NAME = 'ZXXX'
**** no_flush = 'X'
IMPORTING
RETCODE = RETCODE
ERROR = ERROR
CHANGING
DATA_TABLE = TDATA
FIELDS_TABLE = TFIELD.
IF RETCODE EQ C_OI_ERRORS=>RET_OK.
" Document opened successfully
ELSE.
CALL METHOD C_OI_ERRORS=>RAISE_MESSAGE
EXPORTING TYPE = 'I'.
ENDIF.