Skip to Content

Problem on mail sending program (SO_NEW_DOCUMENT_ATT_SEND_API1)

Hi Experts,

I have one mail sending program .i.e Sending mail body as HTML format. In this program i have one major problems.

Problem 1:

sometimes My mail content is going as attachment Along with my mail content. The attachment have the same content like my mail content. Sometimes many number of attachment is going like 7,8,9 , etc.. Sometimes no attachment is going . Only the mail content is going without attachment. I confused lot about this. I dont know why this happening and how its happening. Please help me.

Note:

I am using SO_NEW_DOCUMENT_ATT_SEND_API1 function module for sending my mail as HTML format.

Please Help me for this. If my details is not enough for you. Please tell me . I will update my more information. Like screen shots, Coding Etc.

Thanks and Regards

Linganathan.K

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2012 at 05:45 PM

    if you must use this ancient API, instead of SAP's current email technology (BCS - see programs named like BCS* for great working examples, including attachments)....

    If you are doing this in a loop, and I suspect you are, be sure that you CLEAR the recipeints, the packing list, etc., ALL the tables and objects before you build them again for the next send...I suspect that you are "doubling up on each iteration of the loop that calls this antiquated API.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2012 at 07:57 AM

    Hi,

    try to passing only below fields to FM , dont pass the Attachment field to fucntion module.

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = gs_doc_data
    put_in_outbox = 'X'
    commit_work = 'X'
    TABLES
    packing_list = gt_packing_list
    object_header = gt_objhead
    contents_txt = gt_message
    receivers = gt_receivers
    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2012 at 10:27 AM

    Dear Experts,

    Can anyone please help me to solve my issue. Its Important for me.

    Thanks ,

    Linganathan.K

    Add a comment
    10|10000 characters needed characters exceeded

    • There can be but at this time as you are saying its urgent this is probably the best one.

      It has been many a times reported on scn regarding the errors or weird behavior of this FM.

      For a hit and trial basis you can where use the FM and check for the necessary fields that have been passed in standard SAP.

      Regards,

      Sandeep

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2012 at 09:56 AM

    Hi,

    Can u plz provide ur code.

    Regard's

    Smruti

    Add a comment
    10|10000 characters needed characters exceeded

    • Dear Smruthi Ranjan,

      I am pasting the code.

      loop at it_second. " from this code

      data billno like vbrk-vbeln.

      data itab like table of it_second with header line.

      data itab1 like table of it_second with header line.

      data dat1 type string.

      data dat3 type string.

      data dat type dats.

      data dat2 type dats.

      dat = sy-datum + 2.

      dat2 = sy-datum.

      concatenate dat+6(2) '.' dat+4(2) '.' dat+0(4) into dat1.

      concatenate dat2+6(2) '.' dat2+4(2) '.' dat2+0(4) into dat3.

      if it_second-d_date = dat.

      move it_second to itab.

      move it_second to itab1.

      append itab.

      append itab1.

      endif.

      endloop.

      sort itab by custno.

      DELETE ADJAcenT DUPLICATES from itab COMPARING custno.

      loop at itab.

      data adrnr1 like kna1-adrnr.

      data mailid like adr6-SMTP_ADDR.

      select adrnr from kna1 into adrnr1 where kunnr = itab-custno.

      endselect.

      select SMTP_ADDR from adr6 into mailid where ADDRNUMBER = adrnr1.

      endselect.

      read table itab1 with key custno = itab-custno.

      loop at itab1 where custno = itab-custno.

      *if itab-custno is not initial.

      move itab1-vbeln1 to it_third.

      append it_third.

      endloop.

      DATA:

      w_docdata TYPE sodocchgi1,

      w_objtxt TYPE solisti1,

      w_objbin TYPE solisti1,

      w_objpack TYPE sopcklsti1,

      w_reclist TYPE somlreci1,

      w_lines TYPE i,

      * Table declaration

      t_objtxt TYPE TABLE OF solisti1, " Message body

      t_objpack TYPE TABLE OF sopcklsti1, " Packing list

      t_reclist TYPE TABLE OF somlreci1, " Receipient list

      t_objhead TYPE TABLE OF solisti1. " Header

      data: time type sy-uzeit,

      out_type(2) TYPE c.

      CALL FUNCTION 'HRVE_CONVERT_TIME'

      EXPORTING

      TYPE_TIME = 'A'

      INPUT_TIME = sy-uzeit

      INPUT_AM_PM = 'AM'

      IMPORTING

      OUTPUT_TIME = time

      OUTPUT_AM_PM = out_type

      EXCEPTIONS

      PARAMETER_ERROR = 1

      OTHERS = 2

      .

      concatenate time+0(2) '.' time+2(2) into time.

      w_docdata-obj_name = 'Payment Reminder'.

      w_docdata-obj_descr = 'Payment Reminder'.

      * Message Body

      w_objtxt-line = '<html> <body>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<p> Dear Customer, </p>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<p> This is to remind that the following invoice(s) due date falls on '.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = dat1.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = 'as per our records for'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = itab-name1.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = 'as on'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = dat3.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = time.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = out_type.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<br><br>'.

      APPEND w_objtxt TO t_objtxt.

      * table display

      w_objtxt-line = '<table style="MARGIN: 5px" bordercolor="blue" '.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = ' cellspacing="0" cellpadding="8" width="400"'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = ' border="1"><tbody><tr>'.

      APPEND w_objtxt TO t_objtxt.

      * table header

      w_objtxt-line = '<th bgcolor="yellow">Billing Document Number</th>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<th bgcolor="yellow">Due Date</th>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<th bgcolor="yellow">Amount</th></tr>'.

      APPEND w_objtxt TO t_objtxt.

      data: details(850),

      details6(450),

      details9(450),

      details7(450),

      details8(450),

      details10(450),

      details11(450),

      details12(450),

      details90 type string.

      loop at it_third.

      LOOP AT ITAB1 WHERE VBELN1 = IT_THIRD-BILLNO1.

      *read table itab1 with key vbeln1 = IT_THIRD-BILLNO1.

      details8 = it_third-billno1.

      details90 = itab1-wrbtr.

      details9 = itab-d_date.

      concatenate details9+6(2) '.' details9+4(2) '.' details9+0(4) into details10.

      CONCATENATE '<tr style="background-color:#eeeee;"><td>'

      details8

      '</td>'

      INTO w_objtxt-line.

      APPEND w_objtxt TO t_objtxt.

      CONCATENATE '<td>' details10 '</td> ' INTO w_objtxt-line.

      APPEND w_objtxt TO t_objtxt.

      CONCATENATE '<td>' details90 '</td> </tr>' INTO w_objtxt-line.

      APPEND w_objtxt TO t_objtxt.

      clear it_third.

      endloop.

      endloop.

      w_reclist-receiver = mailid.

      w_reclist-rec_type = 'U'.

      APPEND w_reclist TO t_reclist.

      CLEAR w_reclist.

      *free it_third.

      w_objtxt-line = '</tbody> </table>'.

      APPEND w_objtxt TO t_objtxt.

      * Signature with background color

      w_objtxt-line = '<br><br>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<p> Please ignore this mail if payment is already made.</p>'.

      w_objtxt-line = '<br>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<p> Regards,</p>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<br><br>'.

      w_objtxt-line = '<p> - Accounts Receivable Team - </p>'.

      APPEND w_objtxt TO t_objtxt.

      w_objtxt-line = '<br><br>'.

      w_objtxt-line = '<p> Surana Industries Limited.</p>'.

      APPEND w_objtxt TO t_objtxt.

      * Document data

      DESCRIBE TABLE t_objtxt LINES w_lines.

      READ TABLE t_objtxt INTO w_objtxt INDEX w_lines.

      w_docdata-doc_size =

      ( w_lines ) * 255 + STRLEN( w_objtxt ).

      * Packing data

      CLEAR w_objpack-transf_bin.

      w_objpack-head_start = 1.

      w_objpack-head_num = 0.

      w_objpack-body_start = 1.

      w_objpack-body_num = w_lines.

      * we will pass the HTML, since we have created the message

      * body in the HTML

      w_objpack-doc_type = 'HTML'.

      APPEND w_objpack TO t_objpack.

      free it_third. " its clearing it_third internal table values.

      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

      EXPORTING

      document_data = w_docdata

      put_in_outbox = 'X'

      commit_work = 'X'

      TABLES

      packing_list = t_objpack

      object_header = t_objhead

      contents_txt = t_objtxt

      receivers = t_reclist

      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 <> 0.

      ELSE.

      MESSAGE 'Message Sent' TYPE 'S'.

      ENDIF.

      clear : mailid.

      free t_reclist .

      free t_objtxt.

      clear it_third.

      endloop.

      Thanks and Regards,

      Linganathan

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.