本文主要是介绍ABAP--一个读取EXCEL单元格的内容超过256个字符的代码样例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我们在sap上限初期经常会将EXCEL数据倒入到SAP,sap也为此封装了许多的函数,但是这些函数都有单元文本长度限制。具体介绍如下:
1、 'TEXT_CONVERT_XLS_TO_SAP'单元格文本不能超过256个字符
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = lt_raw
i_filename = p_file
TABLES
i_tab_converted_data = it_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
2、'ALSM_EXCEL_TO_INTERNAL_TABLE'单元格文本不能超过50个字符
data: gt_upload type alsmex_tabline occurs 0 with header line.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '9'
i_end_row = '50000'
tables
intern = gt_upload.
3、自编程序倒入EXCEL,单元格文本长度可以自定义,代码如下(实现的功能和'ALSM_EXCEL_TO_INTERNAL_TABLE类似):
REPORT RSDEMO01 NO STANDARD PAGE HEADING.
* this report demonstrates how to send some ABAP data to an
* EXCEL sheet using OLE automation.
TYPE-POOLS: ole2.
**TYPE UPLOAD TABLE
TYPES: BEGIN OF ZLSMEX_TABLINE,
row TYPE KCD_EX_ROW_N,
COL TYPE KCD_EX_COL_N,
VALUE(500),
END OF ZLSMEX_TABLINE.
DATA gt_upload type TABLE OF ZLSMEX_TABLINE WITH HEADER LINE.
* value of excel-cell
TYPES: ty_d_itabvalue TYPE ZLSMEX_TABLINE-value,
* internal table containing the excel data
ty_t_itab TYPE ZLSMEX_TABLINE OCCURS 0,
* line type of sender table
BEGIN OF ty_s_senderline,
line(4096) TYPE c,
END OF ty_s_senderline,
* sender table
ty_t_sender TYPE ty_s_senderline OCCURS 0.
CONSTANTS: gc_esc VALUE '"'.
* handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
workbooks TYPE OLE2_OBJECT, " list of workbooks
workbook TYPE OLE2_OBJECT, " workbook
worksheet TYPE ole2_object,
H_CELL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
DATA H TYPE I.
*----------------------------
这篇关于ABAP--一个读取EXCEL单元格的内容超过256个字符的代码样例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!