on 08-13-2010 7:28 AM
Dear Friends,
I have wirtten a code to send a mail with an attached SAP Script output along with subject and body mail.
Everything works fine, but i have an issue on attachment.
that is, when try to open the attachment (it's a PDF file) a pop up shown with message as " cannot extract the embedded font 'TimesNewRoman, BOLD' some charecters may not display or print correctly".
most of the data missing in the ouput of SAP SCRIPT attachment.
please help me out.
thanks,
munvar.
Hi,
Did you try using some other font in your script?
Thanks,
Archana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> {quote:title=P695571 wrote:}{quote}
> Hi,
>
> Which FM you are using to convert script into PDF?
>
> I think there is some issue in PDF conversion.
>
> Thanks,
> Archana
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = i_itcpp
TABLES
OTFDATA = i_otfdata
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
SET COUNTRY space.
IF nast-nacha = l_k_5.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = i_otfdata
lines = i_pdfdata
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 i_pdfdata INTO l_wa_pdfdata.
TRANSLATE l_wa_pdfdata USING ' ~'.
CONCATENATE l_v_gd_buffer l_wa_pdfdata INTO l_v_gd_buffer.
CLEAR l_wa_pdfdata.
ENDLOOP.
TRANSLATE l_v_gd_buffer USING '~ '.
DO.
l_wa_mess_att = l_v_gd_buffer.
APPEND l_wa_mess_att TO l_i_mess_att.
CLEAR l_wa_mess_att.
SHIFT l_v_gd_buffer LEFT BY 255 PLACES.
IF l_v_gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
* Object with PDF.
REFRESH l_i_objbin.
l_i_objbin[] = l_i_mess_att[].
DESCRIBE TABLE l_i_objbin LINES l_v_l_attachment.
READ TABLE l_i_objbin INTO l_wa_objbin INDEX l_v_l_attachment.
IF sy-subrc = 0.
* do nothing
ENDIF.
* Object with main text of the mail.
l_wa_objtxt = 'Hello, please make a payment ASAP'.
APPEND l_wa_objtxt TO l_i_objtxt.
CLEAR l_wa_objtxt.
DESCRIBE TABLE l_i_objtxt LINES l_v_l_testo.
* Create the document which is to be sent
doc_chng-obj_name = 'Invoice'.
doc_chng-obj_descr = 'Invoice Output'.
doc_chng-sensitivty = 'O'.
doc_chng-obj_prio = '1'.
doc_chng-doc_size = l_v_l_testo * 225.
* Pack to main body.
CLEAR l_wa_objpack-transf_bin.
* header
l_wa_objpack-head_start = 1.
* The document needs no header (head_num = 0)
l_wa_objpack-head_num = 0.
* body
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_v_l_testo.
l_wa_objpack-doc_type = 'RAW'.
APPEND l_wa_objpack TO l_i_objpack.
CLEAR l_wa_objpack.
*Create the attachment.
* Fill the fields of the packing_list for the attachment:
l_wa_objpack-transf_bin = 'X' .
* header
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 1.
* body
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_v_l_attachment.
l_wa_objpack-doc_type = 'PDF'.
l_wa_objpack-obj_name = 'Attachment'.
l_wa_objpack-obj_descr = 'Invoice Details.pdf'.
l_wa_objpack-doc_size = ( l_v_l_attachment - 1 ) * 255 + strlen( l_wa_objbin ).
APPEND l_wa_objpack TO l_i_objpack.
CLEAR l_wa_objpack.
* e-mail receivers.
l_wa_email-name = ' '.
APPEND l_wa_email TO l_i_email.
IF l_i_email IS NOT INITIAL.
LOOP AT l_i_email INTO l_wa_email.
l_wa_reclist-receiver = l_wa_email-name.
l_wa_reclist-rec_type = 'U'.
l_wa_reclist-notif_del = 'X'.
l_wa_reclist-express = 'X'.
l_wa_reclist-notif_ndel = 'X'.
APPEND l_wa_reclist TO l_i_reclist.
ENDLOOP.
IF l_i_reclist IS NOT INITIAL.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
PUT_IN_OUTBOX = 'X'
* commit_work = 'X'
TABLES
packing_list = l_i_objpack
object_header = l_i_objhead
contents_bin = l_i_objbin
contents_txt = l_i_objtxt
receivers = l_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.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF
Edited by: Munvar Basha on Aug 16, 2010 7:49 AM
Edited by: Munvar Basha on Aug 16, 2010 7:51 AM
Hi I am very Sorry,
code i posted is not Properly aliigned.
Initially i passing X to GETOTFDATA to OPEN_FORM function module and then i getting OTF data from CLOSE_FORM function module.
later i am using Function modlue CONVERT_OTFto convert the data to PDF formate.
Afetr that i am packing body data to as RAW and then Attachment as PDF.
finally i am calling function module to send SO_NEW_DOCUMENT_ATT_SEND_API1mail with attachment.
Thanks,
Munvar Basha.
Hi,
Try fetching 'V_PDF_XSTRING' in FM 'CONVERT_OTF', which will be of type xstring.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_bin_filesize
BIN_FILE = V_PDF_XSTRING
TABLES
otf = i_otfdata
lines = i_pdfdata
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
Then, Convert this string into BIN type using below FM ,
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = V_PDF_XSTRING
TABLES
BINARY_TAB = I_CONTENT_BIN.
Use this internal table 'I_CONTENT_BIN' to send mail.
It should solve your problem.
Thanks,
Archana
Hi,
Please try downloading that file on your local machine using FM 'GUI_DOWNLOAD'.
* Downloading the PDF File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = V_BYTECOUNT
FILENAME = V_PATH
FILETYPE = L_C_BIN
TABLES
DATA_TAB = I_CONTENT_BIN.
And try opening that file.
Please let me know if your are still getting that message.
Thanks,
Archana
Hi Archana,
Thnaks for your response,
PDF file downloded sucessfully, Few data is missing in the PDF now.
like Line item is missing and certain dates in header window, i need to check which font they used for this.
becasue line items are displyed using Time new roman. but for the same billing document i can see the line item in print preview. not in PDF.
it is strange for me.
kindly let me know if you have any solution.
thabks a lot your help on this.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.