rnsap 0.4.8 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/auth.rb +132 -0
  3. data/lib/helper/rfc_helper.rb +19 -15
  4. data/lib/helper/util_helper.rb +1 -1
  5. data/lib/po_detail/all.rb +27 -0
  6. data/lib/po_detail/po_account.rb +93 -0
  7. data/lib/po_detail/po_addrdelivery.rb +115 -0
  8. data/lib/po_detail/po_all_versions.rb +55 -0
  9. data/lib/po_detail/po_components.rb +53 -0
  10. data/lib/po_detail/po_cond.rb +91 -0
  11. data/lib/po_detail/po_cond_header.rb +91 -0
  12. data/lib/po_detail/po_confirmation.rb +39 -0
  13. data/lib/po_detail/po_contract_limits.rb +21 -0
  14. data/lib/po_detail/po_exp_imp_header.rb +7 -0
  15. data/lib/po_detail/po_exp_imp_item.rb +21 -0
  16. data/lib/po_detail/po_extension_out.rb +13 -0
  17. data/lib/po_detail/po_header.rb +131 -0
  18. data/lib/po_detail/po_history.rb +107 -0
  19. data/lib/po_detail/po_history_ma.rb +37 -0
  20. data/lib/po_detail/po_history_totals.rb +51 -0
  21. data/lib/po_detail/po_inv_plan_header.rb +49 -0
  22. data/lib/po_detail/po_inv_plan_item.rb +51 -0
  23. data/lib/po_detail/po_item.rb +359 -0
  24. data/lib/po_detail/po_limits.rb +47 -0
  25. data/lib/po_detail/po_partner.rb +11 -0
  26. data/lib/po_detail/po_schedule.rb +59 -0
  27. data/lib/po_detail/po_serial_number.rb +13 -0
  28. data/lib/po_detail/po_services.rb +137 -0
  29. data/lib/po_detail/po_shipping_exp.rb +53 -0
  30. data/lib/po_detail/po_srv_access_values.rb +17 -0
  31. data/lib/po_detail/po_text_header.rb +13 -0
  32. data/lib/po_detail/po_text_item.rb +13 -0
  33. data/lib/po_release_info/all.rb +1 -0
  34. data/lib/po_release_info/po_release_final.rb +53 -0
  35. data/lib/preq_detail/all.rb +8 -0
  36. data/lib/preq_release_info/all.rb +4 -0
  37. data/lib/rnsap.rb +141 -40
  38. metadata +35 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dd7ba84b18711bdaf64bc605af4003b21f41296896cba5ae13681b41244750f
4
- data.tar.gz: 51728b725b3aaa900a517425aa0897b25f449fd44f962fa7ce3ab346917d4a53
3
+ metadata.gz: e1d839817ae1d8f4264066df07ca40d636746be3eadb962a36c9b5aa98ff86e9
4
+ data.tar.gz: 8ba9e2b2374a100950ba1d4f11f0684b6c63e09e30b0abbeadb7b4bf32da0795
5
5
  SHA512:
6
- metadata.gz: a1de3138f78004c63c9174e5c97441babc5e83efb7e930ec8bdb4986a5768f6f3aca8fefdc762c1548350bb8116cbf532c76370b969ccfad7c963513ecf3b968
7
- data.tar.gz: d6fcd634233711dccb18da6ba342c9bf9ddccef11ca50917c31bb39d53767fcfc2b7e41996d7fa41445e07740b371b84a6083cae24cfec5e4d956e37c98f1b92
6
+ metadata.gz: 397f61575fdca3c5dcbf9b521bd5e1e6337e21600033463eb7a706bfcf6a26640ce9a9b2c2f7f4d6eac395b6711fef7cddcbb9735440c4826f13fc2a0380d581
7
+ data.tar.gz: 976094292a14865df24a8c193a93c4db4d39dc3727a453b3dca2dc3db409852c4d3f4793f17a3ed208269dd90819e3d785ca57ad5ff63e8a82236b4fe49a4f1c
data/lib/auth.rb ADDED
@@ -0,0 +1,132 @@
1
+ # Class to handle authorization related SAP information
2
+ # @author Rogerio Nascimento (26/03/2021)
3
+ class Auth
4
+
5
+ # Return a list of users with authorization
6
+ # for an object
7
+ # @param json containing authorization object and optionaly
8
+ # the tuples with field and value to be checked
9
+ # @return an array of strings with the list of users
10
+ def self.for_object(*options)
11
+ users = []
12
+ conn, obj, field1, value1, field2, value2 = validate_options(options)
13
+ return users unless conn && obj
14
+
15
+ ## Busca o AUTH na tabela UST12
16
+ ust12_list = Auth.auth_list(conn, obj, field1, value1, field2, value2)
17
+ return users unless ust12_list
18
+
19
+ ## Busca o PROFN na tabela UST10S
20
+ ust10s_list = Auth.profile_list(conn, obj, ust12_list)
21
+
22
+ ## Busca os Usuários na tabela UST04
23
+ Auth.user_list(conn, obj, ust10s_list)
24
+ end
25
+
26
+ #
27
+ # Select Authorization roles for the Profile
28
+ # @param list List of profiles to be searched
29
+ # @return Array<string> with list of authorizations
30
+ def self.profiles_for_composite(conn, list = [])
31
+ return [] if list.empty?
32
+
33
+ fname = conn.conn.get_function('SIAG_PROF_GET_AUTH')
34
+ fcall = fname.get_function_call
35
+
36
+ fcall[:IV_PROFILE_TYPE] = 'C'
37
+ list.each do |prof|
38
+ row = fcall[:IT_PROFILE_RANGE].new_row
39
+ row[:SIGN] = 'I'
40
+ row[:OPTION] = 'EQ'
41
+ row[:LOW] = prof
42
+ end
43
+
44
+ fcall.invoke
45
+
46
+ ret = []
47
+ fcall[:ET_COMPOSITE_PROFILE].each do |row|
48
+ ret.push(row[:SINGLE_PROFILE])
49
+ end
50
+
51
+ ret
52
+ end
53
+
54
+
55
+ private
56
+
57
+ def self.validate_options(options)
58
+ return [] if options.empty?
59
+ params = options.first
60
+
61
+ conn = params[:conn]
62
+ obj = params[:obj]
63
+
64
+ return [] unless conn && obj
65
+ return [] unless conn.class.name == 'RnSap::Sap'
66
+
67
+ field1 = params[:field1]
68
+ value1 = params[:value1]
69
+ field2 = params[:field2]
70
+ value2 = params[:value2]
71
+
72
+ [conn, obj, field1, value1, field2, value2]
73
+ end
74
+
75
+ def self.auth_list( conn, obj, field1, value1, field2, value2)
76
+
77
+ fields = ['AUTH']
78
+ filter = ["OBJCT = '#{obj}' "]
79
+ if field1 && value1
80
+ filter.push(" AND ( FIELD = '#{field1}' AND ( VON = '*' OR VON = '#{value1}' ) ")
81
+ if field2 && value2
82
+ filter.push(" OR FIELD = '#{field2}' AND ( VON = '*' OR VON = '#{value2}' ) )")
83
+ else
84
+ filter.push( ')')
85
+ end
86
+ end
87
+
88
+ conn.read_table('UST12', fields, filter)
89
+ end
90
+
91
+ def self.profile_list( conn, obj, ust12_list)
92
+ sap_all = 'SAP_ALL'
93
+ profiles = Auth.profiles_for_composite(conn, [sap_all])
94
+ profiles.push(sap_all)
95
+
96
+ fields = ['PROFN']
97
+ filter = ["OBJCT = '#{obj}' AND AUTH IN ("]
98
+ profiles.each do |prof|
99
+ filter.push( "'#{prof}' , ")
100
+ end
101
+ ust12_list.each do |ust|
102
+ filter.push( "'#{ust.auth}' , ")
103
+ end
104
+ filter = filter.uniq
105
+ puts filter
106
+
107
+ new_last = "#{filter.last[0..(filter.last.length - 4)]} )"
108
+ filter = filter[0..-1].push(new_last)
109
+
110
+ conn.read_table('UST10S', fields, filter)
111
+ end
112
+
113
+ def self.user_list(conn, obj, ust10s_list)
114
+ users = []
115
+ fields = ['BNAME']
116
+ filter = ['PROFILE IN (']
117
+ filter.push("'SAP_ALL' , ")
118
+ ust10s_list.each do |ust|
119
+ filter.push("'#{ust.profn}' , ")
120
+ end
121
+ new_last = "#{filter.last[0..(filter.last.length - 4)]} )"
122
+ filter = filter[0..-1].push(new_last)
123
+
124
+ ust04_list = conn.read_table('UST04', fields, filter)
125
+
126
+ ust04_list.each do |ust|
127
+ users.push( ust.bname )
128
+ end
129
+
130
+ users.uniq.sort
131
+ end
132
+ end
@@ -1,21 +1,25 @@
1
- def get_object_list(table, klass_name)
1
+ def get_object_list(table, klass)
2
2
  list = []
