‎2009 Sep 08 2:47 PM
Hallo ,
I am using FM CONVERT_OTFSPOOLJOB_2_PDF. After I have binary data in a internal table PDF_ONE. How can I send this data as a PDF attachment sending e_mail.
I find the class cl_document_bcs My code is
CALL METHOD l_result->add_attachment
EXPORTING
i_attachment_type = l_extension
i_attachment_subject = 'Bestellung'
i_attachment_size = l_size
i_att_content_text = pdf_one.
i_att_content_hex = pdf_one.
i can send a e_mail with pdf attachment but adobe reader dont show it.
can somebody tell me where is my mistake.
regards
rana
‎2009 Sep 08 2:55 PM
Hi,
Use the following code to create the PDF from Binary data.
LOOP AT li_binarchivobject INTO lwa_binarchivobject.
CONCATENATE lv_buffer lwa_binarchivobject-line
INTO lv_buffer IN BYTE MODE .
ENDLOOP.
*---Find the number of lines buffer string.
lv_last = XSTRLEN( lv_buffer ) MOD 255.
lv_lines = XSTRLEN( lv_buffer ).
lv_lines = lv_lines / 255.
DO lv_lines TIMES.
*---Check after adding 255 to the offset if length becomes more than
*---total length then don't add 255 instead add lv_last.
lv_temp = lv_offset + 255.
IF lv_temp GE lv_binlength.
lwa_objhex-line = lv_buffer+lv_offset(lv_last).
APPEND lwa_objhex TO li_objhex.
ELSE.
lwa_objhex-line = lv_buffer+lv_offset(255).
APPEND lwa_objhex TO li_objhex.
lv_offset = lv_offset + 255.
ENDIF.
ENDDO.
*---Populate Packing internal table from relevant information required
*---to send the attachment.
CLEAR lv_temp.
DESCRIBE TABLE li_objhex LINES lv_temp.
READ TABLE li_objcont INTO lwa_objcont INDEX lv_temp.
CLEAR lwa_objpack.
lwa_objpack-head_start = c_1.
lwa_objpack-head_num = c_0.
lwa_objpack-body_start = c_1.
lwa_objpack-body_num = lv_temp.
lwa_objpack-doc_type = c_raw.
APPEND lwa_objpack TO li_objpack.
CLEAR lwa_objpack.
CLEAR lwa_objpack-transf_bin.
lwa_objpack-transf_bin = c_x.
lwa_objpack-head_start = c_1.
lwa_objpack-head_num = c_1.
lwa_objpack-body_start = c_1.
lwa_objpack-body_num = lv_temp.
lwa_objpack-obj_name = c_invoice.
CONCATENATE c_invoice wa_rbkp-belnr
INTO lwa_objpack-obj_descr
SEPARATED BY space.
lwa_objpack-doc_size = lv_temp * 255.
APPEND lwa_objpack TO li_objpack.
CLEAR: lwa_objpack.
ENDIF. "IF sy-subrc <> 0.
ENDIF."IF sy-subrc <> 0.
*---Find the document type in which the image was stored in the archieve
*---server.
CASE lv_toa01-reserve.
WHEN c_fax.
doc_type = c_tif.
lwa_objpack-doc_type = c_fax.
WHEN c_pdf.
doc_type = c_pdf.
lwa_objpack-doc_type = c_pdf.
ENDCASE.KR Jaideep,
‎2009 Sep 08 2:55 PM
Hi,
Use the following code to create the PDF from Binary data.
LOOP AT li_binarchivobject INTO lwa_binarchivobject.
CONCATENATE lv_buffer lwa_binarchivobject-line
INTO lv_buffer IN BYTE MODE .
ENDLOOP.
*---Find the number of lines buffer string.
lv_last = XSTRLEN( lv_buffer ) MOD 255.
lv_lines = XSTRLEN( lv_buffer ).
lv_lines = lv_lines / 255.
DO lv_lines TIMES.
*---Check after adding 255 to the offset if length becomes more than
*---total length then don't add 255 instead add lv_last.
lv_temp = lv_offset + 255.
IF lv_temp GE lv_binlength.
lwa_objhex-line = lv_buffer+lv_offset(lv_last).
APPEND lwa_objhex TO li_objhex.
ELSE.
lwa_objhex-line = lv_buffer+lv_offset(255).
APPEND lwa_objhex TO li_objhex.
lv_offset = lv_offset + 255.
ENDIF.
ENDDO.
*---Populate Packing internal table from relevant information required
*---to send the attachment.
CLEAR lv_temp.
DESCRIBE TABLE li_objhex LINES lv_temp.
READ TABLE li_objcont INTO lwa_objcont INDEX lv_temp.
CLEAR lwa_objpack.
lwa_objpack-head_start = c_1.
lwa_objpack-head_num = c_0.
lwa_objpack-body_start = c_1.
lwa_objpack-body_num = lv_temp.
lwa_objpack-doc_type = c_raw.
APPEND lwa_objpack TO li_objpack.
CLEAR lwa_objpack.
CLEAR lwa_objpack-transf_bin.
lwa_objpack-transf_bin = c_x.
lwa_objpack-head_start = c_1.
lwa_objpack-head_num = c_1.
lwa_objpack-body_start = c_1.
lwa_objpack-body_num = lv_temp.
lwa_objpack-obj_name = c_invoice.
CONCATENATE c_invoice wa_rbkp-belnr
INTO lwa_objpack-obj_descr
SEPARATED BY space.
lwa_objpack-doc_size = lv_temp * 255.
APPEND lwa_objpack TO li_objpack.
CLEAR: lwa_objpack.
ENDIF. "IF sy-subrc <> 0.
ENDIF."IF sy-subrc <> 0.
*---Find the document type in which the image was stored in the archieve
*---server.
CASE lv_toa01-reserve.
WHEN c_fax.
doc_type = c_tif.
lwa_objpack-doc_type = c_fax.
WHEN c_pdf.
doc_type = c_pdf.
lwa_objpack-doc_type = c_pdf.
ENDCASE.KR Jaideep,
‎2009 Sep 08 2:58 PM
TRY.
lv_sub = lv_subject.
CALL METHOD cl_document_bcs=>create_from_text
EXPORTING
i_text = li_text
i_subject = lv_sub
i_importance = c_1
RECEIVING
result = lref_document_bcs.
CLEAR lv_sub.
CATCH cx_document_bcs.
ENDTRY.
TRY.
CALL METHOD cl_bcs=>create_persistent
RECEIVING
result = lref_bcs.
CATCH cx_send_req_bcs .
ENDTRY.
TRY.
lref_send_request = lref_bcs->send_request.
CATCH cx_bcs.
ENDTRY.
IF NOT li_objhex IS INITIAL.
CONCATENATE wa_rbkp-belnr wa_rbkp-gjahr INTO lv_att_name
SEPARATED BY space.
TRY.
CALL METHOD lref_document_bcs->add_attachment
EXPORTING
i_attachment_type = lv_type
i_attachment_subject = lv_att_name
i_att_content_hex = li_objhex.
CATCH cx_document_bcs INTO lref_bcs_exception.
error_handling 'lref_document_bcs->add_attachment'
lref_bcs_exception->error_type.
ENDTRY.
ENDIF."IF NOT li_objhex IS INITIAL.
lref_if_document = lref_document_bcs.
‎2009 Sep 08 2:58 PM
TRY.
CALL METHOD lref_send_request->setu_document
EXPORTING
i_document = lref_if_document.
CATCH cx_send_req_bcs INTO lref_bcs_exception.
error_handling 'lref_send_request->setu_document'
lref_bcs_exception->error_type.
ENDTRY.
TRY.
CALL METHOD lref_send_request->setu_message_subject
EXPORTING
ip_message_subject = lv_subject.
CATCH cx_send_req_bcs.
ENDTRY.
IF NOT lv_receiver IS INITIAL.
*---Set Receiver as direct internet mail address.
TRY.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = lv_receiver
RECEIVING
result = lv_cam_address.
CATCH cx_address_bcs INTO lref_bcs_exception.
error_handling 'cl_cam_address_bcs=>create_internet_address'
lref_bcs_exception->error_type.
ENDTRY.
lv_recipient = lv_cam_address.
*---Add the receipient
TRY.
CALL METHOD lref_send_request->add_recipient
EXPORTING
i_recipient = lv_recipient
i_express = c_x.
CATCH cx_send_req_bcs INTO lref_bcs_exception.
error_handling 'send_request->add_recipient'
lref_bcs_exception->error_type.
ENDTRY.
TRY.
CALL METHOD lref_send_request->release
EXPORTING
i_with_error_screen = c_x.
CATCH cx_send_req_bcs INTO lref_bcs_exception.
error_handling 'send_request->release'
lref_bcs_exception->error_type.
ENDTRY.
ENDIF."IF NOT p_test IS INITIAL.
‎2009 Sep 08 3:00 PM
DATA: lv_sub TYPE sood-objdes,
li_text TYPE bcsy_text,
lv_date TYPE char10,
lv_type TYPE soodk-objtp,
lv_reply TYPE adr6-smtp_addr,
lv_subject TYPE string,
lv_att_name TYPE sood-objdes,
lv_recipient TYPE REF TO if_recipient_bcs,
lv_cam_address TYPE REF TO cl_cam_address_bcs,
*---Local Work area declarations.
lwa_text TYPE soli,
*---Local Reference variable declarations.
lref_bcs TYPE REF TO cl_bcs,
lref_reply_to TYPE REF TO if_recipient_bcs,
lref_if_document TYPE REF TO if_document_bcs,
lref_document_bcs TYPE REF TO cl_document_bcs,
lref_send_request TYPE REF TO cl_send_request_bcs,
lref_bcs_exception TYPE REF TO cx_bcs.
DATA: lv_temp TYPE i,
lv_last TYPE i,
lv_toa01 TYPE toa01,
lv_lines TYPE i,
lv_offset TYPE i,
lv_buffer TYPE xstring,
lv_bus2081 TYPE toa01-sap_object VALUE 'BUS2081',
lv_binlength TYPE sapb-length,
lv_object_id TYPE toa01-object_id,
lv_archiv_id TYPE toa01-archiv_id,
lv_doc_type_pdf TYPE toaom-doc_type VALUE 'PDF'.KR Jaideep,
‎2009 Sep 23 8:13 AM