如何在字符串中加入回车换行,tab字符
1个回答
展开全部
字符串加回车换行TAB符号
所有字符在下面的类中:
cl_abap_char_utilities=>horizontal_tab — 09
cl_abap_char_utilities=>CR_LF ———- 0D0A
cl_abap_char_utilities=>VERTICAL_TAB — 0B
cl_abap_char_utilities=>NEWLINE —- 0A
cl_abap_char_utilities=>FORM_FEED —- 0C
cl_abap_char_utilities=>BACKSPACE — 08
如果是要单独取得回车或者换行(不是回车加换行),可以采用:
cl_abap_char_utilities=>CR_LF(1)
cl_abap_char_utilities=>CR_LF 1(1)
从EXCEl文件中传上的文件的回车符就是cl_abap_char_utilities=>CR_LF 1(1)
DATA: crlf(2) TYPE c.
crlf = cl_ABAP_char_utilities=>cr_lf. "换行符
在字符串中加入回车换行或TAB字符,在其他语言可以使用$13$10的ASCII码进行插入.而在abap里却出错,为了解决此问题,请使用sap的类CL_ABAP_CHAR_UTILITIES.
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
例:
DATA: crlf(2) TYPE c.
DATA: l_html(4096) TYPE C.
crlf = cl_ABAP_char_utilities=>cr_lf.
CONCATENATE l_html crlf '_FUNCTION'
'30'
'WWW_GET_REPORT' '>' INTO l_html.
----
调用方法产生文件路径对话框
DATA: p_file LIKE rlgrap-filename.
FIELD-SYMBOLS <fs> TYPE file_table.
FIELD-SYMBOLS <f>.
DATA: f_table TYPE filetable.
DATA: rc TYPE i.
DATA: user_action TYPE i.
DATA: l_index TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择要汇入的文件'
file_filter = 'Excel files (*.XLS)|*.XLS'
initial_directory = 'D:\'
CHANGING
file_table = f_table
rc = rc
user_action = user_action
EXCEPTIONS
cntl_error = 1
file_open_dialog_failed = 2
error_no_gui = 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <fs> INDEX 1.
IF sy-subrc = 0.
p_file = <fs>-filename.
ENDIF.
所有字符在下面的类中:
cl_abap_char_utilities=>horizontal_tab — 09
cl_abap_char_utilities=>CR_LF ———- 0D0A
cl_abap_char_utilities=>VERTICAL_TAB — 0B
cl_abap_char_utilities=>NEWLINE —- 0A
cl_abap_char_utilities=>FORM_FEED —- 0C
cl_abap_char_utilities=>BACKSPACE — 08
如果是要单独取得回车或者换行(不是回车加换行),可以采用:
cl_abap_char_utilities=>CR_LF(1)
cl_abap_char_utilities=>CR_LF 1(1)
从EXCEl文件中传上的文件的回车符就是cl_abap_char_utilities=>CR_LF 1(1)
DATA: crlf(2) TYPE c.
crlf = cl_ABAP_char_utilities=>cr_lf. "换行符
在字符串中加入回车换行或TAB字符,在其他语言可以使用$13$10的ASCII码进行插入.而在abap里却出错,为了解决此问题,请使用sap的类CL_ABAP_CHAR_UTILITIES.
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
例:
DATA: crlf(2) TYPE c.
DATA: l_html(4096) TYPE C.
crlf = cl_ABAP_char_utilities=>cr_lf.
CONCATENATE l_html crlf '_FUNCTION'
'30'
'WWW_GET_REPORT' '>' INTO l_html.
----
调用方法产生文件路径对话框
DATA: p_file LIKE rlgrap-filename.
FIELD-SYMBOLS <fs> TYPE file_table.
FIELD-SYMBOLS <f>.
DATA: f_table TYPE filetable.
DATA: rc TYPE i.
DATA: user_action TYPE i.
DATA: l_index TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = '请选择要汇入的文件'
file_filter = 'Excel files (*.XLS)|*.XLS'
initial_directory = 'D:\'
CHANGING
file_table = f_table
rc = rc
user_action = user_action
EXCEPTIONS
cntl_error = 1
file_open_dialog_failed = 2
error_no_gui = 3.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
CLEAR p_file.
READ TABLE f_table ASSIGNING <fs> INDEX 1.
IF sy-subrc = 0.
p_file = <fs>-filename.
ENDIF.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询