2008 Aug 22 6:36 AM
Hi,
I am trying to read a tab delimited file and I see following in a temperary place holder.
0002#02#10032#1000280#10.00 #1#EA#08/19/2008#12/31/9999
Infact, tab has been replaced by # in the above string.
Now I need to take each field into an internal tabel.
I tried following and none worked.
split w_line at '09' into table IT_ZR00_DATA. " In this string 09 is equvalent of TAB
split w_line at '#' into table IT_ZR00_DATA.
What mistake am I doing in reading ?
How generally people read a tab delimited file from application server ?
2008 Aug 22 6:44 AM
Hi,
Its not required to handle for #
just read the dataset into the string and split the string into work area fields seoparated by TAb delimiter.
Eg:
READ DATASET <filename> INTO l_string.
SPLIT l_string
AT cl_abap_char_utilities=>horizontal_tab "Horizontal tab
INTO l_funcloc_clas-tplnr
w_funcloc_clas-class
w_funcloc_clas-klart
w_funcloc_clas-atnam
w_funcloc_clas-atwrt
w_funcloc_clas-atfor.
append w_funcloc_clas to l_funcloc_clas.
With Regards,
Dwarakanath.S
Hi,
I am trying to read a tab delimited file and I see following in a temperary place holder.
0002#02#10032#1000280#10.00 #1#EA#08/19/2008#12/31/9999
Infact, tab has been replaced by # in the above string.
Now I need to take each field into an internal tabel.
I tried following and none worked.
split w_line at '09' into table IT_ZR00_DATA. " In this string 09 is equvalent of TAB
split w_line at '#' into table IT_ZR00_DATA.
What mistake am I doing in reading ?
How generally people read a tab delimited file from application server ?
2008 Aug 22 6:44 AM
Hi,
Its not required to handle for #
just read the dataset into the string and split the string into work area fields seoparated by TAb delimiter.
Eg:
READ DATASET <filename> INTO l_string.
SPLIT l_string
AT cl_abap_char_utilities=>horizontal_tab "Horizontal tab
INTO l_funcloc_clas-tplnr
w_funcloc_clas-class
w_funcloc_clas-klart
w_funcloc_clas-atnam
w_funcloc_clas-atwrt
w_funcloc_clas-atfor.
append w_funcloc_clas to l_funcloc_clas.
With Regards,
Dwarakanath.S
2008 Aug 22 6:52 AM
No need to handle that #, as when u download it to internal table it goes to the next fields where # is there.
OPEN DATASET p_asfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET p_asfile INTO wa_emp.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND wa_emp TO it_emp.
ENDDO.
CLOSE DATASET p_asfile.
If u further want to download that internal table data to desktop.
In GUI_DOWNLOAD FM in file type use 'DBF'.
Regards
Bala Krishna
2008 Aug 22 6:55 AM
> I am trying to read a tab delimited file and I see following in a temperary place holder.
>
> 0002#02#10032#1000280#10.00 #1#EA#08/19/2008#12/31/9999
>
those # are nothing but Tabs, if you want to replace that you can use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB and replace them.
as suggested above you can split the records at this CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
If you try to replace '#' you have to use the equivalent CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in your code.
2008 Aug 22 7:44 AM
Thanks Dwarakanath and Vijay. The solution provided by you was perfect and resolved my issue.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |