Skip to Content
avatar image
Former Member

Mail Merge

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jun 21, 2011 at 06:35 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2011 at 02: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2015 at 04: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.

    Add comment
    10|10000 characters needed characters exceeded