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

SPLIT by TAB

Former Member
0 Likes
6,587

Hey Masters,

I have a text file that I'm uploading into a local table and then checking it line by line.

In each line, I'm splitting it by coma (,), the problem is that at some point there are addresses in the line, which have comas...and there goes my splitting. This file is also splited by TAB. So I need to know how can I split by TAB.

Something like:


SPLIT line AT TAB INTO var1 var2 var3

Thank you in advance.

Jorge Ferreira

1 ACCEPTED SOLUTION
Read only

Former Member
2,420

Instead of using TYPE X value '09' it is better to use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

Greetings,

Gert.

4 REPLIES 4
Read only

Former Member
0 Likes
2,420

Hope this helps


CONSTANTS:
  c_tab TYPE x VALUE '09'.


    SPLIT wk_rec AT c_tab
      INTO  in_rec-recnum
            in_rec-leadid
            in_rec-ltype
            in_rec-ltype_txt
            in_rec-status
            in_rec-status_txt

*
*
*

Read only

Former Member
0 Likes
2,420

hi,

do this way ..


data : TAB type x value '09'.

SPLIT line AT TAB INTO var1 var2 var3. 

Regards,

santosh

Read only

Former Member
0 Likes
2,420

Hi,

ur requirement is not clear, ur file is tab separated or comma separated?

if it is comma separated then do like this, - ((here i m assuming that data in first column will never contain , )

as it is comma separated file if any of ur data contains , then " (double quote) will be added at start and end of that data.

First read file into an internal table which contains only one column.

Then split each row into an internal table at "

then loop through the internal table and replace (,) by space of data in each even number row.

now loop through the same table again and concatenate all the splits and insert into say final dummy table.

do this for all rows of first internal table (which contains the uploaded data)

now loop through the final dummy table, split at ,

hope this will help u.

reward if useful

Read only

Former Member
2,421

Instead of using TYPE X value '09' it is better to use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

Greetings,

Gert.