2008 Feb 06 9:57 AM
Hi there,
Is there any function module to read file in Application server.
Pls provide logic.
Thanks in advance.
Naseer.
Hi there,
Is there any function module to read file in Application server.
Pls provide logic.
Thanks in advance.
Naseer.
2008 Feb 06 10:00 AM
Instead of FM you can just type in a simple code.
data: w_dataset1(27) value '/var/textfile.txt',
w_dataset2(27) value '/var/outfile.txt'.
data:begin of itab1 occurs 0, "Text file format
matnr(18), "MATERIAL NUMBER
bwkrs(4), "PLANT
end of itab1.
*Uploading of text file from Application server.
open dataset w_dataset1 for input in text mode.
do.
if sy-subrc <> 0.
exit.
endif.
read dataset w_dataset1 into itab1.
append itab1.
clear itab1.
enddo.
close dataset w_dataset1.
Jayant Sahu
2008 Feb 06 10:02 AM
call function 'RZL_READ_DIR_LOCAL'
exporting
name = lv_dst
tables
file_tbl = it_filedir.
2008 Feb 06 10:02 AM
Reading it with the help of Function module.
Do keep these points in mind.
1. I don't think there is any directy way,
to rad .XLS file
into internal table
on the application server.
2. The reason is :
a) .XLS is a Microsoft technology
b) the application server OS may not be microsoft os,
it may be UNIX, AIX etc.
c) Converter tehnology is not there,
and possibly SAP does not support it.
3. FILE_READ_AND_CONVERT_SAP_DATA
This FM,
can read files from applicatin server
in TXT and other formats.
4. BUT, in case of .XLS file,
it EXPECTS the file to be on the presentation server only.
(bcos Microsoft OS be there on presentation server)
5. IN SAP,
people don't work directly with .xls file
while uploading data.
We need to work with TEXT Files
which are TAB DELIMITED or CSV files etc.
Jayant Sahu.
2008 Feb 06 10:05 AM
Hi
Retrieve Data file from Application server(Upload from Unix)
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
OPEN DATASET i_file FOR INPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE e999(za) WITH 'Error opening file' i_file.
ENDIF.
DO.
Reads each line of file individually
READ DATASET i_file INTO wa_datatab.
Perform processing here
.....
ENDDO.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |