Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for some clarification on Datasets

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

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

8 REPLIES 8

naimesh_patel
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Do I just do something like this?

do.
   read dataset filepath into filestring.
   if sy-subrc <>0.
      exit.
   endif.

*split string*

enddo.

Davis

0 Kudos

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

0 Kudos

Hi,

Check this sample program which will give you an idea -

http://www.sapfans.com/sapfans/alex.htm

ashish

Former Member
0 Kudos

Hi,

Use function module GUI_UPLOAD, pass 'X' to parameter HAS_FIELD_SEPARATOR.

Check the documentation for more details.

ashish

ferry_lianto
Active Contributor
0 Kudos

Hi,

You can use these FM RKD_WORD_WRAP or SWA_STRING_SPLIT.

Regards,

Ferry Lianto