2018 Jul 10 12:28 PM
Need suggestions.
I have a file in my desk top.It has some columns and rows like internal table.
What is the best way to load the file into sap, I.e into my internal table.Once selected the file from the desk top and execute the program. Data has to come to Internal table.
2018 Jul 10 1:57 PM
Once you upload the html file, you have to parse the returned string looking for tags related to table to split data and remove other tags such as display attributes.
* Simple case
table between <table> and </table>
records between <tr> </tr>
header texts between <th> and </th>
cell values between <td> and </td>
* But could be
<table style="width:100%">
<th rowspan="2">Telephone:</th>
* Exercise: generate a table with word and export it to html and look with notepad++
Are you good with string related statements and REGEX?
2018 Jul 11 4:41 AM
Thank you very much , but initially i am struggling to load the file to desktop to my internal table.
2018 Jul 11 5:25 AM
2018 Jul 11 6:50 AM
Then, read links provided by Horst Keller for gui upload method and string manipulation.
2018 Jul 11 6:58 AM
Thanks for your help.I am using below code, first capturing the Data into my internal table. But only Html part i am getting, Content i am not getting.
TYPE-POOLS: truxs.
DATA: i_text_data TYPE truxs_t_text_data,
v_filename_string TYPE string.
DATA: BEGIN OF itab OCCURS 0,
name(30),
phone(15),
fax(500).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename.
START-OF-SELECTION.
v_filename_string = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename_string
filetype = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
" dat_mode = 'I'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_text_data
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.
2018 Jul 11 7:34 AM
Try to clear the 'has field separator' and 'read by line' parameters. (How was this html generated, asking cause some CR/LF characters were found?) then build the work area string from internal table whose rows should now been completely filled with the file data.
Are you not confident with you OO abilities, you didn't use CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD (At least you didn't use obsolete WS_UPLOAD)
2018 Jul 11 7:37 AM
Don't use GUI_UPLOAD, use the appropriate method CL_GUI_FRONTEND_SERVICES. This will not resolve your problem, but it makes your program slightly better.
2018 Jul 11 7:48 AM
But only fist row only it is fetching.
this feature is only supported for internal tables that have exactly one data field which must be of the type character or string.
2018 Jul 11 7:50 AM
2018 Jul 11 8:10 AM
Ok multiple lines some how i got it.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\Users\user\Desktop\final.html'
* FILETYPE = 'ASC
* has_field_separator = ',' <-- Comment this
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_datatab
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.
IF sy-subrc EQ 0.
ENDIF.
2018 Jul 13 12:02 PM
Thank you very much. Working perfectly. Fetch the data into string. Using Upload method. and used REGEX For removing data between < and > and then done some extra work.
2018 Jul 10 2:37 PM
Upload the file into a string.
Manipulate it in such a way that it becomes valid XML.
Write a simple transformation to deserialize it into an internal table.
https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abenabap_st.htm