Class: NWRFC::FunctionCall
- Inherits:
-
DataContainer
- Object
- DataContainer
- NWRFC::FunctionCall
- Defined in:
- lib/nwrfc.rb
Overview
Represents a callable instance of a function
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Instance Method Summary collapse
-
#active?(parameter) ⇒ Boolean
Returns whether or not a given parameter is active, i.e.
-
#deactivate(parameter) ⇒ Object
Set a named parameter to inactive.
-
#initialize(*args) ⇒ FunctionCall
constructor
Call with either Function or Connection and Function Call instance (handle).
-
#invoke ⇒ Object
Execute the function on the connected ABAP system.
-
#set_active(parameter, active = true) ⇒ Object
Set a named parameter to active or inactive.
Methods inherited from DataContainer
#[], #[]=, #fields, #member_metadata, #value_to_date, #value_to_time
Constructor Details
#new(function) ⇒ FunctionCall #new(function_handle) ⇒ FunctionCall
Call with either Function or Connection and Function Call instance (handle)
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/nwrfc.rb', line 261 def initialize(*args) @error = NWRFCLib::RFCError.new if args[0].class == FFI::Pointer @handle = args[0] @connection = nil @function = nil # @connection = args[0].connection @desc = NWRFCLib.describe_function(@handle, @error) #@todo Investigate having a referenced Function object as well in the server case; does it have practical applications? # Doing this would require an extra way of handling the constructor of Function # @function = Function.new elsif args[0].class == Function @function = args[0] #function @connection = args[0].connection @handle = NWRFCLib.create_function(@function.desc, @error.to_ptr) @desc = args[0].desc end NWRFC.check_error(@error) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
249 250 251 |
# File 'lib/nwrfc.rb', line 249 def connection @connection end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
249 250 251 |
# File 'lib/nwrfc.rb', line 249 def desc @desc end |
#function ⇒ Object (readonly)
Returns the value of attribute function.
249 250 251 |
# File 'lib/nwrfc.rb', line 249 def function @function end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
249 250 251 |
# File 'lib/nwrfc.rb', line 249 def handle @handle end |
Instance Method Details
#active?(parameter) ⇒ Boolean
Returns whether or not a given parameter is active, i.e. whether it will be sent to the server during the RFC call with FunctionCall#invoke. This is helpful for functions that set default values on parameters or otherwise check whether parameters are passed in cases where this may have an impact on performance or otherwise @param[String, Symbol] parameter Name of the parameter
294 295 296 297 298 299 |
# File 'lib/nwrfc.rb', line 294 def active?(parameter) is_active = FFI::MemoryPointer.new :int rc = NWRFCLib.is_parameter_active(@handle, parameter.to_s.cU, is_active, @error) NWRFC.check_error(@error) if rc > 0 is_active.read_int == 1 end |
#deactivate(parameter) ⇒ Object
Set a named parameter to inactive
310 311 312 |
# File 'lib/nwrfc.rb', line 310 def deactivate(parameter) set_active(parameter, false) end |
#invoke ⇒ Object
Execute the function on the connected ABAP system
283 284 285 286 287 288 |
# File 'lib/nwrfc.rb', line 283 def invoke raise "Not a callable function" unless @connection rc = NWRFCLib.invoke(@connection.handle, @handle, @error.to_ptr) #@todo Handle function exceptions by checking for :RFC_ABAP_EXCEPTION (5) NWRFC.check_error(@error) if rc > 0 end |
#set_active(parameter, active = true) ⇒ Object
Set a named parameter to active or inactive
302 303 304 305 306 307 |
# File 'lib/nwrfc.rb', line 302 def set_active(parameter, active=true) (active ? active_flag = 1 : active_flag = 0) rc = NWRFCLib.set_parameter_active(@handle, parameter.to_s.cU, active_flag, @error) NWRFC.check_error(@error) if rc > 0 active end |