data:
i_otf type itcoo occurs 0 with header line,i_tline type table of tline with header line,
i_record like solisti1 occurs 0 with header line,
i_objpack like sopcklsti1 occurs 0 with header line,
i_objtxt like solisti1 occurs 0 with header line,
i_objbin like solisti1 occurs 0 with header line,
i_reclist like somlreci1 occurs 0 with header line,
w_objhead type soli_tab,
w_doc_chng type sodocchgi1,
w_buffer type string,
v_lines_txt type i,
v_lines_bin type i.
constants c_formname type tdsfname value 'ZAU_SMART_EDU'.
data:
st_job_output_info type ssfcrescl,
st_document_output_info type ssfcrespd,
st_job_output_options type ssfcresop,
st_output_options type ssfcompop,
st_control_parameters type ssfctrlop,
st_job_output_info type ssfcrescl,
st_document_output_info type ssfcrespd,
st_job_output_options type ssfcresop,
st_output_options type ssfcompop,
st_control_parameters type ssfctrlop,
v_len_in type so_obj_len,
v_language type sflangu value 'E',
v_e_devtype type rspoptype,
v_bin_filesize type i,
v_name type string,
v_path type string,
v_fullpath type string,
v_filter type string,
v_uact type i,
v_guiobj type ref to cl_gui_frontend_services,
v_filename type string,
v_fm_name type rs38l_fnam.
v_language type sflangu value 'E',
v_e_devtype type rspoptype,
v_bin_filesize type i,
v_name type string,
v_path type string,
v_fullpath type string,
v_filter type string,
v_uact type i,
v_guiobj type ref to cl_gui_frontend_services,
v_filename type string,
v_fm_name type rs38l_fnam.
*Device settings
call function 'SSF_GET_DEVICE_TYPE'
exporting
i_language = v_language
i_application = 'SAPDEFAULT'
importing
e_devtype = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
*convert smartform name to function
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = c_formname
importing
fm_name = v_fm_name
exceptions
no_form = 1
no_function_module = 2
others = 3.
exporting
i_language = v_language
i_application = 'SAPDEFAULT'
importing
e_devtype = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
*convert smartform name to function
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = c_formname
importing
fm_name = v_fm_name
exceptions
no_form = 1
no_function_module = 2
others = 3.
*call smartform with function
call function v_fm_name
exporting
control_parameters = st_control_parameters
output_options = st_output_options
* USER_SETTINGS = 'X'
importing
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
tables
gt_data = gt_data[]
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
i_otf[] = st_job_output_info-otfdata[].
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
err_bad_otf = 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.
loop at i_tline.
translate i_tline using '~'.
concatenate w_buffer i_tline into w_buffer.
endloop.
translate w_buffer using '~'.
do.
i_record = w_buffer.
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.
i_objbin[] = i_record[].
describe table i_objbin lines v_lines_bin.
i_objtxt = 'Smartforms with PDF attachment.'.
append i_objtxt.
i_objtxt = 'Regards,'.
append i_objtxt.
i_objtxt = 'Alara'.
append i_objtxt.
describe table i_objtxt lines v_lines_txt.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10 .
w_doc_chng-obj_descr = 'Smartform PDF mail'.
w_doc_chng-sensitivty = 'F'.
w_doc_chng-doc_size = v_lines_txt * 255.
clear i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_txt.
i_objpack-doc_type = 'RAW'.
append i_objpack.
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' 'pdf'
into i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
append i_objpack.
clear i_reclist.
i_reclist-receiver = 'alaraumdu@text.com.'.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'.
append i_reclist.
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
contents_bin = i_objbin
object_header = w_objhead
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 'Mail sent failed' type 'S' display like 'E'.
else.
message 'Mail sent successfully' type 'S'.
endif.
endform.
After all, you can check the mail from SOST t-code.
One example;
ALARA UMDU - SAP ABAP DEVELOPER
Yorumlar
Yorum Gönder