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: 

Send Email with Lines >255Char attachment

Former Member
0 Kudos

Is itpossible in SAP?

I want my line to be read in the notepad and keep linebyline.

When I use WS_DOWNLOAD =>100% what I want

Idon'tknow how to do it by mail!

Use the fm SO_DOCUMENT_SEND_API1 but how?

7 REPLIES 7

rahulkavuri
Active Contributor
0 Kudos

u can use FM SO_NEW_DOCUMENT_SEND_API1

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_DATA

IMPORTING

NEW_OBJECT_ID = OBJECT_ID

TABLES

OBJECT_CONTENT = OBJCONT

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

http://sapr3.tripod.com/abap011.htm

Message was edited by: Rahul Kavuri

Former Member
0 Kudos

HI

GOOD

GO THROUGH THIS LINK

/people/dezso.pap/blog/2006/03/28/send-mail-fax-with-100-lines-from-a-bsp-application

http://www.thespot4sap.com/articles/SAP_Mail_Understanding_SO_Object_Send.asp

THANKS

MRUTYUN

Former Member
0 Kudos

i dont think its possible of sending more than 255 char length attachment text by using the standard function module.

regards

srikanth

Former Member
0 Kudos

Stephan,

What is your emai id. I have a program which is used to send attachment thru mail.

Cheers,

Nilesh

0 Kudos

my email is abap@STEKAM.COM

Thanks!

Former Member
0 Kudos

Hai Stephan

Check the following COde

FORM SEND_MAIL.

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 = 'test@here.com'.

RECLIST-EXPRESS = 'X'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

  • copy recipents

clear RECLIST.

RECLIST-RECEIVER = 'secondtest@here.com'.

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

Thanks & Regards

Sreenivasulu P

Former Member
0 Kudos

Hi,

I just found a quite neat way of dealing with this problem that works well... Here is some example code... Its based on the BCS_EXAMPLE_1 program but instead of messing around with the texts table as I was having issues with linefeeds I convert my extract table into a string and manually add linefeed characters. From here I convert the STRING to the XSTRING format and finally into the SOLIX_TAB format. I noticed that if you specify the attachment type as TXT you get the correct extension and it opens as desired in your text editor.

Regards,

Pete White

&----


*& Form email_extract

&----


  • text

----


  • -->P_GT_FULL_DATA[] text

  • -->P_P_EMAIL text

----


FORM email_extract USING it_gt_zartifoo TYPE ty_ta_zartifoo

ic_email TYPE ad_smtpadr.

DATA: str TYPE string,

ls_zartifoo TYPE zartifoo,

ls_string TYPE string,

ls_xstring type xstring.

DATA: text_content TYPE soli_tab,

bin_content type solix_tab.

TRY.

  • -------- create persistent send request ------------------------

send_request = cl_bcs=>create_persistent( ).

  • -------- create and set document -------------------------------

  • create document from internal table with text

CLEAR text_content[].

LOOP AT it_gt_zartifoo INTO ls_zartifoo.

ls_string = ls_zartifoo.

CONCATENATE str ls_string cl_abap_char_utilities=>cr_lf INTO str.

ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = str

  • MIMETYPE = ' '

  • ENCODING =

IMPORTING

BUFFER = ls_xstring

EXCEPTIONS

FAILED = 1

OTHERS = 2.

CALL METHOD cl_document_bcs=>xstring_to_solix

EXPORTING

ip_xstring = ls_xstring

receiving

rt_solix = bin_content.

document = cl_document_bcs=>create_document(

i_type = 'RAW'

  • i_text = text_content

i_subject = 'Depositos Material Extract' ).

CALL METHOD document->add_attachment

EXPORTING

i_attachment_type = 'TXT'

i_attachment_subject = 'ARTIFOO'

  • i_att_content_text = text_content.

i_att_content_hex = bin_content.

  • add document to send request

CALL METHOD send_request->set_document( document ).

  • --------- set sender -------------------------------------------

  • note: this is necessary only if you want to set the sender

  • different from actual user (SY-UNAME). Otherwise sender is

  • set automatically with actual user.

sender = cl_sapuser_bcs=>create( sy-uname ).

CALL METHOD send_request->set_sender

EXPORTING

i_sender = sender.

  • --------- add recipient (e-mail address) -----------------------

  • create recipient - please replace e-mail address !!!

recipient = cl_cam_address_bcs=>create_internet_address(

ic_email ).

  • add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'.

  • ---------- send document ---------------------------------------

CALL METHOD send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = sent_to_all ).

IF sent_to_all = 'X'.

WRITE text-003.

ENDIF.

COMMIT WORK.

  • -----------------------------------------------------------

  • * exception handling

  • -----------------------------------------------------------

  • * replace this very rudimentary exception handling

  • * with your own one !!!

  • -----------------------------------------------------------

CATCH cx_bcs INTO bcs_exception.

WRITE: text-001.

WRITE: text-002, bcs_exception->error_type.

EXIT.

ENDTRY.

ENDFORM. " email_extract