on 07-16-2010 4:15 AM
Hi everyone... I have this problem... I need to send a smartform attached to an email... I'm doing the following:
- Create the OTF using the smartform function importing job_output_info.
- Convert the OTF (job_output_info-otfdata) to PDF using CONVERT_OTF_2_PDF.
- Change the table line's width using SX_TABLE_LINE_WIDTH_CHANGE.
- Send the email using SO_NEW_DOCUMENT_ATT_SEND_API1.
Everything seems to be OK. But When I check the PDF file attached in the email and open it, everything there is a mess. The letters are superimposed over each other and the grills are not painted (instead it shows a black block).
Any ideas how to solve this???
Thanks a lot!!!
Try this out..!
<removed by moderator>
To convert the script out put to PDF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF' u201C FOR out put format
max_linewidth = 132 u201CFor ASCII format: Number of lines in LINES-TDLINE
IMPORTING
bin_filesize = gv_bin_filesize u201CFile size reference
TABLES
otf = gt_otf u201CInput table with OTF format
lines = gt_pdf_tab " Output table with target format
To mail Order in PDF format:
Data declaration part :
DATA: gt_reclist TYPE TABLE OF somlreci1, " SAPoffice: Structure of the API Recipient List
gt_pdf_tab TYPE TABLE OF tline, " SAPscript: Text Lines
gt_otf TYPE TABLE OF itcoo, " OTF Structure
gt_objbin TYPE TABLE OF solisti1, " SAPoffice: Single List with Column Length 255
gt_objpack TYPE TABLE OF sopcklsti1. " SAPoffice: Description of Imported Object Components
DATA: gv_form_name TYPE rs38l_fnam, " Used to store the function module generated by Smartform
gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
DATA : gc_text(11) TYPE c VALUE 'Form Output',
gc_tst(3) TYPE c VALUE 'TST',
gc_testing(30) TYPE c VALUE 'Zellar Sales Document'.
1. Assigning the Description of the object sent in the mail
CLEAR gs_docdata.
gs_docdata-obj_name = gc_tst.
gs_docdata-obj_descr = gc_testing.
Assigning the email id to Structure of the API Recipient List table
CLEAR : gt_reclist, gs_reclist. u201C variables used
gs_reclist-receiver = mail address'. u201CTo whom this mail should go
GS_RECLIST-REC_TYPE = 'U'.
APPEND gs_reclist TO gt_reclist. u201C Internal table for storing mail address
2.Passing the Smart form text lines to SAP office: Single List with Column Length 255 table ,this logic is used to get all the data into PDF file while you send an attachment through mail..
CLEAR: gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab. u201CLoop the content of PDF table
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin. u201CTable contains Single List with Column Length 255 table
ENDIF.
3. Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = 'ATTACHMENT'.
gs_objpack-obj_descr = 'test'.
APPEND gs_objpack TO gt_objpack.
ENDIF.
4. Sending the Form Output in the PDF format to email
data: WK_OBJHEAD TYPE SOLI_TAB.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' u201Cfunction module used for sending mail
EXPORTING
document_data = gs_docdata u201CAttributes of new document
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = gt_objpack u201CInformation about structure of data tables
OBJECT_HEADER = WK_OBJHEAD u201CHeader data for document (spec.header)
contents_bin = gt_objbin u201CData which is to be sent as pdf attachment
receivers = gt_reclist u201Cmailing list
EXCEPTIONS u201CException Handling
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.
ELSE.
WRITE 'Sent Successfully'.
ENDIF.
Edited by: Thomas Zloch on Jul 16, 2010 10:38 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Problem solved. There wasn´t anything wrong with my code. The problem was they had a thai printer set as the default printer. Thanks for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a similar program that works OK, the only difference is that I use FM CONVERT_OTF. Other steps are the same. The usual suspect in such cases is the file size, so check if it is correct.
Also try to save a file instead of emailing it. If it looks OK then it gets corrupted somewhere in the middle. And make sure you have the latest Adobe software.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a similar program that works OK, the only difference is that I use FM CONVERT_OTF. Other steps are the same. The usual suspect in such cases is the file size, so check if it is correct.
Also try to save a file instead of emailing it. If it looks OK then it gets corrupted somewhere in the middle. And make sure you have the latest Adobe software.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a similar program that works OK, the only difference is that I use FM CONVERT_OTF. Other steps are the same. The usual suspect in such cases is the file size, so check if it is correct.
Also try to save a file instead of emailing it. If it looks OK then it gets corrupted somewhere in the middle. And make sure you have the latest Adobe software.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.