Class: SAPNW::RFC::FunctionDescriptor

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(methid, *rest) ⇒ Object



59
60
61
62
63
64
65
66
# 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

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



24
25
26
# File 'lib/sapnwrfc/functions.rb', line 24

def callback
  @callback
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/sapnwrfc/functions.rb', line 23

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



23
24
25
# File 'lib/sapnwrfc/functions.rb', line 23

def parameters
  @parameters
end

Instance Method Details

#addParameter(*parms) ⇒ Object

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)



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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

#handler(function) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# 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_callObject



34
35
36
# File 'lib/sapnwrfc/functions.rb', line 34

def make_empty_function_call
  return SAPNW::RFC::FunctionCall.new(self)
end

#new_function_callObject

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.



30
31
32
# File 'lib/sapnwrfc/functions.rb', line 30

def new_function_call
  return create_function_call(SAPNW::RFC::FunctionCall)
end