cancel
Showing results for 
Search instead for 
Did you mean: 

Upload .csv file in ABAP webdynpro

former_member215781
Active Participant
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

ChrisPaine
Active Contributor
0 Kudos

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

Answers (0)