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 attachment 'TXT' alignment

Former Member
0 Likes
975

Hi,

I am trying to attach a 'TXT' format in the email but im not getting the proper format in the output.

READ TABLE T_ATTACHMENT_DATA INTO W_ATTACHMENT_DATA INDEX GV_TAB_LINES.

W_OBJPACK-TRANSF_BIN = 'X'.

W_OBJPACK-HEAD_START = 1.

W_OBJPACK-HEAD_NUM = 0.

W_OBJPACK-BODY_START = 1.

W_OBJPACK-BODY_NUM = GV_TAB_LINES.

W_OBJPACK-OBJ_DESCR = SY-DATUM.

W_OBJPACK-OBJ_NAME = 'Head count'.

W_OBJPACK-DOC_TYPE = 'TXT'.

W_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255.

APPEND W_OBJPACK TO T_OBJPACK.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = W_DOC_CHNG

PUT_IN_OUTBOX = ' '

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = T_OBJPACK

CONTENTS_BIN = T_ATTACHMENT_DATA "T_ATTACHMENT_BIN "t_attachment

CONTENTS_TXT = T_MAILBODY

RECEIVERS = T_RECEIVER.

Regards,

Roop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
842

Hi

Please define the packing list for the email document object . Have only defined the packing list for mail attachment object.

Please note that the first entry in the packing list table is always for the email document , subsequent entries are each for one attachment. In your case , you have defined the packing list for email attachment , which should be second entry in packing list. Define one for email document and insert as first entry of the packing list.

Also would suggest to use SAP's communication services , class cl_document_bcs to send documents which is more beneficial.

Hope it helps.

Regards,

Pawan

Hi,

I am trying to attach a 'TXT' format in the email but im not getting the proper format in the output.

READ TABLE T_ATTACHMENT_DATA INTO W_ATTACHMENT_DATA INDEX GV_TAB_LINES.

W_OBJPACK-TRANSF_BIN = 'X'.

W_OBJPACK-HEAD_START = 1.

W_OBJPACK-HEAD_NUM = 0.

W_OBJPACK-BODY_START = 1.

W_OBJPACK-BODY_NUM = GV_TAB_LINES.

W_OBJPACK-OBJ_DESCR = SY-DATUM.

W_OBJPACK-OBJ_NAME = 'Head count'.

W_OBJPACK-DOC_TYPE = 'TXT'.

W_OBJPACK-DOC_SIZE = ( GV_TAB_LINES - 1 ) * 255.

APPEND W_OBJPACK TO T_OBJPACK.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = W_DOC_CHNG

PUT_IN_OUTBOX = ' '

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = T_OBJPACK

CONTENTS_BIN = T_ATTACHMENT_DATA "T_ATTACHMENT_BIN "t_attachment

CONTENTS_TXT = T_MAILBODY

RECEIVERS = T_RECEIVER.

Regards,

Roop.

6 REPLIES 6
Read only

Former Member
0 Likes
843

Hi

Please define the packing list for the email document object . Have only defined the packing list for mail attachment object.

Please note that the first entry in the packing list table is always for the email document , subsequent entries are each for one attachment. In your case , you have defined the packing list for email attachment , which should be second entry in packing list. Define one for email document and insert as first entry of the packing list.

Also would suggest to use SAP's communication services , class cl_document_bcs to send documents which is more beneficial.

Hope it helps.

Regards,

Pawan

Read only

0 Likes
842

Hi Roob;

I send to email in HTM attach file from SAP. I checked your code and my code. I found only one difference between the two.

I'm using FM SO_DOCUMENT_SEND_API1. This function very similar to FM SO_NEW_DOCUMENT_ATT_SEND_API1.

Can you tyr to FM SO_DOCUMENT_SEND_API1.

Best regards.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
842

> I send to email in HTM attach file from SAP. I checked your code and my code. I found only one difference between the two.

> I'm using FM SO_DOCUMENT_SEND_API1. This function very similar to FM SO_NEW_DOCUMENT_ATT_SEND_API1.

>

> Can you tyr to FM SO_DOCUMENT_SEND_API1.

Hello Melih,

SO_NEW_DOCUMENT_ATT_SEND_API1: If you want to send the email with attachments.

SO_NEW_DOCUMENT_SEND_API1: Send emails only. You cannot attach any files via this API.

@All: SAP recommends using the BCS classes to send mails instead of using the SO* APIs.

Cheers,

Suhas

Read only

0 Likes
842

hi all,

thanks for your valuable suggestion. now the problem is im not able to send the column length more 255 chars in the attachment. the type is SOLISTI1.

Regards,

Roops

Read only

0 Likes
842

Hi,

You would not be able to append more length than 255. Either use append in internal table and break lines.

Thanks,

Gaurav.

Read only

praveen_reddy2
Active Participant
0 Likes
842

Hello,

W_OBJPACK-DOC_TYPE = 'TXT'. " This TXT is not available in TSOTD table..

So make sure of that.. And pass instead of TXT as RAW.

Regards,

Praveen