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

Fun module to read file in Application server ?

Former Member
0 Likes
2,868

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.

4 REPLIES 4
Read only

Former Member
0 Likes
1,326

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

Read only

Former Member
0 Likes
1,326

call function 'RZL_READ_DIR_LOCAL'

exporting

name = lv_dst

tables

file_tbl = it_filedir.

Read only

Former Member
0 Likes
1,326

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.

Read only

Former Member
0 Likes
1,326

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.