2005 Feb 02 11:36 AM
Hi,
Someone knows how to use this FM SX_OBJECT_CONVERT_OTF_PDF
Tks
2005 Feb 02 11:59 AM
Hello,
call function 'SX_OBJECT_CONVERT_OTF_PDF'
exporting
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = '1234'
IMPORTING
LEN_OUT =
tables
content_in = objbin
content_out = objpdf
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2.
I hope this helps you.
Regards, Murugesh AS
2005 Feb 02 11:59 AM
Hello,
call function 'SX_OBJECT_CONVERT_OTF_PDF'
exporting
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
FUNCPARA =
len_in = '1234'
IMPORTING
LEN_OUT =
tables
content_in = objbin
content_out = objpdf
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2.
I hope this helps you.
Regards, Murugesh AS
2005 Feb 02 12:08 PM
Hi Murugesh,
Can explain me what I have to put in content_in and in content_out please because I want to convert a smartform to a pdf but I don't know exactly how.
Thks
2005 Feb 02 12:39 PM
Hello,
If you are creating a form by SAPScript, then
CALL FUNCTION 'CLOSE_FORM'
TABLES
otfdata = te_otf_table
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
OTHERS = 3.
'te_otf_table' will have OTFDATA and you need to pass this to content_in.
else if you are using a Smartform, the FM has a IMport parameter 'job_output_info-otfdata' which will have the OTFData. Now to convert this Form output which is in OTF to PDF we either use 'SX_OBJECT_CONVERT_OTF_PDF' or CONVERT_OTF_2_PDF.
sample code for CONVERT_OTF_2_PDF:
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = filesize
TABLES
otf = l_t_job_output-otfdata
doctab_archive = l_t_docs
lines = pdfdata_tab
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
I hope this helps you
Regards, Murugesh AS
2005 Feb 02 12:52 PM
Hi,
I tried the suggestion but in the moment I download to the pc and opening said: There was an error opening the document. A file read error was ocurred.
I am doing this, I don't know if it's right or not.
CALL FUNCTION '/1BCDWB/SF00000003'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
p_vbeln = d_vbeln
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = output_data
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE i208(00) WITH 'Error al imprimir la factura'.
ENDIF.
PERFORM pdf.
PERFORM email.
ENDFORM. "entry
**&----
*
**& Form PDF
**&----
*
text
**----
*
--> p1 text
<-- p2 text
**----
*
FORM pdf .
*--
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = L_PDF_LEN
TABLES
otf = OUTPUT_DATA-OTFDATA
doctab_archive = itab2
lines = LT_LINES
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\factura.pdf'
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'
IMPORTING
FILELENGTH = L_PDF_LEN
tables
data_tab = itab2
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.
2005 Feb 02 1:27 PM
Hello,
Please note the following:
1. Get the FM name of the SSF:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'SSF'"Name of the SSF
IMPORTING
fm_name = fmname "Variable
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.
2. Get the Output of the Form....
DATA :l_t_job_output TYPE ssfcrescl OCCURS 0 WITH HEADER LINE.
DATA :l_t_out LIKE ssfcompop OCCURS 0 WITH HEADER LINE.
DATA :l_t_control LIKE ssfctrlop OCCURS 0 WITH HEADER LINE.
l_t_out-tddest = 'LOCL'.
APPEND l_t_out.
l_t_control-no_dialog = 'X'.
l_t_control-getotf = 'X'.
l_t_control-no_close = space.
APPEND l_t_control.
CALL FUNCTION fmname
EXPORTING
control_parameters = l_t_control
output_options = l_t_out
IMPORTING
job_output_info = l_t_job_output
TABLES
*
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
3. Convert the OTF to PDF format...
DATA :l_t_pdfdata_tab LIKE tline OCCURS 200.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = l_filesize_deck "Variable
TABLES
otf = l_t_job_output-otfdata
doctab_archive = l_t_docs " Variable
lines = l_t_pdfdata_tab
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
4. Download the PDF data...
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = l_filesize "Variable
filename = 'C:\temp.pdf'
filetype = 'BIN"
mode = ' '
IMPORTING
filelength = l_filesize "Variable
TABLES
data_tab = l_t_pdfdata_tab
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
5. View the Doc...
CALL FUNCTION 'WS_EXECUTE'
EXPORTING
document = 'X'
cd = 'C:\'
program = 'C:\temp.pdf'
EXCEPTIONS
frontend_error = 1
no_batch = 2
prog_not_found = 3
illegal_option = 4
gui_refuse_execute = 5
OTHERS = 6.
Note: The Exceptions in any FM are to be uncommented to catch the errer. Else SAP may trigger a dump.
I hope this helps you.
Regards, Murugesh AS
2005 Feb 03 8:45 AM
Hi Murugesh,
Thanks a lot!!! It's working now 🐵
Another question, how can sent the pdf by email?
🐵
2005 Feb 03 1:10 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |