04-23-2014 4:12 AM
Hi,
I have a requirement in script i have to convert that that otf file to pdf format,when i use function modules its corrupting that pdf file,So i want convert otf to pdf using class method any one can help me for that.If any sample coding for class method.
Thanks.
04-23-2014 5:35 AM
Hi Pradeep,
Refer below mentioned thread. I hope it will be helpful for you.
https://scn.sap.com/thread/824152
Regards,
Sudeesh Soni
04-23-2014 6:06 AM
Hi Sudeesh,
I have also used same process i used convert_otf and i converted data otf to pdf but problem is there in pdf file some data comming like
#### 2# L#B# 1.28 1.28
### INDULIN AQS-1M (RAILCAR)
##### ### #### ##### ##
############# ######## ##
This type of can you suggest for this issue.
Thanks.
04-23-2014 6:11 AM
04-23-2014 6:45 AM
04-23-2014 6:50 AM
04-23-2014 6:59 AM
ok
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* max_linewidth = 255
IMPORTING
bin_filesize = lv_bin_filesize
* bin_file = pdf_xstring
TABLES
otf = lt_otf
lines = lt_pdf_table
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_bin_filesize
filename = c_name
filetype = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
* SHOW_TRANSFER_STATUS = ABAP_TRUE
* VIRUS_SCAN_PROFILE = '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH =
TABLES
data_tab = lt_pdf_table
* FIELDNAMES =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
TRY.
GET PARAMETER ID 'RECEIPTENT' FIELD lvs_recipient1.
send_request = cl_bcs=>create_persistent( ).
* lt_attach_bin = cl_document_bcs=>xstring_to_solix( ip_xstring = lt_solix ).
APPEND 'Test message' TO lt_text.
l_sub_50 = lc_test1.
document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = lt_text
i_subject = l_sub_50 ).
document->add_attachment( i_attachment_type = 'PDF'
i_attachment_subject = 'script.pdf'
i_att_content_hex = lt_attach_bin ).
l_sub_line = lc_test1.
TRY.
* Build subject line for email.
CALL METHOD send_request->set_message_subject
EXPORTING
ip_subject = l_sub_line.
CATCH cx_send_req_bcs INTO loref_obj_error.
PERFORM sub_catch_error1 USING loref_obj_error.
ENDTRY.
send_request->set_document( document ).
* sender = cl_cam_address_bcs=>create_internet_address( 'jonh@gmail.com' ).
recipient1 = lvs_recipient1-objkey.
recipient = cl_cam_address_bcs=>create_internet_address( 'pradeep.padhy2@cognizant.com' ).
* send_request->set_sender( sender ).
send_request->add_recipient( i_recipient = recipient
i_express = 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
MESSAGE 'eee' TYPE 'S'.
EXIT.
ENDTRY.
04-23-2014 7:14 AM
Hi Pradeep,
Try below mentioned FM inplace of FM-CONVERT_OTF.
Converting to PDF Format
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = c_otf
format_dst = c_pdf
CHANGING
transfer_bin = w_transfer_bin
content_txt = i_content_txt
content_bin = i_content_bin
objhead = i_objhead
len = v_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
v_size = v_len_in.
Downloading the PDF File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = c_name
filetype = c_bin
TABLES
data_tab = i_content_bin.
Regards,
Sudeesh
04-23-2014 7:40 AM
Yes i tried also using this function module but i am getting same type of data output.
#### 2# L#B# 1.28 1.28
### INDULIN AQS-1M (RAILCAR)
##### ### #### ##### ##
############# ######## ##
Thanks.
04-23-2014 10:26 AM
Hi Pradeep,
We need to convert PDF output of width 132 char to 255 char using FM-SX_TABLE_LINE_WIDTH_CHANGE and further, it should be converted to SOLIX tab for mailing it in PDF Format.
Refer below sample code for you reference. Try it.
DATA: BEGIN OF i_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF i_pdf_output,
i_binary_content_pdf_temp TYPE soli_tab,
i_binary_content_pdf TYPE solix_tab.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = i_pdf_output "<= Returned from FM 'CONVERT_OTF'
content_out = i_binary_content_pdf_temp
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s000(0k) WITH 'Conversion Failed'.
EXIT.
ENDIF.
CALL METHOD cl_bcs_convert=>soli_to_solix
EXPORTING
it_soli = i_binary_content_pdf_temp
receiving
et_solix = i_binary_content_pdf.
Regards,
Sudeesh Soni
04-23-2014 12:55 PM
yes, I have used this also while opening that file i am getting the
error 'There was an error opening this document.The root object is missing or invalid."
Thanks.
04-23-2014 3:29 PM
Hi,
I have a requirement add one field to existing costum table after all existing fields,So any one can suggest me which is the better way for adding fields in ztable through append or direct.
Thanks.
04-23-2014 4:57 PM
Hi Pradeep,
You can directly add new field in custom table and adjust the database.
If you have created the table maintenance generator then delete the old one and generate the new table maintenance generator.
Regards,
Sudeesh Soni