class SAPNW::RFC::FunctionDescriptor

These are automatically created as a result of SAPNW::RFC::Connection#discover - do not instantiate these yourself yourself!

Attributes

callback[RW]
name[R]
parameters[R]

Public Instance Methods

addParameter(*parms) click to toggle source
internal method used to add parameters from within the C extension

def addParameter(name = nil, direction = 0, type = 0, len = 0, ulen = 0, decimals = 0)

# File lib/sapnwrfc/functions.rb, line 70
                def addParameter(*parms)
                        parms = parms.first if parms.class == Array and (parms.first.class == Hash || parms.first.kind_of?(SAPNW::RFC::Parameter))
                  case parms
                          when Array
                                  name, direction, type, len, ulen, decimals = parms
                          when Hash
    name = parms.has_key?(:name) ? parms[:name] : nil
    direction = parms.has_key?(:direction) ? parms[:direction] : nil
    type = parms.has_key?(:type) ? parms[:type] : nil
    len = parms.has_key?(:len) ? parms[:len] : nil
    ulen = parms.has_key?(:ulen) ? parms[:ulen] : nil
    decimals = parms.has_key?(:decimals) ? parms[:decimals] : nil
                    when SAPNW::RFC::Export, SAPNW::RFC::Import, SAPNW::RFC::Changing, SAPNW::RFC::Table
                                  # this way happens when a function def is manually defined
                                  self.add_parameter(parms)
    @parameters[parms.name] = parms
                                        return parms
                          else
                      raise "invalid SAPNW::RFC::FunctionDescriptor parameter supplied: #{parms.inspect}\n"
                        end
                        
                  #$stderr.print "parm: #{name} direction: #{direction} type: #{type} len: #{len} decimals: #{decimals}\n"
case direction
                          when SAPNW::RFC::IMPORT
                                  if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::EXPORT
                                    p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)
                                        else
                                    p = SAPNW::RFC::Import.new(self, name, type, len, ulen, decimals)
                                        end
                                when SAPNW::RFC::EXPORT
                                  if @parameters.has_key?(name) and @parameters[name].direction == SAPNW::RFC::IMPORT
                                    p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)
                                        else
                                    p = SAPNW::RFC::Export.new(self, name, type, len, ulen, decimals)
                                        end
                                when SAPNW::RFC::CHANGING
                                  p = SAPNW::RFC::Changing.new(self, name, type, len, ulen, decimals)
                                when SAPNW::RFC::TABLES
                                  p = SAPNW::RFC::Table.new(self, name, type, len, ulen, decimals)
                                else
                                  raise "unknown direction (#{name}): #{direction}\n"
                        end
@parameters[p.name] = p
                        return p
                end
callback=(proc) click to toggle source
# File lib/sapnwrfc/functions.rb, line 38
def callback=(proc)
  if proc.instance_of?(Proc)
    @callback = proc
  else
    raise "Must pass in an instance of Proc for the callback"
  end
  return @callback
end
handler(function) click to toggle source
# File lib/sapnwrfc/functions.rb, line 47
              def handler(function)
                      begin
return @callback.call(function)
                      rescue SAPNW::RFC::ServerException => e
                        #$stderr.print "ServerException => #{e.error.inspect}\n"
                        return e
                      rescue StandardError => e
                        #$stderr.print "StandardError => #{e.inspect}/#{e.message}\n"
                        return SAPNW::RFC::ServerException.new({'code' => 3, 'key' => 'RUBY_RUNTIME', 'message' => e.message})
                      end
              end
make_empty_function_call() click to toggle source
# File lib/sapnwrfc/functions.rb, line 34
def make_empty_function_call
  return SAPNW::RFC::FunctionCall.new(self)
end
method_missing(methid, *rest) click to toggle source
# File lib/sapnwrfc/functions.rb, line 59
def method_missing(methid, *rest)
  meth = methid.id2name
  if @parameters.has_key?(meth)
                      return @parameters[meth]
                    else
                      raise NoMethodError
                    end
end
new_function_call() click to toggle source

create a new SAPNW::RFC::FunctionCall object for this FunctionDescriptor.

You must call this each time that you want to invoke() a new function call, as this creates a one shot container for the passing back and forth of interface parameters.

# File lib/sapnwrfc/functions.rb, line 30
def new_function_call
  return create_function_call(SAPNW::RFC::FunctionCall)
end