1、各語種的Codepage查詢
Language Keys---語種存放表(T002)
我們可能常用到的:
Codepage的查詢:
REPORT zrab_zyb_test MESSAGE-ID sabapdocu.*CONSTANTS: tcode(8) TYPE c VALUE 'YPPM1021'.DATA: l_codepage TYPE cpcodepage, l_flag TYPE c.CALL FUNCTION 'NLS_GET_FRONTEND_CP' EXPORTING langu = 'M' "注意,此處使用SPRAS類型,1 Char fetype = 'MS' IMPORTING frontend_codepage = l_codepage EXCEPTIONS illegal_syst_codepage = 1 no_frontend_cp_found = 2 internal_or_db_error = 3 OTHERS = 4.*IF sy-subrc <> 0.* CASE sy-subrc.* WHEN 1.* MESSAGE i055.* WHEN 2.* **** ENDCASE.* LEAVE TO TRANSACTION tcode.*ENDIF.WRITE: / l_codepage.
2、Upload/Download
upload文件存在與否的判斷
form check_file_exist . data: l_result type abap_bool, l_file type string. l_file = p_upath. call method cl_gui_frontend_services=>file_exist exporting file = l_file receiving result = l_result exceptions cntl_error = 1 error_no_gui = 2 wrong_parameter = 3 not_supported_by_gui = 4 others = 5. if sy-subrc <> 0.* CASE sy-subrc.* WHEN 1.* MESSAGE i039.* WHEN 2.* MESSAGE i040.* WHen OTHERS.* MESSAGE i041.* ENDCASE.* LEAVE TO TRANSACTION tcode. endif. if l_result <> 'X'. message e888 with 'Invalid file'. endif.endform. " check_file_exist
download文件格式及保存路徑存在與否的判斷
Language Keys---語種存放表(T002)
我們可能常用到的:
Laiso | Sptxt | codepage |
ZH | Chinese | 8404 |
ZF | Chinese trad | 8300 |
EN | English | 1160 |
- REPORT zrab_zyb_test MESSAGE-ID sabapdocu.
- *CONSTANTS: tcode(8) TYPE c VALUE 'YPPM1021'.
- DATA: l_codepage TYPE cpcodepage,
- l_flag TYPE c.
- CALL FUNCTION 'NLS_GET_FRONTEND_CP'
- EXPORTING
- langu = 'M' "注意,此處使用SPRAS類型,1 Char
- fetype = 'MS'
- IMPORTING
- frontend_codepage = l_codepage
- EXCEPTIONS
- illegal_syst_codepage = 1
- no_frontend_cp_found = 2
- internal_or_db_error = 3
- OTHERS = 4.
- *IF sy-subrc <> 0.
- * CASE sy-subrc.
- * WHEN 1.
- * MESSAGE i055.
- * WHEN 2.
- * ***
- * ENDCASE.
- * LEAVE TO TRANSACTION tcode.
- *ENDIF.
- WRITE: / l_codepage.
REPORT zrab_zyb_test MESSAGE-ID sabapdocu.*CONSTANTS: tcode(8) TYPE c VALUE 'YPPM1021'.DATA: l_codepage TYPE cpcodepage, l_flag TYPE c.CALL FUNCTION 'NLS_GET_FRONTEND_CP' EXPORTING langu = 'M' "注意,此處使用SPRAS類型,1 Char fetype = 'MS' IMPORTING frontend_codepage = l_codepage EXCEPTIONS illegal_syst_codepage = 1 no_frontend_cp_found = 2 internal_or_db_error = 3 OTHERS = 4.*IF sy-subrc <> 0.* CASE sy-subrc.* WHEN 1.* MESSAGE i055.* WHEN 2.* **** ENDCASE.* LEAVE TO TRANSACTION tcode.*ENDIF.WRITE: / l_codepage.
2、Upload/Download
upload文件存在與否的判斷
- form check_file_exist .
- data: l_result type abap_bool,
- l_file type string.
- l_file = p_upath.
- call method cl_gui_frontend_services=>file_exist
- exporting
- file = l_file
- receiving
- result = l_result
- exceptions
- cntl_error = 1
- error_no_gui = 2
- wrong_parameter = 3
- not_supported_by_gui = 4
- others = 5.
if sy-subrc <> 0.- * CASE sy-subrc.
- * WHEN 1.
- * MESSAGE i039.
- * WHEN 2.
- * MESSAGE i040.
- * WHen OTHERS.
- * MESSAGE i041.
- * ENDCASE.
- * LEAVE TO TRANSACTION tcode.
- endif.
if l_result <> 'X'.- message e888 with 'Invalid file'.
- endif.
- endform. " check_file_exist
form check_file_exist . data: l_result type abap_bool, l_file type string. l_file = p_upath. call method cl_gui_frontend_services=>file_exist exporting file = l_file receiving result = l_result exceptions cntl_error = 1 error_no_gui = 2 wrong_parameter = 3 not_supported_by_gui = 4 others = 5. if sy-subrc <> 0.* CASE sy-subrc.* WHEN 1.* MESSAGE i039.* WHEN 2.* MESSAGE i040.* WHen OTHERS.* MESSAGE i041.* ENDCASE.* LEAVE TO TRANSACTION tcode. endif. if l_result <> 'X'. message e888 with 'Invalid file'. endif.endform. " check_file_exist
download文件格式及保存路徑存在與否的判斷
- form check_file_path .
- data: l_result type abap_bool,
- l_directory type string,
- l_filename type string,
- l_index type i.
- data: begin of lt_tab occurs 0,
- cont(100) type c,
- end of lt_tab.
if not p_spath cs '.txt'.- message e888 with 'Invalid file format.'.
- elseif not p_spath cs ':\'.
- message e888 with 'Invalid driver.'.
- endif.
- *** 通過split分割,concatenate組合,實例存儲路徑、文件名的分離
- split p_spath at '\' into table lt_tab.
- describe table lt_tab lines l_index.
- read table lt_tab index l_index.
- l_filename = lt_tab-cont.
- delete lt_tab index l_index.
- loop at lt_tab.
- concatenate l_directory lt_tab-cont '\' into l_directory.
- clear lt_tab.
- endloop.
- call method cl_gui_frontend_services=>directory_exist
- exporting
- directory = l_directory
- receiving
- result = l_result
- exceptions
- cntl_error = 1
- error_no_gui = 2
- wrong_parameter = 3
- not_supported_by_gui = 4
- others = 5.
- if sy-subrc <> 0.
- * CASE sy-subrc.
- * WHEN 1.
- * MESSAGE i039.
- * WHEN 2.
- * MESSAGE i040.
- * WHen OTHERS.
- * MESSAGE i041.
- * ENDCASE.
- * LEAVE TO TRANSACTION tcode.
- endif.
- if l_result <> 'X'.
- message e888 with 'Invalid save path.'.
- endif.
- endform. " check_file_path
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21122155/viewspace-578423/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/21122155/viewspace-578423/