cancel
Showing results for 
Search instead for 
Did you mean: 

Dataset error

Former Member
0 Kudos

Hi all,

<b>OPEN DATASET p_fname FOR OUTPUT IN TEXT MODE .</b>

the contents of p_fname is :

/QR1/interfaces/msds/out/msds_out.txt

Can anyone tell me when does the bove staement returns sy-subrcd value 8.Should the file exist on the applicaton server ? I am trying to write some data into the file msds_out.txt on the application server but the fle is not there.

Regards,

Varun.

Message was edited by: varun sonu

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If it is not there, it will create it. If you are getting a sy-subrc = 8, the problem is probably with the path. Make sure that you are using a valid path to the application server.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos



report zrich_0001.

* ABC here is of course the system id.
parameters: d1 type localfile default '/usr/sap/ABC/sys/Data1.txt'.

data: it001 type table of t001 with header line.

start-of-selection.

  select * into table it001 from t001.

  open dataset d1 for output in text mode.
  loop at it001.
    transfer it001 to d1.
  endloop.
  close dataset d1.

Regards,

RIch Heilman

Former Member
0 Kudos

Hi Rich Hielman,

I am sure the path is correct.

/QR1/interfaces/msds/out this is the path.

FORM check_file_access.

OPEN DATASET p_fname FOR OUTPUT IN TEXT MODE .

IF NOT syst-subrc IS INITIAL .

MESSAGE e398(00) WITH text-m01 .

ENDIF .

ENDFORM.

Regards,

Varun.

Message was edited by: varun sonu

Former Member
0 Kudos

Varun,

Make sure that your app server can "see" this pathing (filesystem).

You will get this error if the app server does not have authority to read/write to the filesystem. A Basis/UNIX person at your site could assist with that.

Former Member
0 Kudos

I don't see anything wrong with this code. What is the definition of p_fname? In debugging check if the value of p_fname is converting to uppercase. Also, make sure that you have 'write' permissions to this directory. I think permissions is the issue here.

Answers (3)

Answers (3)

Former Member
0 Kudos

SY-SUBRC = 0:

The file was opened.

SY-SUBRC = 8:

The file could not be opened.

Example

DATA:

dsn(20) TYPE C VALUE '/usr/test.dat',

rec(80) TYPE C.

OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

EXIT.

ENDIF.

READ DATASET dsn INTO rec.

WHILE sy-subrc <> 0.

WRITE / rec. READ DATASET dsn INTO rec.

ENDWHILE.

CLOSE DATASET dsn.

Thanks

Vikranth Khimavath

sreemsft
Contributor
0 Kudos

Hi Varun,

Write like this:

OPEN DATASET P_Fname IN TEXT MODE.

Do not use FOR OUTPUT. Check if it works.

Thanks,

Sreekanth G

former_member181966
Active Contributor
0 Kudos

You can execute tr.AL11 and make sure about the path ..

Thanks

Saquib