‎2008 Oct 30 10:08 AM
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
‎2008 Oct 30 10:14 AM
Split your string at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB which corresponds to the keyboard TAB key.
‎2008 Oct 30 10:10 AM
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.
‎2008 Oct 30 10:12 AM
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.
‎2008 Oct 30 10:17 AM
Hi Navneet,
Thanks for your promt reply.
I already open dataset.
problem in split the string on '#' . system is not reading '#' symbol.
Paras
‎2008 Oct 30 10:14 AM
Split your string at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB which corresponds to the keyboard TAB key.
‎2008 Oct 30 10:15 AM
Tab equivalent is '#' , you can replace that with the help of
utlities class.
use cl_abap_char_utilities=>horizontal_tab instead of '#'.
‎2008 Oct 30 10:22 AM
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.
‎2008 Oct 30 10:24 AM
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 '#'.
‎2008 Oct 30 10:22 AM
Thank you Manoj and Vijay...
You are great!!!!!
Thanks once again.
Paras