Text File Attachment in SAP Mail ECC 6.0
Hi,
Is it possible to use a text format 'TXT' on the Function Module "O_NEW_DOCUMENT_ATT_SEND_API1" in ECC 6.0? Because I've seen alot of examples in the forum that are using 'XLS' Format attachments.
I made a program that have been attaching text fomat file in the SAP mail. It is working fine in other SAP boxes but in our current box, as I tested it, opening the text attachment, the result is a file text now contained a long string (max1022 char) instead of a file that is tab-delimited. What would you suggest on this?
yes u can attach txt file.refer to the code below!
data: itcpo like itcpo,
tab_lines like sy-tabix.
Variables for EMAIL functionality
data: maildata like sodocchgi1.
data: mailpack like sopcklsti1 occurs 2 with header line.
data: mailhead like solisti1 occurs 1 with header line.
data: mailbin like solisti1 occurs 10 with header line.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: solisti1 like solisti1 occurs 0 with header line.
perform send_form_via_email.
FORM SEND_FORM_VIA_EMAIL *
form send_form_via_email.
clear: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
refresh: mailtxt, mailbin, mailpack, mailhead, mailrec.
Creation of the document to be sent File Name
maildata-obj_name = 'TEST'.
Mail Subject
maildata-obj_descr = 'Subject'.
Mail Contents
mailtxt-line = 'Here is your file'.
append mailtxt.
Prepare Packing List
perform prepare_packing_list.
Set recipient - email address here!!!
mailrec-receiver = [email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
Sending the document
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = ' '
tables
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
endform.
Form PREPARE_PACKING_LIST
form prepare_packing_list.
clear: mailpack, mailbin, mailhead.
refresh: mailpack, mailbin, mailhead.
describe table mailtxt lines tab_lines.
read table mailtxt index tab_lines.
maildata-doc_size = ( tab_lines - 1 ) * 255 + strlen( mailtxt ).
Creation of the entry for the compressed document
clear mailpack-transf_bin.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'RAW'.
append mailpack.
mailhead = 'TEST.TXT'.
append mailhead.
File 1
mailbin = 'This is file 1'.
append mailbin.
describe table mailbin lines tab_lines.
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = 1.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'TXT'.
mailpack-obj_name = 'TEST1'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
*File 2
mailbin = 'This is file 2'.
append mailbin.
data: start type i.
data: end type i.
start = tab_lines + 1.
describe table mailbin lines end.
mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 1.
mailpack-body_start = start.
mailpack-body_num = end.
mailpack-doc_type = 'TXT'.
mailpack-obj_name = 'TEST2'.
mailpack-obj_descr = 'Subject'.
mailpack-doc_size = tab_lines * 255.
append mailpack.
endform.
regards,
madhu
Similar Messages
-
How to send a text file attachment through mail in ECC 6.0
Hi Friends,
As per the requirement, I need to send a ALV report result as text file attachment to user in ECC 6.0 . I know how to do in 4.6C version. But the same code is not working here in ECC 6.0.
Generally to get the data in new row in the text file we use below code in 4.6c.
data: c_value type x value ' 0D '.
concatenate c_value itab-line into itab-line.
By using above code, we get each row of the itab in a new line in text file.
Same code is not working in ECC6.0 as it is not supporting to concatenate bytes with characters. Getting the error like " field c_value should be diclared as type C or I or N or T or P"
Even I have used function module NLS_STRING_CONVERT_TO_SYS to convert hexa to char. It is converting the value' 0D' to ' # '. But it is not working.
Could you please suggest me that how can get each row of itab as a new line in text file in ECC 6.0.
Itab value:
abcdefdfldjfñlkdsjfñldsjfdsñljñla
fdsljfñldskjfldsñkjfñldsjfñldsajñld
vcxusfcxusfcusafcxusafcusafcdsauc
Actual result currently coming in text file:
abcdefdfldjfñlkdsjfñldsjfdsñljñlafdsljfñldskjfldsñkjfñldsjfñldsajñldvcxusfcxusfcusafcxusafcusafcdsauc
Expected result in text file:
abcdefdfldjfñlkdsjfñldsjfdsñljñla
fdsljfñldskjfldsñkjfñldsjfñldsajñld
vcxusfcxusfcusafcxusafcusafcdsauc
Please do the needful.
Thanks
Kumarhi,
Try this function Module
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1 '
*example code
******* Create Message Body Title and Description****************
i_objtxt = 'test with pdf-Attachment!'.
append i_objtxt.
describe table i_objtxt lines v_lines_txt.
read table i_objtxt index v_lines_txt.
wa_doc_chng-obj_name = 'smartform'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = 'smartform'.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
**** Main Text*****************************
clear i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
append i_objpack.
**** Attachment (pdf-Attachment)*************
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'smartform'.
concatenate i_objpack-obj_name i_objpack-doc_type into
i_objpack-obj_descr separated by '.'.
* I_OBJPACK-OBJ_DESCR = 'test'.
i_objpack-doc_size = v_lines_bin * 255 .
append i_objpack.
* Länge des Attachment ermitteln
clear i_reclist.
i_reclist-receiver = 'email address'.
i_reclist-rec_type = 'U'.
i_reclist-express = 'X'.
data: tab_lines like sy-tabix.
describe table i_objbin lines tab_lines.
append i_reclist.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = i_objpack
object_header = wa_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_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.
write:/ 'Error When Sending the File', sy-subrc.
else.
write:/ 'Mail sent'.
endif. -
Mail Adapter: How to send data as a simple text file attachment?
Hi All
I have a proxy to file scenario, where i write data to a text file.
Now, i need to have a second receiver. I have to send an email, with the above file as an attachment, to this receiver.
How can i do this?
How can i send the data as a text file attachment to the receiver?
Many Thanks
ChandraHi,
To send the message to the second receiver you need to have:
1) Necessary mail message format (can download from service marketplace)
2) Receiver mail communication channel.
3) Create the necessary Configuration Objects .... Receiver Determination, Interface Determination, Receiver Agreement.
3) You can do a XSLT mapping (if required)....if no complex logic is needed then you can do a simple Message mapping.
4) In the receiver CC make sure that you check the Adapter Specific Message Attribute checkbox.
For more info you can refer my answer in this thread:
Re: xml in mail
Also refer the blog:
/people/michal.krawczyk2/blog/2005/11/23/xi-html-e-mails-from-the-receiver-mail-adapter
Regards,
Abhishek. -
Email with Text File Attachement as Source
Hi All,
One of my interfaces needs to listen to incoming mails with an text file attachements.I wish to know how we can convert the text file contents into XML to further process it on the reciever side.Hi,
To perform content conversion of a flat file, check these blogs,
/people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
/people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
Also, to understand file content conversion better, you can check this link on SAP Help,
http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
Regards,
Bhavesh -
Text file attachment in UTF-8 encoding
Hi
I have written a program which sends mails to the users with text file attached. the problem is the text file when you save it to the local desktop ( by clicking on save as ) the encoding is by default ANSI. I want to make the encoding as UTF-8. Is it possible to change this in program?.
thanks
sankarOPEN DATASET - encoding
Syntax
... ENCODING { DEFAULT
| {UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]}
| NON-UNICODE } ... .
Alternatives:
1. ... DEFAULT
2. ... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]
3. ... NON-UNICODE
Effect
: The additions after ENCODING determine the character representation in which the content of the file is handled. The addition ENCODING must be specified in Unicode programs and may only be omitted in non-Unicode programs. If the addition ENCODING is not specified in non-Unicode programs, the addition NON-UNICODE is used implicitly.
Note
: It is recommended that files are always written in UTF-8, if all readers can process this format. Otherwise, the code page can depend on the text environment and it is difficult to identify the code page from the file content.
Alternative 1
... DEFAULT
Effect
: In a Unicode system, the specification DEFAULT corresponds to UTF-8, and in a non-Unicode system, it corresponds to NON-UNICODE.
Alternative 2
... UTF-8 [SKIPPING|WITH BYTE-ORDER MARK]
Addition:
... SKIPPING|WITH BYTE-ORDER MARK
Effect
: The characters in the file are handled according to the Unicode character representation UTF-8.
Notes
: The class CL_ABAP_FILE_UTILITIES contains the method CHECK_UTF8 for determining whether a file is a UTF-8 file.
A UTF-16 file can only be opened as a binary file.
Addition
... SKIPPING|WITH BYTE-ORDER MARK
Effect
: This addition defines how the byte order mark (BOM), with which a file encoded in the UTF-8 format can begin, is handled. The BOM is a sequence of 3 bytes that indicates that a file is encoded in UTF-8.
SKIPPING BYTE-ORDER MARK
is only permitted if the file is opened for reading or changing using FOR INPUT or FOR UPDATE. If there is a BOM at the start of the file, this is ignored and the file pointer is set after it. Without the addition, the BOM is handled as normal file content.
WITH BYTE-ORDER MARK
is only permitted if the file is opened for writing using FOR OUTPUT. When the file is opened, a BOM is inserted at the start of the file. Without the addition, no BOM is inserted.
The addition BYTE-ORDER MARK cannot be used together with the AT POSITION.
Notes
: When opening UTF-8 files for reading, it is recommended to always enter the addition SKIPPING BYTE-ORDER MARK so that a BOM is not handled as file content.
It is recommended to always open a file for reading as a UTF-8 with the addition WITH BYTE-ORDER MARK, if all readers can process this format.
Alternative 3
... NON-UNICODE
Effect
: In a non-Unicode system, the data is read or written without conversion. In a Unicode system, the characters of the file are handled according to the non-Unicode codepage that would be assigned at the time of reading or writing in a non-Unicode system according to the entry in the database table TCP0C of the current text environment. -
No support for text files attached in emails
I was shocked to discover that a simple RTF (Rich Text File) is not supported by iPhone. I was sent a small attachment as a text file and was unable to open it. Surely something as simple as a text file attachment should be easy to display.
Come on Apple, lets get working on version 1.1fixed in later OS
-
Receiver mail with text file attached without line feeds
Hi, friends
I have a text file to mail scenario, where file must be attached to receiver mail.
Receiver CC mail is protocol XIPAYLOAD and use mail package and keep attachment.
In tab module, i have:
Module name --> SAP XI Sample/ConvertCRLFfromToLF
Module configuration --> mode LFtoCRLF
The plain text file is attached to mail but there are no line feeds after the plain text lines.
Thanks, in advanceStefan,
This is not a Java mapping, it's an ABAP mapping.
I've tryed also to insert this characters, but without success.
In my abap class i have:
data: l_newline type c value cl_abap_char_utilities=>newline.
data: l_linefeed type c value cl_abap_char_utilities=>CR_LF.
clear wa_string.
incode = idocument->get_elements_by_tag_name( 'linea' ).
length = incode->GET_LENGTH( ).
do length times.
outcode = incode->get_item( index = d_lines ).
wa_linea = outcode->get_value( ).
if wa_string is initial.
wa_string = wa_linea.
else.
concatenate wa_string l_newline l_linefeed crlf wa_linea into wa_string.
endif.
add 1 to d_lines.
enddo.
l_element_dummy = l_document->create_simple_element(
name = 'Content'
VALUE = wa_string
parent = l_element_root ).
so...it's similar to your suggestion..
Any other input, please?
Regards,
Carme. -
Send PDF Attachment to SAP Mail Inbox.
Dear all,
I have problem please help me out.
i have to create an PDF file with
my own data and that created PDF file
i have to send it to SAP mail inbox
(Transaction code : so01).hi sudheer,
Let the data be populated into ur itab ,
Now in the code just concentrate on
Perform fill structure.
the process u need to do is from ur layout convert from
itab o/p format itab>OTF/OTF->PDF .
see the function modules .
on execution of this a mail will be in ur outbox .
regards,
vijay.
tables : vbak.
type-pools:slis.
data: begin of it_t1 occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
ernam like vbak-ernam,
netwr like vbak-netwr,
waerk like vbak-waerk,
end of it_t1.
select-options : so_vbeln for vbak-vbeln.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
it_listheader TYPE slis_t_listheader,
it_alvevent TYPE slis_t_event.
DATA : wa_fieldcat TYPE slis_fieldcat_alv,
w_pos TYPE i VALUE 1,
wa_listheader TYPE slis_listheader,
wa_alvevent TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.
Data: it_outtab like it_t1 occurs 0 with header line.
DATA : MAILREC LIKE SOMLRECI1 occurs 0 WITH HEADER LINE,
MAILBIN LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
MAILBIN2 LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
MAILTXT LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
MAILHEAD LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
MAILSTRUC LIKE SOPCKLSTI1 occurs 0 WITH HEADER LINE,
MAILDATA LIKE SODOCCHGI1 occurs 0 WITH HEADER LINE.
DATA: BEGIN OF GT_OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF GT_OTF.
DATA: ITCPO LIKE ITCPO,
ITCPP LIKE ITCPP.
DATA: tlines type i,
len_in like SOOD-OBJLEN,
len_out like SOOD-OBJLEN.
data: gt_pdf like solisti1 occurs 0 with header line.
DATA: gt_otfdata LIKE SOLISTI1 occurs 0 WITH HEADER LINE.
CONSTANTS: c_formname_top_of_page TYPE slis_formname
VALUE 'F_TOP_OF_PAGE'.
select vbeln
erdat
ernam
netwr
waerk into corresponding fields of table
it_outtab from vbak where vbeln in so_vbeln.
loop at it_t1.
write:/ it_t1-vbeln,
it_t1-erdat,
it_t1-ernam,
it_t1-netwr,
it_t1-waerk.
endloop.
perform alv_disp.
*& Form alv_disp
text
--> p1 text
<-- p2 text
FORM alv_disp.
PERFORM build_fcat USING '1' 'VBELN' 'IT_OUTTAB' ' ' ' ' ' '
'SALESNO'.
PERFORM build_fcat USING '2' 'ERDAT' 'IT_OUTTAB' ' ' ' ' ' '
'CRTNDATE'.
PERFORM build_fcat USING '3' 'ERNAM' 'IT_OUTTAB' ' ' ' ' ' '
'CRNAME'.
PERFORM build_fcat USING '4' 'NETWR' 'IT_OUTTAB' ' ' ' ' ' '
'NETPRICE'.
PERFORM build_fcat USING '5' 'WAERK' 'IT_OUTTAB' ' ' ' ' ' '
'CURRENCY'.
***Top of Page Heading purpose " u can add the date and column over here
PERFORM buildtop USING it_listheader[].
perform top_of_page.
*------Sort The Catalog
PERFORM sort_cat TABLES it_outtab USING it_sort[].
*------Display Table In GRID
PERFORM disp_grid TABLES it_outtab[].
**For email stuff follow the perform
perform fill_struct.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = MAILDATA
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = MAILSTRUC
OBJECT_HEADER = MAILHEAD
CONTENTS_BIN = MAILBIN
CONTENTS_TXT = MAILTXT
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
RECEIVERS = MAILREC
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " alv_disp
*& Form build_fcat
text
-->P_0104 text
-->P_0105 text
-->P_0106 text
-->P_0107 text
-->P_0108 text
-->P_0109 text
-->P_0110 text
FORM build_fcat USING value(col_pos)
value(fieldname)
value(tabname)
value(key)
value(no_zero)
value(do_sum)
value(reptext_ddic).
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = col_pos.
wa_fieldcat-fieldname = fieldname.
wa_fieldcat-tabname = tabname.
wa_fieldcat-key = key.
wa_fieldcat-no_zero = no_zero.
wa_fieldcat-do_sum = do_sum.
wa_fieldcat-reptext_ddic = reptext_ddic.
APPEND wa_fieldcat TO it_fieldcat.
ENDFORM. " build_fcat
*& Form Top_Of_Page
Top of page for Grid.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
I_LOGO = 'MY_SAP_ENJOY'.
ENDFORM. "top_of_page
text
-->P_IT_LISTHEADER[] text
FORM buildtop USING IT_LISTHEADER type slis_t_listheader.
DATA : text(100) TYPE c.
CLEAR it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Sales Details' .
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = 'Demo'.
APPEND wa_listheader TO it_listheader.
*CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = it_listheader
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM. " Top_Of_Page
*& Form sort_cat
text
-->P_IT_OUTTAB text
-->P_IT_SORT[] text
FORM sort_cat TABLES IT_OUTTAB STRUCTURE IT_OUTTAB USING IT_SORT
TYPE
slis_t_sortinfo_alv.
CLEAR wa_sort.
wa_sort-fieldname = 'VBELN'.
wa_sort-tabname = 'IT_OUTTAB'.
wa_sort-spos = 1.
wa_sort-up = 'X'.
wa_sort-subtot = ' '.
APPEND wa_sort TO it_sort.
ENDFORM. " sort_cat
*& Form disp_grid
text
-->P_IT_OUTTAB[] text
FORM disp_grid TABLES IT_OUTTAB STRUCTURE IT_OUTTAB.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZEX2' "sy-repid
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IT_FIELDCAT = IT_FIELDCAT
IT_SORT = IT_SORT
TABLES
T_OUTTAB = IT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " disp_grid
*& Form fill_struct
text
--> p1 text
<-- p2 text
FORM fill_struct.
Text
MOVE 'Hi vijay ' TO MAILTXT-LINE.
APPEND MAILTXT.
Data
MAILDATA-OBJ_NAME = 'Document'.
MAILDATA-OBJ_DESCR = 'E-maiL From vij'.
MAILDATA-OBJ_PRIO = '1'.
MAILDATA-DOC_SIZE = strlen( MAILTXT ).
Structure
MAILSTRUC-HEAD_START = 1.
MAILSTRUC-HEAD_NUM = 0.
MAILSTRUC-BODY_START = 1.
MAILSTRUC-BODY_NUM = 1.
mailstruc-obj_name = 'Vijay Simha'.
MAILSTRUC-DOC_TYPE = 'RAW'.
APPEND MAILSTRUC.
Receivers
**u can use ur mail id(s) overhere
MOVE '[email protected]' TO MAILREC-RECEIVER.
MAILREC-REC_TYPE = 'U'.
APPEND MAILREC.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
***moving to the output/format of the attachment.
final pdf format in the mail attachemnt
LOOP AT it_outtab.
MOVE it_outtab-vbeln TO MAILBIN.
MOVE it_outtab-erdat TO MAILBIN+18.
MOVE it_outtab-ernam TO MAILBIN+40.
MOVE it_outtab-netwr TO MAILBIN+70.
MOVE it_outtab-waerk TO MAILBIN+78.
APPEND MAILBIN.
CLEAR MAILBIN.
ENDLOOP.
**convert the scrap to otf.
CALL FUNCTION 'SX_OBJECT_CONVERT_SCR_OTF'
EXPORTING
format_src = 'RAW'
format_dst = 'OTF'
devtype = 'POSTSCPT'
funcpara = ' '
len_in = LEN_IN
IMPORTING
LEN_OUT = LEN_OUT
tables
content_in = MAILBIN
content_out = MAILBIN2
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH MAILBIN.
CONVERT OTF to PDF
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
DEVTYPE = 'POSTSCPT'
FUNCPARA =
LEN_IN = LEN_IN
IMPORTING
LEN_OUT = LEN_OUT
TABLES
CONTENT_IN = MAILBIN2
CONTENT_OUT = MAILBIN
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH MAILBIN2.
DESCRIBE TABLE MAILBIN LINES TLINES.
Structure
MAILSTRUC-HEAD_START = 1.
MAILSTRUC-HEAD_NUM = 1.
MAILSTRUC-BODY_START = 1.
MAILSTRUC-BODY_NUM = TLINES.
MAILSTRUC-TRANSF_BIN = 'X'.
MAILSTRUC-DOC_TYPE = 'PDF'.
MAILSTRUC-DOC_TYPE = 'XLS'.
mailstruc-obj_name = 'Vijay.S.Reddy'.
MAILSTRUC-DOC_SIZE = tlines * 255.
APPEND MAILSTRUC.
ENDFORM. " fill_struct -
Hi All,
I'm using ECC 6.0 version, I'm trying to attach a pdf file to a mail using the function module SO_NEW_DOCUMENT_ATT_SEND_API1. But gtting error as "wasn't decoded correctly", but the same coding is working fine in 4.6 version. What changes i should do while using this function module in ECC 6.0 to get it corrected.
Thanks & Regards,
Sabu.Hi ,
I tried with SBWP, I'm able to see the pdf file attached while sending from SBWP.
Please see the below coding
FORM make_the_message *
FORM make_the_message.
Create Message Body
Title and Description
CLEAR : docdata,
objtxt[],
objpack[],
objbin[].
docdata-obj_name = sy-repid.
docdata-obj_descr = p_subj.
Main Text
LOOP AT gt_text INTO objtxt.
APPEND objtxt.
ENDLOOP.
Write Packing List (Main)
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
Sabu
objpack-doc_type = 'RAW'.
objpack-doc_type = 'PDF'.
End Sabu
APPEND objpack.
*Start of Upgrade ECC 6.0
Data: l_mi_bytecount TYPE i.
*End of Upgrade ECC 6.0
Create Message Attachment (As read earlier from frontend)
Write Packing List (Attachment)
Handle the attached file.
objbin[] = gt_pdffile[].
att_type = 'PDF'.
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
*****Sabu 8496
objpack-head_num = 0.
objpack-head_num = 1.
End Sabu
objpack-body_start = 1.
objpack-body_num = tab_lines.
*Start of Upgrade ECC 6.0
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT.pdf'.
objpack-obj_descr = 'Attached Document'.
*End of Upgrade ECC 6.0
APPEND objpack.
Create receiver list
Generate ALV list for either Customers/Vendors/Contact persons etc.
ENDFORM. "make_the_message
FORM fill_the_distribution_list *
FORM fill_the_distribution_list USING i_test
i_fax
i_faxcntry
i_email.
Just as a test...
CLEAR: reclist, reclist[].
IF i_test EQ 'X'.
CASE 'X'.
WHEN p_sndfax.
By Fax
rec_fax-rec_fax = i_fax.
rec_fax-rec_state = i_faxcntry.
Start of Changes 07/09/2008
reclist-receiver = rec_fax.
ASSIGN reclist-receiver TO <fs_reclist> CASTING.
<fs_reclist> = rec_fax.
rec_fax = <fs_reclist>.
End of Changes 07/09/2008
reclist-rec_type = 'F'.
APPEND reclist.
WHEN p_sndint.
By Email
reclist-receiver = i_email.
reclist-rec_type = 'U'.
reclist-BLIND_COPY = 'X'.
APPEND reclist.
ENDCASE.
ELSE.
This is not a test....
LOOP AT gt_detail INTO gs_detail.
CHECK gs_detail-flag EQ icon_green_light.
CASE 'X'.
WHEN p_sndfax.
By Fax
rec_fax-rec_fax = gs_detail-faxnr.
rec_fax-rec_state = gs_detail-land1.
Start of Changes 07/09/2008
ASSIGN reclist-receiver TO <fs_reclist> CASTING.
<fs_reclist> = rec_fax.
rec_fax = <fs_reclist>.
reclist-receiver = rec_fax
End of Changes 07/09/2008
reclist-rec_type = 'F'.
APPEND reclist.
WHEN p_sndint.
By Email
reclist-receiver = gs_detail-email.
reclist-rec_type = 'U'.
reclist-BLIND_COPY = 'X'.
APPEND reclist.
ENDCASE.
ENDLOOP.
ENDIF.
ENDFORM. "fill_the_distribution_list
FORM send_the_messages *
FORM send_the_messages.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
OBJECT_PARA =
OBJECT_PARB =
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.
MESSAGE ID 'SO'
TYPE 'S'
NUMBER '023'
WITH docdata-obj_name.
ELSE.
PERFORM popup.
ENDIF.
ENDFORM. "send_the_messages
Thanks & Regards,
Sabu -
Sending text files as attachments in mails
Hi Experts,
I want to send some content in a text file as an attachment in the mail. Can anybody provide me the sample code for this.
points guaranteed.
thanks
sanakrHI
Check this one
first create a Include report with the following coding
*& Include ZPA1_INCLFOR_MAIL *
* Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
* FORM
FORM ml_customize USING objname objdesc.
*----------- Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
*--------- Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
* FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
* FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
* FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
*--------- Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
* Header Data
* Already Done Thru FM
* Main Text
* Already Done Thru FM
* Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
* Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
* Receiver List
* Already done thru fm
ENDFORM. "ml_prepare
* FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
* CONTENTS_HEX = objhex
* OBJECT_PARA =
* object_parb =
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.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
* FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
*-------------- Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
*------------- Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
* FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
*-------- Data
DATA : pos TYPE i.
DATA : len TYPE i.
*------------ Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
Then include that report in the following report and copy the same code and paste it there
*& Report ZPA_TEMP147 *
REPORT ZPA_TEMP147 .
INCLUDE zpa1_inclfor_mail.
* DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
* SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
* FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
EXTENSION = extension
NAME = name
* NAME_WITH_EXT =
* PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
Regards
Pavan -
To Send HTML Format and excel file attachment in same mail
Dear All,
Have requerment ,to send a mail options HTML table format and same data in excel file attachement.have capable to do the html format using methods BCS .but how to send excel format attachment in same mail.
Please guide me how to do it.
Regards ,
Santhu
Edited by: santosh jajur on Apr 9, 2010 1:54 PMSanthosh,
please check the code:
report bcs_example_7.
This report provides an example for sending an Excel
attachment in Unicode Systems
constants:
gc_tab type c value cl_bcs_convert=>gc_tab,
gc_crlf type c value cl_bcs_convert=>gc_crlf.
parameters:
mailto type ad_smtpadr
default 'ur mail id'. "#EC *
data send_request type ref to cl_bcs.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs.
data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
data sent_to_all type os_boolean.
start-of-selection.
perform create_content.
perform send.
form send.
try.
send_request = cl_bcs=>create_persistent( ).
create document object from internal table with text
append 'Hello world!' to main_text. "#EC NOTEXT
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Test Created By BCS_EXAMPLE_7' ). "#EC NOTEXT
add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls' "#EC NOTEXT
i_attachment_subject = 'ExampleSpreadSheet' "#EC NOTEXT
i_attachment_size = size
i_att_content_hex = binary_content ).
add document object to send request
send_request->set_document( document ).
--------- add recipient (e-mail address) -----------------------
create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
add recipient object to send request
send_request->add_recipient( recipient ).
---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
commit work.
if sent_to_all is initial.
message i500(sbcoms) with mailto.
else.
message s022(so).
endif.
endtry.
endform. "send
form create_content.
data lv_string type string.
data ls_t100 type t100.
columns are separated by TAB and each line ends with CRLF
concatenate 'This Is Just Example Text!' "#EC NOTEXT
gc_crlf gc_crlf
into lv_string.
header line
concatenate lv_string
'MSGID' gc_tab
'MSGNO' gc_tab
'Language' gc_tab "#EC NOTEXT
'Text' gc_crlf "#EC NOTEXT
into lv_string.
data lines
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '182'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
select * from t100 into ls_t100
where arbgb = 'SO' and msgnr = '316'.
concatenate lv_string
ls_t100-arbgb gc_tab
ls_t100-msgnr gc_tab
ls_t100-sprsl gc_tab
ls_t100-text gc_crlf
into lv_string.
endselect.
try.
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_string
iv_codepage = '4103' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
importing
et_solix = binary_content
ev_size = size ).
catch cx_bcs.
message e445(so).
endtry.
endform. "create_content
Thanks. -
Zip file attachment in Apple Mail
I am new to Mac and Apple Mail. I received a mail with a zip file attached. But Apple Mail shows the attachment as some html text. How do I retrieve and save the zip file?
some one sent you a zip file and you are having trouble opening it... it shouldn't... but if you do you can down load: http://www.stuffit.com/mac-expander.html
or http://itunes.apple.com/us/app/stuffit-expander/id405580712?mt=12 -
How to determine the size of a flat file attachment in a mail sender cc?
Hi
I use PI 7.11
I have a scenario where a flat file attachment is being picked up by a MailSender adapter and if the size of the attached flat file is larger that 500 bytes the receiver is A and if the attachment is less that 500 bytes the receiver is B.
I have checked the Context Object list in the Conditions section of Receiver Determination, and it seems, that only the file adapter allows for validation on the file size.
I contemplated an extended receiver determination but the attachment is a flat file which just needs to be passed thru without being converted to an XML document, so my source document is not of XML format.
An other but not very nice way would be to use an intermediate folder to drop the attachment in and from there use a file sender adapter and thus get access to the filesize attribute in my receiver determination, but I would like to avoid this.
Any suggestions?
BR MIkaelHi
I have decided to make a module, where I plan to place the size of the attachment in the Dynamic Configuration variable "ProcessStep", but to my surprise, it seems that all the context objects in the receiver determination condition section are of type String and hence it is not possible to make a condition where I test for whether the value is smaller than say 500!? Only equal, NOT equal and LIKE are available (EX seems to be disabled as this probably only works in an xpath.
Would one way be to use the xpath expression like this ns1:Main\ProcessStep < 500 where ns1: http://sap.com/xi/XI/System?
MIkael -
Can't open a pdf file attachement to e-mail
I canot open an e-mail pdf file attachment..I get a message
You have chosen to open Invoice---pdf
which is: Firefox HTML Document (479kB)
What should Thunderbird do with this file?
Open with Firefox (default)
I do all of the above but nothing happens and I keep getting the same message over andf over again??
Please advise what I should do
ThanksdThanks. I disabled Protected Mode, and I was able to open the pdf attachment. Just to make sure, I enabled it and then disabled it again, and when I tried to open the attachment, it did as before – Adobe Reader (Not Responding) and Internal Error message. Tried it several more times, (enable and then disable Protected Mode) and each time, Adobe Reader wouldn’t launch (Not Responding, Internal Error).
Morris Davidson -
Before I install Firefox 4, I have been use Firefox 3.6 and when I was checking my yahoo mail, there was not any problem to view or download file attachment.
After installing Firefox 4, when I receive a new mail with file attachment, like as video, or document, I can not see the attachment to download it. but with other web browsers like IE, I can see the attachment of the email.Hi!
People using a Trend Micro virus scanner should disable some webmail function. You can find the solution [http://en.kioskea.net/forum/affich-33677-can-t-download-attachments-on-my-yahoo-email here]
I do not use Trend Micro, but have the same issues. I just found my "AdBlock Plus" add-on was stopping the attachment download. What you should do to see if this is your problem too: disable AdBlock Plus, restart firefox and see if your problem is solved. Now enable AdBlock Plus again and restart Firefox.
To fix this problem: In Firefox, click on Add-ons, go to AdBlock Plus, go to Options, click on Filters--> reset statistics. Go to your attachment, click on the attachment (it will fail to download of course). Go back to AdBlock Plus and sort the statistics for "Hits". Now you can see which filter is blocking your attachment download. Disable this filter and you problem is solved!
Regards!
Maybe you are looking for
-
Error 5: Access Denied can not start the DHCP Client service on Local Computer.
Ran into this error problem with both the DHCP and BFE service. Neither will start and both give me the same error code 5 access denied. Found this little nugget below: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dhcp Right click and choose
-
LR 4.2 crashes on Windows 7 (32 bit)
Hello, I have serious trouble with LR 4.2 (although I had similar problems with 4.1). LR simply crashes from time to time (mainly when I edit the files), I receive message that the program stopped responding and must be closed. Please provide me with
-
Problem Using Zoom H4 as an Audio Interface with Garageband
I'm new to GB and I am having problems getting started using my Zoom H4 as an Audio Interface with Garageband on my iMAC. I'm fairly certain that I have the connection and all of the setting configurations correct, and yet I cannot get any sound from
-
I have version 4, just downloaded, and a Mac w. OS 10.6. 7. The bookmarks display (when I pull down "bookmarks") is much too wide. I can't figure out how to reduce the display size. The window is not persistent so I can't even get you a screen shot.
-
Business Connector System tasks
I am trying to determine where the system tasks in SAP Business Connector are documented. There are a number of system tasks in the Scheduler and no documentation. The task that I am concerned with is the 'DB Session Sweeper'.