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

SO_NEW_DOCUMENT_ATT_SEND_API1- problem in mail text

Former Member
2,494

Hi All,

I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails.

I have taken the reference program from the documentation of this function module given by SAP.

I want to send two attachments in text format using this FM and I am able to send the same.

The problem I am facing is that every character of text is seprated by one space. i.e. between any two characters one space is inserted in the attachement.

e.g. if I need to display :::

"This is test mail" -->

I am gettting the output as

"T h i s i s t e s t m a i l".

Is there any parameter which I need to set to avoid this problem.

Any input would be highly appreciated.

regards,

Lalit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,784

Hi,

Please refer following program for email with 2 attachment.

REPORT ztest_mail.

DATA : t_receiver TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0,

w_receiver TYPE somlreci1,

w_document_data TYPE sodocchgi1,

t_packing_list TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0,

w_packing_list TYPE sopcklsti1,

sent_to_all TYPE sonv-flag,

t_msg TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

w_msg TYPE solisti1.

DATA : l_mail_msg_length TYPE so_bd_num,

l_attachment_length TYPE so_bd_num,

l_t_msg_attachment TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

l_w_msg_attachment TYPE solisti1,

l_trailer_count TYPE i,

l_trailer_count_char TYPE char9.

l_w_msg_attachment-line = 'hi'.

APPEND l_w_msg_attachment TO l_t_msg_attachment.

w_document_data-priority = '1'.

    • Populate the subject/generic message attributes

w_document_data-obj_langu = sy-langu.

w_document_data-obj_descr = 'YOUR ACTION REQUIRED'.

CONCATENATE 'Please check the attached files for erroneous records of employees.'

'Also, Please check error messages in the table ZHR_ERR, if any.'

INTO w_msg-line SEPARATED BY space.

APPEND w_msg TO t_msg.

w_receiver-rec_type = 'U'.

w_receiver-receiver = email id.

APPEND w_receiver TO t_receiver.

    • Information about structure of data tables

CLEAR w_packing_list.

REFRESH t_packing_list.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = 1.

w_msg-line = 'hi'.

APPEND w_msg TO t_msg.

DESCRIBE TABLE t_msg LINES l_mail_msg_length.

DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

w_packing_list-body_num = l_mail_msg_length - l_attachment_length.

w_packing_list-doc_type = 'RAW'.

APPEND w_packing_list TO t_packing_list.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

w_packing_list-body_num = l_attachment_length.

w_packing_list-doc_type = 'RAW'.

w_packing_list-obj_name = '1nd_attach'.

w_packing_list-obj_descr = '1nd_attach'.

w_packing_list-obj_langu = 'EN'.

APPEND w_packing_list TO t_packing_list.

w_msg-line = 'bye'.

APPEND w_msg TO t_msg.

DESCRIBE TABLE t_msg LINES l_mail_msg_length.

DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

w_packing_list-body_num = l_attachment_length.

w_packing_list-doc_type = 'RAW'.

w_packing_list-obj_name = '2nd_attach'.

w_packing_list-obj_descr = '2nd_attach'.

w_packing_list-obj_langu = 'EN'.

APPEND w_packing_list TO t_packing_list.

    • Call Function Module to send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_document_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = sent_to_all

  • NEW_OBJECT_ID =

TABLES

packing_list = t_packing_list

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = t_msg

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = t_receiver

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.

IF syst-subrc = 0 .

ENDIF.

Hope this will help you.

Hi All,

I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails.

I have taken the reference program from the documentation of this function module given by SAP.

I want to send two attachments in text format using this FM and I am able to send the same.

The problem I am facing is that every character of text is seprated by one space. i.e. between any two characters one space is inserted in the attachement.

e.g. if I need to display :::

"This is test mail" -->

I am gettting the output as

"T h i s i s t e s t m a i l".

Is there any parameter which I need to set to avoid this problem.

Any input would be highly appreciated.

regards,

Lalit

9 REPLIES 9
Read only

Former Member
0 Likes
1,784

Hi,

Any input on this would be highly appreciated.

Regards,

Lalit

Read only

0 Likes
1,784

u this f.m to convert to 255 char

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = i_tline

t_target_tab = so_ali[]

EXCEPTIONS

convert_not_possible = 1

OTHERS = 2.

pass so_ali in

SO_NEW_DOCUMENT_ATT_SEND_API1

contents_bin = so_ali[]

Read only

0 Likes
1,784

Hi Lalit,

Are you directly assigning string value ( for ex. 'This is a test file' ) to the itab OBJCONT? or you are appending single words in it ( for ex. this...and then....is....and so on ).

If assigning complete string then spaces should not come in between coz even i have tried appending complete string in the attachment.

If appending words then try using 'CONDENSE' statement.

Hope this is useful.

Regards,

Saba

Edited by: Saba Sayed on Oct 31, 2008 6:09 AM

Read only

0 Likes
1,784

Hi,

I tried the solutions given to me but I am sorry to say that still my problem persists.

I am pasting my test code below. Request your help.

Regards,

Lalit

REPORT ZTEST_LALIT2.

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: OBJBIN1 type soli_tab. " 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 = 0.

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 = 'This is a test mail'. condense objbin. APPEND OBJBIN.

OBJBIN = ' | '. APPEND OBJBIN.

OBJBIN = 'test '. APPEND OBJBIN.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'picasso.txt'. 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 = 'TXT'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 132.