3
- avoid_list = ['!','__','+', '=','!', '?','~','>', '<']
4
3
  table.each do |row|
5
- obj = eval("#{klass_name}.new")
6
- obj.class.instance_methods.each do |method_name|
7
- begin
8
- if obj.respond_to?("#{method_name}=")
9
- unless avoid_list.any? { |word| method_name.to_s.include?(word)}
10
- value = row[method_name]
11
- eval("obj.#{method_name} = '#{value}'")
12
- end
13
- end
14
- rescue
15
- end
16
- end
17
- list.push(obj)
4
+ list.push(get_object(row, klass))
18
5
  end
19
6
 
20
7
  list
21
8
  end
9
+
10
+ AVOID_LIST ||= ['!','__','+', '=','!', '?','~','>', '<']
11
+ def get_object(struct, klass)
12
+ obj = klass.new #eval("#{klass.to_s}.new")
13
+ klass.instance_methods.each do |method_name|
14
+ begin
15
+ if obj.respond_to?("#{method_name}=")
16
+ unless AVOID_LIST.any? { |word| method_name.to_s.include?(word)}
17
+ value = struct[method_name]
18
+ eval("obj.#{method_name} = '#{value}'")
19
+ end
20
+ end
21
+ rescue
22
+ end
23
+ end
24
+ obj
25
+ end
@@ -1,5 +1,5 @@
1
1
  module UtilHelper
2
- require 'JSON'
2
+ require 'json'
3
3
 
4
4
  def log(msg='no message')
5
5
  puts obj_to_s(msg)
