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 error

Former Member
0 Likes
2,304

Hi All,

I am facing problem on OPEN DATASET. I want to read files from Dev server.

I used FM : EPS_GET_DIRECTORY_LISTING to get the directory.

i am getting 2 files into my itab from that one file i am trying to reading. Error message is : No such file or directory

Can anybody help...

here is the code :

dirname = '/home/sap/empdata.d/'.

call function 'EPS_GET_DIRECTORY_LISTING'

exporting

dir_name = dirname

tables

dir_list = dirlist

loop at dirlist.

concatenate dirname dirlist-name into lv_file.

exit.

endloop.

open dataset lv_file for input in text mode message errtxt.

if sy-subrc ne 0.

write 😕 errtxt.

exit.

endif.

13 REPLIES 13
Read only

former_member156446
Active Contributor
0 Likes
2,055

[Hope this link help you.|http://www.sapfans.com/sapfans/alex.htm]

Read only

venkat_o
Active Contributor
0 Likes
2,055

Hi, I think that the problem with DOT(.) in the directory path. Try

dirname = '/home/sap/empdatad/'.
Instead of
dirname = '/home/sap/empdata.d/'.
Thanks Venkat.O

Read only

Former Member
0 Likes
2,055

Hi Venkat,

If i remove DOT. the FM is not giving any files list into DIRLIST. If i keep DOT i am getting 2 files into DIRLIST.

Is anything wrong in my code.

Thanks.

Read only

venkat_o
Active Contributor
0 Likes
2,055

<li>add ENCODING DEFAULT to OPEN DATA SET and try. <li>Doubt: When OPEN DATASET is run what is the file name you are getting and check that in original directory through AL11. Thanks Venkat.O

Read only

Former Member
0 Likes
2,055

Hi,

Funtcion module return all file names DIRLIST related to that directory.

loop at dirlist.

concatenate dirname dirlist-name into lv_file.

open dataset lv_file for input in text mode message errtxt.

exit.

endloop

dirname = '/home/sap/empdata.d/'.

call function 'EPS_GET_DIRECTORY_LISTING'

exporting

dir_name = dirname

tables

dir_list = dirlist

loop at dirlist.

concatenate dirname dirlist-name into lv_file.

exit.

endloop.

open dataset lv_file for input in text mode message errtxt.

Read only

0 Likes
2,055

Hi All,

My lv_file contains space in file name. Is that cause error. The name i am getting is

/home/sap/empdata.d/2009_1008 TMS Dev.txt

Is that would be any problem ?

Thanks.

Read only

former_member156446
Active Contributor
0 Likes
2,055

This code worked for me:

lv_file is case sensitve.. the path need to exactly same as it shows in AL11...

DATA: dirname TYPE epsf-epsdirnam.
DATA: dirlist TYPE STANDARD TABLE OF epsfili WITH HEADER LINE.
DATA: lv_file TYPE string.

dirname = '/usr/sap/tmp/'.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
  EXPORTING
    dir_name = dirname
  TABLES
    dir_list = dirlist.

LOOP AT dirlist.
  CONCATENATE dirname dirlist-name INTO lv_file.
  EXIT.
ENDLOOP.

OPEN DATASET lv_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
  WRITE :/ sy-subrc.
  EXIT.
ENDIF.

Read only

0 Likes
2,055

Hi J@Y,

How can i see AL11, I am unable to find the path /home/sap/empdata.d/.

But my BASIS person said he put 2 files in server. And the function module giving 2 file names.

Any specific directory i needs to see in AL11.

Thanks.

Read only

0 Likes
2,055

Tr. AL11 > search for your directory name...

once you see the directory double click on the folder and double click on the file name and on the top you can see the file name as its stored in server... the same case and spaces need to be pulled in lv_file..

Read only

venkat_o
Active Contributor
0 Likes
2,055

Hey, Try this program. Its not giving any problem.

REPORT  ztest_notepad.
 DATA dir_list TYPE TABLE OF epsfili." WITH HEADER LINE.
 DATA w_dir_list LIKE LINE OF dir_list.
 DATA: path  TYPE epsf-epsdirnam VALUE '/tmp/'.

 CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
   EXPORTING
     dir_name = path
   TABLES
     dir_list = dir_list.

 DATA:file TYPE char80.
 LOOP AT dir_list INTO w_dir_list.
   CONCATENATE path w_dir_list-name INTO file.
   EXIT.
 ENDLOOP.
 DATA msg TYPE string.
 OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE msg.
 IF sy-subrc NE 0.
   WRITE :/ msg.
   EXIT.
 ENDIF.
Thanks Venkat.O

Read only

venkat_o
Active Contributor
0 Likes
2,055

Hey dear, What is the problem you found ? Thanks Venkat.O

Read only

Former Member
0 Likes
2,055

Hi Venkat,

I tried with your code. Still same error i am getting. And in AL11 i am unable to find my file path.

i have only below list in AL11

DIR_ATRA /usr/sap/PD1/DVEBMGS00/data

DIR_BINARY /usr/sap/PD1/SYS/exe/run

DIR_CT_LOGGING /usr/sap/PD1/SYS/global

DIR_CT_RUN /usr/sap/PD1/SYS/exe/ctrun

DIR_DATA /usr/sap/PD1/DVEBMGS00/data

DIR_DBMS /usr/sap/PD1/SYS/SAPDB

DIR_EXECUTABLE /usr/sap/PD1/SYS/exe/run

DIR_EXE_ROOT /usr/sap/PD1/SYS/exe

DIR_GEN /usr/sap/PD1/SYS/gen/dbg

DIR_GEN_ROOT /usr/sap/PD1/SYS/gen

DIR_GLOBAL /usr/sap/PD1/SYS/global

DIR_GRAPH_EXE /usr/sap/PD1/SYS/exe/run

DIR_GRAPH_LIB /usr/sap/PD1/SYS/exe/run

DIR_HOME /usr/sap/PD1/DVEBMGS00/work

DIR_INF_INFORMIXDIR /informix/PD1

DIR_INSTALL /usr/sap/PD1/SYS

But i used old path, i am able to read files. My old path is : /home/sap/data.d/2009011.txt. This file i can read. Only deference i found in OLD and NEW is the file name dont contain any spaces. I am searching options to upload a file into server. Please let me know t-code to upload file into server.

I already tried CG3Z in my system it is not existed. I am using 4.0 version.

Thanks.

Read only

Former Member
0 Likes
2,055

Hi All,

Problem got solved. It is because of file name contains space.

Thanks one to all.