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

Reading file from application sever.

Former Member
0 Likes
679

The sap standard program rfchke00 generates a file wich is stored on application server.. I am able to open it after sumitting the pragram in my report.. Now ,how can i read it, character by character, so taht i can change the layout of the data present in it and map it to an internal table.

5 REPLIES 5
Read only

Former Member
0 Likes
640

use

OPEN DATASET <filename> for input in text mode.

READ DATASET into <var>

CLOSE DATASET.

Read only

Former Member
0 Likes
640

open dataset <filename> for input in text mode....

do.

read dataset <filename.>

move to string or internal table

enddo.

reward points if helpful

Read only

Former Member
0 Likes
640

if u know the location of the file on app server then u can read the file in a program through open data set

read data set

close data set

For a full code do revert back.

If found useful reward with points.

Read only

Former Member
0 Likes
640

Hello,

Better upload the file from Apll. server to internal table and make the modification.

Sample code:





*   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.


Refer this link

http://www.sapdevelopment.co.uk/file/file_updown.htm

Vasanth

Message was edited by:

Vasanth M

Read only

Former Member
0 Likes
640

Here is full code.

data:begin of itab occurs 0,

data(500),

end of itab.

open dataset <file name> for input in text mode.

if sy-subrc = 0.

do .

read dataset <filename> into itab-data.

if sy-subrc = 0.

append itab.

else.

exit.

endif.

enddo.

close dataset <filename>.

endif.

Regards,

Ravi