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

OPEN DATA SET

Former Member
0 Likes
601

HI ALL

i am facing some problem with open data set

here is my program

open dataset '/tmp/MHI' for output in text mode encoding default .

if sy-subrc ne 0.

SKIP 2.

write:/ 'Download failed', sy-subrc.

else.

loop at itab1.

transfer itab1 to '/tmp/MHI'.

if sy-subrc ne 0.

write:/ sy-subrc.

endif.

endloop.

close dataset '/tmp/MHI'.

endif.

"here itab1 contains data like 'ACBD' ie char(4) .

'/tmp/MHI' is i found from tcode AL11. ie directory app server.

but after executing program the value of sy-subrc is comming to 8.

and when i remove

this part

if sy-subrc ne 0.

SKIP 2.

write:/ 'Download failed', sy-subrc.

else.

error analyis is as below.

Short text

File "/tmp/MHI" is not open.

Error analysis

An exception occurred that is explained in detail

The exception, which is assigned to class 'CX_SY_

caught and

therefore caused a runtime error.

The reason for the exception is:

When accessing the file "/tmp/MHI", the system re

not open. Therefore, the file cannot be accessed.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
561

Hi

Are you sure MHI is a file? Perhap it's a directory?

IF you can see the file in the AL11, run the trx AL11 and do a doubleclick on that file and check if the system can open the file.

If it can't, probably you can have some problem on the authorizations.

Max

4 REPLIES 4
Read only

Former Member
0 Likes
561

hi Amar,

check out my sample program ,it will surely work.

Hope its required to give the file name in your directory path.

DATA:BEGIN OF WA,

NAME(20) TYPE C,

END OF WA.

DATA: IT_TAB LIKE TABLE OF WA WITH HEADER LINE.

DATA FNAME TYPE STRING VALUE 'C:\SIVA\FILE.TXT'.

BREAK-POINT.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FNAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = '#'

TABLES

DATA_TAB = IT_TAB

.

IF SY-SUBRC <> 0.

ENDIF.

DATA F2 TYPE STRING VALUE 'd:\usr\sap\trans\HI.txt'.

BREAK-POINT.

OPEN DATASET F2 IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.

LOOP AT IT_TAB INTO WA.

TRANSFER WA TO F2.

ENDLOOP.

CLOSE DATASET F2.

Thanks

Siva

Read only

Former Member
0 Likes
562

Hi

Are you sure MHI is a file? Perhap it's a directory?

IF you can see the file in the AL11, run the trx AL11 and do a doubleclick on that file and check if the system can open the file.

If it can't, probably you can have some problem on the authorizations.

Max

Read only

0 Likes
561

thanks max bianchi

my problem has solved, the problem is that the have dose not have write access thats why it is showing error

thanks

Read only

Former Member
0 Likes
561

HI,

YOu are just givile the path not the file name..

just give /tmp/MHI/<filename.extension> isnstead of /tmp/MHI..

reward if useful;

regards,

nazeer