Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Excel file on Applicaiton server

sachin_yadav3
Active Participant
0 Kudos
64

Hi,

I am uploading excel file on appliction server using the tcode CG3Z.

But when i go and see the file from AL11, the file is not readable. Its contains lots of

# charachter.

At the same time when i try to read the file from applicaiton server using Read data set,

its again coming in unreable format.

i am not sure how i can read the data which i have upload.

Kindly help.

Regard

Sachin

3 REPLIES 3

Former Member
0 Kudos
29

The cell splitter in excel will be converted to # (Horizontal tab) in the application server. Hence you are seeing the #.

You can decode this and get the proper data in the internal table with the below logic.

data: l_i_file type standard table of string,            "Table to store the input file data
      i_wa_file type string,
      l_i_file_data type standard table of string.
      l_i_data type standard table of <type>, "<type> is the final structure to hold the file data
      l_wa_date type <type>.

    loop at l_i_file into i_wa_file.     "With "#"
        clear: l_i_file_data[], l_wa_data.

** If the file has data 1#2#3, then l_i_file_data will have 1 in row 1, 2 in row 2 etc (Transpose)
        split i_wa_file at cl_abap_char_utilities=>horizontal_tab into table l_i_file_data.

        loop at l_i_file_data into i_wa_file_data.
          lv_index = sy-tabix.
          assign component lv_index of structure l_wa_data to <fs>.
          <fs> = i_wa_file_data.
        endloop.

        append l_wa_data to l_i_data.   "Append the file data to internal table
    endloop.

0 Kudos
29

Hi,

Supposed in my file i have data like

Fname  Age

Ram     20

Then on the applicaiton server it is not coming as

Fname#Age

Ram#20

But it is coming with lots of # charcter...which is really unreadable.

0 Kudos
29

Yes, since the file is tab-delimited you are seeing the #. After doing READ DATASET, you add the below logic in your code,

    loop at l_i_file into i_wa_file.     "With "#"
        clear: l_i_file_data[], l_wa_data.

** If the file has data 1#2#3, then l_i_file_data will have 1 in row 1, 2 in row 2 etc (Transpose)
        split i_wa_file at cl_abap_char_utilities=>horizontal_tab into table l_i_file_data.

        loop at l_i_file_data into i_wa_file_data.
          lv_index = sy-tabix.
          assign component lv_index of structure l_wa_data to <fs>.
          <fs> = i_wa_file_data.
        endloop.

        append l_wa_data to l_i_data.   "Append the file data to internal table
    endloop.

Where, l_i_file contains the data read from file using READ DATASET.

Message was edited by: Manigandan Ramaratnam Looks like your file has header. You will need to have the logic to skip the header so that the header will not get into your final internal table (it will have only data). So, after loop at, you add a check. If sy-tabix = 1.     Continue. endif.