Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

any alternative for this codding.

hello Tech Experts,

I'm developing a simple application in wd for uploading text file into ztable. I've found some sources to implement, I had a doubt in the following code



CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
  EXPORTING
  in_xstring = l_xstring
  IMPORTING
  out_string = l_string.

  SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

* Bind With table Element.

  LOOP AT i_data INTO l_string.

  SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.

 

READ TABLE fields INTO lv_field INDEX 1.
  fs_table-name = lv_field.

  READ TABLE fields INTO lv_field INDEX 2.
  fs_table-age = lv_field.

  APPEND fs_table TO t_table1.

  ENDLOOP.

  lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
  lo_nd_sflight->bind_table( t_table1 ).

this code works fine, But inside the loop we are reading the value field by field using index in this case it has just 2 records, what if they are n number of records. Do I have to use those read statements for 'n' times.

please help me if there is any alternative solution for this.

thank you,

Regards,

Nagendra

Tags:
Former Member
Former Member replied

Hi,

Alternative can be this for N-Fields.

SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

LOOP AT i_data INTO l_string.

SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO

                                   <workarea>-field1

                                   <workarea>-field2

                                   <workarea>-field3

                                   <workarea>-field4

                                   <workarea>-field5

                                   <workarea>-field6

                                             :

                                             :

append <workarea> to <itab>.

clear <workarea>.                        

ENDLOOP.

Note : <itab> is an internal table where your required fields are declared.

Hope this helps you.

Thanks

KH

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question