Hi,
I am trying to send the smart forms threw code in E-Mail.
After attchning the smart forms in mail with PDF formamt i am not able to open while opening the pDF in mail it Giving me ERROR "Ättachment was not correctly decoded"
Kindly Help Me to resolve this issue .
Here I am mentionin her code also .
Hi,
I am trying to send the smart forms threw code in E-Mail.
After attchning the smart forms in mail with PDF formamt i am not able to open while opening the pDF in mail it Giving me ERROR "Ättachment was not correctly decoded"
Kindly Help Me to resolve this issue .
Here I am mentionin her code also .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZHR_TRAIN_CARD22'
IMPORTING
fm_name = fname.
ls_output_options-xsfcmode = 'X'.
ls_output_options-tddest = 'LOCL'.
* ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
* control_parameters-no_dialog = 'X'.
* control_parameters-getotf = 'X'.
CALL FUNCTION fname
EXPORTING
control_parameters = x_ctrl_p
MAIL_RECIPIENT = MAIL_REC_OBJ
MAIL_SENDER = MAIL_SEN_OBJ
IMPORTING
job_output_info = x_output_data
TABLES
IT_EMP = it_emp
IT_EMP1 = it_emp1
IT_EMP2 = it_emp2
IT_EMP3 = it_emp3
IT_EMP4 = it_emp4
IT_EMP5 = it_emp5
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
REFRESH i_otf[].
i_otf[] = x_output_data-otfdata .
IF i_otf[] IS NOT INITIAL.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 134
IMPORTING
bin_filesize = v_size
TABLES
otf = i_otf
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
endif.
LOOP AT it_lines.
TRANSLATE it_lines USING '~'.
CONCATENATE wa_buffer it_lines INTO wa_buffer.
ENDLOOP.
TRANSLATE wa_buffer USING '~'.
DO.
i_record = wa_buffer.
APPEND i_record.
SHIFT wa_buffer LEFT BY 255 PLACES.
IF wa_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = 255
TABLES
content_in = it_lines
content_out = it_soli
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
*-----To caluculate total number of lines of internal table
DESCRIBE TABLE it_emp LINES v_lines.
DESCRIBE TABLE it_emp1 LINES v_lines1.
DESCRIBE TABLE it_emp2 LINES v_lines2.
DESCRIBE TABLE it_emp3 LINES v_lines3.
DESCRIBE TABLE it_emp4 LINES v_lines4.
DESCRIBE TABLE it_emp5 LINES v_lines5.
v_lines6 = ( v_lines + v_lines1 + v_lines2 + v_lines3 + v_lines4 + v_lines5 ).
*-----Create Message Body and Title and Description
it_mess = 'Please find attached Training Card : .'.
" and i have attached that in mail'.
CONDENSE it_mess.
APPEND it_mess.
DESCRIBE TABLE it_mess LINES v_lines_txt.
READ TABLE it_mess INDEX v_lines_txt.
MOVE 'Training Card' to lv_sub.
wa_doc_data-obj_name = 'smartform'.
wa_doc_data-expiry_dat = sy-datum + 10.
wa_doc_data-obj_descr = lv_sub.
wa_doc_data-sensitivty = 'F'.
wa_doc_data-doc_size = v_lines_txt * 255.
* APPEND it_pcklist.
* Main Text
CLEAR it_pcklist-transf_bin.
it_pcklist-head_start = 1.
it_pcklist-head_num = 0.
it_pcklist-body_start = 1.
it_pcklist-body_num = v_lines_txt.
it_pcklist-doc_type = 'RAW'.
APPEND it_pcklist.
*-----PDF Attachment
it_pcklist-transf_bin = 'X'.
it_pcklist-head_start = 1.
it_pcklist-head_num = 0.
it_pcklist-body_start = 1.
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
it_pcklist-doc_size = v_lines_bin * 255 .
it_pcklist-body_num = v_lines6.
it_pcklist-doc_type = 'PDF'.
it_pcklist-obj_name = 'smartform'.
MOVE 'Training Card' TO it_pcklist-obj_descr.
it_pcklist-obj_langu = 'E'.
it_pcklist-doc_size = v_lines * 255.
APPEND it_pcklist.
CLEAR lv_mailid.
*-----Giving the receiver email-id
IF lv_mailid IS INITIAL.
SELECT SINGLE usrid_long INTO lv_mailid FROM pa0105
WHERE pernr = wa7-pernr
AND usrty = '0030'.
ENDIF.
it_receivers-receiver = lv_mailid.
it_receivers-rec_type = 'U'.
APPEND it_receivers.
*-----Calling the function module to sending email
*
* CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = 'X'
sender_address = lv_eaddr
sender_address_type = 'SMTP'
commit_work = 'X'
IMPORTING
sent_to_all = lv_sent
new_object_id = lv_object
TABLES
packing_list = it_pcklist
object_header = wa_objhead
contents_txt = it_mess
contents_hex = it_table
receivers = it_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.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
WITH rfcgroup = 'iwdf7ytc_YD3_94'
AND RETURN.
REFRESH: it_receivers,
it_mess,
it_pcklist.
ENDIF.