Hi Team,
i have implemented the logic for sales order status change that time this action will be triggered and email send automatically and PDF attachment is also attached.
but here problem is mail sent but there is no PDF attachment..and body text also it is not getting displayed..please find the below line code and give any suggestions to change the logic for attaching pdf document.
IF ls_crm_survey-lens_type = 'C'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZCRM_CONTACT_LENS_CUST_OPT'
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
ELSEIF ls_crm_survey-lens_type = 'S'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZCRMline
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
ENDIF.
CALL FUNCTION fm_name
EXPORTING
control_parameters = control
output_options = output_options
user_settings = ' '
object_id = lv_object_id
IMPORTING
job_output_info = info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
APPEND LINES OF info-otfdata TO it_itcoo.
lt_otfdata[] = it_itcoo[].
DATA:l_dummy TYPE STANDARD TABLE OF tline,
pdf_data TYPE xstring,
pdf_size TYPE i.
DATA t_att_content_hex TYPE solix_tab.
CLEAR:pdf_data, pdf_size.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = pdf_size
bin_file = pdf_data
TABLES
otf = lt_otfdata[]
lines = l_dummy
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
REFRESH t_att_content_hex.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = pdf_data
TABLES
binary_tab = t_att_content_hex.
TYPE-POOLS: ixml.
DATA: w_pdf_source TYPE xstring.
DATA lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
DATA: lt_message_body TYPE bcsy_text VALUE IS INITIAL,
headertxt TYPE so_obj_des,
lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
DATA: lv_text_type TYPE so_obj_tp VALUE 'RAW'.
DATA: l_len TYPE so_obj_len.
DATA: wsubject TYPE sood-objdes.
CLASS cl_bcs DEFINITION LOAD.
lo_send_request = cl_bcs=>create_persistent( ).
DATA:lv_cust_name TYPE char100.
*****create message body and subject.
CONCATENATE 'Dear' lv_cust_name INTO lv_cust_name SEPARATED BY space.
APPEND lv_cust_name TO lt_message_body.
APPEND '' TO lt_message_body.
APPEND 'Thank you for undergoing the Vision Express comprehensive 6 step eye test.' TO lt_message_body.
APPEND '' TO lt_message_body.
APPEND 'Please refer attachment for your prescription details.' TO lt_message_body.
APPEND '' TO lt_message_body.
APPEND 'We recommend that you undergo an eye test once a year.' TO lt_message_body.
APPEND '' TO lt_message_body.
l_len = '200'.
headertxt = 'Vision Express- Details of eye wear prescription'.
wsubject = headertxt.
lo_document = cl_document_bcs=>create_document( i_type = lv_text_type
i_length = l_len
i_language = sy-langu
i_text = lt_message_body
i_subject = wsubject ).
TRY.
lo_document->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'Invoice Copy'
i_att_content_hex = t_att_content_hex ).
CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.
* add attachment
* Pass the document to send request
CALL METHOD lo_send_request->set_document( lo_document ).
* Create sender
DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
l_send TYPE adr6-smtp_addr VALUE 'mankil@lt.com.
lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
* lo_sender = cl_sapuser_bcs=>create( sy-uname ).
lo_send_request->set_sender( EXPORTING i_sender = lo_sender ).
DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
l_send = 'dattatreya.mankar@ril.com'.
lo_recipient = cl_cam_address_bcs=>create_internet_address( l_send ).
* Set recipient
lo_send_request->add_recipient( EXPORTING i_recipient = lo_recipient
i_express = 'X' ).
* Send email
DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
lo_send_request->send( EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = lv_sent_to_all ).
COMMIT WORK.
Thanks
Kalpana