16 Replies Latest reply: Sep 13, 2010 6:39 PM by Break Point RSS

SO_NEW_DOCUMENT_SEND_API1 multiple recipients

Anne Gerten
Currently Being Moderated

Hi,

 

I am using SO_NEW_DOCUMENT_SEND_API1 and it is working fine for me if there is one recipient.

 

Now I want to send the email to more than one recipient, so I just added the additional recipients into the table LT_MAILRECIPIENTS.

 

LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
LT_MAILRECIPIENTS-RECEIVER = 'email1address'.
APPEND LT_MAILRECIPIENTS .
LT_MAILRECIPIENTS-RECEIVER = 'email2address'.
APPEND LT_MAILRECIPIENTS .
CLEAR LT_MAILRECIPIENTS.

 

Now if I call the function, it will only send to the first recipient in the table!

I tried to do  a loop at   LT_MAILRECIPIENTS and then call the function. Then it will send to all of them, but in the above case, every recipient will receive 2 emails instead of only 1.

 

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = LT_MAILSUBJECT
      TABLES
        OBJECT_CONTENT             = LT_MAILTXT
        RECEIVERS                  = LT_MAILRECIPIENTS
      EXCEPTIONS
        TOO_MANY_RECEIVERS         = 1
        DOCUMENT_NOT_SENT          = 2
        DOCUMENT_TYPE_NOT_EXIST    = 3
        OPERATION_NO_AUTHORIZATION = 4
        PARAMETER_ERROR            = 5
        X_ERROR                    = 6
        ENQUEUE_ERROR              = 7
        OTHERS                     = 8.
    IF SY-SUBRC EQ 0.
      COMMIT WORK.

 

Any suggestions how I can send the email to all recipients in my table?

 

Thanks

