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

Problem in Upload and Split

Former Member
0 Likes
867

Hello All,

I have one text file with 'TAB' seperated fields. When i am uploading this file into UNIX server(thru customize prog) fille uploaded successfully but it take field sepration '#' instead of 'TAB'.

now uploaded file looks like

AAA#BBB#CCC#DDD#

Now if i am split this file to '#' it is not heppening.

DATA: BEGIN OF T_TEMP OCCURS 16,

TEXT(300),

END OF T_TEMP.

DATA: LV_FILE(3000).

DATA: L_INT TYPE I,

L_COUNT TYPE I. "For index

DO.

READ DATASET INPUT INTO LV_FILE.

IF SY-SUBRC = 0.

SPLIT LV_FILE AT '#' INTO TABLE T_TEMP.

endif.

enddo.

Can any body help me out.

Rgds,

Paras

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
851

Split your string at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB which corresponds to the keyboard TAB key.

8 REPLIES 8
Read only

Former Member
0 Likes
851

Hi,

I am not finding OPEN Dataset statement, please check. Since you cannot read a dataset without opening it.

Also check that

READ DATASET INPUT INTO LV_FILE.

returns sy-subrc eq 0.

Thanks & Regards,

Navneeth K.

Read only

Former Member
0 Likes
851

Modify code as:

DATA: BEGIN OF T_TEMP OCCURS 16,

TEXT(300),

END OF T_TEMP.

DATA: LV_FILE(3000).

DATA: L_INT TYPE I,

L_COUNT TYPE I. "For index

open dataset INPUT for input in text mode.

if sy-subrc eq 0.

DO.

READ DATASET INPUT INTO LV_FILE.

IF SY-SUBRC = 0.

SPLIT LV_FILE AT '#' INTO TABLE T_TEMP.

endif.

enddo.

endif.

Read only

0 Likes
851

Hi Navneet,

Thanks for your promt reply.

I already open dataset.

problem in split the string on '#' . system is not reading '#' symbol.

Paras

Read only

Former Member
0 Likes
852

Split your string at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB which corresponds to the keyboard TAB key.

Read only

Former Member
0 Likes
851

Tab equivalent is '#' , you can replace that with the help of

utlities class.

use cl_abap_char_utilities=>horizontal_tab instead of '#'.

Read only

Former Member
0 Likes
851

Can you check the contents of lv_file after read statement is it just like format you gave : AAA#BBB#CCC#DDD#

I tried the sample code it works:

DATA:
  str TYPE string VALUE 'AAA#BBB#CCC#DDD#'.

DATA:
  BEGIN OF itab OCCURS 0,
    data(255),
  END OF itab.

SPLIT str AT '#' INTO TABLE itab.

Read only

0 Likes
851

The '#' is not normal one. simple replace or split will not work, tab(key board) will be displayed as '#' , though it appears as '#' it won't recognize when you use split or replace using normal '#'.

Read only

Former Member
0 Likes
851

Thank you Manoj and Vijay...

You are great!!!!!

Thanks once again.

Paras