‎2009 Mar 09 9:53 AM
Hi,
i am working on uploading .CSV data. After uploading the data we use the command SPLIT to split the data based on delimiter and put into corresponding fields.
here i want to make it work dynamically i.e. once i upload the data i ll write logic to split the data and put into respective fields(making it dynamic).
i am able to split the data and find out the structure of internal table but UNABLE TO ASSIGN data to corresponding fields.
here is my code :
to findout structure of internal table.
ref_descr ?= cl_abap_typedescr=>describe_by_data( it_itab ).
it_details[] = ref_descr->components[].
loop at it_details into wa_comp.
cnt = cnt + 1.
wa_fcat-col_pos = cnt.
wa_fcat-fieldname = wa_comp-name.
append wa_fcat to t_fcat.
endloop.Code to split the file based on delimiter.
*LOOP AT wtg_bomb INTO wsg_string.*
*find all occurrences of c_semicolon in wsg_string results result_tab.*
loop at result_tab into wa_reslt.*
if sy-tabix = 1.*
str1 = wsg_string+0(wa_reslt-offset).*
wa_prev_offset = wa_reslt-offset.*
wa_prev_offset = wa_prev_offset + 1.*
clear str1.*
else.*
count = wa_reslt-offset - wa_prev_offset.*
count = count.*
str2 = wsg_string+wa_prev_offset(count).*
wa_prev_offset = wa_reslt-offset.*
wa_prev_offset = wa_prev_offset + 1.*
endif.
endloop.*after this can someone tell me how to workout ot provide the logic u have if u have already worked on this requirement. thanks in advance
Edited by: Matt on Mar 9, 2009 1:51 PM - modified formatting
‎2009 Mar 09 10:09 AM
hi
can anyone give me some solution ...still watng.i am able to create dynamic internal table but not able to populate dynamically....
‎2009 Mar 09 12:55 PM
Have you looked at the possibilities of ASSIGN COMPONENT? Check the F1 help.
Use SPLIT AT ... INTO TABLE t_values to get the values.
Then something like:
LOOP AT t_values INTO l_value.
ASSIGN COMPONENT sy-tabix OF STRUCTURE <ls_dynamic_structure> INTO <l_field>.
<l_field> = l_value.
ENDLOOP.Where <ls_dynamic_structure> is a work area defined using RTTS, with the required number and type of fields, and <l_field> is a field symbol of type ANY.
matt
‎2009 Mar 11 10:14 AM
Hi
i tried it but didnt get result. also can u tell me what type should be the internal table t_value?
thanks
‎2009 Mar 12 11:50 AM
A table with a single column should be appropriate...
DATA t_values TYPE STANDARD TABLE OF string.
DATA lv_value TYPE string.
LOOP AT t_values INTO lv_value.
....
ENDLOOP.~Jose
‎2009 Mar 12 4:20 PM
>
>also can u tell me what type should be the internal table t_value?
>
> thanks
Read the F1 help on split.