‎2011 Feb 03 8:22 AM
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.
‎2011 Feb 03 9:11 AM
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/]
‎2011 Feb 03 8:40 AM
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.
‎2011 Feb 03 8:52 AM
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.
‎2011 Feb 03 8:54 AM
Hi,
Go through the Below link.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d42358411d1829f0000e829fbfe/content.htm
With Regards,
Sumodh.P
‎2011 Feb 03 9:11 AM
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/]