Hi Deepak,
Try like this
*--------------------------------------------------------------------*
* V A R I A B L E S *
*--------------------------------------------------------------------*
data : w_frm type rs38l_fnam, " Smart form Function Module
w_binsize typei, " Binary Size
w_str type string. " String Variable
*--------------------------------------------------------------------*
* I N T E R N A L T A B L E D E C L A R A T I O N *
*--------------------------------------------------------------------*
data : it_final typetableof sflight, " Final Table
it_pdf typetableof tline, " Internal Table For PDF Format
it_cbin typetableof solisti1, " Internal Table For Character Binary Format
it_ctxt typetableof solisti1, " Internal Table For Character Text Format
it_pack typetableof sopcklsti1, " Internal Table For Packing Data
it_rec typetableof somlreci1, " Internal Table For Receivers List
it_mail typetableof ymail_id. " Internal Table For Mail ID's
*--------------------------------------------------------------------*
* W O R K A R E A D E C L A R A T I O N *
*--------------------------------------------------------------------*
data : wa_final type sflight, " Wark Area For Final
wa_ctrl type ssfctrlop, " Work Area For Control Data
wa_out type ssfcompop, " Work Area For Out Data
wa_otf type ssfcrescl, " Work Area For OTF Data
wa_cbin type solisti1, " Work Area For Character Binary Data
wa_ctxt type solisti1, " Work Area For Character Text Data
wa_doc type sodocchgi1, " Work Area For document
wa_pack type sopcklsti1, " Work Area For Packed Data
wa_rec type somlreci1, " Work Area For Receiver's Data
wa_mail type ymail. " Work Area For Mail Id's
*--------------------------------------------------------------------*
* F I E L D S Y M B O L S *
*--------------------------------------------------------------------*
field-symbols : <f_pdf> type tline. " Field Symbol For PDF Format
*--------------------------------------------------------------------*
* S E L E C T I O N S C R E E N *
*--------------------------------------------------------------------*
selection-screen : beginofblock b1 withframetitletext-001.
parameters : p_date type sy-datum.
selection-screen : endofblock b1.
*--------------------------------------------------------------------*
* S T A R T - O F - S E L E C T I O N *
*--------------------------------------------------------------------*
start-of-selection.
select * from sflight intotable it_final upto10rows.
end-of-selection.
callfunction'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'YSMARTFORM_NAME'
importing
fm_name = w_frm
exceptions
no_form = 1
no_function_module = 2
others = 3.
if sy-subrc <> 0.
messageid sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
wa_ctrl-no_dialog = 'X'. "No Dialog for properties
wa_ctrl-preview = ' '. "No Preview of printing
wa_ctrl-getotf = 'X'. "To get in OTF Format
wa_out-tddest = 'LP01'. "Standard Printer Format
clear wa_otf.
callfunction w_frm
exporting
control_parameters = wa_ctrl
output_options = wa_out
user_settings = ' '
importing
job_output_info = wa_otf
tables
it_final = it_final
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
if sy-subrc <> 0.
messageid sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
clear : w_binsize,
it_pdf,
w_str,
wa_cbin,
it_cbin,
wa_ctxt,
it_ctxt.
callfunction'CONVERT_OTF'
exporting
format = 'PDF'
max_linewidth = 132
importing
bin_filesize = w_binsize
tables
otf = wa_otf-otfdata[]
lines = it_pdf
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
if sy-subrc <> 0.
messageid sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
loopat it_pdf assigning<f_pdf>.
concatenate w_str <f_pdf> into w_str.
endloop.
do.
wa_cbin = w_str.
append wa_cbin to it_cbin.
clear wa_cbin.
shift w_str leftby255places.
if w_str isinitial.
exit.
endif.
enddo.
concatenate'Sflight Details'(002) p_date into wa_ctxt separatedby space.
append wa_ctxt to it_ctxt.
clear wa_ctxt.
append wa_ctxt to it_ctxt.
append wa_ctxt to it_ctxt.
concatenate'Regards'(003) ' 'into wa_ctxt.
append wa_ctxt to it_ctxt.
concatenate'ABAP Team'(004) ' 'into wa_ctxt.
append wa_ctxt to it_ctxt.
wa_doc-obj_name = 'Testing'(005).
concatenate'Testing'(006) p_date into wa_doc-obj_descr.
wa_doc-obj_langu = 'E'.
wa_doc-sensitivty = 'O'. "Standard
wa_doc-doc_size = w_binsize.
wa_pack-obj_name = text-005.
concatenate'Testing'(006) p_date into wa_pack-obj_descr.
wa_pack-transf_bin = space.
wa_pack-head_start = 1.
wa_pack-head_num = 1.
wa_pack-body_start = 1.
wa_pack-body_num = lines( it_ctxt ).
wa_pack-doc_type = 'RAW'. "RAW type Data
append wa_pack to it_pack.
wa_pack-doc_size = w_binsize.
wa_pack-transf_bin = 'X'.
wa_pack-head_start = 1.
wa_pack-head_num = 1.
wa_pack-body_start = 1.
wa_pack-body_num = lines( it_cbin ).
wa_pack-doc_type = 'PDF'. "PDF Type data
append wa_pack to it_pack.
loopat it_mail into wa_mail.
clear wa_rec.
wa_rec-rec_type = 'U'. " Specification Of Receipient Type - ( To )
wa_rec-com_type = 'INT'. " Transmission Method (Fax, Telex, ...) - ( Internet)
wa_rec-receiver = wa_mail-email.
append wa_rec to it_rec.
endloop.
callfunction'SO_DOCUMENT_SEND_API1'
exporting
document_data = wa_doc
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = it_pack
contents_bin = it_cbin
contents_txt = it_ctxt
receivers = it_rec
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.
messageid sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
message'Mail Sended Successfully'(008) type'I'.
endif.
endif.
*--------------------------------------------------------------------*
* E N D - O F - S E L E C T I O N *
*--------------------------------------------------------------------*