Problem in sending the file as an attachment through mail
Hi,
I have developed a Zreport. The functionality is like on executing this report it should send an e-mail with an attachment of the data in the xcel format.
So, while execting this report in background mode in ECC 5.0, it is able to send the mail as an attachment but the file doesn't contain the data in it But, the same report while trying to execute in back ground mode in ECC 6.0, it is able to send the mail with the attachment and the file also has the data.
So, my question is like are there any patches that has to be installed in ECC 5.0 system to get this successfully done.
Thanks in advance for your answers.
Rohith
Hello,
Are you using the standad sap function module or using OLE objects to generate excel?
First try creating the excel file in foreground and see if the data is being populated.
Kind Regards,
Niky.
Similar Messages
-
Problem in sending the Smartform Output as PDF through Mail
Dear All,
I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file, it is giving error that FILE IS DAMAGED. Below is the code:
REPORT Y_SEND_MAIL2.
TABLES: vbrk, vbrp.
TYPE-POOLS: abap.
DATA: it_vbrk TYPE TABLE OF vbrk WITH HEADER LINE.
DATA: i_formname TYPE tdsfname,
i_fm_name TYPE rs38l_fnam,
it_vbak TYPE TABLE OF vbak WITH HEADER LINE,
it_ekko TYPE TABLE OF ekko WITH HEADER LINE.
DATA: is_bil_invoice TYPE lbbil_invoice,
output_options TYPE ssfcompop,
control_parameters TYPE ssfctrlop,
e_devtype TYPE rspoptype,
job_output_info TYPE ssfcrescl,
bin_file TYPE xstring,
lines TYPE TABLE OF tline WITH HEADER LINE,
doctab_archive TYPE TABLE OF docs WITH HEADER LINE,
filelength TYPE i,
bin_filesize TYPE i,
docs TYPE TABLE OF docs WITH HEADER LINE.
*"Types
TYPES: t_document_data TYPE sodocchgi1,
t_packing_list TYPE sopcklsti1,
t_attachment TYPE solisti1,
t_body_msg TYPE solisti1,
t_receivers TYPE somlreci1,
t_pdf TYPE tline.
*"Workareas
DATA :w_document_data TYPE t_document_data,
w_packing_list TYPE t_packing_list,
w_attachment TYPE t_attachment,
w_body_msg TYPE t_body_msg,
w_receivers TYPE t_receivers,
w_pdf TYPE t_pdf.
*internal tables
DATA : i_document_data TYPE STANDARD TABLE OF t_document_data,
i_packing_list TYPE STANDARD TABLE OF t_packing_list,
i_attachment TYPE STANDARD TABLE OF t_attachment,
i_body_msg TYPE STANDARD TABLE OF t_body_msg,
i_receivers TYPE STANDARD TABLE OF t_receivers,
i_pdf TYPE STANDARD TABLE OF t_pdf.
DATA: BEGIN OF line_bin,
data(1024) TYPE x,
END OF line_bin.
DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
So please suggest a solution.
Regards,
VishalContinued:
SELECT-OPTIONS: s_vbeln FOR vbrk-vbeln,
s_fkdat FOR vbrk-fkdat OBLIGATORY DEFAULT sy-datum.
SELECT * FROM vbrk
INTO TABLE it_vbrk
WHERE fkdat IN s_fkdat
AND vbeln IN s_vbeln.
i_formname = 'Z_SD_JINDAL_INVOICE10'.
output_options-tddest = 'LP02'.
output_options-tdimmed = 'X'.
output_options-tdnewid = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = i_formname
IMPORTING
fm_name = i_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0. "checking subrc
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. "IF sy-subrc <> 0
READ TABLE it_vbrk INDEX 1.
IF sy-subrc = 0.
is_bil_invoice-hd_gen-bil_number = it_vbrk-vbeln.
ENDIF.
control_parameters-no_dialog = 'X'.
control_parameters-getotf = 'X'.
CALL FUNCTION i_fm_name "'/1BCDWB/SF00000097'
EXPORTING
control_parameters = control_parameters
output_options = output_options
user_settings = space
is_bil_invoice = is_bil_invoice
IMPORTING
job_output_info = job_output_info
TABLES
it_vbak = it_vbak
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*FORM convert_otf_2_pdf.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
* EXPORTING
* USE_OTF_MC_CMD = 'X'
* ARCHIVE_INDEX =
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = job_output_info-otfdata[]
doctab_archive = docs[]
lines = lines[]
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
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. "convert_otf_2_pdf -
How do I scan a photo to a file and then send the file as an attachment via email.
How do I scan a photo to a file and then send the file as an attachment via email.
All of this depends largely on what printer /software you have, which Email client you use and to some extent which OS you are running.
Most HP printers have HP Solution Center which is used to set up scanning,choosing where to save,etc. Once a file/photo is scanned and saved to the folder, open the folder.Select the file and at the top of the window should be the option to 'Email'.
******Clicking the Thumbs-Up button is a way to say -Thanks!.******
**Click Accept as Solution on a Reply that solves your issue to help others** -
I have to send large files like 5MB or biger via mobile phone, but in that cases phone is telling mi to plug in power. And when I do that, there is no problem to send the file. For smaller files there is no problem. How can I solve the problem? Because when I'm not at home I can't plug in the power.
hi,
I am sending file from server to client i.e client will request for a file and service will send it back....... no socket connection is there...I am using JBOSS and apache axis.
pls help me out.....
Rashi -
To send the Payload as PDF Attachment in mail in PI 7.1
Hi All,
I have to send a file as PDF attachment using a mail adapter. I gave the Content_Type as 'application.pdf'. I am receiving the mail, but I am unable to open the PDF. It says 'Could not open because the type is not supported or unable to decode'. How do I resolve this?
Thanks,
GeethaHi,
You need to perform the conversion usign the PayloadSwapBean in the Module tab.
Please refer to the following link
/people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi
http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/5af7c0c994e24fb0d0088443513de2/content.htm
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
hope this helps,
Regards,
Bhanu
Edited by: nanduri bhanu on May 21, 2009 5:21 AM -
Problem in sending .doc file as an attachment.!
Hi SDN,
I am using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send a .doc file as an attachment i am filling the the table contents_hex with my internal table containing the data in hex format but the attachment coming to the SAP office inbox is not showing the actual data it's showing the file with all hex values.
can any one tell the reason?
Please give sample code if possible for sending a word file as an attachment..
Regards,
RahulHi Rahul,
I am sending you the sample code I have written for TXT.
you can use the same code for .doc with small modification.
You use this code and check once and let me know.
Sample code:
Declaration:
DATA : w_name TYPE sos04-l_adr_name.
DATA: sent_to_all LIKE sonv-flag.
DATA:
l_datum(10),
ls_docdata TYPE sodocchgi1,
lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,
lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,
l_tab_lines TYPE i,
l_tab_lines1 TYPE i,
l_tab_lines2 TYPE i,
l_att_type LIKE soodk-objtp.
CONSTANTS : c_tab TYPE x VALUE '09'. "tab delimiter between records.
CONSTANTS : c_line(2) TYPE x VALUE '0D'.
CONSTANTS : l_newline(2) TYPE x VALUE '0D0A'. "To insert Newline.
DATA: v_str LIKE lt_objbin.
*Program logic
Main Text
lt_objtxt = 'Dummy heading. ' .
APPEND lt_objtxt.
lt_objtxt = '' .
APPEND lt_objtxt.
lt_objtxt = 'Dummy second line.'.
APPEND lt_objtxt.
lt_objtxt = '' .
APPEND lt_objtxt.
lt_objtxt = 'Regards,'.
APPEND lt_objtxt.
lt_objtxt = 'Field Service Team' .
APPEND lt_objtxt.
lt_objtxt = '----
APPEND lt_objtxt.
lt_objtxt = 'This is system-generated email;please do not reply to this
message.' .
APPEND lt_objtxt.
lt_objtxt = 'If there are any questions regarding this error message'.
APPEND lt_objtxt.
lt_objtxt = '----
APPEND lt_objtxt.
Write Packing List (Main)
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Create Message Attachment "Attachmant of file
LOOP AT itab1.
CONCATENATE itab1-bldat itab1-blart itab1-bukrs itab1-budat
itab1-monat itab1-waers itab1-xblnr itab1-bktxt
INTO lt_objbin SEPARATED BY c_tab .
CONCATENATE l_newline lt_objbin INTO lt_objbin.
APPEND lt_objbin.
CLEAR lt_objbin.
ENDLOOP.
Write Packing List (Attachment)
l_att_type = 'txt'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255
+ STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'Header file name'.
lt_objpack-obj_descr = 'Header file name'.
APPEND lt_objpack.
*refresh bdclm. "Attachemnt of second file
CLEAR lt_objbin.
LOOP AT bdclm.
CONCATENATE itab2-indate itab2-intime itab2-tcode
itab2-longtext
INTO lt_objbin SEPARATED BY c_tab.
CONCATENATE l_newline lt_objbin INTO lt_objbin.
APPEND lt_objbin.
CLEAR lt_objbin.
ENDLOOP.
CLEAR lt_objbin.
Write Packing List (Attachment)
l_att_type = 'txt'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines1.
l_tab_lines2 = l_tab_lines1 - l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines2.
lt_objpack-doc_size = ( l_tab_lines2 - 1 ) * 255 + STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = l_tab_lines2.
lt_objpack-head_num = 0.
lt_objpack-body_start = l_tab_lines + 1.
lt_objpack-body_num = l_tab_lines2.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'file name '.
lt_objpack-obj_descr = 'file name '.
APPEND lt_objpack.
Create receiver list
lt_reclist-receiver = '[email protected]'.
lt_reclist-rec_type = 'U'.
APPEND lt_reclist.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_docdata
put_in_outbox = 'X'
commit_work = 'X '
*put_in_outbox = ''
IMPORTING
sent_to_all = sent_to_all
VALUE(NEW_OBJECT_ID) LIKE SOFOLENTI1-OBJECT_ID
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
*COMMIT_WORK = X
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.
Thanks,
Yuvaraj -
I bought this Adobe program to convert PDF files to Word doc. files so I could e-mail them as an attachment to people who do not have Adobe Reader. When the people got my e-mail with the attachment and opened it. The attachment was BLANK!! Is there a way to correct this?? or should I just get my money back and cancel this program?
Hi bogy,
How very frustrating! I'm sorry that your email attachment was blank. I'm sure this is a silly question, but did the Word file display as expected on your own machine? If not, then the issue is quite likely with the conversion from PDF to Word (but what you describe isn't a common issue that we're hearing about).
If it looks OK for you, then I suspect the issue lies outside of ExportPDF. If the Word doc is blank when you open it, then please tell me a bit more about the PDF that you're trying to convert and we will take it from there.
Best,
Sara -
To send TXT file as an attachment through Email
Hi Experts,
I am working on requirement where i have to send a txt file as an attachment.
Could any one suggest me a solution.
Thanks and Regards,
Jeswanth KadaliHi,
Use the function module SO_NEW_DOCUMENT_ATT_SEND_API1.
We find it convenient to use a custom function module as a wrapper for that.
Here's the code.
FUNCTION Z_EMAILS_ATTACH.
""Local interface:
*" IMPORTING
*" VALUE(EMAIL_SUBJECT) LIKE SODOCCHGI1-OBJ_DESCR
*" VALUE(ATTACHMENT_SUBJECT) LIKE SOPCKLSTI1-OBJ_DESCR OPTIONAL
*" VALUE(ATTACHMENT_DOC_TYPE) TYPE SO_OBJ_TP OPTIONAL
*" REFERENCE(ATTACHMENT_HEADER) LIKE SOLISTI1 STRUCTURE SOLISTI1
*" TABLES
*" EMAIL_BODY STRUCTURE SOLISTI1
*" EMAIL_ATTACHMENT STRUCTURE SOLISTI1 OPTIONAL
*" RECEIVERS STRUCTURE SOMLRECI1
*" EXCEPTIONS
*" UNKNOWN_COMMUNICATION_TYPE
*" ERROR_SENDING_MAIL
*" EMPTY_ATTACHMENT
*" NO_ATTACHMENT_SUBJECT
*" USER_HAS_NO_EMAIL_ADDRESS
*" NO_RECEIVERS
NOTE
Single-testing when the tables passed to the function have reference
structure SOLISTI1 meets with a problem.
Entering non-blank rows into these tables is impossible, it seems.
This is believed to be because the single testing fails to cope with
the width of SOLISTI1-LINE [255 char].
For single testing, use CVDTLINE as the reference structure - it's
only 132 char. Then remember to change it back to SOLISTI1...
Based on Z_EMAIL_ATTACH which sends just one mail.
08.06.2007 JNM
DATA: document LIKE sodocchgi1.
DATA: packlist LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: contents LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: header LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: RECVLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: NEXT_ROW LIKE SY-TABIX.
DATA: lines LIKE sy-tabix.
DATA: LAST_LINE_LENGTH TYPE I.
DATA: d_doc_size LIKE packlist-doc_size.
data: email_address type ad_smtpadr.
A user without an email address cannot email.
CALL FUNCTION 'Z_USER_EMAIL_ADDRESS'
EXPORTING
USER_NAME = SY-UNAME
IMPORTING
EMAIL_ADDRESS = email_address
EXCEPTIONS
UNKNOWN_USER = 1
NO_ADDRESS_KEY = 2
NO_ADDRESS_DATA = 3
NO_EMAIL_ADDRESS = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
raising USER_HAS_NO_EMAIL_ADDRESS.
ENDIF.
Receivers?
describe table receivers lines lines.
if lines eq 0.
raise no_receivers.
endif.
initialization
CLEAR: CONTENTS, DOCUMENT, HEADER, PACKLIST, RECVLIST.
REFRESH: CONTENTS, HEADER, PACKLIST, RECVLIST.
attachment?
DESCRIBE TABLE EMAIL_ATTACHMENT LINES LINES.
IF LINES EQ 0 AND ATTACHMENT_SUBJECT CN SPACE.
RAISE EMPTY_ATTACHMENT.
ENDIF.
IF LINES NE 0 AND ATTACHMENT_SUBJECT CO SPACE.
RAISE NO_ATTACHMENT_SUBJECT.
ENDIF.
email body
concatenate 'SAP client:'
sy-host sy-sysid sy-mandt
into contents separated by space.
append contents.
clear contents.
append contents.
APPEND LINES OF EMAIL_BODY TO CONTENTS.
header - row for body
HEADER = 'BODY HEADER'.
APPEND HEADER.
packing list - row for body
PACKLIST-TRANSF_BIN = SPACE.
PACKLIST-HEAD_START = 1.
PACKLIST-HEAD_NUM = 1.
PACKLIST-BODY_START = 1.
DESCRIBE TABLE CONTENTS LINES PACKLIST-BODY_NUM.
NEXT_ROW = 1 + PACKLIST-BODY_NUM.
*packlist-doc_type = 'EXT'.
PACKLIST-DOC_TYPE = 'RAW'.
APPEND PACKLIST.
IF ATTACHMENT_SUBJECT CN SPACE. " if there's an attachment
attachment into contents
APPEND LINES OF EMAIL_ATTACHMENT TO CONTENTS.
DESCRIBE TABLE EMAIL_ATTACHMENT LINES LINES.
READ TABLE EMAIL_ATTACHMENT INDEX LINES.
LAST_LINE_LENGTH = STRLEN( EMAIL_ATTACHMENT ).
header - attachment
if attachment_header is initial.
HEADER = 'ATTACH'.
else.
header = attachment_header.
endif.
APPEND HEADER.
packing list - row for attachment
CLEAR PACKLIST.
case attachment_doc_type.
when 'XLS'.
PACKLIST-TRANSF_BIN = 'X'.
when others.
PACKLIST-TRANSF_BIN = SPACE.
endcase.
PACKLIST-HEAD_START = 2.
PACKLIST-HEAD_NUM = 1.
PACKLIST-BODY_START = NEXT_ROW.
if not attachment_doc_type is initial.
packlist-doc_type = attachment_doc_type.
else.
PACKLIST-DOC_TYPE = 'RAW'.
endif.
packlist-doc_type = 'EXT'.
PACKLIST-OBJ_DESCR = ATTACHMENT_SUBJECT.
PACKLIST-OBJ_NAME = 'ATTACHMENT'.
PACKLIST-BODY_NUM = LINES.
D_DOC_SIZE = LAST_LINE_LENGTH + ( 255 * ( LINES - 1 ) ).
PACKLIST-DOC_SIZE = D_DOC_SIZE.
APPEND PACKLIST.
ENDIF. "attachment
document
document-obj_name = 'EMAIL'.
DOCUMENT-OBJ_DESCR = EMAIL_SUBJECT.
document-obj_langu = sy-langu.
document-obj_expdat = sy-datum.
document-sensitivty = 'F'.
document-obj_prio = 9.
document-no_change = 'X'.
document-priority = 9.
document-expiry_dat = sy-datum.
ADD 1 TO: DOCUMENT-OBJ_EXPDAT, DOCUMENT-EXPIRY_DAT.
DESCRIBE TABLE contents LINES lines.
D_DOC_SIZE = LAST_LINE_LENGTH + ( 255 * ( LINES - 1 ) ).
document-doc_size = d_doc_size.
call the mail function
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = document
put_in_outbox = 'X'
commit_work = 'X'
TABLES
object_header = header
packing_list = packlist
contents_txt = contents
receivers = receivers
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.
RAISE ERROR_SENDING_MAIL.
ENDIF.
ENDFUNCTION.
Also remember that the SAP user sending the email must have an email address in the user details, so that SAP has something to put in the "From" field when creating the email.
That's why we use this:
FUNCTION Z_USER_EMAIL_ADDRESS.
""Local interface:
*" IMPORTING
*" REFERENCE(USER_NAME) TYPE SYUNAME DEFAULT SY-UNAME
*" EXPORTING
*" REFERENCE(EMAIL_ADDRESS) TYPE AD_SMTPADR
*" EXCEPTIONS
*" UNKNOWN_USER
*" NO_ADDRESS_KEY
*" NO_ADDRESS_DATA
*" NO_EMAIL_ADDRESS
tables:
adr6,
usr21,
usr02.
SAP logon data
select single *
from usr02
where bname = user_name.
if sy-subrc ne 0.
message i017(ZREP) with
'SAP user' user_name 'is unknown'
raising unknown_user.
endif.
SAP user address key
select single *
from usr21
where bname = user_name.
if sy-subrc ne 0.
message i017(ZREP) with
'No address data assigned to SAP user' user_name
raising no_address_key.
endif.
SAP user address
select single *
from adr6
where addrnumber = usr21-addrnumber and
persnumber = usr21-persnumber.
if sy-subrc ne 0.
message i017(ZREP) with
'No address data found for SAP user' user_name
raising no_address_data.
endif.
email_address = adr6-smtp_addr.
if email_address is initial.
message i017(ZREP) with
'No address data found for SAP user' user_name
raising no_email_address.
endif.
ENDFUNCTION.
John -
Send RFQ as an PDF attachment through mail
Hi All,
I wanna send the quotation format to multiple vendors in PDF through mail.
I have developed RFQ using smartforms.
Please lemme know how to do this and wat r the steps to be taken.
Regards,
PriyaHello,
you only need to convert your smartform into PDF and next send.
The sending can be seen for example here:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
or you can just search for the sending code, you will find something like this:
http://monoceros85.blogspot.com/2009/04/send-email-in-abap-using-class-clbcs.html
Email using cl_bcs
Or direct example is here:
Multiple PDF attachments using CL_BCS Class
Regards, Otto
p.s.: please search the next time first and ask later -
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. -
Logo Problem While sending the smart form as an attachment via Email
Hi ,
I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the smartforma as an attachement into the mailbox . it is sent correctly but the COLOR LOGO are not coming correctlly .
I checked the OTF to PDF file is getting converted correctly .i.e. if i am downloading the foem then it is displaying correctly , but in case of sending it to mailbox as an attached PDF file ,the logo are not comming correctly ,
If anybody faced such type of problem can u please clarify .
I am thinking the problem is in FM SO_NEW_DOCUMENT_ATT_SEND_API1 . this FM is not sending the Attached PDF file correctly .
All the TExt/variables are displaying correctly in the PDF file except the LOGO.while opening the PDF file one Warnng message is getting displayed : "An error occured while opening the Image" .
PLease help ..
Thanks,
sachiHi,
Edit your logo as 256 color bit map image and save it and upload into SE78,
And also better to use this FM :SO_DOCUMENT_SEND_API1 it is good for new versions.
thanks,
venkat.
Edited by: Satya venkat Rao.R on Dec 13, 2011 6:02 AM -
Problem in sending table to excel in attach file .
I want to send excel file in attachment ( build from my internal table ) .
so i use func. SO_DOCUMENT_SEND_API1 and it's ok.
But when i want to send line bigger than 255 characters in the attach
i can't do so ,
The table "CONTENTS_BIN" is type SOLISTI1 and can get line just
in size of 255 characters .
is there any solution for it ?
i need to send 500 characters in one line .
i use this example to send the file :
*& Report YTEST_EXCEL_MAIL1 *
REPORT YTEST_EXCEL_MAIL1 .
TABLES: EKKO.
PARAMETERS: P_EMAIL TYPE SOMLRECI1-RECEIVER
DEFAULT '[email protected]'.
TYPES: BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
END OF T_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,
WA_EKPO TYPE T_EKPO.
TYPES: BEGIN OF T_CHAREKPO,
EBELN(10) TYPE C,
EBELP(5) TYPE C,
AEDAT(8) TYPE C,
MATNR(18) TYPE C,
END OF T_CHAREKPO.
DATA: WA_CHAREKPO TYPE T_CHAREKPO.
DATA: IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
W_CNT TYPE I,
W_SENT_ALL(1) TYPE C,
W_DOC_DATA LIKE SODOCCHGI1,
GD_ERROR TYPE SY-SUBRC,
GD_RECIEVER TYPE SY-SUBRC.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM DATA_RETRIEVAL.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Example .xls documnet attachment'
'XLS'
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP AEDAT MATNR
UP TO 10 ROWS
FROM EKPO
INTO TABLE IT_EKPO.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
DATA: LD_STORE(50) TYPE C. "Leading zeros
CONSTANTS: CON_CRET(2) TYPE C VALUE '0D', "OK for non Unicode
CON_TAB(2) TYPE C VALUE ' '. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO IT_ATTACH SEPARATED BY con_tab.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_EKPO INTO WA_CHAREKPO.
*Modification to retain leading zeros
inserts code for excell REPLACE command into ld_store
=REPLACE("00100",1,5,"00100")
CONCATENATE '=REPLACE("' WA_CHAREKPO-EBELP '",1,5,"'
WA_CHAREKPO-EBELP '")' INTO LD_STORE .
concatenate ld_store into .xls file instead of actual value(ebelp)
CONCATENATE WA_CHAREKPO-EBELN LD_STORE
*End of modification
WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
INTO IT_ATTACH SEPARATED BY con_tab.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
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.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. "send_file_as_email_attachmenthii
in gui_download FM which file type you have given?
suppose i have file type as DBF so it will consider all the data as text or string so it will print that green in excel sheet.and ya it will display that green mark only to those fields who will have leading zero like for text file for other file it will not so it will not display that green mark.
thx
twinkal
Edited by: twinkal patel on Jun 11, 2008 2:27 PM -
Problem in sending the smartform as email for other language except english
Hi Experts,
I could not send the smartform as an attachment for other languages, but where as i could send it in english.
The program is working fine with print priview but not when sending the SF as an attachment
(in other languages except english).
Please do find the below code which i used to send the smartform as an attachment.
Please let me know if there is any mistake in the code.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
*TRY.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_language = nast-spras
i_importance =
i_sensitivity =
i_text = l_text
i_hex =
i_header =
i_sender =
receiving
RESULT = l_email_object
CATCH cx_document_bcs .
*ENDTRY.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.hi,
i tried with ur problem.but i am able send mail in other languages also.actaullly i wrote a msg whether the mail has been sent or not.i got success message. i am placing my code here please go thorugh it,and do relavant modifications.
*& Report ZPPS_SMARTFORM_TO_PDF
REPORT ZPPS_SMARTFORM_TO_PDF.
PARAMETER: p_date LIKE sy-datum.
PARAMETER: p_rea TYPE char255.
DATA: t_otfdata TYPE ssfcrescl,
t_lines LIKE tline OCCURS 0 WITH HEADER LINE,
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
Objects to send mail.
DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: w_filesize TYPE i,
w_bin_filesize TYPE i,
wa_ctrlop TYPE ssfctrlop,
wa_outopt TYPE ssfcompop,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
WA_OBJHEAD TYPE SOLI_TAB,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1.
DATA: form_name TYPE rs38l_fnam,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I,
nast-spras type sy-langu value 'DE'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSR_DEMO1'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = form_name
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_outopt-tdnoprev = 'X'.
CALL FUNCTION form_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = wa_ctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = wa_outopt
USER_SETTINGS = 'X'
MYDATE = p_date
REASON = p_rea
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = t_otfdata
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = w_bin_filesize
BIN_FILE =
TABLES
OTF = t_otf
LINES = t_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at t_lines.
TRANSLATE t_lines USING '~'.
CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
t_RECORD = WA_BUFFER.
APPEND t_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: T_RECLIST,
T_OBJTXT,
T_OBJBIN,
T_OBJPACK.
CLEAR WA_OBJHEAD.
T_OBJBIN[] = T_RECORD[].
Create Message Body Title and Description
T_OBJTXT = 'test with pdf-Attachment!'.
APPEND T_OBJTXT.
DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.
READ TABLE T_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 T_OBJPACK-TRANSF_BIN.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
T_OBJPACK-BODY_NUM = V_LINES_TXT.
T_OBJPACK-DOC_TYPE = 'RAW'.
APPEND T_OBJPACK.
Attachment (pdf-Attachment)
T_OBJPACK-TRANSF_BIN = 'X'.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.
READ TABLE T_OBJBIN INDEX V_LINES_BIN.
T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
T_OBJPACK-BODY_NUM = V_LINES_BIN.
T_OBJPACK-DOC_TYPE = 'PDF'.
T_OBJPACK-OBJ_NAME = 'smart'.
T_OBJPACK-OBJ_DESCR = 'test'.
APPEND T_OBJPACK.
CLEAR T_RECLIST.
T_RECLIST-RECEIVER = 'MAIL-ID'.
T_RECLIST-REC_TYPE = 'U'.
APPEND T_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 = T_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = T_OBJBIN
CONTENTS_TXT = T_OBJTXT
RECEIVERS = T_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.
and i thought of one more soluyion u can write
wa_ctrlop-langu = T002-spras. i think it will also help for u.
revert back if any questions.
please reward me if helpful.
gupta.pullipudi -
Hello,
I try to send pdf file as attachments file to mail with XI.
I use with this blog
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
My problems is:
1. to all mails that I send have another e file Untiteld.doc, how I can avoid this file?
2. When I received the pdf file I not succeed to open it I received the message:
Adobe reader could not open 'elad.pdf' because it is either not supported
File type or because the file has been damaged (for example, it was sent as an
Email attachment and wasn't correctly decoded)
Regards
Elad Peleghi
ref this
Receiver Mail Adapter message with PDF attachment
PDF attachment in mail adapter
File adapter with attachment to mail
File with attachment to mail scenario
File To Mail Scenario With An Attachment -
Issue in sending the email with XL attachment in ECC version
Hi,
I have an issue with sending the email with XL attachment. My program is sending a mail to the receiver with XLS as attachment. Recently we have migrated from 4.6B to ECC version. Same code was worked in 4.6B.But it is not working in ECC version.When i try to open the attachment, i get a Dialog Box with the following message
"The file is not in a recognizable format.
1. if you know the file is from another program whih is incompatible with Microsoft excel,click cancel,then open this file in its original application
2.If you suspect the file is damaged, click help for more information about solving theproblem.
3.if you still want to see what text is contained in the file, click OK.Then click the text import wizard. "
when i click OK, the excel sheet is opening with all required data.
Can anyone kindly tell me why this is happening.
I am also attaching part of the coding related to this requirement.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM build_xls_data_table.
DATA: w_total(13),
w_clabs(13),
w_cinsm(13),
w_ceinm(13),
w_cretm(13),
w_cspem(13),
w_cumlm(13),
w_exp_date(8),
w_v_totalp(13),
w_min_rem(8),
w_ersda(10),
w_hsdat(10),
w_vfdat(10),
w_ship_date(10),
w_plnmg(13),
w_mhdrz(4).
CLEAR: w_total, w_clabs, w_cinsm, w_ceinm, w_cspem, w_exp_date,
w_v_totalp, w_min_rem, w_ersda, w_hsdat, w_vfdat, w_ship_date,
w_plnmg, w_mhdrz.
w_total = it_batch1-total.
w_clabs = it_batch1-clabs.
w_cinsm = it_batch1-cinsm.
w_ceinm = it_batch1-ceinm.
w_cspem = it_batch1-cspem.
w_cumlm = it_batch1-cumlm.
w_cretm = it_batch1-cretm.
w_exp_date = it_batch1-exp_date.
w_v_totalp = it_batch1-v_totalp.
w_min_rem = it_batch1-min_rem.
w_plnmg = it_batch1-plnmg.
w_mhdrz = it_batch1-mhdrz.
CONCATENATE it_batch1-ersda6(2) it_batch1-ersda4(2)
it_batch1-ersda+0(4) INTO w_ersda SEPARATED BY '.'.
CONCATENATE it_batch1-hsdat6(2) it_batch1-hsdat4(2)
it_batch1-hsdat+0(4) INTO w_hsdat SEPARATED BY '.'.
CONCATENATE it_batch1-vfdat6(2) it_batch1-vfdat4(2)
it_batch1-vfdat+0(4) INTO w_vfdat SEPARATED BY '.'.
CONCATENATE it_batch1-ship_date6(2) it_batch1-ship_date4(2)
it_batch1-ship_date+0(4) INTO w_ship_date SEPARATED BY '.'
CONCATENATE
it_batch1-werks it_batch1-mtart it_batch1-matnr it_batch1-maktg
it_batch1-prdha it_batch1-prctr it_batch1-ktext it_batch1-dispo
it_batch1-charg it_batch1-lgort it_batch1-herkl w_clabs
w_cinsm w_ceinm w_cretm w_cspem
w_cumlm w_total it_batch1-meins it_batch1-v_spr_unit
w_v_totalp it_batch1-waers w_plnmg it_batch1-meins
w_ersda w_hsdat w_vfdat w_exp_date
w_ship_date w_mhdrz w_min_rem it_batch1-zlifer
it_batch1-doknr it_batch1-dokar it_batch1-doktl it_batch1-dokvr
INTO L_STRING SEPARATED BY CON_TAB.
INTO l_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
WHILE l_string <> space.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = 255
text = l_string
as_character = 'X'
IMPORTING
line = it_attach
rest = l_string.
IF l_string = space.
CONCATENATE IT_ATTACH CON_CRET INTO IT_ATTACH.
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ELSE.
APPEND it_attach.
CLEAR it_attach.
ENDIF.
ENDWHILE.
move l_string to it_attach .
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
text
--> p1 text
<-- p2 text
FORM send_file_as_email_attachment.
DATA:w_length TYPE i.
DATA: w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = text-034 .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
DESCRIBE TABLE it_attach LINES w_cnt.
DESCRIBE TABLE it_message LINES w_cnt.
READ TABLE it_message INDEX w_cnt.
w_length = STRLEN( it_attach ).
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_message ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = text-034.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
***Start of changes by 501507008 on 29.01.2009
t_packing_list-obj_descr = 'MAIL BODY'.
***End of changes by 501507008 on 29.01.2009
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'XLS'.
t_packing_list-obj_descr = text-034.
t_packing_list-obj_name = 'filename'.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
LOOP AT it_adr6.
t_receivers-receiver = it_adr6-smtp_addr.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ' '
sender_address_type = ' '
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = ' '
IMPORTING
sent_to_all =
new_object_id =
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
contents_hex =
object_para =
object_parb =
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.
ENDIF.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENTHi,
could you tell me which opeion should i select in SCOT under INT node. I have tried with diffrent options. but no luck.
SAPscript/Smart Forms - No Conversion
ABAP List - No Conversion
Business Object/Link - No Conversion
RAW Text - No Conversion
Maybe you are looking for
-
Set a default value to checkbox on Active Directory form
Hi all how to set a default value to checkbox UD_ADUSER_MUST on Active Directory form? I set the value 1 on the column default value (ADUSER form), i try the provisioning resource AD to the user and this field is not selected. please help me.
-
Update, printer no longer working
hi, i've had the 1.4.x series of CUPS for a while, and had to rmmod usblp to print. not a big deal. this is no longer working, and i'm not sure why. i've blacklisted usblp, still no dice. print jobs are permanently reported as: Processing - "Waiting
-
Problem with Character Set after upgrade
Hello, I have a probelm and was wondering if anyone has seen this before. I have been running Java 1.4.2_13 for a while now on some Windows servers. About a month ago we upgraded to Java 1.6.0_12. We are reading input files that are in the character
-
HI, IN our application, We are uisng quicktime plug in to play MPEG4 vedios. But in internet explorer, the vedios are not fitting into the quicktime plug in. The edges of vedio is getting cut off (like vedio is bigger than quicktime window..). Please
-
Permanently Deleting Photos from Hard Drive
Hi, I recently upgraded to a macbook pro from a macbook. I backed up all of my photos to an external hard drive from the macbook, then moved the entire library to the trash then emptied the trash. I just ran a program called "Disk Inventory X" to fin