1. 上傳EXCEL文件
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 256
i_end_row = 65536
TABLES
intern = l_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
2 . 函數WS_UPLOAD
功能﹕將TXT文件轉換成SAP中的內表定義的數據表格文件
注意﹕1 函數將按參數 data_tab 的實際參數(假設為 table1) table1 定
義的各個字段的長度來依次將TXT文件間隔開﹐并依次將對應的值付給table1的
字段,table中的各個字段必須為C 型
2 TXT文件中﹐各個字段值之間不能有空格
3. 下臷文件
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = g_filesize
* CODEPAGE = ' '
filename = zfile
filetype = 'BIN'
TABLES
data_tab = i_pdf_tab.
===>txt
例子
parameters: p_file1 like rlgrap-filename default 'C:\ZCBDC001_A.TXT'.
perform download_data_to_file tables itab using p_file1.
Form download_data_to_file tables p_itab using p_file.
call function 'WS_DOWNLOAD'
exporting
filename = p_file
filetype = 'DAT'
tables
data_tab = p_itab
exceptions
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
gui_refuse_filetransfer = 8
others = 9.
endform. " DOWNLOAD_DATA_TO_FILE
4. EXCEL_OLE_STANDARD_DAT:Upload internal table to excel
'********************************************************************
5. 把ABAP數据轉換成PDF
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = t_spool_no "打印的對列號
no_dialog = ' '
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = pdf "打印的數據存放的數據表
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11.
6. 把smartforms轉換成pdf
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
* MAX_LINEWIDTH =
* ARCHIVE_INDEX =
IMPORTING
bin_filesize = g_filesize
TABLES
otf = job_output_info-otfdata
lines = i_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
7.獲得在屏幕上打印出來的結果
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
list_index = 0
TABLES
listasci = text
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3 .
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9333231/viewspace-277701/ ,如需转载,请注明出处,否则将追究法律责任。