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 fails...says "error opening input file"

Former Member
0 Kudos

Hi,

I am trying to open a file in my BDC program and get the following error "error opening input file". Its a text file with continuous data. No delimiters and hence character count will be used to parse the data.

I am using the following statement to open it..

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

but sy-subrc is set to 8 !!

what could be the problem ??

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

for ur 1st question :

1. How do I place my file in application server and how do i refer its path in my program when it is executed !!

SOlution :

use <b>CG3Z</b> to transfer your presentation server(local drive) file to application server.

for your second question :

2. Suppose I want the file to be accessed from my local file system, what change do i need to do ?? anything in OPEN DATASET ??

to upload data from presentation server to ABAP program,

use GUI_UPLOAD function module.

as you already mentioned that its a flat file

just give FILENAME

& FILETYPE = 'ASC'

and TABLES = ITAB.

(ITAB Should be of line structure of length = total no of characters in your input file

ex : data : begin of itab occurs 0,

line(400) type c,

end of itab .

)

after this Function module call, data will be passed to ITAB .

check this,i hope this will resolve the issue.

thanks

srikanth

15 REPLIES 15

suresh_datti
Active Contributor
0 Kudos

Hi Rad,

You have to first ensure the file exists on the application server.Did you do that?

Regards,

Suresh Datti

0 Kudos

Verify the path and file name in p_file.

Make sure that the file actually exists.

Regards,

Rich Heilman

0 Kudos

thanks to all for ur inputs..

Yes, Suresh, it seems the application server is being searched for the file where as my file is in c drive of my system !!

I have two questions here:

1. How do I place my file in application server and how do i refer its path in my program when it is executed !!

2. Suppose I want the file to be accessed from my local file system, what change do i need to do ?? anything in OPEN DATASET ??

awating for your reply..

thanks

0 Kudos

You can:


REPORT ztest .

DATA: BEGIN OF itab OCCURS 0,
        field(256),
      END   OF itab.
DATA: dsn(100) VALUE '/usr/sap/xfr/FIS/testbmp',
      length  LIKE sy-tabix,
      lengthn LIKE sy-tabix.

CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename   = 'c:tempfile.txt'
     TABLES
          data_tab   = itab.

OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.

LOOP AT itab.
  TRANSFER itab-field TO dsn.
ENDLOOP.

CLOSE DATASET dsn.

Rob

Former Member
0 Kudos

Try to print the message:

<b>OPEN DATASET g_otfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_mesg.</b>

0 Kudos

You can declare the message variable as:

w_mesg(100) TYPE c (for example)

Former Member
0 Kudos

Hi,

<b>P_FILE</b> will contain the total path for that file, you will get this error if the path is incorrect or the file name is incorrect.. check once again you and correct it, you won't get this error messages

Regards

Sudheer

former_member186741
Active Contributor
0 Kudos

check that you have access in unix (or whatever db systen you use) to the file you're trying to use.

0 Kudos

If the file indeed exists and your pathing to the file is correct, then you are having a "rights/permissions" issue.

You will need to grant yourself read/write access to the file. In this case, you only have read access.

Reward points accordingly. Reply back if you need help determining what permissions exist on the file.

govind_seenivasan
Participant
0 Kudos

Hi,

To place your file in Application server you have to get the access to that directory.

Use Gui_upload to upload the file from your presentation server.

Thanks

0 Kudos

This is pretty confusing !!I would explain to you my exact issue !!

I have a program in which there is no GUI_UPLOAD call but just a direct open dataset statement !!

This program runs fine for my collegue who has the file in a server (not the application server). She gives the full path name as
servername\foldername\filename.

I tried doing the same but as I did not have access to that server, it failed. So I received that file from her and stored it in my local system. So on program execution, i gave the path as c:\filename and I got the error message "Error opening the file"

Find below some code extracts..

-


PARAMETERS : p_sname TYPE d0100_mapn ,

p_file(136) TYPE c ,

....

....

....

FORM open_file .

*open file in textmode

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

DO.

  • Read the file data and tranfer to workarea to internal table

READ DATASET p_file INTO x_legacy_rec.

...

....

...

-


Please help in debugging this issue !!

thanks

0 Kudos

If the file is on your PC, you have to upload it using GUI_UPLOAD or something like that. OPEN and READ will not work. If you want it on the server, you can use the code I suggested to upload it form your PC and than write it to your app server. Then you can use OPEN.

Rob

0 Kudos

Hi Rad,

you cannot use open dataset etc for stuff on your c drive.

Either,

...change program to use GUI_UPLOAD

or

...move the file to a network drive that you have access to.

govind_seenivasan
Participant
0 Kudos

Hi,

If you have a file in the application server, Then error is with the p_file.

In application server the file names are case sensitive so use "p_file(136) TYPE c lowercase'.

I think this will solve your problem.

Thanks

Former Member
0 Kudos

hi,

for ur 1st question :

1. How do I place my file in application server and how do i refer its path in my program when it is executed !!

SOlution :

use <b>CG3Z</b> to transfer your presentation server(local drive) file to application server.

for your second question :

2. Suppose I want the file to be accessed from my local file system, what change do i need to do ?? anything in OPEN DATASET ??

to upload data from presentation server to ABAP program,

use GUI_UPLOAD function module.

as you already mentioned that its a flat file

just give FILENAME

& FILETYPE = 'ASC'

and TABLES = ITAB.

(ITAB Should be of line structure of length = total no of characters in your input file

ex : data : begin of itab occurs 0,

line(400) type c,

end of itab .

)

after this Function module call, data will be passed to ITAB .

check this,i hope this will resolve the issue.

thanks

srikanth