Application Development 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 DATASET

Former Member
0 Kudos

Hi

uploaded into SAP. When tried to open and read the flat file using OPEN DATASET and READ DATASET commands,

the Sy-subrc value returned is 8 and the error message 'the specified file not found' is displayed. We checked the path and

the file is in the correct location. What is missing?

4 REPLIES 4

Former Member
0 Kudos

File names and paths are case sensitive in a lot of server operating systems - check that yours is correct in this aspect.

Also see if you can find / display the dataset in AL11 - could be permissions for the file are not correct.

Andrew

Former Member
0 Kudos

Hi Rahul

Before data can be processed , a file need to be opened.

open dataset <file name> for < input / output / appending >

in < text mode / binary mode>

Processing a file involves reading the file or writing on to the file transfer.

read dataset <file name> into < field>

Each read will get one record from the dataset . In binary mode it reads the length of field and in text mode it reads each line.

If the program attempts to read a record that do not exist ,then it will show an error.

So it is the error in mode( text mode or binary mode)

Manas

If useful donot forget to reward me

Former Member
0 Kudos

Hi

OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*--- Display error messages if any.

IF sy-subrc NE 0.

MESSAGE e001(zsd_mes).

EXIT.

ELSE.

*---Data is downloaded to the application server file path

LOOP AT it_tab2 INTO wa_tab2.

TRANSFER wa_tab2 TO p_file.

ENDLOOP.

ENDIF.

*--Close the Application server file (Mandatory).

CLOSE DATASET p_file.

varma_narayana
Active Contributor
0 Kudos

Hi..Sharma..

you can print the Exact message why the File is not opened using this code:

PARAMETERS : P_DSN(40) DEFAULT 'TEMP.TXT'.

DATA : V_MSG TYPE STRING.

OPEN DATASET P_DSN FOR INPUT

IN TEXT MODE ENCODING DEFAULT

MESSAGE V_MSG. "Returns the Actual message why the file not opened

if sy-subrc ne 0.

Message v_msg type 'E'.

Else.

<<<<< do the Processing here>>>>

Endif.

<b>Reward if Helpful</b>