上傳本地.CSV檔案到內表中
TYPE-POOLS: truxs.
DATA: filename TYPE string VALUE '',
path TYPE string VALUE '',
fullpath TYPE string VALUE ''.
DATA: l_rc TYPE i,
l_filetable TYPE filetable.
DATA w_ans .
DATA gt_line TYPE truxs_t_text_data.
DATA: gt_data LIKE STANDARD TABLE OF zobj_personeel WITH HEADER LINE.
PARAMETERS p_file TYPE string.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Open The txt File
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'please choose import file'
file_filter = 'Notpad(*.TXT)|*.TXT|Excel(*.XLS)|*.XLS|ALL(*.*)|*.*|'
multiselection = space
CHANGING
file_table = l_filetable
rc = l_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc = 0 AND l_rc = 1.
READ TABLE l_filetable INTO p_file INDEX 1.
ENDIF.
START-OF-SELECTION.
IF p_file IS INITIAL.
MESSAGE 'please select a file' TYPE 'I'.
SET SCREEN 1000.
LEAVE SCREEN.
ENDIF.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
TABLES
data_tab = gt_line
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_CSV_TO_SAP'
EXPORTING
i_field_seperator = ';'
i_tab_raw_data = gt_line
TABLES
i_tab_converted_data = gt_data
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
1) you use the function POPUP_TO_CONFIRM serveral times in the program, but did not test what button the user cklicked on. There is a return field (answer) from that function that contains a code for each button (1 = yes, 2 = no and a = cancel.) by testing this field you can decide if the action should be done.
2) when creating the screen 1100 in which you showed all fields under eachother. Herefor you created textelements for that screen. it is always better to refer to fields in the datadictionary. By doing so you don't have to translate all your textelements when someone logs on in another language. I changed all these references to the table fileds to which they correspond.
3) there was also a problem with the data saved to the table. e.g. for matnr ther is a standard convertion exit that you can use for converting the data to standard SAP data. A material is always stored with leading zeros. therefor you can define on the screenfield that userexit (MATN1).
4.also I added search helps where possible . you can do that also on the definition of the screen field.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11011430/viewspace-1017639/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 下載內表到本地.CSV檔案中
- git和tormoisegit上傳本地檔案到githubORMGithub
- 本地專案上傳到 CODING
- 將本地檔案傳輸到GitHubGithub
- 檔案包含漏洞(本地包含配合檔案上傳)
- 使用git將本地專案上傳到githubGithub
- 使用scp將linux伺服器中的檔案傳到windows本地主機上Linux伺服器Windows
- 如何將自己的本地專案上傳到github上?Github
- ABAP 報表中如何以二進位制方式上傳本地檔案試讀版
- Node.js 一行命令上傳本地檔案到伺服器Node.js伺服器
- 標記本地映象並上傳到映象庫中
- csv跨域傳輸再生成csv檔案處理跨域
- post 表單大檔案上傳
- 將csv檔案匯入到neo4j中
- 怎麼把本地資料庫檔案上傳到雲伺服器ecs資料庫伺服器
- 租用的外網Server(ubuntu)上傳檔案到Dropbox,再下載回本地ServerUbuntu
- Tp3如何實現本地視訊檔案上傳到七牛雲
- Laravel 中的檔案上傳Laravel
- 把本地專案上傳到github 不使用eclipseGithubEclipse
- 關於本地專案上傳到碼雲和GitGit
- 使用Git工具,實現上傳本地專案到GitHubGithub
- 如何用命令將本地專案上傳到gitGit
- php檔案上傳之多檔案上傳PHP
- java檔案上傳到伺服器Java伺服器
- PHP上傳檔案到七牛(Qiniu)PHP
- 使用Vue+go實現前後端檔案的上傳下載,csv檔案上傳下載可直接照搬VueGo後端
- 解決從linux本地檔案系統上傳檔案到HDFS時的許可權問題Linux
- 從ASM磁碟中複製檔案到本地檔案系統ASM
- laravel-admin 檔案分別上傳(oss,本地)Laravel
- 檔案上傳本地預覽js程式碼例項JS
- git上傳到遠端有部分檔案未上傳Git
- 儲存檔案到本地
- Java 中的 GraphQL 上傳檔案Java
- 【ubuntu】git安裝配置以及本地版本庫內容上傳到githubUbuntuGithub
- vue 靜態檔案上傳到七牛Vue
- 上傳執行sql檔案到linuxSQLLinux
- Java上傳檔案到ftp伺服器JavaFTP伺服器
- markdown檔案上傳到部落格園教程