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: 

Problem in sending Mail In TXT format.

Former Member
0 Kudos

Hi All,

I am developing a program for sending a mail in .TXT format using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.

The Mail is getting successfully send with the attachment, but inside the file its coming as say for e.g.V i c k y k u m a r " , " 3 4 0 0 1 8 2 7 instead of "Vicky kumar","34001827". Can you please let me know why its coming in this way.

Below is the table where i am passing the data to li_objbin for the attachment.

LOOP AT TAB_105_FNL.

  • CONCATENATE wa_error-pernr wa_error-desc INTO lwa_objbin SEPARATED BY

  • cl_abap_char_utilities=>horizontal_tab.

lwa_objbin = TAB_105_FNL.

CONCATENATE cl_abap_char_utilities=>newline lwa_objbin

INTO lwa_objbin.

APPEND lwa_objbin TO li_objbin.

CLEAR lwa_objbin.

ENDLOOP.

lwa_objhead = 'Employee_Mass_Data.xls'.

APPEND lwa_objhead TO li_objhead.

lwa_objpack-transf_bin = 'X'.

lwa_objpack-head_start = 1.

lwa_objpack-head_num = 1.

lwa_objpack-body_start = 1.

lwa_objpack-body_num = LINES( li_objbin ).

lwa_objpack-doc_type = 'DAT'. " Here I tried with TXT also but still its is working the same way

lwa_objpack-obj_name = 'ATTACHMENT'.

lwa_objpack-obj_descr = 'Employee Mass Data'.

lwa_objpack-doc_size = lwa_objpack-body_num * 255.

APPEND lwa_objpack TO li_objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lv_doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = li_objpack

object_header = li_objhead

contents_bin = li_objbin

contents_txt = li_objtxt

receivers = li_reclist

Thanks and Regards,

Salish

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Salish,

If i understand correctly you are getting the text file in this format because you have passed the attachment as a BIN object.

Can you please explain why you are doing so ?

BR,

Suhas

14 REPLIES 14

Former Member
0 Kudos

Hi Salish,

Try this way:

CONSTANTS : c_raw(3)   TYPE c VALUE 'RAW'
          if lwa_objpack-doc_type = 'TXT'. 
            it_objpack-doc_type   = C_RAW.
          endif.

or directly assign C_RAW

Secondly you can use function READ_TEXT. Have a try with this too.

0 Kudos

Hi,

Thanks for the reply but when i tried with RAW the output file is coming with some invalid characters as follows:

"Vicky kumar","34001827","00000000","APVYK00",123456,"IN14","1","MJ","01502000",CP:India-Mumbai Head Office,"Vicky_kumar@colpa

氀⸀挀漀洀u2200

Can you please let me know why this is coming.

Thanks

Salish.                             

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Salish,

If i understand correctly you are getting the text file in this format because you have passed the attachment as a BIN object.

Can you please explain why you are doing so ?

BR,

Suhas

Former Member
0 Kudos

Hi Suhas,

If I do not pass BIN value as X then it takes contents_txt = li_objtxt (see in the parameters of the FM) as the attachment.

I mean the data in the context_txt is seen in the attachment.

Thanks

Salish.

0 Kudos

Suhas meant (I guess) that you passed your text to CONTENTS_BIN instead of CONTENTS_TXT

0 Kudos

You are correct

Former Member
0 Kudos

Hi Suhas,

Thanks for the Reply...It is getting fine now. But there is one more thing, In the mail part i have to write someting in the body, since I was writing the body in the context_txt part, now where should i have to write now??

Thanks

Salish.

0 Kudos

First context_txt part is considered to be the body, and the following context_txt parts are considered as attachments.

Former Member
0 Kudos

Hi all,

Thanks for your help, the problem is solved now and also points has been rewarded. Again thank you for the quick response.

Thanks,

Salish

0 Kudos

Hi Salish,

I am facing the same issue in sending text file as attachment, Can you please help.

Regards

Manu

Former Member
0 Kudos

Check the SAP note 936447.

Regards,

Sai Prasad

Former Member
0 Kudos

in the context_txt tables parameters pass the first table line in li_objtxt is for the email body and the second append should be for attachment text in li_objtxt,

Former Member
0 Kudos

Hi,

use function Module ''SCMS_TEXT_TO_BINARY'' and pass 'contents_bin' to it before calling 'SO_NEW_DOCUMENT_ATT_SEND_API1'. This will align the content of text attachment.

Thanks

Amol

former_member186734
Active Participant
0 Kudos

Check out this easy e-mail routine: [http://lucattelli.com/blog/?page_id=478|http://lucattelli.com/blog/?page_id=478]