module NWRFC

This library provides a way to call the functions of the SAP Netweaver RFC SDK, i.e. opening a connection to an ABAP system, calling functions etc., as well as running an RFC service

Constants

NW_DATE_FORMAT

ABAP Date Format (“YYYYMMDD”)

NW_TIME_FORMAT

ABAP Time Format (“HHMMSS”)

Public Class Methods

abap_bool(value) click to toggle source

Converts ABAP true/false into Ruby true/false @return True for ‘X’, False for ‘ ’ or nil otherwise

# File lib/nwrfc.rb, line 149
def NWRFC.abap_bool(value)
  return true if value == 'X'
  return false if value == ' '
  nil
end
bool_abap(value) click to toggle source

Converts Ruby true/false into ABAP true/false @return ‘X’ for true,, ‘ ’ for false or nil otherwise

# File lib/nwrfc.rb, line 157
def NWRFC.bool_abap(value)
  return 'X' if value == true
  return ' ' if value == false
  nil
end
check_error(error_handle) click to toggle source

Check for an error using error handle (used internally)

# File lib/nwrfc.rb, line 58
def NWRFC.check_error(error_handle)
  raise NWError, error_handle \
    if error_handle[:code] > 0
  #raise "Error code #{error_handle[:code]} group #{error_handle[:group]} message #{error_handle[:message].get_str}" \
    
end
get_version() click to toggle source

Return the version of the NW RFC SDK library

# File lib/nwrfc.rb, line 32
def NWRFC.get_version
  # See custom method FFI::Pointer#read_string_dn in nwrfclib.rb
  # http://stackoverflow.com/questions/9293307/ruby-ffi-ruby-1-8-reading-utf-16le-encoded-strings
  major = FFI::MemoryPointer.new(:uint)
  minor = FFI::MemoryPointer.new(:uint)
  patch = FFI::MemoryPointer.new(:uint)
  version = NWRFCLib.get_version(major, minor, patch)
  [version.read_string_dn.uC, major.read_uint, minor.read_uint, patch.read_uint]
end
make_conn_params(params) click to toggle source

Take Hash of connection parameters and returns FFI pointer to an array for setting up a connection

# File lib/nwrfc.rb, line 44
def NWRFC.make_conn_params(params) #https://github.com/ffi/ffi/wiki/Structs
  par = FFI::MemoryPointer.new(NWRFCLib::RFCConnParam, params.length)
  pars = params.length.times.collect do |i|
    NWRFCLib::RFCConnParam.new(par + i * NWRFCLib::RFCConnParam.size)
  end
  tpar = params.to_a
  params.length.times do |n|
    pars[n][:name] = FFI::MemoryPointer.from_string(tpar[n][0].to_s.cU)
    pars[n][:value] = FFI::MemoryPointer.from_string(tpar[n][1].to_s.cU)
  end
  par
end

Public Instance Methods

inspect() click to toggle source
# File lib/nwrfc.rb, line 27
def inspect
  self.to_s
end