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: 

Email with Attachment

Former Member
0 Kudos

Hi,

I am using CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send email and attach text file. My program is working. The problem is I cannot add line with more than 128 characters. If the line (record) is too long, funny characters are inserted into my attachment. Is this the limitation of this function module? I further check found that data element "solisti1" only support 255 characters.

Can someone show me complete working program (email with attachment) with can support like 2000 characters in each record (line)?

Thanks in advance.

4 REPLIES 4

Former Member
0 Kudos

hi

try this code

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.

DATA L_NUM(3).

Creation of the document to be sent

File Name

DOC_CHNG-OBJ_NAME = 'SENDFILE'.

Mail Subject

DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.

Mail Contents

OBJTXT = 'Object text'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

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

Creation of 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.

Creation of the document attachment

LOOP AT ITAB_DATA.

CONCATENATE ITAB_DATA-PRODUCTOR

ITAB_DATA-VBELN

ITAB_DATA-POSNR

ITAB_DATA-MATNR INTO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'ORDERS'.

APPEND OBJHEAD.

Creation of 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 = 'TXT'.

OBJPACK-OBJ_NAME = 'WEBSITE'.

OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

Completing the recipient list

target recipent

clear RECLIST.

RECLIST-RECEIVER = 'email address 1'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

copy recipents

clear RECLIST.

RECLIST-RECEIVER = 'email address 2'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

RECLIST-COPY = 'X'.

APPEND RECLIST.

Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

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.

ENDFORM. " SEND_MAIL

hope this helps

regards

Aakash Banga

Former Member
0 Kudos

Hi Paul,

If we can use structure with field value 2000 char then there may be compatable problem while passing to FM with FM parameter. So we have to use solisti1 structure for this FM for supporting compatability. If we want ot pass more than 25 characters then use spilt and append records to that intenral table. I think this only option we have. Hope this helps you..

Regards,

kumar.

Former Member
0 Kudos

Hi

Make sure you are passing your text in this table :

T_TEXT TYPE TABLE OF SOLISTI1 INITIAL SIZE 0 WITH HEADER LINE.

SOLIST1 has only one field and length is 255.

you can populate your text line in this one.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = I_DOCDATA

commit_work = 'X'

TABLES

PACKING_LIST = I_OBJPACK

CONTENTS_BIN = T_BIN

CONTENTS_TXT = T_TEXT

RECEIVERS = T_RECV

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.

Regards

Neha

Former Member
0 Kudos

Paul:

Did you find any solution for this.

I am facing the same issue.

Kindly let me know if you have solved this issue.

regards

vijai