2005 Aug 22 7:44 PM
Hello ,
Í´m uploading a file with OPEN DATASET fron the app server. I read the contents into a string. I then want to split the contents of each string into my internal table/ work area. For some reason it packs everything into the first field (type string). When I test with other data in the string, everything is fine. The contents of the string is eg. '01#AED#EUR#1001#' . I´m worried that the '#' symbol is for tabulator or something and therefore the SPLIT command does not work correctly. But if its a string it should recognise # as a symbol?
Thanks for any ideas?
Kevin
2005 Aug 22 7:53 PM
Here is some code....
report zrich_0002 .
parameters: d1 type localfile default '/usr/sap/TST/SYS/Test.txt'.
data: begin of itab occurs 0,
field1(20) type c,
field2(20) type c,
field3(20) type c,
end of itab.
data: wa type string.
<b>CONSTANTS: con_tab TYPE x VALUE '09'.</b>
* if you have a newer version, then you can use this instead.
<b>*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.</b>
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
* Here you are splitting at the hex value of "tab" not at
* the # sign.
split wa at con_tab into itab-field1 itab-field2 itab-field3.
append itab.
enddo.
endif.
close dataset d1.
This worked good in my system.
Regards,
Rich Heilman
2005 Aug 22 7:53 PM
Here is some code....
report zrich_0002 .
parameters: d1 type localfile default '/usr/sap/TST/SYS/Test.txt'.
data: begin of itab occurs 0,
field1(20) type c,
field2(20) type c,
field3(20) type c,
end of itab.
data: wa type string.
<b>CONSTANTS: con_tab TYPE x VALUE '09'.</b>
* if you have a newer version, then you can use this instead.
<b>*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB.</b>
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
* Here you are splitting at the hex value of "tab" not at
* the # sign.
split wa at con_tab into itab-field1 itab-field2 itab-field3.
append itab.
enddo.
endif.
close dataset d1.
This worked good in my system.
Regards,
Rich Heilman
2005 Aug 22 8:08 PM
Hi Rich,
nice one! Its working fine now. I´m using SAP ERP and the 'type x value '09' wasn´t working for me.
The following value definition did the trick!!
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB
Thanks a lot!
Kevin
2005 Aug 22 8:09 PM
2005 Aug 22 8:09 PM
If Rich's answer solved your problem, please reward him with full points and close the post.
2005 Aug 22 8:04 PM
Looks like it is the tabulator. What you can do is declare a variable as follows:
data:c_tab type x value '09'.
After that you can use your split command as follows
SPLIT v_string at c_tab.
Regards,
Srinivas