Application Development 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: 

Using Split command for a tab delimited text file

Former Member
0 Kudos

I upload a tab delimited text file and am trying to split the record to the fields in my internal structure and the program is failing. When I looked at the entries from the file in debugging they are seperated by '#' sign and that's how I am performing the split command.

Can you suggest any tips here in spliting a tab delimited text file and assigning the contents to fields in a structure.

8 REPLIES 8

LucianoBentiveg
Active Contributor
0 Kudos

Why you are splitting the file? You can use:

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = filestring

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = auxitab

Are you reading it from App Server? in that case look:

Former Member
0 Kudos

Hi,

For tab delimited, u need not use split command..

Just use the GUI_UPLOAD and get the contents in internal table..

Mind u the internal table fields should coresponds to the columns in the file..

If u are worried abt '#', dont worry.

Thats how tab gets represented in ABAP debugger ...

Its actually a TAB!!

Regards,

Tanveer

Hey Peluka,

I appreciate ur intelligence to grab the place of first reply..

I tried it too but u were a bit fast..

0 Kudos

Hi,

I am using the GUI_UPLOAD now and made sure the file structure/lenghts correspond to my internal table and yet these '#' signs are coming in the fields.

This is how I created the tab delimited file. Created an excel file with column sizes matching to my internal table. Populated the excel file with data and saved it as "Text(Tab delimeted)" file type.

Any more suggestions......

0 Kudos

Amrutha,

the '#'s are not really hashes but represent an unprintable character, probably the 'tab'....as Vinay suggested change your split to:

split l_string at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

into l_f1 l_f2. " etc

Former Member
0 Kudos

Hi Amrutha,

If your structure only contains only one field of character type then SPILT your record with CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB and move respective fields to structure.Generally tab will be displayed as # in debugging.(or)

If the defined record contains fields of structure then use function module 'GUI_UPLOAD'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = LV_FILENAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = IT_DATA

EXCEPTIONS

............

Its advisable to maintain record as structure of fields with respective data types and call function module 'GUI_UPLOAD'.

Thanks,

Vinay

Former Member
0 Kudos

Hi Amrutha,

Do the same directly with text file without entering into excel file and see results.Even though problem persists just paste code to know more about issue.<b>(or)</b>

If you want to upload excel data directly into internal table then use Function module 'ALSM_EXCEL_TO_INTERNAL_TABLE'. This uploads data into excel cell by cell. To convert cell data into internal table use Function module 'GET_COMPONENT_LIST'.

This may solve your problem.

Thanks,

Vinay

Former Member
0 Kudos

Define a variable as type x

e.g. l_delimiter type x value '09' (Tab)

Your input file should have the following structure

f1...

Tab1 type x value '09',

f2

Tab2 type x value '09',

f3

Tab1 type x value '09',

& so on..

While reading in the file, use the command as follows

split input_string at l_delimiter into f1 f2 f3.

This will get your values into the correct fields without the # mark...

Former Member
0 Kudos

This worked fine for me:


REPORT ztest.

DATA: BEGIN OF itab OCCURS 0,
        f1(10),
        f2(10),
        f3(10),
        f4(10),
      END OF itab.

CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename            = 'c:temptab.txt'
          filetype            = 'ASC'
          has_field_separator = 'X'
     TABLES
          data_tab            = itab.

Rob