2007 Oct 30 5:59 PM
Alright, I need to read in a csv file that contains several lines. The delimiter is ^. This file holds one line that has the header information for a sales order. The subsequent lines are individual line items (1-many). How can I read one line at a time and end when I reach the end of the file? I would be reading the line into a string and split it from there.
Regards,
Davis
2007 Oct 30 6:04 PM
Hello,
LOOP AT ITAB. " this contains your file.
at first.
* split and move records to header
continue.
endat.
split and move records to item
endloop.Regards,
Naimesh Patel
Alright, I need to read in a csv file that contains several lines. The delimiter is ^. This file holds one line that has the header information for a sales order. The subsequent lines are individual line items (1-many). How can I read one line at a time and end when I reach the end of the file? I would be reading the line into a string and split it from there.
Regards,
Davis
2007 Oct 30 6:04 PM
Hello,
LOOP AT ITAB. " this contains your file.
at first.
* split and move records to header
continue.
endat.
split and move records to item
endloop.Regards,
Naimesh Patel
2007 Oct 30 6:08 PM
I should add that this is a background job, or will be a background job. That means that I will be using datasets and can't use anything related to the GUI.
Davis
2007 Oct 30 6:11 PM
Hi,
In that case, you can read the lines of file in Text mode. Get the line into a string and then use SPLIT command to split the values at '^' into the table fields.
ashish
2007 Oct 30 6:14 PM
Do I just do something like this?
do.
read dataset filepath into filestring.
if sy-subrc <>0.
exit.
endif.
*split string*
enddo.Davis
2007 Oct 30 6:16 PM
Yes, but you have to use the OPEN DATASET command before trying to read it.
If you search the forum, you'll see many examples of exactly how to do this.
Rob
2007 Oct 30 6:18 PM
Hi,
Check this sample program which will give you an idea -
http://www.sapfans.com/sapfans/alex.htm
ashish
2007 Oct 30 6:06 PM
Hi,
Use function module GUI_UPLOAD, pass 'X' to parameter HAS_FIELD_SEPARATOR.
Check the documentation for more details.
ashish
2007 Oct 30 6:19 PM
Hi,
You can use these FM RKD_WORD_WRAP or SWA_STRING_SPLIT.
Regards,
Ferry Lianto
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |