08-24-2005 12:05 PM
Hi All,
In connection with my yesterday's post of how to read a tab delimited file from
application server, I have this question.
How do we save a file as a tab delimited file in the application server because
yesterday's suggestions don't seem to work because even though I applied the logic
suggested it doesn't work out so I feel there is a problem in the files being saved in
application server. I am attaching yesterday's discussion. Please suggest.
Regards,
Karthik
Posts: 6
Registered: 8/22/05
Solved it on my own!
Reading file from Application Server
Posted: Aug 23, 2005 12:41 PM Reply E-mail this post
Hi All,
I have an old program which is throwing up an issue.
I am succesfully uploading a tab-delimited(DAT) text file from a local server using the
'UPLOAD' Function Module. But when I try to use the same file saved in the application
server and upload it using 'OPEN DATASET P_FILE FOR INPUT IN TEXT MODE' statement and
next 'READ DATASET P_FILE INTO INT_TABLE', it is not considering the tab-delimiters and
reading the adjacent fields into a single field using # as the separator
For example in the text file I have 3 fields
Field1 Field2 Field3
AAAAA BBBBB CCCCC
After the READ DATASET statement the work area is being populated as <wa>-field1 =
AAAAA#BB
<wa>-field2 = BBB#CCC
<wa>-field3 = CC
The field length's of the 3 fields are 8, 7 & 7 respectively.
Could you suggest me a solution such that the fields are populated as below
<wa>-field1 = AAAAA
<wa>-field2 = BBBBB
<wa>-field3 = CCCCC
Thanks,
Karthik
Durairaj Athavan Raja
Posts: 1,957
Registered: 2/14/04
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:46 PM Reply E-mail this post
may be you have to split it manually
split <text> at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into filed1 field2 field3 etc.
Regards
Raja
Patrick Yee
Posts: 124
Registered: 4/20/05
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:47 PM Reply E-mail this post
Hi Karthik,
Try something like this:
data: g_data(1000) type c,
g_delim TYPE c value cl_abap_char_utilities=>horizontal_tab. "Tab Delim
open dataset....
read dataset into g_data.
split g_data at g_delim into ....
append ....
Let me know how this goes.
Cheers,
Pat.
Svetlin Rusev
Posts: 212
Registered: 3/22/05
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:47 PM Reply E-mail this post
Hi,
Open the dataset in IN BINARY MODE ( not in text mode ) and use SPLIT stmt at tab.
Svetlin
Karthik Boyapalli
Posts: 6
Registered: 8/22/05
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:51 PM Reply E-mail this post
Durai,
Thanks for the answer but this OO Concept CL_ABAP_CHAR_UTILITIES is not available in
4.6C.
Regards,
Karthik
Patrick Yee
Posts: 124
Registered: 4/20/05
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:52 PM Reply E-mail this post
Karthik,
Then use:
data: g_delim(1) type x value '09'.
Cheers,
Pat.
Durairaj Athavan Raja
Posts: 1,957
Registered: 2/14/04
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 12:54 PM Reply E-mail this post
data : tab type x .
move: '09' to tab .
now use tab in place of CL_ABAP_CHAR_UTILITIES=>horizontal_tab
Regards
Raja
Karthik Boyapalli
Posts: 6
Registered: 8/22/05
Re: Reading file from Application Server
Posted: Aug 23, 2005 2:14 PM Reply E-mail this post
Hi,
I will try this, but could you please explain what is the significance of '09'. I have
not understood that.
Thanks,
Karthik
Venkatesan G
Posts: 80
Registered: 7/22/04
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 2:16 PM Reply E-mail this post
'09' is the Hexadecimal value for tab.
regds
gv
Svetlin Rusev
Posts: 212
Registered: 3/22/05
(Unassign)
Solved Problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Reading file from Application Server
Posted: Aug 23, 2005 2:19 PM Reply E-mail this post
Hi,
data: hor_tab type x value '09'.
is the hex value of horizontal tab. When you work in binary mode you can read this
values and split your fields at it.
Svetlin
P.S. In case you find some answers useful, please assign reward poits.
Replies: 9 Pages: 1 Back to Topic List
Topics: [ Previous | Next ]
Forum Home | Help | Search
08-24-2005 12:10 PM
Hi,
Did you try to read it in binary mode ?
OPEN DATASET P_FILE FOR INPUT IN BINARY MODE
Svetlin
08-24-2005 12:37 PM
Hi,
try this , it should work.
data p_FILE LIKE draw-filep.
DATA: BEGIN OF itab OCCURS 0,
record(255),
END OF itab1.
p_FILE = '/tmp/TEMP.TXT'
OPEN DATASET pt_infil FOR INPUT IN TEXT MODE.
IF sy-subrc = 0.
DO.
READ DATASET p_FILE INTO itab.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND itab.
ENDDO.
ENDIF.
CLOSE DATASET p_FILE.
Cheers,
Sasi.
08-24-2005 12:44 PM