Skip to Content
0
Former Member
Apr 22, 2009 at 11:43 AM

EPS_OPEN_OUTPUT_FILE via Python-RFC fails with OPEN_FAILED

247 Views

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