Skip to Content
0
Former Member
Nov 16, 2012 at 07:17 PM

OPEN DATASET file not opening

2693 Views

Hi Experts,

I am trying to open a file on my pc.

I have not been able to find a solution in the SAP site or on line. The example code that I have been using is from the help menu:

DATA:
dsn(20) VALUE '/usr/test.dat',
rec(80).

It appears from the discussions that there is a "usr" folder on the server. I just want to open a file on my pc to test a bdc. If someone could help me I would be very grateful. The code that I am using is below and I am able to pass the string to the variable dsn but I am not able to open the document. I think that I am not writing the string path correctly. I am using Windows XP and SAP 4.6c.

START-OF-SELECTION.

DATA:

dsn(80) VALUE 'C:\Documents and Settings\TestFile.txt',

rec(80).

OPEN DATASET dsn FOR INPUT IN TEXT MODE.

IF sy-subrc = 0.

DO.

READ DATASET dsn INTO rec.

IF sy-subrc <> 0.

EXIT.

ELSE.

WRITE / rec.

ENDIF.

ENDDO.

ELSE.

WRITE: 'Could not open file'.

ENDIF.

CLOSE DATASET dsn.

Cheers,

Doug