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: 

To send mails by SO_DOCUMENT_SEND_API1

Former Member
0 Kudos

Hi All !!

I want to send mails to two persons through this function module SO_DOCUMENT_SEND_API1 .Can you please suggest me an example of the same where the mail has been sent to two receivers.The mail is to be sent internally within SAP.

Thanks in advance...

Prabhas.

1 REPLY 1

Former Member
0 Kudos

Hi Prabhas,

Find below code, which downloads the data to a PC file and attach to the mail(no restriction of 256 characters). You can use this to modify accordingly. Have tried this quite long back.

DATA: METHOD1 LIKE SY-UCOMM,

G_USER LIKE SOUDNAMEI1,

G_USER_DATA LIKE SOUDATAI1,

G_OWNER LIKE SOUD-USRNAM,

G_RECEIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,

G_DOCUMENT LIKE SOOD4,

G_HEADER LIKE SOOD2,

G_FOLMAM LIKE SOFM2,

G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE,

G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,

G_OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,

G_OBJPARB LIKE SOOP1 OCCURS 0 WITH HEADER LINE,

G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE,

G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE.

DATA: G_AUTHORITY LIKE SOFA-USRACC,

G_REF_DOCUMENT LIKE SOOD4,

G_NEW_PARENT LIKE SOODK.

DATA: BEGIN OF G_FILES OCCURS 10 ,

TEXT(4096) TYPE C,

END OF G_FILES.

DATA: FOLD_NUMBER(12) TYPE C,

FOLD_YR(2) TYPE C,

FOLD_TYPE(3) TYPE C.

PARAMETERS P_FILE(4096) TYPE C DEFAULT 'C:\MATERIALS.TXT' OBLIGATORY.

DATA: IT_MARA TYPE STANDARD TABLE OF MARA.

DATA: L_FILE TYPE STRING.

START-OF-SELECTION.

SELECT * FROM MARA INTO TABLE IT_MARA UP TO 20 ROWS.

L_FILE = P_FILE.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = L_FILE

TABLES

DATA_TAB = IT_MARA

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22.

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: / 'FILE'(007), L_FILE, 'WAS CREATED.'(008).

ENDIF.

  • CAN BE ANY FILE FROMYOUR PC ....EITHER XLS OR WORD OR PPT ETC ...

G_USER-SAPNAME = SY-UNAME.

CALL FUNCTION 'SO_USER_READ_API1'

EXPORTING

USER = G_USER

  • PREPARE_FOR_FOLDER_ACCESS = ' '

IMPORTING

USER_DATA = G_USER_DATA

EXCEPTIONS

USER_NOT_EXIST = 1

PARAMETER_ERROR = 2

X_ERROR = 3

OTHERS = 4.

IF SY-SUBRC 0.

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

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

ENDIF.

FOLD_TYPE = G_USER_DATA-OUTBOXFOL+0(3).

FOLD_YR = G_USER_DATA-OUTBOXFOL+3(2).

FOLD_NUMBER = G_USER_DATA-OUTBOXFOL+5(12).

CLEAR G_FILES.

REFRESH : G_OBJCNT, G_OBJHEAD, G_OBJPARA, G_OBJPARB, G_RECEIPIENTS,

G_ATTACHMENTS, G_REFERENCES, G_FILES.

METHOD1 = 'SAVE'.

G_DOCUMENT-FOLTP = FOLD_TYPE.

G_DOCUMENT-FOLYR = FOLD_YR.

G_DOCUMENT-FOLNO = FOLD_NUMBER.

G_DOCUMENT-OBJTP = G_USER_DATA-OBJECT_TYP.

G_DOCUMENT-OBJDES = 'Material Details'.

G_DOCUMENT-FOLRG = 'O'.

G_DOCUMENT-OBJLEN = '0'.

G_DOCUMENT-FILE_EXT = 'TXT'.

G_HEADER-OBJDES = 'Material Details'.

G_HEADER-FILE_EXT = 'TXT'.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

METHOD = METHOD1

OFFICE_USER = SY-UNAME

REF_DOCUMENT = G_REF_DOCUMENT

NEW_PARENT = G_NEW_PARENT

IMPORTING

AUTHORITY = G_AUTHORITY

TABLES

OBJCONT = G_OBJCNT

OBJHEAD = G_OBJHEAD

OBJPARA = G_OBJPARA

OBJPARB = G_OBJPARB

RECIPIENTS = G_RECEIPIENTS

ATTACHMENTS = G_ATTACHMENTS

REFERENCES = G_REFERENCES

FILES = G_FILES

CHANGING

DOCUMENT = G_DOCUMENT

HEADER_DATA = G_HEADER.

  • FILE FROM THE PC TO SEND...

METHOD1 = 'ATTCREATEFROMPC'.

G_FILES-TEXT = P_FILE.

APPEND G_FILES.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

METHOD = METHOD1

OFFICE_USER = G_OWNER

REF_DOCUMENT = G_REF_DOCUMENT

NEW_PARENT = G_NEW_PARENT

IMPORTING

AUTHORITY = G_AUTHORITY

TABLES

OBJCONT = G_OBJCNT

OBJHEAD = G_OBJHEAD

OBJPARA = G_OBJPARA

OBJPARB = G_OBJPARB

RECIPIENTS = G_RECEIPIENTS

ATTACHMENTS = G_ATTACHMENTS

REFERENCES = G_REFERENCES

FILES = G_FILES

CHANGING

DOCUMENT = G_DOCUMENT

HEADER_DATA = G_HEADER.

METHOD1 = 'SEND'.

G_RECEIPIENTS-RECNAM = 'MK085'.

G_RECEIPIENTS-RECESC = 'B'.

G_RECEIPIENTS-SNDEX = 'X'.

APPEND G_RECEIPIENTS.

CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'

EXPORTING

METHOD = METHOD1

OFFICE_USER = G_OWNER

REF_DOCUMENT = G_REF_DOCUMENT

NEW_PARENT = G_NEW_PARENT

IMPORTING

AUTHORITY = G_AUTHORITY

TABLES

OBJCONT = G_OBJCNT

OBJHEAD = G_OBJHEAD

OBJPARA = G_OBJPARA

OBJPARB = G_OBJPARB

RECIPIENTS = G_RECEIPIENTS

ATTACHMENTS = G_ATTACHMENTS

REFERENCES = G_REFERENCES

FILES = G_FILES

CHANGING

DOCUMENT = G_DOCUMENT

HEADER_DATA = G_HEADER.

hope this helps,

kindly reward if found helpful.

cheers,

Hema.