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
1,108

Hi,

Is SO_NEW_DOCUMENT_ATT_SEND_API1 is used to send an existing file or it will create a new file and will send as attachment to the external internet mail id?

Awaiting for early response.

Thanks.

12 REPLIES 12
Read only

Former Member
0 Likes
1,078

Hi pavan,

1. The FM uses the concept of

internal table (in raw format)

to send the attachment.

2. So when the file is existing,

we read the file

and transfer the file contents

to the internal table of this FM.

3. Then this FM takes care.

4. IT NEVER CREATES A NEW FILE !

regards,

amit m.

Read only

Former Member
0 Likes
1,078

the function module does not create a new file it uses the existing file.

Read only

Former Member
0 Likes
1,078

hi

SO_NEW_DOCUMENT_ATT_SEND_API1 will Send a document as part of an email. The documentation is better than normal for this function

regards,

padma

Read only

Former Member
0 Likes
1,078

Hi,

Can anybody give me the code as i have to send a txt file as attachment (and the file is present in d:\pavan\test.txt) to some internet mail id. ex : pavan@yahoo.com. using the FM as mentioned above.

Thanks.

Message was edited by: Pavan Panduru

Read only

0 Likes
1,078
Read only

Former Member
0 Likes
1,078

yes.it Sends a document as part of an email.

check this...

reward if useful...

for the sample program check this..

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

Message was edited by: Ashok Kumar Prithiviraj

Read only

Former Member
0 Likes
1,078

This function module enables you send a new document including any existing attachments. The document and the attachments are transferred in the same table. They are created when sent and can also be placed in the ender's outbox.

It is necessary to distinguish between the document and its folder entries. The document itself only exists in the database once. It is a template for the folder entries and can be addressed via its object ID.Any number of folder entries can belong to the document. The folder entries contain the attributes of the document as well as some additional attributes relating to the folder entry itself. (Send priority and expiry date of the entry, for example.) Folder entries are created when a document is resubmitted, referenced or sent as well as when a new document is created.

Example

Sending a new RAW document with a BMP attachment to an Internet address

and a private distribution list.

REPORT ZSSO_DOCUMENT_SEND_API1.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

  • Creating the document to be sent

DOC_CHNG-OBJ_NAME = 'OFFER'.

DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.

OBJTXT = 'Reserve price : $250000'.

APPEND OBJTXT.

OBJTXT = 'A reproduction of the painting to be auctioned'.

APPEND OBJTXT.

OBJTXT = 'is enclosed as an attachment.'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • Creating the entry for the compressed document

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • Creating the document attachment

  • (Assume the data in OBJBIN are given in BMP format)

OBJBIN = ' \O/ '. APPEND OBJBIN.

OBJBIN = ' | '. APPEND OBJBIN.

OBJBIN = ' / \ '. APPEND OBJBIN.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'BMP'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK..

  • Entering names in the distribution list

RECLIST-RECEIVER = 'guido.geldsack@money.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

RECLIST-RECEIVER = 'DLI-NEUREICH'.

RECLIST-REC_TYPE = 'P'.

APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

WRITE: / 'Result of the send process:'.

LOOP AT RECLIST.

WRITE: / RECLIST-RECEIVER(48), ':'.

IF RECLIST-RETRN_CODE = 0.

WRITE 'sent successfully'.

ELSE.

WRITE 'not sent'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'no authorization to send to the specified number of'

'recipients!'.

WHEN 2.

WRITE: / 'document could not be sent to any of the recipients!'.

WHEN 4.

WRITE: / 'no authorization to send !'.

WHEN OTHERS.

WRITE: / 'error occurred during sending !'.

ENDCASE.

Read only

Former Member
0 Likes
1,078

HI,

Here is my code :

parameters : filename like rlgrap-filename obligatory,

email_id(50) type c default 'abcd@gmail.com' lower case.

Data :

docdata LIKE sodocchgi1,

objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,

objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,

objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,

objhead like solisti1 occurs 10 with header line,

reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,

tab_lines TYPE sy-tabix.

DATA: BEGIN OF i_data OCCURS 0,

a(20),

b(20),

END OF i_data.

docdata-obj_name = filename.

docdata-obj_descr = 'Excel file attachment'.

objtxt = 'Excel file is attached'.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'RAW'.

APPEND objpack.

i_data-a = 'Sample'.

i_data-b = 'File'.

CONCATENATE i_data-a i_data-b INTO objbin.

APPEND objbin.

DESCRIBE TABLE objbin LINES tab_lines.

objpack-doc_size = tab_lines * 255.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'txt'.

docdata-obj_name = filename.

objpack-obj_descr = 'Excel File Attachment'.

APPEND objpack.

reclist-receiver = email_id.

reclist-rec_type = 'U'.

reclist-express = 'X'.

APPEND reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = docdata

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = objpack

CONTENTS_BIN = objbin

CONTENTS_TXT = objtxt

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

COMMIT WORK.

if sy-subrc eq 0.

write : / 'Successfully sent'.

else.

write : / 'Not Send'.

endif.

When i execute this file it is sending a file as attachment but not the one i have mentioned in the parameters instead it is sending a file named Excel File Attachment.xls as attachment.

Please rectify the problem and give me the solution.

Thanks,

Pavan.

Read only

0 Likes
1,078

Hi pavan,

1.

objpack-obj_name = 'ATTACHMENT'.

objpack-obj_descr = filename

modify the below (BOLD 2 lines)

2.

DESCRIBE TABLE objbin LINES tab_lines.

objpack-doc_size = tab_lines * 255.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'txt'.

<b>docdata-obj_name = filename.

objpack-obj_descr = 'Excel File Attachment'.</b>APPEND objpack.

regards,

amit m.

Read only

0 Likes
1,078

Hi Amit,

I changed the program as u said, but i am attaching a file names test.txt present in d:\pavan\test.txt when i executed the program the mail has been sent but the attached file is something like this : d:pavantest.txt and the contents in this S a m p l e F i l e the contents in the test file is compltely different.

I think the contents of the file are the comming by this statement in my program.

i_data-a = 'Sample'.

i_data-b = 'File'.

CONCATENATE i_data-a i_data-b INTO objbin.

APPEND objbin.

Please rectify and give me a solution .

THanks,

Pavan.

Read only

0 Likes
1,078

Hi Pavan,

according to mentioned parameter file , read the contents , then pass to objbin table , you have not written any code to get the data of the mentioned file , use GUI_UPLOAD to read the file and then transfer data from GUI_UPLOAD data to objbin table

Laxman

Read only

0 Likes
1,078

Hi again,

1. but the attached file is something like this : d:pavantest.txt

Thats bcos THE FULL PATH ALONG WITH THE FILE NAME

is specified.

2. For that SPLIT THE FULL PATH

into extension, and PURE FILE NAME like below :

data : path like PCFILE-PATH.

path = file_name.

CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'

EXPORTING

complete_filename = path

  • CHECK_DOS_FORMAT =

IMPORTING

  • DRIVE =

EXTENSION = extension

NAME = name

  • NAME_WITH_EXT =

  • PATH =

EXCEPTIONS

INVALID_DRIVE = 1

INVALID_EXTENSION = 2

INVALID_NAME = 3

INVALID_PATH = 4

OTHERS = 5

3. Then give

objpack-obj_descr = name.

*------ NAME = ONLY PURE NAME (WITHOUT PATH)

regards,

amit m.