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

Using open dataset for network file

Former Member
0 Likes
1,413

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

5 REPLIES 5
Read only

Former Member
0 Likes
767

Check the file name,and make sure it is exist or not and should not be in Open(Change) mode in network anywhere.

Read only

ThomasZloch
Active Contributor
0 Likes
767

> data: dpfile(128) type c value '
server.domain.com\dp\ test.txt',

Is that a deliberate space before "test.txt"?

Thomas

Read only

Former Member
0 Likes
767

Hello,

Use open dataset dpfile for input IGNORING CONVERSION ERRORS.

Thanks,

Jayant

Read only

Former Member
0 Likes
767

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.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
767

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