‎2008 Dec 04 2:06 PM
Those smarter than me:
The following code returns sy-subrc=8 on the open dataset statement.
data: dpfile(128) type c value '
server.domain.com\dp\ test.txt',
dp100 type string.
open dataset dpfile for input in text mode encoding default.
if sy-subrc eq 0.
do.
read dataset dpfile into dp100
if sy-subrc = 0.
write: / dp100.
else.
exit.
endif.
enddo.
close dataset dpfile.
else.
write: / sy-subrc.
endif.
I'm trying to read a text file on the network from SAP/ECC on AIX. I've done this many times with ECC on NT reading a non-SAP NT server.
Thanks in advance!
Edited by: Gary Rose on Dec 4, 2008 3:07 PM
‎2008 Dec 04 2:10 PM
Check the file name,and make sure it is exist or not and should not be in Open(Change) mode in network anywhere.
‎2008 Dec 04 2:13 PM
> data: dpfile(128) type c value '
server.domain.com\dp\ test.txt',
Is that a deliberate space before "test.txt"?
Thomas
‎2008 Dec 04 2:17 PM
Hello,
Use open dataset dpfile for input IGNORING CONVERSION ERRORS.
Thanks,
Jayant
‎2008 Dec 04 3:10 PM
The file is not locked by any other user as I'm still in development. The space in the filename is a typo. I had the IGNORING in my code at one point, but I will try that again. Thanks for the responses.
If this doesn't work, I'll have to use FTP, but I certainly would prefer using the share for obvious reasons.
‎2008 Dec 04 3:16 PM
HI Gary, you can only use DATASET statements when you are dealing with a file that resides on the application server in which the program is running. You can not read a file on another network share using these statements.
You can however use the following to read a network file.
REPORT zrich_0001.
TYPES: BEGIN OF t_data,
line TYPE string,
END OF t_data.
DATA: lt_data TYPE TABLE OF t_data.
DATA: ls_data LIKE LINE OF lt_data.
DATA: lv_file TYPE string.
PARAMETERS: p_file TYPE localfile DEFAULT '\\theServer.sap.corp\someFolder\theFile.txt''.
START-OF-SELECTION.
lv_file = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_file
CHANGING
data_tab = lt_data
EXCEPTIONS
OTHERS = 19.Regards,
Rich Heilman