Today, I read the O & M program of Ziguang and the ws_upload function. I think I have read a class cl_gui_frontend_services, which also has some static methods to upload files. Today I have studied the differences between them as well as the class cl_gui_frontend_services. Summary:
1. cl_gui_frontend_services class
This class provides many operations on operating system files, such as copying and listing file names. These methods are similar to those written in VBA in Java. Therefore, if you want to perform file operations in the future, you can use the static methods provided by this class. By the way, test_frontend_services is an example program in ides. You can check it in it, but only a few methods are used.
2. ws_upload and gui_upload
The difference between the two is that I use phenomena to show their differences from a problem I encountered today. It is too painful to look at the underlying code. I wrote a small test program to read a TXT text and then output the list. TXT text is in Chinese. I used ws_upload and gui_upload to implement them separately. I found that they could not be implemented in any way, but they could only be implemented in English. I don't think this is possible! After Unicode was installed, it was impossible to read Chinese characters. Later, I logged on to the system program in Chinese with a reminder from my colleagues! However, I think it is still wrong. It should be able to read Chinese characters in the English system. After all, both GUI and server have Unicode. In the parameter list, I found the code page parameter, so I added code page = '20140901 '. Haha, I finally found that I can upload Chinese text in the English login status. However, I still cannot upload Chinese Text Using ws_upload, and gui_upload can.
After reading the relevant information, ws_upload is a funtion to be replaced by gui_upload. Therefore, you can use gui_upload to write programs in the future.
3. Call gui_upload in two ways
Although gui_upload is a static method of the cl_gui_frontend_services class, it can also be called using the function method! SAP estimates that some static methods are encapsulated by one layer, so you can call the gui_upload method by calling the function. I tested gui_download and get_windows_directory again, but only gui_download can be called using functions. It seems that not all static methods can be called using functions. The following code provides a simple code for calling gui_upload:
Data: Filename type string value 'd: toolsreadme.txt '.
Types: Begin of itab,
FL1 (0, 300) type C,
End of itab.
Data: data_tab type standard table of itab,
Wa_tab like line of data_tab.
Call method cl_gui_frontend_services => gui_upload
Exporting
Filename = filename
Filetype = 'asc'
CodePage = '20140901'
Changing
Data_tab = data_tab
Exceptions
File_open_error = 1
File_read_error = 2
No_batch = 3
Gui_refuse_filetransfer = 4
No_authority = 6
Unknown_error = 7
Bad_data_format = 8
Unknown_dp_error = 12
Access_denied = 13
Others = 17.
Loop at data_tab into wa_tab.
Write:/wa_tab-fl1.
Endloop.
It has been tested that reading Chinese documents is correct, but filetype cannot be set to bin.
4. Share the Applet
This was found in the process of searching for data on SDN, and I think it is a very enlightening program. The complete function is to open a dialog box, select multiple files, and then print out these file names. The procedure is as follows:
Select-options: so_file for file_table no intervals.
At selection-screen on value-request for so_file-low.
Call method cl_gui_frontend_services => file_open_dialog
Exporting
* Window_title =
* Default_extension =
* Default_filename =
* File_filter =
Initial_directory = 'e: study'
Multiselection = 'X'
Changing
File_table = lt_file_names []
Rc = lv_subrc
* User_action =
Exceptions
File_open_dialog_failed = 1
Cntl_error = 2
Error_no_gui = 3
Others = 4.
If sy-subrc <> 0.
* Message ID SY-MSGID type SY-MSGTY number SY-MSGNO
* With SY-MSGV1 SY-MSGV2 SY-MSGV3.
Endif.
So_file-sign = 'I '.
So_file-option = 'eq '.
Loop at lt_file_names into lwa_file_name.
So_file-low = lwa_file_name.
Append so_file.
Endloop.
Start-of-selection.
Loop at so_file.
Write:/so_file-low.
Endloop.