APPEND OBJPACK..

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = OBJBIN

t_target_tab = OBJBIN1[]

EXCEPTIONS

convert_not_possible = 1

OTHERS = 2.

  • Entering names in the distribution list

RECLIST-RECEIVER = 'LALITK'.

RECLIST-REC_TYPE = 'B'.

APPEND RECLIST.

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 = OBJBIN1[]

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

Read only

0 Likes
1,784

check this coding

objtxt = '<This is system generated message>.'.

APPEND objtxt.

objtxt = space.

APPEND objtxt.

  • Mail Body of message over.

DESCRIBE TABLE objtxt[] LINES v_lines_txt.

CONCATENATE 'Inv.' invno INTO sub SEPARATED BY space.

doc_chng-obj_name = sub.

doc_chng-expiry_dat = sy-datum + 10.

  • Mail Subject

refresh objpack[].

CONCATENATE 'Pricol Dispatch - Invoice' invno '- Reg.' INTO sub SEPARATED BY space.

doc_chng-obj_descr = sub.

doc_chng-sensitivty = 'F'.

doc_chng-doc_size = v_lines_txt * 255.

objpack-transf_bin = ' '.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = v_lines_txt.

objpack-doc_type = 'RAW'.

APPEND objpack.

*PDF Attachment

DESCRIBE TABLE so_ali[] LINES lineno.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-doc_size = lineno * 255 .

objpack-body_num = lineno.

objpack-doc_type = 'PDF'.

objpack-obj_name = 'INVOICE'.

objpack-obj_descr = 'Invoice'.

objpack-obj_langu = 'E'.

APPEND objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

contents_txt = objtxt[]

contents_bin = so_ali[]

*contents_hex = so_ali[]

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.

IF sy-subrc = 0.

PERFORM mail.

MESSAGE 'Mail sent successfully' TYPE 'S'.

*SUBMIT RSCONN01 WITH MODE = MODE.

ENDIF.

Read only

Former Member
0 Likes
1,784

hi

try condense statement

shiva

Read only

Former Member
0 Likes
1,784

Hi

Use "Condense statement"

regards,

Ramya

Read only

Former Member
0 Likes
1,785

Hi,

Please refer following program for email with 2 attachment.

REPORT ztest_mail.

DATA : t_receiver TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0,

w_receiver TYPE somlreci1,

w_document_data TYPE sodocchgi1,

t_packing_list TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0,

w_packing_list TYPE sopcklsti1,

sent_to_all TYPE sonv-flag,

t_msg TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

w_msg TYPE solisti1.

DATA : l_mail_msg_length TYPE so_bd_num,

l_attachment_length TYPE so_bd_num,

l_t_msg_attachment TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,

l_w_msg_attachment TYPE solisti1,

l_trailer_count TYPE i,

l_trailer_count_char TYPE char9.

l_w_msg_attachment-line = 'hi'.

APPEND l_w_msg_attachment TO l_t_msg_attachment.

w_document_data-priority = '1'.

    • Populate the subject/generic message attributes

w_document_data-obj_langu = sy-langu.

w_document_data-obj_descr = 'YOUR ACTION REQUIRED'.

CONCATENATE 'Please check the attached files for erroneous records of employees.'

'Also, Please check error messages in the table ZHR_ERR, if any.'

INTO w_msg-line SEPARATED BY space.

APPEND w_msg TO t_msg.

w_receiver-rec_type = 'U'.

w_receiver-receiver = email id.

APPEND w_receiver TO t_receiver.

    • Information about structure of data tables

CLEAR w_packing_list.

REFRESH t_packing_list.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = 1.

w_msg-line = 'hi'.

APPEND w_msg TO t_msg.

DESCRIBE TABLE t_msg LINES l_mail_msg_length.

DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

w_packing_list-body_num = l_mail_msg_length - l_attachment_length.

w_packing_list-doc_type = 'RAW'.

APPEND w_packing_list TO t_packing_list.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

w_packing_list-body_num = l_attachment_length.

w_packing_list-doc_type = 'RAW'.

w_packing_list-obj_name = '1nd_attach'.

w_packing_list-obj_descr = '1nd_attach'.

w_packing_list-obj_langu = 'EN'.

APPEND w_packing_list TO t_packing_list.

w_msg-line = 'bye'.

APPEND w_msg TO t_msg.

DESCRIBE TABLE t_msg LINES l_mail_msg_length.

DESCRIBE TABLE l_t_msg_attachment LINES l_attachment_length.

w_packing_list-transf_bin = space.

w_packing_list-head_start = 1.

w_packing_list-head_num = 0.

w_packing_list-body_start = ( l_mail_msg_length - l_attachment_length ) + 1.

w_packing_list-body_num = l_attachment_length.

w_packing_list-doc_type = 'RAW'.

w_packing_list-obj_name = '2nd_attach'.

w_packing_list-obj_descr = '2nd_attach'.

w_packing_list-obj_langu = 'EN'.

APPEND w_packing_list TO t_packing_list.

    • Call Function Module to send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_document_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = sent_to_all

  • NEW_OBJECT_ID =

TABLES

packing_list = t_packing_list

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = t_msg

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = t_receiver

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.

IF syst-subrc = 0 .

ENDIF.

Hope this will help you.

Read only

Former Member
0 Likes
1,784

Thanks a Lot for your valueable inputs!!!

Regards,

Lalit