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

Function Module

Former Member
0 Likes
877

Hello,

Is there any FM that sends a mail via SAP inbox to the distribution list or user group.It should sent to a distribution List or the user group not to individual receipients..What should be the parameters that shud pass to the FM?

Thanks

Vinod

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
742

Hi, please see the following code, notice that when filling the mailrec table, I am passing a distribution list which I created in "WorkPlace". You also need to set the RECTYPE = 'C', for shared distribution, or 'P' for private distribution list.



report zrich_0003 .

* For API
data: maildata type sodocchgi1.
data: mailtxt  type table of solisti1 with header line.
data: mailrec  type table of somlrec90 with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test'.
  maildata-obj_langu = sy-langu.

  mailtxt-line = 'This is a test'.
  append mailtxt.

<b>  mailrec-receiver = 'ZTESTDSTLIST'.
  mailrec-rec_type  = 'C'.
  append mailrec.</b>

    call function 'SO_NEW_DOCUMENT_SEND_API1'
         exporting
              document_data              = maildata
              document_type              = 'RAW'
              put_in_outbox              = 'X'
         tables
              object_header              = mailtxt
              object_content             = mailtxt
              receivers                  = mailrec
         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.
* submit rsconn01 with mode = 'INT' and return.

Regards,

Rich Heilman

7 REPLIES 7
Read only

Former Member
0 Likes
742

hi Vicky,

Check

http://www.sap-img.com/fu016.htm

Reards,

Santosh

Read only

Former Member
0 Likes
742

u can use this FM SO_NEW_DOCUMENT_ATT_SEND_API1

and give the recipient mail id as group mail id , so that automatically it will be sent to group

Read only

anversha_s
Active Contributor
0 Likes
742

hi,

chk this.

REPORT Z895_DOCATTC.

data : wa_doc_data like SODOCCHGI1,

v_lin like Sy-tabix,

v_obj_id like SOFOLENTI1-OBJECT_ID.

data : wa_reciever like SOMLRECI1,

t_reciever like standard table of wa_reciever.

data : wa_pk_list like SOPCKLSTI1,

t_pk_list like standard table of wa_pk_list.

data : wa_con_txt like SOLISTI1,

t_TEMP like standard table of wa_con_txt,

t_con_txt like standard table of wa_con_txt.

wa_con_txt = 'hello'.

append wa_con_txt to t_con_txt.

append wa_con_txt to t_con_txt.

describe table t_con_txt lines v_lin.

read table t_con_txt index v_lin into wa_con_txt.

wa_doc_data-doc_size = ( v_lin - 1 ) * 255 + strlen( wa_con_txt ).

wa_doc_data-OBJ_NAME = 'ATC'.

wa_doc_data-OBJ_DESCR = 'to send an attachment'.

wa_doc_data-OBJ_LANGU = 'E'.

<b>wa_reciever-RECEIVER = 'xyz@yahoo.com'.

wa_reciever-REC_TYPE = 'B'.

wa_reciever-com_type = 'INT'.

append wa_reciever to t_reciever.

"add more recivers like above</b>

clear wa_pk_list-transf_bin.

wa_pk_list-head_start = 1.

wa_pk_list-head_num = 0.

wa_pk_list-BODY_START = 1.

wa_pk_list-body_num = v_lin.

wa_pk_list-doc_type = 'RAW'.

append wa_pk_list to t_pk_list.

to upload a pdf file

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings'

FILETYPE = 'BIN'

TABLES

DATA_TAB = T_TEMP

.

DESCRIBE TABLE T_TEMP LINES V_LIN.

WA_PK_LIST-TRANSF_BIN = 'X'.

WA_PK_LIST-HEAD_NUM = 0.

WA_PK_LIST-BODY_START = 1.

WA_PK_LIST-BODY_NUM = V_LIN.

WA_PK_LIST-DOC_TYPE = 'PDF'.

WA_PK_LIST-OBJ_NAME = 'ATTACHMENT'.

WA_PK_LIST-OBJ_DESCR = 'Reproduction object 138'.

WA_PK_LIST-DOC_SIZE = V_LIN * 255.

APPEND WA_PK_LIST TO T_PK_LIST..

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = wa_doc_data

IMPORTING

NEW_OBJECT_ID = v_obj_id

TABLES

