rnsap 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rnsap.rb +48 -16
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b08656a22732937af89f8dff31270e6e1be78b64bc54ffc6ebd66e5e2c1f6b8a
4
- data.tar.gz: 6ef4877da02494a42b50ad96279b53f7b6a6266cf7a2186b0aa9a53f6d46f59b
3
+ metadata.gz: 4f007a1ea7e705a5e9d6071a22eda01f95debc6c5f2190df7720c2cc5359022e
4
+ data.tar.gz: aab89dd84c193006677e4f952e5703cfde3a28babdb6db445fdad3bc29ca316f
5
5
  SHA512:
6
- metadata.gz: d08e2404802ae98c3d318a77f7a2a97be10dc81a50d0b00309a3f19c0f73f1e6f39f996d9fbe7c917e1fe75960fdb7a64581a2f8364518cbd463aee8ff4c6ca1
7
- data.tar.gz: 91031854f317b89ac641010efbd804be84b9a69589aaa3446a3a0b2cb72237d27412530f3dc5222de936fb345a966296a51c7fec89572cd8f8f527cfdbe5a89e
6
+ metadata.gz: d04e02c23e7fee1f3af3577ede5195c8ba096062d81cd50be1a0c1a60203fffbd5637c24cb167072cbf2e7cf8dec98102485c5f9d339aa298d521e4f2903185a
7
+ data.tar.gz: 6b6f07b8d353fdfd91db749c67a2b67640d3e8c815a03b648a5ae97f0af720d594299b0d8e5441680a6b4c53a03f02e63fda7e45339685c09f280d82bdb25592
@@ -4,35 +4,59 @@ require 'nwrfc'
4
4
 
5
5
  include NWRFC
6
6
 
7
+ # Module for SAP helper methods. RnSap allows for a simpler
8
+ # manner to access SAP servers calling RFC BAPIs.
9
+ # @author Rogerio Nascimento
7
10
  module RnSap
11
+ # This is the central class responsible for SAP remote function calls.
12
+ # Currently the RFC_READ_TABLE BAPI is implemented.
13
+ #
14
+ # * TODO
15
+ #
16
+ # Implement other SAP BAPIs, such as BAPI_GOODS_MOVEMENT.
8
17
  class Sap
18
+ # keeps the SAP connection alive during the Sap instance lifecycle
9
19
  attr_reader :conn
10
20
 
11
21
  # Constructor requires to receive connection parameters,
12
22
  # a hash containint necessary information to logon to SAP
13
- def initialize(_conn_parms)
14
- @conn = Connection.new(_conn_parms)
23
+ # @param conn_parms [Hash] SAP Connection Parameters
24
+ def initialize(conn_parms)
25
+ @conn = Connection.new(conn_parms)
15
26
  end
16
27
 
17
- # Closes SAP connection
28
+ # Closes the instance's SAP connection#
18
29
  def close
19
30
  conn.disconnect
20
31
  end
21
32
 
22
- # def read_table(params = {})
23
- # return [] unless params[:name].present?
24
- # return [] unless params[:fields].present?
25
-
26
- # name = params[:name]
27
- # fields = params[:fields]
28
- # clauses = params[:clauses].present? ? params[:clauses] : []
29
- # rowskips = params[:row_skip].present? ? params[:row_skip] : 0
30
- # rowcount = params[:row_count].present? ? params[:row_count] : 0
31
-
32
- # read_table(name, fields, clauses, rowskips, rowcount)
33
+ # Invokes SAP RFC_READ_TABLE function module remotely, passing
34
+ # the table to be read and receiving back a list of objects of that
35
+ # table.
36
+ #
37
+ # Example:
38
+ #
39
+ # - name: 'lfa1'
40
+ # - fields: ['name1', 'land1']
41
+ #
42
+ # The return will be an array of object <b>Lfa1</b> with the
43
+ # attributes <b>name1</b> and <b>land1</b>.
44
+ #
45
+ # ```ruby
46
+ # conn = RnSap::Sap.new(conn_parms)
47
+ # list = conn.read_table('lfa1', ['name1', 'land1'])
48
+ # list.each do |item|
49
+ # puts item.name1
33
50
  # end
34
-
35
- def read_table(name = '', fields = [], clauses = [], _row_skip = 0, _row_count = 0)
51
+ # ```
52
+ #
53
+ # @param name [String] Name of SAP table to be read
54
+ # @param fields [Array] Array of strings containing the table field names to be retrieved
55
+ # @param clauses [Array] Optional 'where' clauses applicable to the table reading. respects SAP sintax
56
+ # @param _row_skip [Integer] number of rows to be skipped within the selected data
57
+ # @param _row_count [Integer] max number of rows to be returned
58
+ # @return [Array] Array of the Objects named after the table (i.e. Lfa1, Mara, Bkpf) with its selected columns as attributes (see example)
59
+ def read_table(name, fields = [], clauses = [], _row_skip = 0, _row_count = 0)
36
60
  if name.is_a?(Hash)
37
61
  fields = name[:fields]
38
62
  clauses = name[:clauses]
@@ -101,6 +125,7 @@ module RnSap
101
125
 
102
126
  attr_writer :conn
103
127
 
128
+ # Dumps to the output the content of an object
104
129
  def dump_instance_variables(obj)
105
130
  puts "Class: #{obj.class} -> #{obj}"
106
131
  obj.instance_variables.map do |var|
@@ -108,6 +133,11 @@ module RnSap
108
133
  end
109
134
  end
110
135
 
136
+ # Dynamically returns a class instance with the name 'name' and with each
137
+ # of its fields as an attribute
138
+ # @param name [String] name of the intended class instance
139
+ # @param fields [Array] array of strings containing the list of attributes to be available in the class instance
140
+ # @return [Object] instance of the object 'Name'
111
141
  def get_class_instance(name, fields)
112
142
  # puts "Class name: #{name}"
113
143
  klass = Object.const_set(name, Class.new).new # , Struct.new(*attributes)
@@ -118,6 +148,8 @@ module RnSap
118
148
  end
119
149
  end
120
150
 
151
+ # class used to represent a Table Column. Used internally
152
+ # to map SAP's returned working area (WA) into class instances
121
153
  class TableColumn
122
154
  attr_accessor :field_name, :offset, :length, :type, :description
123
155
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnsap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rogerio Nascimento