Hi Mohit,
I tried the code what you had attached but I am getting error as
"OTF end command // missing in OTF data".
Could you please help me in this regard.
When I checked in transaction sost it is giving blank pdf.
Suppose if I want to add the image from my pc with a path like 'c:/documents and setting' etc how can I specify for the graphics part.
My code is
REPORT zprogram66_10.
INCLUDE <cntn01>.
* DECLARATION SECTION
START-OF-SELECTION.
* My Smartforms.
MOVE 'ZMY_SMARTFORMS' TO w_formname.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMARTFORM99'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = w_funcname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE : 'X' TO is_control_param-no_dialog ,
' ' TO is_control_param-preview ,
'X' TO is_control_param-getotf ,
sy-langu TO is_control_param-langu ,
'PRINTER' TO is_control_param-device ,
'X' TO is_composer_param-tdnoprint ,
'X' TO is_composer_param-tdnoprev ,
'X' TO is_composer_param-tdfinal ,
'X' TO is_composer_param-xdfcmode ,
' ' TO is_composer_param-xdf ,
'X' TO is_composer_param-xsfcmode ,
'X' TO is_composer_param-xsf ,
' ' TO is_composer_param-xsfoutdev ,
'A' TO is_composer_param-xsfoutmode ,
'X' TO is_composer_param-xsfformat ,
'My Mail' TO is_composer_param-tdtitle.
* For the Graphics
MOVE : 'GRAPHICS' TO is_xfsparam-name ,
'EXTRACT' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
MOVE : 'GRAPHICS-DIRECTORY' TO is_xfsparam-name ,
'MyDirY' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
MOVE : 'CONTENT-ID' TO is_xfsparam-name ,
'ENABLE' TO is_xfsparam-value.
APPEND is_xfsparam TO is_composer_param-xsfpars.
* Conversion du HTML Hex en Text.
LOOP AT is_job_info-xmloutput-trfresult-content
INTO is_html_raw.
CONCATENATE w_html_xtxt
is_html_raw
INTO w_html_xtxt
IN BYTE MODE.
ENDLOOP.
w_html_xtxt = w_html_xtxt(is_job_info-xmloutput-trfresult-length).
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
inbuff = w_html_xtxt
incode = '4110'
outcode = '0000'
csubst = 'X'
substc_space = 'X'
IMPORTING
outbuff = w_html_txt
outused = w_html_len
EXCEPTIONS
OTHERS = 5.
REPLACE ALL OCCURRENCES OF 'utf-8' IN w_html_txt WITH 'latin1'.
w_html_len = strlen( w_html_txt ).
* Creation objet pour mail.
CREATE OBJECT obj_mime_helper.
* Récupère les graphiques.
it_graphics = is_job_info-xmloutput-xsfgr[].
LOOP AT it_graphics
INTO is_graphic.
CLEAR w_gr_xtxt.
LOOP AT is_graphic-content
INTO is_gr_raw.
CONCATENATE w_gr_xtxt
is_gr_raw-line
INTO w_gr_xtxt
IN BYTE MODE.
ENDLOOP.
w_gr_xtxt = w_gr_xtxt(is_graphic-length).
w_offset = 0.
w_len = 255.
CLEAR it_solix[].
WHILE w_offset < is_graphic-length.
w_diff = is_graphic-length - w_offset.
IF w_diff > w_len.
is_solix-line = w_gr_xtxt+w_offset(w_len).
ELSE.
is_solix-line = w_gr_xtxt+w_offset(w_diff).
ENDIF.
APPEND is_solix TO it_solix.
ADD w_len TO w_offset.
ENDWHILE.
CONCATENATE 'MyDir'
is_graphic-graphics
'.bmp'
INTO w_file.
CONCATENATE 'MyDir'
is_graphic-graphics
'.bmp'
INTO w_content_id.
w_content_type = is_graphic-httptype.
w_obj_len = is_graphic-length.
CALL METHOD obj_mime_helper->add_binary_part
EXPORTING
content = it_solix
filename = w_file
extension = 'BMP'
description = 'Graphic in BMP format'
content_type = w_content_type
length = w_obj_len
content_id = w_content_id2.
ENDLOOP.
w_offset = 0.
w_len = 255.
WHILE w_offset < w_html_len.
w_diff = w_html_len - w_offset.
IF w_diff > w_len.
is_soli-line = w_html_txt+w_offset(w_len).
ELSE.
is_soli-line = w_html_txt+w_offset(w_diff).
ENDIF.
APPEND is_soli TO it_soli.
ADD w_len TO w_offset.
ENDWHILE.
* Ajoute le corps.
CALL METHOD obj_mime_helper->set_main_html
EXPORTING
content = it_soli
filename = ''
description = 'My mail'.
* Ajoute le titre
MOVE is_composer_param-tdtitle TO w_title.
obj_doc_bcs = cl_document_bcs=>create_from_multirelated(
i_subject = w_title
i_importance = '9' " 1 / 5 / 9
i_multirel_service = obj_mime_helper ).
CALL METHOD obj_doc_bcs->get_docno
RECEIVING
result = w_docno.
obj_bcs = cl_bcs=>create_persistent( ).
obj_bcs->set_document( i_document = obj_doc_bcs ).
*---------------------------------------------------------------------*
* Create the attachment. *
*---------------------------------------------------------------------*
* Call the Smartforms
CALL FUNCTION w_funcname
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = is_control_param
mail_appl_obj = is_mailobj
mail_recipient = is_recipient
mail_sender = is_sender
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
invoice = p
output_options = is_composer_param
user_settings = ' '
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = is_job_info
*JOB_OUTPUT_OPTIONS =
TABLES
itab = itab
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
break fgi.
** Convert the OTF to PDF.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = w_doc_size
TABLES
otf = is_job_info-otfdata
doctab_archive = it_docs
lines = it_tline
EXCEPTIONS
OTHERS = 3.
CLEAR w_gr_xtxt.
CREATE OBJECT obj_conv.
* Change the output format.
LOOP AT it_tline
INTO is_tline.
CALL METHOD obj_conv->convert
EXPORTING
inbuff = is_tline
outbufflg = 2500
IMPORTING
outbuff = w_xtxt.
CONCATENATE w_gr_xtxt
w_xtxt
INTO w_gr_xtxt
IN BYTE MODE.
ENDLOOP.
w_gr_xtxt = w_gr_xtxt(w_doc_size).
w_offset = 0.
w_len = 255.
CLEAR it_solix[].
WHILE w_offset < w_doc_size.
w_diff = w_doc_size - w_offset.
IF w_diff > w_len.
is_solix-line = w_gr_xtxt+w_offset(w_len).
ELSE.
is_solix-line = w_gr_xtxt+w_offset(w_diff).
ENDIF.
APPEND is_solix TO it_solix.
ADD w_len TO w_offset.
ENDWHILE.
MOVE : 'Attachment' TO w_title ,
'Attachment.pdf' TO w_content_id.
w_content_type = ' '.
w_obj_len = w_doc_size.
* Add as attachment the PDF
CALL METHOD obj_doc_bcs->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = w_content_id
i_attachment_size = w_obj_len
i_att_content_hex = it_solix.
* add the email address.
obj_recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = 'zzzz@gmail.com' ).
obj_bcs->add_recipient( i_recipient = obj_recipient ).
* Statut change
MOVE 'N' TO w_status.
CALL METHOD obj_bcs->set_status_attributes
EXPORTING
i_requested_status = w_status.
* Send the mail.
obj_bcs->send( ).
* Commit Work.
IF sy-subrc EQ space.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
END-OF-SELECTION.
Thank You.