Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to make SPLIT command work dynamically using OOP's

Former Member
0 Likes
672

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

5 REPLIES 5
Read only

Former Member
0 Likes
630

hi

can anyone give me some solution ...still watng.i am able to create dynamic internal table but not able to populate dynamically....

Read only

matt
Active Contributor
0 Likes
630

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

Read only

0 Likes
630

Hi

i tried it but didnt get result. also can u tell me what type should be the internal table t_value?

thanks

Read only

0 Likes
630

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

Read only

matt
Active Contributor
0 Likes
630

>

>also can u tell me what type should be the internal table t_value?

>

> thanks

Read the F1 help on split.