Read text file from PC one line at a time
Moderators: Snowy, thx4allthefish, YuriT, Gothmog
Read text file from PC one line at a time
Hi,
Need something similar to a READ DATASET but for the PC...
Everything I've come across seems to read the whole file into an internal table at one go.
Thanks.
Need something similar to a READ DATASET but for the PC...
Everything I've come across seems to read the whole file into an internal table at one go.
Thanks.
Re: Read text file from PC one line at a time
Why do you need read the file only one line at a time?
MattG.
Search SAPfans

Re: Read text file from PC one line at a time
'cause i'm a sadist.. 

Re: Read text file from PC one line at a time
You're trying to code this, so you must be a masochist 

MattG.
Search SAPfans

Re: Read text file from PC one line at a time
So I'm getting the distinct impression that it's not possible then... 

Re: Read text file from PC one line at a time
Read the file in one go, using the standard upload, then write it to the appserver. Then read it from the appserver a line at a time. Alternatively, use ftp, or other file transfer means, to get it to the appserver.
If you would explain WHY you want to read it a line at a time, you might get more help.
m@t
If you would explain WHY you want to read it a line at a time, you might get more help.
m@t
TULY
The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.

The downside of being better than everyone else is that people tend to assume you're pretentious.
Re: Read text file from PC one line at a time
Maybe the functional consultant wants it done that way.
...and functional consultant always knows best...
...and functional consultant always knows best...

Re: Read text file from PC one line at a time
Well.
Just defer the reading of the uploaded text till later.
Stick it all into a table and then Loop around (That's reading it one line at a time), or even use READ TABLE ..... INDEX and just keep incrementing the index. If said functional consultant asks if you are reading it one line at a time just point to the code and say with conviction 'YES'.
Just defer the reading of the uploaded text till later.
Stick it all into a table and then Loop around (That's reading it one line at a time), or even use READ TABLE ..... INDEX and just keep incrementing the index. If said functional consultant asks if you are reading it one line at a time just point to the code and say with conviction 'YES'.
Regards
Rich

Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com
Rich

Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com
Re: Read text file from PC one line at a time
Here's how you turn sadistic - this will really hurt the person that asked for itMattG wrote:You're trying to code this, so you must be a masochist

Code: Select all
DO.
* Call file open dialog
* Call file upload (to internal table)
* Delete all lines in the internal table except the one matching the index of the current DO loop
* If all lines deleted --> Exit
* Read internal table index 1 - move line to other internal table
ENDDO.
* Now process your other internal table

Ironman Triathlete and SAP Dev/Config Expert
(which is harder?)
(which is harder?)
Re: Read text file from PC one line at a time
No. The functional consultant is always a loony, who's best not let out on their own. Anyway, what self-respecting functional conslutant even knows what a line in a file is?phillipm wrote:Maybe the functional consultant wants it done that way.
...and functional consultant always knows best...
TULY
The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.

The downside of being better than everyone else is that people tend to assume you're pretentious.
Re: Read text file from PC one line at a time
A true functional consultant will notice it and say: "you're still reading the complete file in 1 go!"
Best to ask for seperate files with only 1 line in it.
Best to ask for seperate files with only 1 line in it.

Re: Read text file from PC one line at a time
You could write some kind of OLE program to split the file into seperate lines, I suppose.
m@t
m@t
TULY
The quality of answers is roughly proportional to the quality of the question.
The downside of being better than everyone else is that people tend to assume you're pretentious.

The downside of being better than everyone else is that people tend to assume you're pretentious.
-
- Posts: 135
- Joined: Thu May 15, 2008 4:25 pm
- Location: Butterball LLC., Goldsboro, NC, USA
- Contact:
Re: Read text file from PC one line at a time
If the file were an excel, you could read row 1 and then delete row 1. Or is that to obvious? I didn't see that you said what format the file was in.
Neal Wilhite (WilhiteRN1)
