2006 Aug 14 11:29 AM
Hi All,
After lots of hard work I am posting this query. It may be easy for you but I need the solution as soon as possible.
Problem: I have a txt file on application server. Which has got 3 fields. First 2 are character and third is currency field. (E.G. Currency field value may be - 125.26) This text file is tab delimited.
E.G.
0000012 12121 12.26
0001742 54844 125.15
Now if you see this file on App. Server on AL11 it looks like '#' character is there instead of tab space. I want to get all these 3 fields into internal table.
I am facing the problem with '#'. Its neither accessible nor I can perform any string operation on it. In internal table also record is coming like this ::
0000012#12121#12.26
Can anyone help me getting these fields seperately?
Thanks in advance,
Jignesh.
2006 Aug 14 11:31 AM
Hi jignesh,
1. For capturing / detecting this character
(its nothing but a horiontal tab,
shown as #)
2. use
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
(the above is nothing but TAB character)
regards,
amit m.
Hi jignesh,
1. For capturing / detecting this character
(its nothing but a horiontal tab,
shown as #)
2. use
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
(the above is nothing but TAB character)
regards,
amit m.
2006 Aug 14 11:31 AM
Hi jignesh,
1. For capturing / detecting this character
(its nothing but a horiontal tab,
shown as #)
2. use
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
(the above is nothing but TAB character)
regards,
amit m.
2006 Aug 14 11:35 AM
Hi Amit.. can you put a code snippet how to use this while parsing ??
2006 Aug 14 11:38 AM
Hi again,
1. we can use like this.
2. suppose your whole 1st line,
is in some long character variable myline,
(after uploading)
3. and itab is your final internal table,
where values should go,
4.
split myline at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
into table itab.
regards,
amit m.
2006 Aug 14 11:40 AM
Hi,
The '#' represents the Tab . becasue the file is tabdelimited file.
0000012#12121#12.26
you have to use <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b> (equivalent for '#' ) to replace with ' ' . use replace or split and then remove '#' in your file.
Regards
vijay
2006 Aug 14 11:44 AM
Thanks all... Problem solved.. I learned one new thing.... Thanks again !!! You all are appreciated with points
Jignesh
2006 Aug 14 11:53 AM
Hi Jignesh
Consider the below code.
Ignore l_cr part if you dont have problem with Carriage Return when you read your input file.
parameters: p_file like rlgrap-filename.
data: l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab.
data: l_cr(1) type c value cl_abap_char_utilities=>cr_lf.
data: l_text(100) type c.
data: begin of itab occurs 0,
text1(10) type c,
text2(10) type c,
end of itab.
open dataset p_file in text mode for input encoding default.
if sy-subrc ne 0.
*** error message
else.
do.
read dataset p_file into l_text.
if sy-subrc ne 0.
exit.
else.
replace l_cr in l_text with space.
clear: itab.
split l_text at l_tab into itab-text1 itab-text2.
append itab.
endif.
enddo.
endif.
Kind Regards
Eswar
Am slow to respond, maybe next time.
Message was edited by: Eswar Rao Boddeti
2006 Aug 14 11:31 AM
Hi Jignesh
The problem is with the code-page conversion. Try using ENCODING NON-UNICODE and see if it works.
Also as suggested by Amit, split the text read with method horizantal_tab of class *char_utilities to get to the work area
Kind Regards
Eswar
Message was edited by: Eswar Rao Boddeti
2006 Aug 14 11:32 AM
2006 Aug 14 11:36 AM
The hash is a tab character.
use the CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB can be used to identify the so called # and replace it
Regards,
ravi
2006 Aug 14 11:39 AM
open dataset file for input.
OPEN DATASET file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET file INTO line.
IF sy-subrc <> 0.
EXIT.
ENDIF.
split line at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into wa_line.
append wa_line to it_line.
clear it_line.
ENDDO.
wa_line should have three fields yo uhave mentioned and it line should be a table having the same structure
Regards,
ravi
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |