cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform Conversion

Former Member
0 Kudos

Hi Experts, I want to convert a smartform to PDF and send as email attachment. I used following code to achieve this. I am getting mail with smartform attachment but there is no content in the attachment. Only the outline of smartform is getting displayed in the attachment. When I preview the form in program I am getting corect output. But after converting to pdf, I am not getting any value printed in this smartform. Pasting the code below: CALL FUNCTION 'CONVERT_OTF' EXPORTING format = 'PDF' max_linewidth = 132 IMPORTING bin_filesize = v_len_in TABLES otf = i_otf lines = i_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. * Convert PDF from 132 to 255. LOOP AT i_tline. * Replacing space by ~ TRANSLATE i_tline USING ' ~'. CONCATENATE w_buffer i_tline INTO w_buffer. ENDLOOP. * Replacing ~ by space TRANSLATE w_buffer USING '~ '. DO. i_record = w_buffer. * Appending 255 characters as a record APPEND i_record. SHIFT w_buffer LEFT BY 255 PLACES. IF w_buffer IS INITIAL. EXIT. ENDIF. ENDDO. Refresh: i_reclist, i_objtxt, i_objbin, i_objpack. clear w_objhead. * Object with PDF. i_objbin[] = i_record[]. DESCRIBE TABLE i_objbin LINES v_lines_bin. * Object with main text of the mail. i_objtxt = 'Find attached the output of the smart form.'. APPEND i_objtxt. i_objtxt = 'Regards,'. APPEND i_objtxt. i_objtxt = 'Sibin'. APPEND i_objtxt. DESCRIBE TABLE i_objtxt LINES v_lines_txt. * Document information. w_doc_chng-obj_name = 'Smartform'. w_doc_chng-expiry_dat = sy-datum + 10. w_doc_chng-obj_descr = 'Smart form output'. w_doc_chng-sensitivty = 'F'. "Functional object w_doc_chng-doc_size = v_lines_txt * 255. * Pack to main body as RAW. * Obj. to be transported not in binary form CLEAR i_objpack-transf_bin. * Start line of object header in transport packet i_objpack-head_start = 1. * Number of lines of an object header in object packet i_objpack-head_num = 0. * Start line of object contents in an object packet i_objpack-body_start = 1. * Number of lines of the object contents in an object packet i_objpack-body_num = v_lines_txt. * Code for document class i_objpack-doc_type = 'RAW'. APPEND i_objpack. * Packing as PDF. 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 'Smartform_output' '.pdf' INTO i_objpack-obj_descr. i_objpack-doc_size = v_lines_bin * 255. APPEND i_objpack. * Document information. CLEAR i_reclist. * e-mail receivers. i_reclist-receiver = 'sibin@xyz.com'. i_reclist-express = 'X'. i_reclist-rec_type = 'U'. "Internet address APPEND i_reclist. * Sending mail. CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING document_data = w_doc_chng *put_in_outbox = 'X' commit_work = 'X' TABLES packing_list = i_objpack object_header = w_objhead *contents_hex = i_objbin 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.   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE.     SUBMIT RSCONN01 WITH MODE = 'INT' WITH OUTPUT = ' '. ENDIF.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Using CALL FUNCTION 'GUI_DOWNLOAD' I can download the smartform to desktop.If I open this attachment, I am getting proper output. But while attaching and sending through mail, I am not getting contents in smartform.

I checked with SSFCOMP_PDF_PREVIEW function and here also the output is perfect. Please help me to resolve this.

Regards,

Sibin