PACKING_LIST = t_pk_list

CONTENTS_BIN = T_TEMP

CONTENTS_TXT = t_con_txt

RECEIVERS = t_reciever

rgds

anver

.

Read only

Former Member
0 Likes
742

HI,

See this one, you need to create a Function module for this one ..This is copied from web

<b>ABAP CODE</b>

  • Email ITAB structure

DATA: BEGIN OF EMAIL_ITAB OCCURS 10.

INCLUDE STRUCTURE SOLI.

DATA: END OF EMAIL_ITAB.

DATA: T_EMAIL LIKE SOOS1-RECEXTNAM. "EMail distribution list

<b>CONSTANTS: C_EMAIL_DISTRIBUTION LIKE SOOS1-RECEXTNAM VALUE ‘abc@here.com,abc@there.com’.</b>

  • Initialization

REFRESH EMAIL_ITAB.

  • Populate data

EMAIL_ITAB-LINE = ‘Email body text 1’.

APPEND EMAIL_ITAB.

EMAIL_ITAB-LINE = ‘Email body text 2’.

APPEND EMAIL_ITAB.

T_EMAIL = C_EMAIL_DISTRIBUTION.

CALL FUNCTION 'Z_SEND_EMAIL_ITAB'

EXPORTING

APPLICATION = 'EMAIL'

EMAILTITLE = 'Email Subject'

RECEXTNAM = T_EMAIL

TABLES

TEXTTAB = EMAIL_ITAB

EXCEPTIONS

OTHERS = 1.

-


<b>FUNCTION MODULE</b>

-


Function Z_SEND_EMAIL_ITAB

""Local interface:

*" IMPORTING

*" VALUE(APPLICATION) LIKE SOOD1-OBJNAM

*" VALUE(EMAILTITLE) LIKE SOOD1-OBJDES

*" VALUE(RECEXTNAM) LIKE SOOS1-RECEXTNAM

*" TABLES

*" TEXTTAB STRUCTURE SOLI

*"----


*- local data declaration

DATA: OHD LIKE SOOD1,

OID LIKE SOODK,

TO_ALL LIKE SONV-FLAG,

OKEY LIKE SWOTOBJID-OBJKEY.

DATA: BEGIN OF RECEIVERS OCCURS 0.

INCLUDE STRUCTURE SOOS1.

DATA: END OF RECEIVERS.

*- fill odh

CLEAR OHD.

OHD-OBJLA = SY-LANGU.

OHD-OBJNAM = APPLICATION.

OHD-OBJDES = EMAILTITLE.

OHD-OBJPRI = 3.

OHD-OBJSNS = 'F'.

OHD-OWNNAM = SY-UNAME.

*- send Email

CONDENSE RECEXTNAM NO-GAPS.

CHECK RECEXTNAM <> SPACE AND RECEXTNAM CS '@'.

*- for every individual recipient send an Email

  • (see OSS message 0120050409/0000362105/1999)

WHILE RECEXTNAM CS ','.

PERFORM INIT_REC TABLES RECEIVERS.

READ TABLE RECEIVERS INDEX 1.

RECEIVERS-RECEXTNAM = RECEXTNAM+0(SY-FDPOS).

ADD 1 TO SY-FDPOS.

SHIFT RECEXTNAM LEFT BY SY-FDPOS PLACES.

MODIFY RECEIVERS INDEX 1.

PERFORM SO_OBJECT_SEND_REC

TABLES TEXTTAB RECEIVERS

USING OHD.

ENDWHILE.

*- check last recipient in recipient list

IF RECEXTNAM <> SPACE.

PERFORM INIT_REC TABLES RECEIVERS.

READ TABLE RECEIVERS INDEX 1.

RECEIVERS-RECEXTNAM = RECEXTNAM.

MODIFY RECEIVERS INDEX 1.

PERFORM SO_OBJECT_SEND_REC

TABLES TEXTTAB RECEIVERS

USING OHD.

ENDIF.

ENDFUNCTION.

----


  • FORM SO_OBJECT_SEND_REC *

----


FORM SO_OBJECT_SEND_REC

TABLES OBJCONT STRUCTURE SOLI

RECEIVERS STRUCTURE SOOS1

USING OBJECT_HD STRUCTURE SOOD1.

DATA: OID LIKE SOODK,

