Skip to Content
author's profile photo Former Member
Former Member

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 13, 2015 at 08:46 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.