12-13-2005 11:19 PM
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
12-14-2005 5:12 PM
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
12-13-2005 11:25 PM
Hi Rad,
You have to first ensure the file exists on the application server.Did you do that?
Regards,
Suresh Datti
12-13-2005 11:30 PM
12-14-2005 4:52 PM
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
12-14-2005 5:02 PM
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
12-13-2005 11:29 PM
Try to print the message:
<b>OPEN DATASET g_otfile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE w_mesg.</b>
12-13-2005 11:31 PM
You can declare the message variable as:
w_mesg(100) TYPE c (for example)
12-14-2005 12:30 AM
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
12-14-2005 1:17 AM
check that you have access in unix (or whatever db systen you use) to the file you're trying to use.
12-14-2005 2:10 AM
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.
12-14-2005 4:56 PM
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
12-14-2005 5:04 PM
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
12-14-2005 5:15 PM
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
12-15-2005 12:36 AM
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.
12-14-2005 5:10 PM
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
12-14-2005 5:12 PM
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