on 03-31-2010 3:28 PM
Hi,
I have a table with 3 columns - name, age, gender.
I am trying to upload the details from .csv file into my table.
The problem is that all the 3 values appear in 1 column i.e name
e.g John,30, M appears in NAME column and AGE and GENDER colum are blank.
Snippet of code
After conversion of XSTRING to STRING, i have my data in v_string.
SPLIT v_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
LOOP AT i_data INTO v_string.
SPLIT v_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE v_values.
READ TABLE v_values INTO x_tab-name INDEX 1.
READ TABLE v_values INTO x_tab-age INDEX 2.
READ TABLE v_values INTO x_tab-gender INDEX 3.
APPEND x_tab TO i_tab.
ENDLOOP.
*"Import to webDynpro Table
lo_view_nnode = wd_context->get_child_node( 'DETAILS' ).
lo_view_nnode->bind_table( i_tab[] ).
The problem appears in the statement SPLIT v_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE v_values.
It does not separate values into 3 lines but only 1 line and when I read the table v_values at INDEX 1 i get all the values in first column!
Hi Sim.
should you not be trying to split the string at a comma for a csv file rather than a tab?
so the code should be:
SPLIT v_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.
LOOP AT i_data INTO v_string.
SPLIT v_string AT ',' INTO TABLE v_values.
READ TABLE v_values INTO x_tab-name INDEX 1.
READ TABLE v_values INTO x_tab-age INDEX 2.
READ TABLE v_values INTO x_tab-gender INDEX 3.
APPEND x_tab TO i_tab.
ENDLOOP.
*"Import to webDynpro Table
lo_view_nnode = wd_context->get_child_node( 'DETAILS' ).
lo_view_nnode->bind_table( i_tab[] ).
Hope this helps,
Cheers,
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.