@@ -0,0 +1,27 @@
1
+ require 'po_detail/po_item'
2
+ require 'po_detail/po_addrdelivery'
3
+ require 'po_detail/po_schedule'
4
+ require 'po_detail/po_account'
5
+ require 'po_detail/po_cond_header'
6
+ require 'po_detail/po_cond'
7
+ require 'po_detail/po_limits'
8
+ require 'po_detail/po_contract_limits'
9
+ require 'po_detail/po_services'
10
+ require 'po_detail/po_srv_access_values'
11
+ require 'po_detail/po_text_header'
12
+ require 'po_detail/po_text_item'
13
+ require 'po_detail/po_exp_imp_item'
14
+ require 'po_detail/po_components'
15
+ require 'po_detail/po_shipping_exp'
16
+ require 'po_detail/po_history'
17
+ require 'po_detail/po_history_totals'
18
+ require 'po_detail/po_confirmation'
19
+ require 'po_detail/po_all_versions'
20
+ require 'po_detail/po_partner'
21
+ require 'po_detail/po_extension_out'
22
+ require 'po_detail/po_serial_number'
23
+ require 'po_detail/po_inv_plan_header'
24
+ require 'po_detail/po_inv_plan_item'
25
+ require 'po_detail/po_history_ma'
26
+ require 'po_detail/po_header'
27
+ require 'po_detail/po_exp_imp_header'
@@ -0,0 +1,93 @@
1
+ # class used to represent POACCOUNT. Used internally
2
+ class PoAccount
3
+ # @return [String] Activity Number
4
+ attr_accessor :activity
5
+ # @return [String] Activity Type
6
+ attr_accessor :acttype
7
+ # @return [String] Main Asset Number
8
+ attr_accessor :asset_no
9
+ # @return [String] FM: Budget Period
10
+ attr_accessor :budget_period
11
+ # @return [String] Business Area
12
+ attr_accessor :bus_area
13
+ # @return [String] Commitment Item
14
+ attr_accessor :cmmt_item
15
+ # @return [String] Commitment item
16
+ attr_accessor :cmmt_item_long
17
+ # @return [String] Cost Center
18
+ attr_accessor :costcenter
19
+ # @return [String] Cost Object
20
+ attr_accessor :costobject
21
+ # @return [String] Controlling Area
22
+ attr_accessor :co_area
23
+ # @return [String] Business Process
24
+ attr_accessor :co_busproc
25
+ # @return [Date] Date on Which Record Was Created
26
+ attr_accessor :creat_date
27
+ # @return [String] Deletion Indicator: Purchasing Document Account Assignment
28
+ attr_accessor :delete_ind
29
+ # @return [Integer] Distribution percentage in the case of multiple acct assgt
30
+ attr_accessor :distr_perc
31
+ # @return [String] Final Account Assignment Indicator
32
+ attr_accessor :final_ind
33
+ # @return [String] Final Account Assignment Reason Code
34
+ attr_accessor :final_reason
35
+ # @return [String] Functional Area
36
+ attr_accessor :func_area
37
+ # @return [String] Functional Area
38
+ attr_accessor :func_area_long
39
+ # @return [String] Fund
40
+ attr_accessor :fund
41
+ # @return [String] Funds Center
42
+ attr_accessor :funds_ctr
43
+ # @return [String] G/L Account Number
44
+ attr_accessor :gl_account
45
+ # @return [String] Grant
46
+ attr_accessor :grant_nbr
47
+ # @return [String] Goods recipient
48
+ attr_accessor :gr_rcpt
49
+ # @return [String] Sales Document Item
50
+ attr_accessor :itm_number
51
+ # @return [String] Network Number for Account Assignment
52
+ attr_accessor :network
53
+ # @return [Integer] Currency amount for BAPIS (with 9 decimal places)
54
+ attr_accessor :net_value
55
+ # @return [Integer] Currency amount for BAPIS (with 9 decimal places)
56
+ attr_accessor :nond_itax
57
+ # @return [String] Order Number
58
+ attr_accessor :orderid
59
+ # @return [String] Partner account number
60
+ attr_accessor :part_acct
61
+ # @return [String] Item Number of Purchasing Document
62
+ attr_accessor :po_item
63
+ # @return [String] Profit Center
64
+ attr_accessor :profit_ctr
65
+ # @return [Integer] Quantity
66
+ attr_accessor :quantity
67
+ # @return [String] Recovery Indicator
68
+ attr_accessor :rec_ind
69
+ # @return [Date] Reference date for settlement
70
+ attr_accessor :ref_date
71
+ # @return [String] Document Number for Earmarked Funds
72
+ attr_accessor :res_doc
73
+ # @return [String] Earmarked Funds: Document Item
74
+ attr_accessor :res_item
75
+ # @return [String] Internal Key for Real Estate Object
76
+ attr_accessor :rl_est_key
77
+ # @return [String] Schedule Line Number
78
+ attr_accessor :sched_line
79
+ # @return [String] Sales and Distribution Document Number
80
+ attr_accessor :sd_doc
81
+ # @return [String] Sequential Number of Account Assignment
82
+ attr_accessor :serial_no
83
+ # @return [String] Asset Subnumber
84
+ attr_accessor :sub_number
85
+ # @return [String] Tax Jurisdiction
86
+ attr_accessor :taxjurcode
87
+ # @return [String] Tax on Sales/Purchases Code
88
+ attr_accessor :tax_code
89
+ # @return [String] Unloading Point
90
+ attr_accessor :unload_pt
91
+ # @return [String] Work Breakdown Structure Element (WBS Element)
92
+ attr_accessor :wbs_element
93
+ end
@@ -0,0 +1,115 @@
1
+ # class used to represent POADDRDELIVERY. Used internally
2
+ class PoAddrDelivery
3
+ # @return [String] Address number
4
+ attr_accessor :addr_no
5
+ # @return [String] Address notes
6
+ attr_accessor :adr_notes
7
+ # @return [String] old: building (no. or abbreviation)
8
+ attr_accessor :building
9
+ # @return [String] Building (Number or Code)
10
+ attr_accessor :build_long
11
+ # @return [String] City file test status
12
+ attr_accessor :chckstatus
13
+ # @return [String] City
14
+ attr_accessor :city
15
+ # @return [String] City code for city/street file
16
+ attr_accessor :city_no
17
+ # @return [String] Communication Method (Key) (Business Address Services)
18
+ attr_accessor :comm_type
19
+ # @return [String] Country Key
20
+ attr_accessor :country
21
+ # @return [String] Country ISO code
22
+ attr_accessor :countryiso
23
+ # @return [String] Customer
24
+ attr_accessor :customer
25
+ # @return [String] c/o name
26
+ attr_accessor :c_o_name
27
+ # @return [String] (Not Supported) Post Delivery District
28
+ attr_accessor :deliv_dis
29
+ # @return [String] District code for City and Street file
30
+ attr_accessor :distrct_no
31
+ # @return [String] District
32
+ attr_accessor :district
33
+ # @return [String] E-Mail Address
34
+ attr_accessor :e_mail
35
+ # @return [String] First fax no.: extension
36
+ attr_accessor :fax_extens
37
+ # @return [String] First fax no.: dialling code+number
38
+ attr_accessor :fax_number
39
+ # @return [String] Floor in building
40
+ attr_accessor :floor
41
+ # @return [String] Form of address text
42
+ attr_accessor :formofaddr
43
+ # @return [String] House Number
44
+ attr_accessor :house_no
45
+ # @return [String] House number supplement
46
+ attr_accessor :house_no2
47
+ # @return [Integer] Language Key
48
+ attr_accessor :langu
49
+ # @return [String] 2-Character SAP Language Code
50
+ attr_accessor :langu_iso
51
+ # @return [String] Street 5
52
+ attr_accessor :location
53
+ # @return [String] Name 1
54
+ attr_accessor :name
55
+ # @return [String] Name 2
56
+ attr_accessor :name_2
57
+ # @return [String] Name 3
58
+ attr_accessor :name_3
59
+ # @return [String] Name 4
60
+ attr_accessor :name_4
61
+ # @return [String] City PO box code (City file)
62
+ attr_accessor :pboxcit_no
63
+ # @return [String] City postal code
64
+ attr_accessor :postl_cod1
65
+ # @return [String] PO Box Postal Code
66
+ attr_accessor :postl_cod2
67
+ # @return [String] Company Postal Code (for Large Customers)
68
+ attr_accessor :postl_cod3
69
+ # @return [String] PO Box
70
+ attr_accessor :po_box
71
+ # @return [String] PO Box city
72
+ attr_accessor :po_box_cit
73
+ # @return [String] Item Number of Purchasing Document
74
+ attr_accessor :po_item
75
+ # @return [String] Regional structure grouping
76
+ attr_accessor :regiogroup
77
+ # @return [String] Region (State, Province, County)
78
+ attr_accessor :region
79
+ # @return [String] Room or Appartment Number
80
+ attr_accessor :room_no
81
+ # @return [String] Subcontracting vendor
82
+ attr_accessor :sc_vendor
83
+ # @return [String] Search Term 1
84
+ attr_accessor :sort1
85
+ # @return [String] Search Term 2
86
+ attr_accessor :sort2
87
+ # @return [String] Street
88
+ attr_accessor :street
89
+ # @return [String] Street
90
+ attr_accessor :street_lng
91
+ # @return [String] Street Number for City/Street File
92
+ attr_accessor :street_no
93
+ # @return [String] (Not Supported) Abbreviation of Street Name
94
+ attr_accessor :str_abbr
95
+ # @return [String] Street 2
96
+ attr_accessor :str_suppl1
97
+ # @return [String] Street 3
98
+ attr_accessor :str_suppl2
99
+ # @return [String] Street 4
100
+ attr_accessor :str_suppl3
101
+ # @return [String] Vendor to be supplied/who is to receive delivery
102
+ attr_accessor :supp_vendor
103
+ # @return [String] Tax Jurisdiction
104
+ attr_accessor :taxjurcode
105
+ # @return [String] First Telephone No.: Extension
106
+ attr_accessor :tel1_ext
107
+ # @return [String] First telephone no.: dialling code+number
108
+ attr_accessor :tel1_numbr
109
+ # @return [String] Address time zone
110
+ attr_accessor :time_zone
111
+ # @return [String] Title text
112
+ attr_accessor :title
113
+ # @return [String] Transportation zone to or from which the goods are delivered
114
+ attr_accessor :transpzone
115
+ end
@@ -0,0 +1,55 @@
1
+ # class used to represent POALLVERSIONS. Used internally
2
+ class PoAllVersions
3
+ # @return [String] Status version completed
4
+ attr_accessor :completed
5
+ # @return [String] Name of Person Who Created the Object
6
+ attr_accessor :created_by
7
+ # @return [Date] Date on Which Record Was Created
8
+ attr_accessor :cr_on
9
+ # @return [Integer] Currency Key
10
+ attr_accessor :currency
11
+ # @return [String] ISO code currency
12
+ attr_accessor :currency_iso
13
+ # @return [String] Deletion indicator in purchasing document
14
+ attr_accessor :delete_ind
15
+ # @return [String] Description of version
16
+ attr_accessor :description
17
+ # @return [String] Object Number in Purchasing
18
+ attr_accessor :doc_number
19
+ # @return [String] Purchasing Document Category
20
+ attr_accessor :doc_type
21
+ # @return [String] Purchasing object: item
22
+ attr_accessor :item_number
23
+ # @return [Integer] Net Order Value in PO Currency
24
+ attr_accessor :net_value
25
+ # @return [Date] Posting date of version
26
+ attr_accessor :post_date
27
+ # @return [String] Reason for change
28
+ attr_accessor :reason
29
+ # @return [String] Entry time
30
+ attr_accessor :rec_time
31
+ # @return [String] Name of approving buyer
32
+ attr_accessor :releaseby_pur
33
+ # @return [Date] Date of buyer approval
34
+ attr_accessor :releasedate_pur
35
+ # @return [String] Name of person effecting release
36
+ attr_accessor :released_by
37
+ # @return [String] Time of buyer approval
38
+ attr_accessor :releasetime_pur
39
+ # @return [Date] Date of release
40
+ attr_accessor :release_date
41
+ # @return [String] Time of release
42
+ attr_accessor :release_time
43
+ # @return [String] Person requesting change
44
+ attr_accessor :req_by
45
+ # @return [String] External Change Number of Version
46
+ attr_accessor :req_by_ext
47
+ # @return [String] Version status
48
+ attr_accessor :status
49
+ # @return [String] Old processing state in purchasing document before version
50
+ attr_accessor :status_doc_old
51
+ # @return [Integer] Value change due to version
52
+ attr_accessor :value_changed
53
+ # @return [String] Version number in Purchasing
54
+ attr_accessor :version
55
+ end