hi,
First set control table's parameters for calling smartform
st_cntrl-getotf = 'X'.
st_cntrl-no_dialog = 'X'.
st_cntrl-preview = ''.
CALL FUNCTION fm_name "'/1BCDWB/SF00000221'
EXPORTING
* ARCHIVE_INDEX = ARCHIVE_INDEX
* ARCHIVE_INDEX_TAB = ARCHIVE_INDEX_TAB
* ARCHIVE_PARAMETERS = ARCHIVE_PARAMETERS
control_parameters = st_cntrl
.
.
.
.
.
IMPORTING
* DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO
job_output_info = st_prnout_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
.
otfdata[] = st_prnout_info-otfdata.
after getting smartform-otfdata table
DATA: v_len_in LIKE sood-objlen,
v_len_out LIKE sood-objlen,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
filename TYPE string.
DATA: l_length TYPE i,"Password length
l_password TYPE c LENGTH 30,
l_key TYPE i VALUE 26101957,
l_ftp_handle TYPE i,"FTP handle
l_cmd TYPE c LENGTH 200,"FTP command
l_error TYPE c,"Error flag
p_ftp_handle TYPE i,
p_cmnd TYPE c,
p_boblen TYPE i.
TYPES: BEGIN OF ty_result,
line(150) TYPE c,
END OF ty_result.
* Table for FTP command results
DATA: it_result TYPE STANDARD TABLE OF ty_result,
wa_result TYPE ty_result.
TYPES: BEGIN OF blob,
line(80) TYPE x,
END OF blob.
DATA : bindata TYPE TABLE OF blob WITH HEADER LINE.
DATA: l_user(30) TYPE c VALUE ' ', "user name of ftp server * to be fill
l_pwd(30) TYPE c VALUE ' ', "password of ftp server * to be fill
l_host(64) TYPE c VALUE ' ', "ip address of FTP server
l_dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'."Background RFC destination*
DATA: wrk_file TYPE char200.
DATA: w_hdl TYPE i,
c_key TYPE i VALUE 26101957, *may change in your case
l_slen TYPE i.
CONCATENATE '/' filename '.pdf' INTO wrk_file.*file name to be fill
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
IMPORTING
bin_filesize = v_len_in
bin_file = bin_file
TABLES
otf = otfdata
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
p_boblen = v_len_in.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = bin_file
* APPEND_TO_TABLE = ' '
* IMPORTING
* OUTPUT_LENGTH =
TABLES
binary_tab = bindata
.
SET EXTENDED CHECK OFF.
l_slen = STRLEN( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
* To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = l_user
password = l_pwd
* ACCOUNT =
host = l_host
rfc_destination = l_dest
* GATEWAY_USER =
* GATEWAY_PASSWORD =
* GATEWAY_HOST =
IMPORTING
handle = w_hdl
EXCEPTIONS
not_connected = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*FTP_R3_TO_SERVER:used to transfer the internal table data as a file to other system in the character mode.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = w_hdl
fname = wrk_file "file path of destination system
blob_length = p_boblen
* CHARACTER_MODE =
TABLES
blob = bindata "otf_data
* TEXT =
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*FTP_DISCONNECT: This is used to disconnect the connection between SAP and other system.
* To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_hdl.
*RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = l_dest
* TASKNAME =
EXCEPTIONS
destination_not_open = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
.
Please revert back if any issue.