Application Development and Automation 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: 
Read only

OPEN DATASET

Former Member
0 Likes
646

Hi All,

I had a requirement, where i have to read a file from Application server and will store it in a Internal table for further process.

Hope, most of us usually do in the same way. But i came across an option, where the File from application server requires to be read, do the validations and post the Document FB01 for the records found in the file. Then close the Dataset once all the records are read.

Kindly advice, which is the best way Using OPEN DATASET(Consider 100 records for examples).

a) Read all datas from Application server into an Internal table & then process the records as required.

b) Read record by record from the Application server & process the records as required.

Awaiting for your valubale reply.

Regards,

Anbalagan.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
617

Hello Anbalagan

I do not see much of a difference between the two approaches whether you open the file, process record by record and then close or open the file, collect all records, close file and then process all records.

You could chose any of these approaches, since the number of records in your input file are not very high.

Ofcourse if the number of records in your file are very high and your input file can not be kept open for such a long time (since it might be needed by other programs), in that case, I would advice the 2nd approach.

BR

[Anand|http://www.saptraininghouse.com/2011/append-structure/]

4 REPLIES 4
Read only

soumya_jose3
Active Contributor
0 Likes
617

Hi,

You should first read the file content in the application server into an internal table and then process those records by looping through the internal table.

OPEN DATASET filename FOR INPUT IN TEXT MODE. "Opens the file in app server in input mode.

DO.

READ DATASET filename INTO tab. "Read the contents line by line into int.table tab

CASE sy-subrc.

WHEN '00'.

APPEND tab.

ADD 1 TO ws_recs_read.

WHEN '04'.

EXIT.

ENDCASE.

ENDDO.

The contents in internal table can be procesed now.

CLOSE DATASET filename.

Regards,

Soumya.

Read only

Former Member
0 Likes
617

Hi,

u can read the file content from the application server and then store it to internal table.Then download the Data into Presentation server.


 open dataset w_filename for input in text mode
                                        encoding default.
**    Reading one by one record
  while sy-subrc eq 0.
    read dataset w_filename into w_readline.
    if sy-subrc ne 0.
      exit.
    endif.                             " IF sy-subrc NE 0.
    wa = w_readline.
    insert wa into table t_itab.
  endwhile.                            " WHILE sy-subrc eq 0

*" Closing the w_filename
  close dataset w_filename.

Now you can read the data from t_itab by using loop or you can download into presentation server by using function module GUI_DOWNLOAD.

Regards,

Suvajit.

Read only

Former Member
0 Likes
617
Read only

Former Member
0 Likes
618

Hello Anbalagan

I do not see much of a difference between the two approaches whether you open the file, process record by record and then close or open the file, collect all records, close file and then process all records.

You could chose any of these approaches, since the number of records in your input file are not very high.

Ofcourse if the number of records in your file are very high and your input file can not be kept open for such a long time (since it might be needed by other programs), in that case, I would advice the 2nd approach.

BR

[Anand|http://www.saptraininghouse.com/2011/append-structure/]