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

EPS_OPEN_OUTPUT_FILE via Python-RFC fails with OPEN_FAILED

Former Member
0 Likes
1,305

Hi guys,

For the purpose of diving into RFC I try to upload a file from a Linux Standard System to the SAP Server (SAP Solution Manager 4.0). I'm using the Python module pysap to accomplish this task, my code looks like:


import sys
import ctypes
import pysap

sap_conn = pysap.Rfc_connection(conn_string='AHOST=172.16.0.131 SYSNR=00 CLIENT=001 USER=SAP* PASSWD=********')

try:
  sap_conn.open()

  # discover interface
  func = sap_conn.get_interface('EPS_OPEN_OUTPUT_FILE')
  # print function describtion if everything went well
  print func.desc

  # adjust function parameters
  func['FILE_NAME'] = 'hello.txt'
  func['DIR_NAME'] = '' # empty, defaults to ESP/in
  func['FILE_SIZE_REQUEST'] = '12' # size of hello.txt according to 'ls -lh'
  func['OVERWRITE_MODE'] = 'recovery'
  func['TEXT_MODE'] = 'X' # textmode

  # call function
  rc = func()

except pysap.SapRfcError, desc:
  print "ERROR: %s" % desc
finally:
  sap_conn.close()

As you see, I'm filling the parameters required by EPS_OPEN_OUTPUT_FILE. The file I want to upload is called hello.txt and is in the same directory as the Python executable.

However, if I execute the script, I get an OPEN_FAILED error. What am I doing wrong?

RFC is working, as I can execute other FMs, e.g. EPS_GET_DIRECTORY_LISTING, without any problems. If I set DIR_NAME to something non existant, e.g. '/usr/sap/nonexistant' the RFC-Calls suceeds and a file (not a directory!?) nonexistant in /usr/sap is created. In this case, EV_LONG_FILE_PATH shows onyl /usr/sap/nonexistant but not /usr/sap/nonexistant/hello.txt.

Edit: I forgot to mention, I don't want to use GUI_UPLOAD.

Please help a young folk struggling with the beast.

Thanks in advance,

Robert

Edited by: Robert Ingruber on Apr 22, 2009 1:49 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,058

Hi Robert,

Here is how to go:

If you don't specify the dir_name parameter, then this one is used:

/usr/sap/SID/trans/EPS/in/

If you specify the dir_name parameter, then must pass the complete path to this parameter, not only the part starting from EPS or EPS/in.

The dir_name cannot handle trailing slashes.

And, the path/directory where you want to write the file to must exist.

Then it works (at least on my systems).

regards

5 REPLIES 5
Read only

Former Member
0 Likes
1,058

Hello Robert,

OPEN_FAILED occurs while trying to write the file in the path you specified.

The SAP-function opens a file (dataset) for output on the target path.

The path is created out of the path and filename you specified.

Mostly there are two reasons for failing to open that dataset:

1. The path and filename isn't correct. Try playing around with a slash ("/") at the end of the path specification.

2. You don't have authorization to create the file in that path.

regards

Read only

Former Member
0 Likes
1,058

Hi, thanks for your answer.

Mostly there are two reasons for failing to open that dataset:

1. The path and filename isn't correct. Try playing around with a slash ("/") at the end of the path specification.

2. You don't have authorization to create the file in that path.

Yeah, I already thought about the tailing slash and already experimented with it, no impact.

I'm issuing the call as user SAP*, so I should have all rights from a SAP point of view. Furthermore I set the UNIX file permissions of ..../EPS/in to 777 temporarily. Unfortunately still no chance for the call to succeed. In addition, no NO_AUTHORIZATION-exception is thrown, so this should't be the problem.

As far as I understand the ABAP source code of EPS_OPEN_OUTPUT_FILE, parameter DIR_NAME defaults zu /usr/sap/trans/EPS/in if I don't supply this parameter, right? Thus I don't supply it in the application. Using the RFC-Call a file named 'hello.txt' should be created, ok up to now?

I just read in a note "(...) you must provide this directory with write authorization for the SAP system." - Are they speaking of traditional UNIX permissions?

EDIT:

I played a bit with EPS_OPEN_INPUT_FILE and can read files from EPS/out. However newly created subdirectories such as 'dirdir' with file 'exists.txt' in it are not accessable (OPEN_FAILED), although correct UNIX permissions have been assigned. I tried it with both, with and without tailing slash, no difference. Strange thing..

Any further advices?

Thanks, Robert.

Edited by: Robert Ingruber on Apr 22, 2009 3:28 PM

Edited by: Robert Ingruber on Apr 22, 2009 3:41 PM

Read only

Former Member
0 Likes
1,058

It seems like EPS_OPEN_OUTPUT_FILE doesn't work with a non existing path (directory).

Have you already tryied to write the file to an existing path, where the permissions are OK?

Read only

Former Member
0 Likes
1,059

Hi Robert,

Here is how to go:

If you don't specify the dir_name parameter, then this one is used:

/usr/sap/SID/trans/EPS/in/

If you specify the dir_name parameter, then must pass the complete path to this parameter, not only the part starting from EPS or EPS/in.

The dir_name cannot handle trailing slashes.

And, the path/directory where you want to write the file to must exist.

Then it works (at least on my systems).

regards

Read only

Former Member
0 Likes
1,058

Hi,

Thanks for your replies again.

It seems like EPS_OPEN_OUTPUT_FILE doesn't work with a non existing path (directory).

Have you already tryied to write the file to an existing path, where the permissions are OK?

Yep, I left DIR_NAME empty thus the file should be written to /usr/sap/SAPSID/trans/EPS/in which exists and is writeable. I tried the version with explicitely setting DIR_NAME to the path mentionied above too, no difference.

If you don't specify the dir_name parameter, then this one is used:

/usr/sap/SID/trans/EPS/in/

Yup, I said this just before. Thanks anyway.

And on your system this works? Crazy..

Regards, Robert.