Class: SAPNW::RFC::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/sapnwrfc/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Connection

Returns a new instance of Connection.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/sapnwrfc/connection.rb', line 96

def initialize(args = nil)
  @connection_parameters = []
    case args
    when nil
    when Hash
      args.each_pair { |key, val|
        @connection_parameters << { 'name' => key.to_s, 'value' => val.to_s }
      }
    else
      raise "Wrong parameters for Connection - must pass a Hash\n"
  end
    SAP_LOGGER.debug("In #{self.class} initialize: #{@connection_parameters.inspect} ...")
@functions = {}
  @handle = SAPNW::RFC::Handle.new(self)
end

Instance Attribute Details

#connection_parametersObject (readonly)

Returns the value of attribute connection_parameters.



94
95
96
# File 'lib/sapnwrfc/connection.rb', line 94

def connection_parameters
  @connection_parameters
end

#functionsObject (readonly)

Returns the value of attribute functions.



94
95
96
# File 'lib/sapnwrfc/connection.rb', line 94

def functions
  @functions
end

#handleObject

Returns the value of attribute handle.



93
94
95
# File 'lib/sapnwrfc/connection.rb', line 93

def handle
  @handle
end

Instance Method Details

#closeObject

FunctionDescriptors associated with this Connection.



135
136
137
138
139
140
141
142
143
# File 'lib/sapnwrfc/connection.rb', line 135

def close
    SAP_LOGGER.debug("In #{self.class} close ...")
  return nil unless self.handle
    SAP_LOGGER.debug("In #{self.class} handle: #{self.handle} ...")
    res = self.handle.close()
  self.handle = nil
# XXX Should destroy all cached functions and structures and types tied to handle ?
  return true
end

#connection_attributesObject



112
113
114
115
# File 'lib/sapnwrfc/connection.rb', line 112

def connection_attributes
    SAP_LOGGER.debug("In #{self.class} connection_attributes ...")
    return self.handle.connection_attributes()
end

#discover(func = nil) ⇒ Object

storing away the meta data of the associated Parameters/Tables and returns this as an instance of SAPNW::RFC::FunctionDescriptor. This is the MANDATORY starting point of all client side RFC.



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/sapnwrfc/connection.rb', line 121

def discover(func = nil)
    SAP_LOGGER.debug("In #{self.class} discover (#{func}) ...")
case func
  when nil
    return nil
  else
        func_def = self.handle.function_lookup(SAPNW::RFC::FunctionDescriptor, SAPNW::RFC::Parameter, func.to_s)
        @functions[func_def.name] = func_def
    return func_def
end
end

#pingObject

ping test a connection to see if it is still alive



146
147
148
149
150
151
# File 'lib/sapnwrfc/connection.rb', line 146

def ping
        SAP_LOGGER.debug("In #{self.class} ping ...")
    return nil unless self.handle
        SAP_LOGGER.debug("In #{self.class} handle: #{self.handle} ...")
        return self.handle.ping()
end