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

email using a function module

Former Member
0 Likes
645

hi experts,

i have been using SO_DOCUMENT_SEND_API1 function module to send a mail, i have sucessfully used it to send a mail but the subject line of the mail is coming empty. i want to display some text in it, how can it possible

5 REPLIES 5
Read only

Former Member
0 Likes
619

hi kiran kumar

Ask to BASIS Team. u are asking them how is work by Email Configuration?

They can solve you.

Regards,

S.Suresh.

Read only

Former Member
0 Likes
619

Hi

Hope it will help you.

In the Code, bold lines are the description for the mail.

Reward if help.

&----


*& Report ZEMAIL_SIVA

*&

&----


*&

*&

&----


REPORT zemail_siva.

DATA : gd_doc_data LIKE sodocchgi1,

l_i_mail TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,

it_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE.

DATA: w_pack TYPE sopcklsti1,

i_pack TYPE TABLE OF sopcklsti1.

PARAMETERS : p_email(100) TYPE c.

gd_doc_data-obj_descr = 'TEST EMAIL FROM ABAP SE TEAM'.

l_i_mail-line = 'Testing the Mail from ABAP on 31st March 2008'.

APPEND l_i_mail.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'A'.

it_receivers-com_type = 'INT'.

*it_receivers-notif_del = 'X'.

*it_receivers-notif_ndel = 'X'.

APPEND it_receivers.

CLEAR w_pack.

w_pack-head_start = 1.

w_pack-head_num = 0.

w_pack-body_start = 1.

DESCRIBE TABLE l_i_mail LINES w_pack-body_num.

w_pack-doc_type = 'RAW'.

w_pack-doc_size = w_pack-body_num * 255.

APPEND w_pack TO i_pack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gd_doc_data

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = i_pack

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = l_i_mail

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = it_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

..

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE : 'Mail Sent to specified address'.

ENDIF.

Read only

Former Member
0 Likes
619

Hi,

Compare this code with your code and pass all the parameters you have missed.code according to this code ,it will definitely work.

codeDATA:

IT_FORMAT TYPE STANDARD TABLE OF SOPCKLSTI1 WITH HEADER LINE,

IT_DEST TYPE STANDARD TABLE OF SOMLRECI1 WITH HEADER LINE,

IT_TEXT TYPE STANDARD TABLE OF SOLISTI1 WITH HEADER LINE,

IT_SUBJ TYPE STANDARD TABLE OF SODOCCHGI1 WITH HEADER LINE.

IMPORT IT_SUBJ FROM MEMORY ID 'SUBL'.

IMPORT IT_FORMAT FROM MEMORY ID 'FORMAT'.

IMPORT IT_TEXT FROM MEMORY ID 'TEXT'.

IMPORT IT_DEST FROM MEMORY ID 'DEST'.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = IT_SUBJ

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = IT_FORMAT

CONTENTS_TXT = IT_TEXT

RECEIVERS = IT_DEST

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.[/code]

It should only be a structure.

codedata: wa_SUBJ TYPE SODOCCHGI1 .[/code]

Make sure it is this way in the importing and exporting progams.

Regards,

Raj.

Read only

0 Likes
619

hi experts,

Using the above function module, i could create an attach ment of all the data to be send, but i want all the data in the mail body only ,but not in attachment file, how can i do it, what parameters have to be used to populate my data in internal table to the above function module to display in mail body

Read only

Former Member
0 Likes
619

Hello ,

Goto to the SE37 and open the FM and

Goto -> Documentation...

This is the way to check the properties of FM related to Subject in Email

And also look at this program....



FORM mail_body.
  DATA:  l_l1 TYPE i.
  CONSTANTS: lc_0 VALUE '0',
             lc_1 VALUE '1',
             lc_raw(3) TYPE c VALUE 'RAW'.
  REFRESH: i_objtxt[],
           i_objpack[].
  CLEAR: wa_objtxt.
  SORT i_fail BY type.
 
* MAIL BODY
* Customer Number
  CONCATENATE text-t18
              w_kunnr
              INTO wa_objtxt
              SEPARATED BY space.
  APPEND wa_objtxt TO i_objtxt.
  CLEAR wa_objtxt.                        "blank line
  APPEND wa_objtxt TO i_objtxt.
*  Complete Payment Doc Nos
     wa_objtxt = text-t16.
    APPEND wa_objtxt TO i_objtxt.
    CLEAR: wa_fail, wa_objtxt.
    APPEND wa_objtxt TO i_objtxt.
    MOVE: text-t23   TO wa_objtxt,
          text-t24   TO wa_objtxt+17(5),
          text-t25   TO wa_objtxt+22(6),
          text-t26   TO wa_objtxt+40(18).
    APPEND wa_objtxt TO i_objtxt.
    CLEAR wa_objtxt.
 
    LOOP AT i_fail INTO wa_fail WHERE type EQ c_comp.
      DIVIDE wa_fail-disper BY 100.
      MOVE: wa_fail-belnr   TO wa_objtxt,
            wa_fail-buzei   TO wa_objtxt+17(5),
            wa_fail-wrbtr   TO wa_objtxt+22(16),
            wa_fail-disper  TO wa_objtxt+40(18).
      APPEND wa_objtxt TO i_objtxt.
      CLEAR: wa_fail, wa_objtxt.
    ENDLOOP.
  
* MAIL BODY-LENGTH
  DESCRIBE TABLE i_objtxt LINES l_l1.
  CLEAR wa_objpack-transf_bin.
  wa_objpack-head_start = lc_1.
  wa_objpack-head_num = lc_0.
  wa_objpack-body_start = lc_1.
  wa_objpack-body_num = l_l1.
  wa_objpack-doc_type = lc_raw.
  APPEND wa_objpack TO i_objpack.
 
*SUBJECT
  CLEAR wa_doc_chng.
  wa_doc_chng-obj_name  = text-t15.
  wa_doc_chng-obj_descr = text-t15.
ENDFORM.                    " mail_body
 
*&---------------------------------------------------------------------*
*&      Form  send_mail
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM send_mail.
  CONSTANTS: lc_c       TYPE so_escape VALUE 'C',
             lc_mode(3) TYPE c         VALUE 'INT'.
  CLEAR: wa_reclist, i_reclist[].
*Recipient list
  wa_reclist-receiver = text-t14.       "DL
  wa_reclist-rec_type = lc_c.
  APPEND wa_reclist TO i_reclist.
 
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data                    = wa_doc_chng
        put_in_outbox                    = c_x
*     IMPORTING
*       SENT_TO_ALL                      =
*       NEW_OBJECT_ID                    =
      TABLES
        packing_list                     = i_objpack
*       OBJECT_HEADER                    =
*       CONTENTS_BIN                     =
        contents_txt                     = i_objtxt
*       CONTENTS_HEX                     =
*       OBJECT_PARA                      =
*       OBJECT_PARB                      =
        receivers                        = i_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.
*    ENDIF.
  IF sy-subrc IS INITIAL.
*Send mail immediately
    SUBMIT rsconn01 USING SELECTION-SET lc_mode AND RETURN.
    CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.
  ELSE.
    RAISE mail_not_sent.
  ENDIF.
ENDFORM.                    " send_mail