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: 

OPEN DATASET Error

Former Member
0 Kudos

Hi gurus,

Pls help me to solve this problem.

f_filename = '/usr/sap/DBI/INVD.txt'.

OPEN DATASET f_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT

MESSAGE mess.

Above statement sometime giving me an error saying 'No such a file or directory'.

How to handle this situation. I needs always to create or overwrite the text file.

Pls help

Best Regards

Thanura

8 REPLIES 8

Former Member
0 Kudos

Hi,

Make sure you have the given the correct filename with the exact case..As the filename is case sensitive

OR

check if the filename is there..in AL11

OR

check if you have authorization to read the file

Thanks

Naren

Former Member
0 Kudos

Hi,

Try this code,


OPEN DATASET f_filename IN TEXT MODE FOR OUTPUT ENCODING DEFAULT

.

Thanks,

Reward If Helpful.

Former Member
0 Kudos

Hi..

U can use the following piece of code..

<b>For checking it file exists:</b>

&----


*& Form sub_validate_appl_file

&----


  • -->P_FILE text

----


  • This routine is used to check the file existence on application

  • server. First check is whether entered file is directory or not

  • and second check is for file

----


FORM sub_validate_appl_file USING p_file TYPE string.

DATA : tl_file_tbl TYPE STANDARD TABLE OF salfldir, "Files table

wl_msg TYPE string. "Message

CALL FUNCTION 'RZL_READ_DIR'

EXPORTING

name = p_file

TABLES

file_tbl = tl_file_tbl

EXCEPTIONS

argument_error = 1

not_found = 2

send_error = 3

system_failure = 4

OTHERS = 5.

IF sy-subrc = 0.

DESCRIBE TABLE tl_file_tbl LINES sy-tfill.

IF sy-tfill > 0.

*This is & directory and not a file

MESSAGE e016(zcaxx) WITH p_file.

ENDIF.

ENDIF.

CATCH SYSTEM-EXCEPTIONS convt_codepage_init = 2

convt_codepage = 3

open_dataset_no_authority = 4

dataset_too_many_files = 5

OTHERS = 6.

OPEN DATASET p_file FOR INPUT IN BINARY MODE MESSAGE wl_msg.

ENDCATCH.

IF sy-subrc <> 0.

*System message

MESSAGE e000(zcaxx) WITH wl_msg p_file.

ENDIF.

CLOSE DATASET p_file.

REFRESH : tl_file_tbl.

FREE : tl_file_tbl.

ENDFORM.

<b>For Fetching data:</b>

FORM sub_get_data_from_unix USING pw_file TYPE string.

*--Work areas

DATA : wal_data TYPE type_all_data, "For preparing structured data

wl_seperator TYPE char1, "For specifying the file seperator

wal_data_fix TYPE type_data, "For processing fixed length file

wl_string TYPE string. "For processing appl. server file

*--Field symbols

FIELD-SYMBOLS : <l_pt_table> TYPE LINE OF tt_data_tab.

"For processing fixed length file

*--Initializing variables and work areas.

CLEAR : wal_data,

wal_data_fix,

wl_string,

wl_seperator,

w_mesg.

*--Reading file from application server

*--Open the server file

CATCH SYSTEM-EXCEPTIONS convt_codepage_init = 1

convt_codepage = 2

open_dataset_no_authority = 3

open_pipe_no_authority = 4

dataset_too_many_files = 5

OTHERS = 6.

OPEN DATASET pw_file FOR INPUT IN TEXT MODE ENCODING DEFAULT

MESSAGE w_mesg.

*--If error on opening file give error message

IF sy-subrc NE 0.

*-- Error message

MESSAGE i019 WITH w_mesg.

LEAVE LIST-PROCESSING.

ENDIF.

ENDCATCH.

*--Read the data from file

DO.

READ DATASET pw_file INTO wl_string.

IF sy-subrc NE 0.

EXIT. "end of file. exit loop

ELSE.

APPEND wl_string TO t_data_table.

CLEAR wl_string.

ENDIF.

ENDDO.

*--Close the server file

CLOSE DATASET pw_file.

Plz reward...

Himanshu

Former Member
0 Kudos

hi thanura,

here path of the file name should be CASE SENSITIVE.

make sure that you have given the file name in right case(Upper/Lower case including Extention of the file name).

Chandra

rainer_hbenthal
Active Contributor
0 Kudos

Above statement does not care if the file is in existance or ot. If it is, it is deleted recreated it it is not, it is created.

So it must be an error in the directory structure. Or the file might be locked by another process.

0 Kudos

Hi,

If it is locked, How to check and how to release, or how to handle the situation.

Best Regards

Thanura

Former Member
0 Kudos

hi

good

check your given path for f_filename and go through this code and use accordingly.

DATA FNAME(60).

FNAME = '/tmp/myfile'.

OPEN DATASET 'myfile'.

OPEN DATASET FNAME.

This example works as long as your R/3 System is running under UNIX. The program opens the file "myfile" in the directory in which the R/3 System is running, and also opens the file "myfile" in directory "/tmp". However, you would have to change the filename for other operating systems. For example, for OpenVMS, you could write the following:

FNAME = '[TMP]myfile.BIN'

OPEN DATASET 'myfile.BIN'.

reward point if helpful.

thanks

mrutyun^

0 Kudos

Hi,

I am using AS/400.

How to use the file path in AS400.

Pls help

Best Regards

Thanura