TO_ALL LIKE SONV-FLAG,

OKEY LIKE SWOTOBJID-OBJKEY.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

EXTERN_ADDRESS = 'X'

OBJECT_HD_CHANGE = OBJECT_HD

OBJECT_TYPE = 'RAW'

OUTBOX_FLAG = 'X'

SENDER = SY-UNAME

IMPORTING

OBJECT_ID_NEW = OID

SENT_TO_ALL = TO_ALL

OFFICE_OBJECT_KEY = OKEY

TABLES

OBJCONT = OBJCONT

RECEIVERS = RECEIVERS

EXCEPTIONS

ACTIVE_USER_NOT_EXIST = 1

COMMUNICATION_FAILURE = 2

COMPONENT_NOT_AVAILABLE = 3

FOLDER_NOT_EXIST = 4

FOLDER_NO_AUTHORIZATION = 5

FORWARDER_NOT_EXIST = 6

NOTE_NOT_EXIST = 7

OBJECT_NOT_EXIST = 8

OBJECT_NOT_SENT = 9

OBJECT_NO_AUTHORIZATION = 10

OBJECT_TYPE_NOT_EXIST = 11

OPERATION_NO_AUTHORIZATION = 12

OWNER_NOT_EXIST = 13

PARAMETER_ERROR = 14

SUBSTITUTE_NOT_ACTIVE = 15

SUBSTITUTE_NOT_DEFINED = 16

SYSTEM_FAILURE = 17

TOO_MUCH_RECEIVERS = 18

USER_NOT_EXIST = 19

X_ERROR = 20

OTHERS = 21.

IF SY-SUBRC <> 0.

RAISE OTHERS.

ENDIF.

ENDFORM.

----


  • FORM INIT_REC *

----


FORM INIT_REC TABLES RECEIVERS STRUCTURE SOOS1.

CLEAR RECEIVERS.

REFRESH RECEIVERS.

MOVE SY-DATUM TO RECEIVERS-RCDAT .

MOVE SY-UZEIT TO RECEIVERS-RCTIM.

MOVE '1' TO RECEIVERS-SNDPRI.

MOVE 'X' TO RECEIVERS-SNDEX.

MOVE 'U-' TO RECEIVERS-RECNAM.

MOVE 'U' TO RECEIVERS-RECESC.

MOVE 'INT' TO RECEIVERS-SNDART.

MOVE '5' TO RECEIVERS-SORTCLASS.

APPEND RECEIVERS.

ENDFORM.

Regards

Sudheer

Read only

Former Member
0 Likes
742

hi,

you can try these FM

QICD_MAIL_SENDING

QFOA_MAIL_SENDING

QFOA_UD_LONGTEXT_SENDING

QFOA_MAIL_SENDING_STANDARD

if it is helpful reward points

Regards

Alfred

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
743

Hi, please see the following code, notice that when filling the mailrec table, I am passing a distribution list which I created in "WorkPlace". You also need to set the RECTYPE = 'C', for shared distribution, or 'P' for private distribution list.



report zrich_0003 .

* For API
data: maildata type sodocchgi1.
data: mailtxt  type table of solisti1 with header line.
data: mailrec  type table of somlrec90 with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test'.
  maildata-obj_langu = sy-langu.

  mailtxt-line = 'This is a test'.
  append mailtxt.

<b>  mailrec-receiver = 'ZTESTDSTLIST'.
  mailrec-rec_type  = 'C'.
  append mailrec.</b>

    call function 'SO_NEW_DOCUMENT_SEND_API1'
         exporting
              document_data              = maildata
              document_type              = 'RAW'
              put_in_outbox              = 'X'
         tables
              object_header              = mailtxt
              object_content             = mailtxt
              receivers                  = mailrec
         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.
* submit rsconn01 with mode = 'INT' and return.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
742

hi,

You can find the different receiver types in the value range of domain <b>SO_ESCAPE</b>.

fixed short text

value

Name

<b>P Private distribution list

C Shared distribution list</b>

O SAPoffice user

B SAP user

U Internet address

X X.400 address

R SAP user in another SAP System

A External address

F Fax number

D X.500 Address

L Telex number

H Organizational unit/position

J SAP object

G Organization object/ID

K Pager/SMS

Regards,

Sailaja.