2010 Jun 09 5:43 PM
Hi Experts,
I'm on a migration from 4.6c to Ecc 6.0 and I'm facing problems about sending emails with pdf. The PDF is generated from a smartforms (The SF works fine). The email is sent with the pdf file but when I try to open the file returns the message: 'There was an error opening this document. The file is damaged and could not be repaired'.
Could anyone help me?
Here are parts of my code:
ls_control-getotf = c_x.
CALL FUNCTION lc_sf_nome
EXPORTING
control_parameters = ls_control
output_options = ls_output
user_settings = space
IMPORTING
job_output_info = ls_job_output
EXCEPTIONS
...
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = c_pdf
IMPORTING
bin_filesize = li_pdf_size
TABLES
otf = ls_job_output-otfdata[]
lines = lw_lines[]
EXCEPTIONS
...
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = '255'
TABLES
content_in = lw_lines[]
content_out = gw_content_bin[]
EXCEPTIONS
...
CHECK sy-subrc = 0.
In the packing list:
DESCRIBE TABLE gw_content_bin LINES li_lines.
ls_pac-transf_bin = c_x.
ls_pac-head_start = 1.
ls_pac-head_num = 1.
ls_pac-body_start = 1.
ls_pac-body_num = li_lines.
ls_pac-doc_type = c_pdf.
ls_pac-obj_name = 'PDF_TESTE'.
ls_pac-obj_descr = ls_packing_list-obj_name.
ls_pac-doc_size = li_lines * 255.
APPEND ls_pact TO gw_pac.
Then, in the FM:
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_doc
put_in_outbox = c_x
commit_work = c_x
TABLES
packing_list = gw_pac
object_header = gw_header
contents_bin = gw_content_bin
contents_txt = gw_objtxt
receivers = gw_reclist
EXCEPTIONS
...
CHECK sy-subrc = 0.
Tks in advance!
Edited by: Gabriel Petrini on Jun 9, 2010 2:00 PM
2010 Jun 09 7:53 PM
See if this helps:
LS_PACKING_LIST-TRANSF_BIN = ''.
LS_PACKING_LIST-HEAD_START = 1.
LS_PACKING_LIST-HEAD_NUM = 0.
LS_PACKING_LIST-BODY_START = 1."LV_TABLINE1.
LS_PACKING_LIST-BODY_NUM = LV_TABLINES. "LV_TABLINE2.
LS_PACKING_LIST-DOC_TYPE = 'RAW'.
*
*
LS_PACKING_LIST-OBJ_NAME = 'ATTACHMENT'.
*
LS_PACKING_LIST-OBJ_DESCR = 'Attached Document'.
APPEND LS_PACKING_LIST TO LT_PACKING_LIST.
LS_PACKING_LIST-TRANSF_BIN = 'X'. "commented by VG 06082009
LS_PACKING_LIST-HEAD_START = 1.
LS_PACKING_LIST-HEAD_NUM = 1.
LS_PACKING_LIST-BODY_START = 1."LV_TABLINE1.
LS_PACKING_LIST-BODY_NUM = TAB_LINES. "LV_TABLINE2.
LS_PACKING_LIST-DOC_TYPE = 'PDF'.
*
LS_PACKING_LIST-DOC_SIZE = TAB_LINES * 255.
*
LS_PACKING_LIST-OBJ_NAME = 'ATTACHMENT'.
*
LS_PACKING_LIST-OBJ_DESCR = 'Attached Document'.
APPEND LS_PACKING_LIST TO LT_PACKING_LIST.
CLEAR LS_PACKING_LIST.
2010 Jun 09 7:53 PM
See if this helps:
LS_PACKING_LIST-TRANSF_BIN = ''.
LS_PACKING_LIST-HEAD_START = 1.
LS_PACKING_LIST-HEAD_NUM = 0.
LS_PACKING_LIST-BODY_START = 1."LV_TABLINE1.
LS_PACKING_LIST-BODY_NUM = LV_TABLINES. "LV_TABLINE2.
LS_PACKING_LIST-DOC_TYPE = 'RAW'.
*
*
LS_PACKING_LIST-OBJ_NAME = 'ATTACHMENT'.
*
LS_PACKING_LIST-OBJ_DESCR = 'Attached Document'.
APPEND LS_PACKING_LIST TO LT_PACKING_LIST.
LS_PACKING_LIST-TRANSF_BIN = 'X'. "commented by VG 06082009
LS_PACKING_LIST-HEAD_START = 1.
LS_PACKING_LIST-HEAD_NUM = 1.
LS_PACKING_LIST-BODY_START = 1."LV_TABLINE1.
LS_PACKING_LIST-BODY_NUM = TAB_LINES. "LV_TABLINE2.
LS_PACKING_LIST-DOC_TYPE = 'PDF'.
*
LS_PACKING_LIST-DOC_SIZE = TAB_LINES * 255.
*
LS_PACKING_LIST-OBJ_NAME = 'ATTACHMENT'.
*
LS_PACKING_LIST-OBJ_DESCR = 'Attached Document'.
APPEND LS_PACKING_LIST TO LT_PACKING_LIST.
CLEAR LS_PACKING_LIST.
2010 Jun 09 9:01 PM
Thanks!
But my problem persists...
I copy both codes bellow to test in my system.
Link: [http://an-abaper.blogspot.com/2008/03/mail-with-pdf-attachment.html]
Link: [http://an-abaper.blogspot.com/2009/07/sending-smartform-as-pdf-through-mail.html]
The problem is the same: the email is in SOST but when I try to open the PDF file attached appears the same message above.
I use the FM GUI_DOWNLOAD to save the pdf in my desktop and the file is OK.
So, I think the problem could be in FM SO_NEW_DOCUMENT_ATT_SEND_API1 or some SAP system configuration.
Thanks in Advance.
Regards.
2010 Jun 09 9:08 PM
Hi Gabriel,
try to set the line width source to 134.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = '134'
line_width_dst = '255'
TABLES
content_in = lw_lines[]
content_out = gw_content_bin[]
EXCEPTIONS
...
regards,
Paulo Carvalho
2010 Jun 09 10:34 PM
Thanks Paulo,
I tried and still doesn't work..
I also tried use the paramenter transfer_bin = 'X' on FM SX_TABLE_LINE_WIDTH_CHANGE but it gives a short dump.
Anyone have more ideas?
Regards.
Gabriel
2010 Jun 09 11:38 PM
Hello,
Please try to remove this special character in the OTF data from internal table lw_lines[]
.before calling this FM.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'.
loop at lw_lines assigning <ls_lines>.
TRANSLATE <ls_lines> USING '~'.
endloop.
Thanks,
Vamshi.
2010 Jun 10 12:53 PM
Thanks,
but it didn't solve my problem!
Can be any problem related with unicode???
Gabriel.
2010 Jun 10 3:31 PM
Hi,
Just to let you know. I solve my problem with aplication sap note 1430123.
Gabriel.
2010 Jul 13 12:27 PM
Hi, i am facing the same issue.. kindly tell me have you just implemented this note 1430123 or have done any further modifications.
Please reply.
Thanks,
Siva
2010 Jun 10 1:20 PM
They changed something with the text to binary conversion. Try SCMS_FTEXT_TO_BINARY instead of SX_TABLE_LINE_WIDTH_CHANGE.
This works for me (code partially):
DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
DATA: i_tline TYPE TABLE OF tline WITH HEADER LINE.
DATA: i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: i_objbin LIKE solix OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
* bin_file = v_bin_file
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
REFRESH: i_record.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = i_tline
t_target_tab = i_record
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
ld_length = LINES( i_record[] ) * 255.
CALL FUNCTION 'SCMS_FTEXT_TO_BINARY'
EXPORTING
input_length = ld_length
TABLES
ftext_tab = i_record[]
binary_tab = i_objbin[]
EXCEPTIONS
failed = 1
OTHERS = 2.
This was part of a quick bugfix, to adress a similar problem.
Edited by: Carsten Grafflage on Jun 10, 2010 2:24 PM
2010 Jun 10 1:30 PM
ehm, you might also want to try:
DATA: LD_BIN TYPE XSTRING.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_file = LD_BIN
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = ld_bin
IMPORTING
output_length = ld_length
TABLES
binary_tab = lt_bin.
Edited by: Carsten Grafflage on Jun 10, 2010 2:34 PM