Application Development and Automation 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: 
Read only

sending mails through report

Former Member
0 Likes
1,180

Hi all...

Now I am training on IDES version. Is it possible to send mails through (IDES demo version) by a report program...???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,143

Hi,

Configuration need to done in the IDES to send the email to external email id..

Check this link /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Hi all...

Now I am training on IDES version. Is it possible to send mails through (IDES demo version) by a report program...???

9 REPLIES 9
Read only

Former Member
0 Likes
1,143

Yes use the FM SO_DOCUMENT_SEND_API1 in the report program , This will send the data in the mail

Read only

0 Likes
1,143

Aaaaaa...... Can you also give a piece of code for that. It will be thankful

Read only

0 Likes
1,143

* Fill the document data.
  DESCRIBE TABLE gt_message LINES gv_cnt.
  READ TABLE gt_message INTO gs_message
                                INDEX gv_cnt.
  gs_doc_chng-doc_size   = ( gv_cnt - 1 ) * 255 + STRLEN( gs_message ).
  gs_doc_chng-obj_langu  = sy-langu.
  gs_doc_chng-obj_name   = 'CONJOB'.
  gs_doc_chng-obj_descr  = text-017.
  gs_doc_chng-sensitivty = 'F'.

* Fill the receiver list
  gs_reclist-rec_date   = sy-datum.
  gs_reclist-rec_type   = 'U' .         " For Internet Address
  gs_reclist-com_type   = 'INT'.
  gs_reclist-notif_ndel = c_x.
  gs_reclist-receiver   = p_email.       "Email addr of Recip
  APPEND gs_reclist TO gt_reclist.
  CLEAR gs_reclist.

  gs_packing_list-transf_bin = space.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE gt_message LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  APPEND gs_packing_list TO gt_packing_list.

  gs_packing_list-transf_bin = c_x.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE pt_attachment LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  gs_packing_list-obj_descr  = gv_atch_name.
  gs_packing_list-obj_name   = gv_atch_name.
  gs_packing_list-doc_size   = gs_packing_list-body_num * 255.
  APPEND gs_packing_list TO gt_packing_list.

* Send the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = gs_doc_chng
            put_in_outbox              = c_x
       TABLES
            packing_list               = gt_packing_list
            contents_txt               = gt_message
            contents_bin               = pt_attachment
            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 e138(zv) WITH text-013.
  ENDIF.

Please refer the below link...where it has been explained in detail..

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/sending+mail

hope it helps!

Read only

Former Member
0 Likes
1,144

Hi,

Configuration need to done in the IDES to send the email to external email id..

Check this link /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Read only

Former Member
0 Likes
1,143

Please find the Email FM with an example:

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
    document_data                    = gwa_doc_data
    put_in_outbox                    = 'X'
    commit_work                      = 'X'
  TABLES
    packing_list                     = git_packing_list
    contents_bin                     = git_contents_bin
    contents_txt                     = git_body
    receivers                        = git_send_email
 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

Mandatory Fields

Receivers - Recipient's Email Address

document data - Email Subject

Read only

former_member302911
Active Participant
0 Likes
1,143

Hi, try this example code:


DATA: MAILDATA LIKE SODOCCHGI1.
DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
DATA EMAIL TYPE SOMLREC90-RECEIVER VALUE 'EMAIL HERE'. "<- EMAIL HERE
CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC. 
REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD,MAILREC.
MAILDATA-OBJ_NAME = 'TEST'.
* MAIL SUBJECT
MAILDATA-OBJ_DESCR = 'Subject'.
* MAIL CONTENTS * HERE IS WHERE YOU PUT THE MAIL BODY CONTENTS.
MAILTXT-LINE = 'Here is your file'. 
APPEND MAILTXT.
PERFORM PREPARE_PACKING_LIST.
* SET RECIPIENT - EMAIL ADDRESS HERE!!!
MAILREC-RECEIVER = EMAIL.
MAILREC-REC_TYPE = 'U'. 
APPEND MAILREC.
* SENDING THE DOCUMENT
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    DOCUMENT_DATA              = MAILDATA
    PUT_IN_OUTBOX              = ' '
  TABLES
    PACKING_LIST               = MAILPACK
    OBJECT_HEADER              = MAILHEAD
    CONTENTS_BIN               = MAILBIN
    CONTENTS_TXT               = MAILTXT
    RECEIVERS                  = MAILREC
  EXCEPTIONS
    TOO_MANY_RECEIVERS         = 1
    DOCUMENT_NOT_SENT          = 2
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS                     = 99.
* FORM PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
  DATA: TAB_LINES LIKE SY-TABIX.
  CLEAR: MAILPACK, MAILBIN, MAILHEAD.
  REFRESH: MAILPACK, MAILBIN, MAILHEAD.
  DESCRIBE TABLE MAILTXT LINES TAB_LINES.
  READ TABLE MAILTXT INDEX TAB_LINES.
  MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
* CREATION OF THE ENTRY FOR THE COMPRESSED DOCUMENT
  CLEAR MAILPACK-TRANSF_BIN.
  MAILPACK-HEAD_START = 1. MAILPACK-HEAD_NUM = 0.
  MAILPACK-BODY_START = 1. MAILPACK-BODY_NUM = TAB_LINES.
  MAILPACK-DOC_TYPE = 'RAW'. 
  APPEND MAILPACK. MAILBIN = 'This is the attachment'.
  APPEND MAILBIN.
  DESCRIBE TABLE MAILBIN LINES TAB_LINES.
  MAILHEAD = 'TEST.OTF'. 
  APPEND MAILHEAD.
** CREATION OF THE ENTRY FOR THE COMPRESSED ATTACHMENT
  MAILPACK-TRANSF_BIN = 'X'. MAILPACK-HEAD_START = 1. MAILPACK-HEAD_NUM = 1.
  MAILPACK-BODY_START = 1. MAILPACK-BODY_NUM = TAB_LINES.
  MAILPACK-DOC_TYPE = 'OTF'.
  MAILPACK-OBJ_NAME = 'TEST'. MAILPACK-OBJ_DESCR = 'Subject'.
  MAILPACK-DOC_SIZE = TAB_LINES * 255.  APPEND MAILPACK.
ENDFORM                    "

Regards,

Angelo.

Read only

0 Likes
1,143

Pleases paste the code in CODE formate

Read only

0 Likes
1,143

hi,

Incase you want to send mails via a report make use of the class CL_BCS.

For examples you can check programs:

BCS_EXAMPLE_1

BCS_EXAMPLE_2

BCS_EXAMPLE_3

BCS_EXAMPLE_4

BCS_EXAMPLE_5

BCS_EXAMPLE_6

Regards,

Ankur Parab

Read only

Former Member
0 Likes
1,143

Hi ,

i think that u can not cofigure this in your IDES system,but i am not sure.Please let me know if you

still need any more help.

Thanks and regards,

Rajeshwar.