Anne

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Abhinandan Alandkar
    Currently Being Moderated

    Go through this already available program on Wiki carefully, i hope it will help you solve your problem.

     

    [http://wiki.sdn.sap.com/wiki/display/Snippets/SendMultipleAttachmentsofSpoolwithE-mail]

     

    Regards

    Abhii

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Kesavadas Thekkillath
    Currently Being Moderated

    Your code seems to be fine.

     

    How is LT_MAILRECIPIENTS declared ?

    • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
      Anne Gerten
      Currently Being Moderated

      Hi,

       

      this is how LT_MAILRECIPIENTS  is declared:

       

      DATA: LT_MAILRECIPIENTS  TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER

      LINE.

       

      thanks

      Anne

      • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
        V Gunturi
        Currently Being Moderated

        try this..

         

        data: LT_MAILRECIPIENTS type standard table of SOMLRECI1.
        
        or 
        
        DATA: LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 . "WITH HEADERLINE.
        

         

        • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
          Anne Gerten
          Currently Being Moderated

          Hi,

           

          I tried the following, but it didn't help.

          data: LT_MAILRECIPIENTS type standard table of SOMLRECI1 WITH HEADER
          LINE.
          

           

          I just realized that I forgot to copy the last 2 lines of my function call.

           

          * Send Mail
              CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                EXPORTING
                  DOCUMENT_DATA              = LT_MAILSUBJECT
                TABLES
                  OBJECT_CONTENT             = LT_MAILTXT
                  RECEIVERS                  = LT_MAILRECIPIENTS
                EXCEPTIONS
                  TOO_MANY_RECEIVERS         = 1
                  DOCUMENT_NOT_SENT          = 2
                  DOCUMENT_TYPE_NOT_EXIST    = 3
                  OPERATION_NO_AUTHORIZATION = 4
                  PARAMETER_ERROR            = 5
                  X_ERROR                    = 6
                  ENQUEUE_ERROR              = 7
                  OTHERS                     = 8.
              IF SY-SUBRC EQ 0.
                COMMIT WORK.
          
          *   Push mail out from SAP outbox
                SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
              ENDIF.
          

           

          Can it have something to do with the line?

          SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.

           

          thanks

          Anne

          • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
            V Gunturi
            Currently Being Moderated
            data: LT_MAILRECIPIENTS type standard table of SOMLRECI1. " WITH HEADER LINE.
            
            * Send Mail
                CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                  EXPORTING
                    DOCUMENT_DATA              = LT_MAILSUBJECT
                  TABLES
                    OBJECT_CONTENT             = LT_MAILTXT
                    RECEIVERS                  = LT_MAILRECIPIENTS
                  EXCEPTIONS
                    TOO_MANY_RECEIVERS         = 1
                    DOCUMENT_NOT_SENT          = 2
                    DOCUMENT_TYPE_NOT_EXIST    = 3
                    OPERATION_NO_AUTHORIZATION = 4
                    PARAMETER_ERROR            = 5
                    X_ERROR                    = 6
                    ENQUEUE_ERROR              = 7
                    OTHERS                     = 8.
                IF SY-SUBRC EQ 0.
                  COMMIT WORK.
             
            *   Push mail out from SAP outbox
                  SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
                ENDIF.

             

            or

             

             

            2. If you declaring internal table with header line, then pass  LT_MAILRECIPIENTS[] to FM as Keshav mentioned.

             

            data: LT_MAILRECIPIENTS type standard table of SOMLRECI1 WITH HEADER LINE.
            * Send Mail
                CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                  EXPORTING
                    DOCUMENT_DATA              = LT_MAILSUBJECT
                  TABLES
                    OBJECT_CONTENT             = LT_MAILTXT
                    RECEIVERS                  = LT_MAILRECIPIENTS[]. "LT_MAILRECIPIENTS
                  EXCEPTIONS
                    TOO_MANY_RECEIVERS         = 1
                    DOCUMENT_NOT_SENT          = 2
                    DOCUMENT_TYPE_NOT_EXIST    = 3
                    OPERATION_NO_AUTHORIZATION = 4
                    PARAMETER_ERROR            = 5
                    X_ERROR                    = 6
                    ENQUEUE_ERROR              = 7
                    OTHERS                     = 8.
                IF SY-SUBRC EQ 0.
                  COMMIT WORK.
             
            *   Push mail out from SAP outbox
                  SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
                ENDIF.

             

            • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
              Anne Gerten
              Currently Being Moderated

              Hi  gvsastry,

               

              I tried both of your options.

               

              For the first, I cannot activate the code, I get:

              "LT_MAILRECIPIENTS" is a table without a header line and therefore has no component called "REC_TYPE".

               

              I can activate the 2nd option, but here I only get one email instead of two.

               

              Thanks

              Anne

              • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
                V Gunturi
                Currently Being Moderated

                >

                Anne wrote:

                 

                > Hi  gvsastry,

                >

                > I tried both of your options.

                >

                > For the first, I cannot activate the code, I get:

                > "LT_MAILRECIPIENTS" is a table without a header line and therefore has no component called "REC_TYPE".

                 

                     

                DATA: LS_MAILRECIPIENTS TYPE SOMLRECI1.
                   APPEND LS_MAILRECIPIENTS TO LT_MAILRECIPIENTS.

                >

                > I can activate the 2nd option, but here I only get one email instead of two.

                >

                > Thanks

                > Anne

                 

                I would suggest you debug and see how many entries are present in lt_mailrecipients when you are passing to FM.

                • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
                  Anne Gerten
                  Currently Being Moderated

                  Hi,

                   

                  I just debugged and there are two entries in LT[].

                   

                  The strange thing for me is, when I do the following, everyone in the list gets 2 emails. So it is behaving actually correct with the loop. Of course I don't want 2 emails, but it seems to send to EVERYONE in the list (vs. just for the first one) for each loop. Does that make sense?

                   

                  LOOP at LT_MAILRECIPIENTS.
                      CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                        EXPORTING
                          DOCUMENT_DATA              = LT_MAILSUBJECT
                        TABLES
                          OBJECT_CONTENT             = LT_MAILTXT
                          RECEIVERS                  = LT_MAILRECIPIENTS
                        EXCEPTIONS
                          TOO_MANY_RECEIVERS         = 1
                          DOCUMENT_NOT_SENT          = 2
                          DOCUMENT_TYPE_NOT_EXIST    = 3
                          OPERATION_NO_AUTHORIZATION = 4
                          PARAMETER_ERROR            = 5
                          X_ERROR                    = 6
                          ENQUEUE_ERROR              = 7
                          OTHERS                     = 8.
                      IF SY-SUBRC EQ 0.
                        COMMIT WORK.
                  
                  *   Push mail out from SAP outbox
                        SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
                      ENDIF.
                  endloop.
                  

                   

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Gautham Vangaveti
    Currently Being Moderated

    Try this code.

     

    LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
    LT_MAILRECIPIENTS-RECEIVER = 'email1address'.
    APPEND LT_MAILRECIPIENTS .
    
    LT_MAILRECIPIENTS-REC_TYPE  = 'U'.
    LT_MAILRECIPIENTS-RECEIVER = 'email2address'.
    APPEND LT_MAILRECIPIENTS .
    
    
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
          EXPORTING
            DOCUMENT_DATA              = LT_MAILSUBJECT
          TABLES
            OBJECT_CONTENT             = LT_MAILTXT
            RECEIVERS                  = LT_MAILRECIPIENTS
          EXCEPTIONS
            TOO_MANY_RECEIVERS         = 1
            DOCUMENT_NOT_SENT          = 2
            DOCUMENT_TYPE_NOT_EXIST    = 3
            OPERATION_NO_AUTHORIZATION = 4
            PARAMETER_ERROR            = 5
            X_ERROR                    = 6
            ENQUEUE_ERROR              = 7
            OTHERS                     = 8.
        IF SY-SUBRC EQ 0.
          COMMIT WORK.
        ENDIF.
    

     

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Jerry Wang
    Currently Being Moderated

    Hello Anne,

     

    you can refer to this link, it is talking about the same topic as yours.

     

    how to send mails to multiple recipents using SO_DOCUMENT_SEND_API

     

    Best Regards,

    Jerry

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Kesavadas Thekkillath
    Currently Being Moderated

    Just a try,

     

    pass it like

     

    RECEIVERS                  = LT_MAILRECIPIENTS[].

     

    Its time to get rid of header lines

     

    Instead of this fm i suggest you to use the BCS classes available. This fm doesnt support certain code pages.

    For BCS classes example sin SE38 just search for BCSEXAMPLE

     

    @gautham - I dont see any difference in OP's code and yours

  • Re: SO_NEW_DOCUMENT_SEND_API1 multiple recipients
    Break Point
    Currently Being Moderated

    In debug, look at the contents of your recipient table and be sure it is correct.  See SAP Note 609696 for update documentation and working code, should you decide to continue to use this out-of-date method for email.

Actions