Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in sending mail

Former Member
0 Kudos

Hi,

I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to trigger email to Distribution lists. I have 2 distribution lists:- One for To-receipients and one for Cc-receipients.

The issue here is the function module is returning no error but the emails are not triggered to the distribution lists.

Help is appreciated to solve this issue.

10 REPLIES 10

Former Member
0 Kudos

Hi Dinkan,

Did you check the allowed email addresses in SCOT TCode? this might be stopping the emails from getting triggered.

Thanks

0 Kudos

Yes it allows upto 16....I have maintained only 1 reciepient in each of the distribution lists.

Clemenss
Active Contributor
0 Kudos

Hi Dinkan,

First of all: Do not use FM SO_NEW_DOCUMENT_ATT_SEND_API1 but CL_BCS.

FORM mail .
  DATA:
    lo_bcs                    TYPE REF TO cl_bcs,
    lt_soli                   TYPE TABLE OF soli,
    lo_document_bcs           TYPE REF TO cl_document_bcs,
    lo_sapuser_bcs            TYPE REF TO cl_sapuser_bcs,
    lo_recipient_bcs          TYPE REF TO if_recipient_bcs,
    lv_soli                   TYPE soli,
    lx_bcs                    TYPE REF TO cx_bcs,
    lv_string                 TYPE string,
    lv_done                   TYPE flag,
    lv_len                    TYPE sy-linsz,
    lv_strlen                 TYPE int4,
    lv_ofs                    TYPE sy-fdpos.
  FIELD-SYMBOLS:
    <soli>                      TYPE soli.
  TRY.
      CONCATENATE:
        'Hi.'
        'I created a program before (which runs dialog and save local TXT file) that worked fine to store up to 240 characters.'
        'But now, I create a new program to run in BACKGROUND and built a TXT file and send it attached by mail.'
        'When inside a form preparing the table lines, I use CONCATENATE statement to concatenate all fields (type c) into ls_line type text2048.'
        'Table also has type text2048.'
        'It''s truncating this text line to 255 characters.'
        'PS: When debugguing I can see all variables filled in concatenate statement, but its result is a line size truncated to 255. Even the result variable having size of 2048.'
        'What is wrong with program or concatenate ?'
        'thanks.'
        'Glauco' INTO lv_string SEPARATED BY cl_abap_char_utilities=>cr_lf.
      lv_strlen = strlen( lv_string ).
      APPEND INITIAL LINE TO lt_soli ASSIGNING <soli>.
      DESCRIBE FIELD <soli> LENGTH lv_len IN CHARACTER MODE.
      WHILE lv_done IS INITIAL.
        IF lv_ofs + lv_len > lv_strlen.
          lv_len = lv_strlen - lv_ofs.
        ENDIF.
        <soli> = lv_string+lv_ofs(lv_len).
        ADD lv_len TO lv_ofs.
        IF lv_ofs >= lv_strlen.
          lv_done = abap_true.
        ELSE.
          APPEND INITIAL LINE TO lt_soli ASSIGNING <soli>.
        ENDIF.
      ENDWHILE.
      lo_bcs = cl_bcs=>create_persistent( ).
 
*     -------- create and set lo_document_bcs -------------------------------
*     create lo_document_bcs from internal table with text
      lo_document_bcs = cl_document_bcs=>create_document(
                      i_type    = 'RAW'
                      i_text    = lt_soli
                      i_subject = 'More than 255 characters mail' ).
 
      lo_document_bcs->add_attachment(
           i_attachment_type     = 'TXT'
          i_attachment_subject  = 'Attachment 1'
           i_att_content_text    = lt_soli
             ).
      lo_document_bcs->add_attachment(
           i_attachment_type     = 'TXT'
          i_attachment_subject  = 'Attachment 2'
           i_att_content_text    = lt_soli
             ).
*     add lo_document_bcs to send request
      lo_bcs->set_document( lo_document_bcs ).
 
*     --------- set lo_sapuser_bcs -------------------------------------------
*     note: this is necessary only if you want to set the lo_sapuser_bcs
*           different from actual user (SY-UNAME). Otherwise lo_sapuser_bcs is
*           set automatically with actual user.
 
      lo_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ).
      lo_bcs->set_sender( i_sender = lo_sapuser_bcs ).
 
*     --------- add lo_recipient_bcs (e-mail address) -----------------------
*     create lo_recipient_bcs - please replace e-mail address !!!
      lo_recipient_bcs = cl_cam_address_bcs=>create_internet_address(
                                        'mail_ID_at_subdomain.domain' ).
 
*     add lo_recipient_bcs with its respective attributes to send request
      lo_bcs->add_recipient(
          i_recipient = lo_recipient_bcs
          i_express   = abap_true ).
      lo_bcs->set_send_immediately( abap_true ).
*     ---------- send lo_document_bcs ---------------------------------------
      lo_bcs->send( abap_true ).
 
      COMMIT WORK.
    CATCH cx_send_req_bcs cx_document_bcs cx_address_bcs .
      MESSAGE 'Mail sending failed' TYPE 'E' .
  ENDTRY.
ENDFORM.                    " MAIL

Here I sent a mail with two text attachments. Once you tried CL_BCS you'll never again have questions about mail from ABAP - never again will use SO_NEW_DOCUMENT....

Regards,

Clemens

Former Member
0 Kudos

Hi Clemens,

I am using ur method but no mail is sent through dynamic actions.

Suggest me .

Regards,

Anish

0 Kudos

Put a break point and check whether this particular code (lei's) is executing or not??

More over go to SOST and check whether the mail is available or not? some times buffer issues so just make Hits unlimited and try it out

sas

Former Member
0 Kudos

Hi after calling FM for send mail, submit your to program RSCONN01 with MODE EQ 'INT'.

For detail ...

  • Sending the Form Output in the PDF format to email

CALL FUNCTION 'ZSO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = GS_DOCDATA

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

OBJECT_HEADER = GT_OBJHEAD

PACKING_LIST = GT_OBJPACK

CONTENTS_BIN = GT_OBJBIN

CONTENTS_TXT = GT_OBJTXT

RECEIVERS = GT_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.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

  • MESSAGE 'Sent Successfully' TYPE 'W'.

ENDIF.

SUBMIT RSCONN01 WITH MODE EQ 'INT' AND RETURN.

Hope this will solve your problem.

0 Kudos

Hi,

> SUBMIT RSCONN01 WITH MODE EQ 'INT' AND RETURN.

You will always find another obsolete way to make tasks more complex and buggy than necessary to make sure they will need you next time.

lo_bcs->set_send_immediately( abap_true ).

could possibly be understood by anyone

Regards,

Clemens

0 Kudos

SUBMIT RSCONN01 WITH MODE EQ 'INT' AND RETURN.

Hope this will solve your problem.

Yikes...you should never submit RSCONN01 manually. This program is generally batch scheduled with certain load balancing parameters. You do realize that it dispatches everything in the queue?

I don't understand why you would use a 'Z' copy of the old API1 function with the same parameters either?

Former Member
0 Kudos

Hi,

Pass this statement after function module is returning sy-subrc is 0.

SUBMIT RSCONN01 WITH MODE EQ 'INT' AND RETURN.

Regards,

Dhina..

Former Member
0 Kudos

Thanks All for valuable help..