rnsap 0.4.1 → 0.4.9
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.
- checksums.yaml +4 -4
- data/lib/helper/rfc_helper.rb +19 -15
- data/lib/helper/util_helper.rb +39 -0
- data/lib/po_detail/all.rb +27 -0
- data/lib/po_detail/po_account.rb +93 -0
- data/lib/po_detail/po_addrdelivery.rb +115 -0
- data/lib/po_detail/po_all_versions.rb +55 -0
- data/lib/po_detail/po_components.rb +53 -0
- data/lib/po_detail/po_cond.rb +91 -0
- data/lib/po_detail/po_cond_header.rb +91 -0
- data/lib/po_detail/po_confirmation.rb +39 -0
- data/lib/po_detail/po_contract_limits.rb +21 -0
- data/lib/po_detail/po_exp_imp_header.rb +7 -0
- data/lib/po_detail/po_exp_imp_item.rb +21 -0
- data/lib/po_detail/po_extension_out.rb +13 -0
- data/lib/po_detail/po_header.rb +131 -0
- data/lib/po_detail/po_history.rb +107 -0
- data/lib/po_detail/po_history_ma.rb +37 -0
- data/lib/po_detail/po_history_totals.rb +51 -0
- data/lib/po_detail/po_inv_plan_header.rb +49 -0
- data/lib/po_detail/po_inv_plan_item.rb +51 -0
- data/lib/po_detail/po_item.rb +359 -0
- data/lib/po_detail/po_limits.rb +47 -0
- data/lib/po_detail/po_partner.rb +11 -0
- data/lib/po_detail/po_schedule.rb +59 -0
- data/lib/po_detail/po_serial_number.rb +13 -0
- data/lib/po_detail/po_services.rb +137 -0
- data/lib/po_detail/po_shipping_exp.rb +53 -0
- data/lib/po_detail/po_srv_access_values.rb +17 -0
- data/lib/po_detail/po_text_header.rb +13 -0
- data/lib/po_detail/po_text_item.rb +13 -0
- data/lib/po_release_info/all.rb +1 -0
- data/lib/po_release_info/po_release_final.rb +53 -0
- data/lib/preq_detail/all.rb +8 -0
- data/lib/preq_release_info/all.rb +4 -0
- data/lib/preq_release_info/preq_gen_release_info.rb +23 -0
- data/lib/preq_release_info/preq_release_final.rb +55 -0
- data/lib/preq_release_info/preq_release_posted.rb +55 -0
- data/lib/preq_release_info/preq_release_prerequisites.rb +55 -0
- data/lib/{preq_detail/preq_return.rb → return.rb} +1 -1
- data/lib/rnsap.rb +307 -61
- data/lib/rnsap_spec.rb +93 -0
- metadata +40 -2
@@ -0,0 +1,23 @@
|
|
1
|
+
# class used to represent GENERAL_RELEASE_INFO. Used internally
|
2
|
+
class PreqGenReleaseInfo
|
3
|
+
# @return [String] Item number of purchase requisition
|
4
|
+
attr_accessor :preq_item
|
5
|
+
# @return [String] Purchase Requisition Number
|
6
|
+
attr_accessor :preq_no
|
7
|
+
# @return [String] Release code
|
8
|
+
attr_accessor :rel_code
|
9
|
+
# @return [String] Description of release code
|
10
|
+
attr_accessor :rel_cod_tx
|
11
|
+
# @return [String] Release group
|
12
|
+
attr_accessor :rel_group
|
13
|
+
# @return [String] Description of release group
|
14
|
+
attr_accessor :rel_grp_tx
|
15
|
+
# @return [String] Release indicator
|
16
|
+
attr_accessor :rel_ind
|
17
|
+
# @return [String] Description of Release Indicator
|
18
|
+
attr_accessor :rel_ind_tx
|
19
|
+
# @return [String] Release Strategy
|
20
|
+
attr_accessor :rel_strat
|
21
|
+
# @return [String] Description of release strategy
|
22
|
+
attr_accessor :rel_str_tx
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# class used to represent RELEASE_FINAL. Used internally
|
2
|
+
class PreqReleaseFinal
|
3
|
+
# @return [String] Item number of purchase requisition
|
4
|
+
attr_accessor :preq_item
|
5
|
+
# @return [String] Purchase Requisition Number
|
6
|
+
attr_accessor :preq_no
|
7
|
+
# @return [String] Description of release code 1
|
8
|
+
attr_accessor :rel_cd_tx1
|
9
|
+
# @return [String] Description of release code 2
|
10
|
+
attr_accessor :rel_cd_tx2
|
11
|
+
# @return [String] Description of release code 3
|
12
|
+
attr_accessor :rel_cd_tx3
|
13
|
+
# @return [String] Description of release code 4
|
14
|
+
attr_accessor :rel_cd_tx4
|
15
|
+
# @return [String] Description of release code 5
|
16
|
+
attr_accessor :rel_cd_tx5
|
17
|
+
# @return [String] Description of release code 6
|
18
|
+
attr_accessor :rel_cd_tx6
|
19
|
+
# @return [String] Description of release code 7
|
20
|
+
attr_accessor :rel_cd_tx7
|
21
|
+
# @return [String] Description of release code
|
22
|
+
attr_accessor :rel_cd_tx8
|
23
|
+
# @return [String] Release code 1
|
24
|
+
attr_accessor :rel_code1
|
25
|
+
# @return [String] Release code 2
|
26
|
+
attr_accessor :rel_code2
|
27
|
+
# @return [String] Release code 3
|
28
|
+
attr_accessor :rel_code3
|
29
|
+
# @return [String] Release code 4
|
30
|
+
attr_accessor :rel_code4
|
31
|
+
# @return [String] Release code 5
|
32
|
+
attr_accessor :rel_code5
|
33
|
+
# @return [String] Release code 6
|
34
|
+
attr_accessor :rel_code6
|
35
|
+
# @return [String] Release code 7
|
36
|
+
attr_accessor :rel_code7
|
37
|
+
# @return [String] Release code 8
|
38
|
+
attr_accessor :rel_code8
|
39
|
+
# @return [String] Role resolution for workflow for release code 1
|
40
|
+
attr_accessor :rel_wf1
|
41
|
+
# @return [String] Role resolution for workflow for release code 2
|
42
|
+
attr_accessor :rel_wf2
|
43
|
+
# @return [String] Role resolution for workflow for release code 3
|
44
|
+
attr_accessor :rel_wf3
|
45
|
+
# @return [String] Role resolution for workflow for release code 4
|
46
|
+
attr_accessor :rel_wf4
|
47
|
+
# @return [String] Role resolution for workflow for release code 5
|
48
|
+
attr_accessor :rel_wf5
|
49
|
+
# @return [String] Role resolution for workflow for release code 6
|
50
|
+
attr_accessor :rel_wf6
|
51
|
+
# @return [String] Role resolution for workflow for release code 7
|
52
|
+
attr_accessor :rel_wf7
|
53
|
+
# @return [String] Role resolution for workflow for release code 8
|
54
|
+
attr_accessor :rel_wf8
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# class used to represent RELEASE_ALREADY_POSTED. Used internally
|
2
|
+
class PreqReleasePosted
|
3
|
+
# @return [String] Item number of purchase requisition
|
4
|
+
attr_accessor :preq_item
|
5
|
+
# @return [String] Purchase Requisition Number
|
6
|
+
attr_accessor :preq_no
|
7
|
+
# @return [String] Description of release code 1
|
8
|
+
attr_accessor :rel_cd_tx1
|
9
|
+
# @return [String] Description of release code 2
|
10
|
+
attr_accessor :rel_cd_tx2
|
11
|
+
# @return [String] Description of release code 3
|
12
|
+
attr_accessor :rel_cd_tx3
|
13
|
+
# @return [String] Description of release code 4
|
14
|
+
attr_accessor :rel_cd_tx4
|
15
|
+
# @return [String] Description of release code 5
|
16
|
+
attr_accessor :rel_cd_tx5
|
17
|
+
# @return [String] Description of release code 6
|
18
|
+
attr_accessor :rel_cd_tx6
|
19
|
+
# @return [String] Description of release code 7
|
20
|
+
attr_accessor :rel_cd_tx7
|
21
|
+
# @return [String] Description of release code
|
22
|
+
attr_accessor :rel_cd_tx8
|
23
|
+
# @return [String] Release code 1
|
24
|
+
attr_accessor :rel_code1
|
25
|
+
# @return [String] Release code 2
|
26
|
+
attr_accessor :rel_code2
|
27
|
+
# @return [String] Release code 3
|
28
|
+
attr_accessor :rel_code3
|
29
|
+
# @return [String] Release code 4
|
30
|
+
attr_accessor :rel_code4
|
31
|
+
# @return [String] Release code 5
|
32
|
+
attr_accessor :rel_code5
|
33
|
+
# @return [String] Release code 6
|
34
|
+
attr_accessor :rel_code6
|
35
|
+
# @return [String] Release code 7
|
36
|
+
attr_accessor :rel_code7
|
37
|
+
# @return [String] Release code 8
|
38
|
+
attr_accessor :rel_code8
|
39
|
+
# @return [String] Role resolution for workflow for release code 1
|
40
|
+
attr_accessor :rel_wf1
|
41
|
+
# @return [String] Role resolution for workflow for release code 2
|
42
|
+
attr_accessor :rel_wf2
|
43
|
+
# @return [String] Role resolution for workflow for release code 3
|
44
|
+
attr_accessor :rel_wf3
|
45
|
+
# @return [String] Role resolution for workflow for release code 4
|
46
|
+
attr_accessor :rel_wf4
|
47
|
+
# @return [String] Role resolution for workflow for release code 5
|
48
|
+
attr_accessor :rel_wf5
|
49
|
+
# @return [String] Role resolution for workflow for release code 6
|
50
|
+
attr_accessor :rel_wf6
|
51
|
+
# @return [String] Role resolution for workflow for release code 7
|
52
|
+
attr_accessor :rel_wf7
|
53
|
+
# @return [String] Role resolution for workflow for release code 8
|
54
|
+
attr_accessor :rel_wf8
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# class used to represent RELEASE_PREREQUISITES. Used internally
|
2
|
+
class PreqReleasePrerequisites
|
3
|
+
# @return [String] Item number of purchase requisition
|
4
|
+
attr_accessor :preq_item
|
5
|
+
# @return [String] Purchase Requisition Number
|
6
|
+
attr_accessor :preq_no
|
7
|
+
# @return [String] Description of release code 1
|
8
|
+
attr_accessor :rel_cd_tx1
|
9
|
+
# @return [String] Description of release code 2
|
10
|
+
attr_accessor :rel_cd_tx2
|
11
|
+
# @return [String] Description of release code 3
|
12
|
+
attr_accessor :rel_cd_tx3
|
13
|
+
# @return [String] Description of release code 4
|
14
|
+
attr_accessor :rel_cd_tx4
|
15
|
+
# @return [String] Description of release code 5
|
16
|
+
attr_accessor :rel_cd_tx5
|
17
|
+
# @return [String] Description of release code 6
|
18
|
+
attr_accessor :rel_cd_tx6
|
19
|
+
# @return [String] Description of release code 7
|
20
|
+
attr_accessor :rel_cd_tx7
|
21
|
+
# @return [String] Description of release code
|
22
|
+
attr_accessor :rel_cd_tx8
|
23
|
+
# @return [String] Release code 1
|
24
|
+
attr_accessor :rel_code1
|
25
|
+
# @return [String] Release code 2
|
26
|
+
attr_accessor :rel_code2
|
27
|
+
# @return [String] Release code 3
|
28
|
+
attr_accessor :rel_code3
|
29
|
+
# @return [String] Release code 4
|
30
|
+
attr_accessor :rel_code4
|
31
|
+
# @return [String] Release code 5
|
32
|
+
attr_accessor :rel_code5
|
33
|
+
# @return [String] Release code 6
|
34
|
+
attr_accessor :rel_code6
|
35
|
+
# @return [String] Release code 7
|
36
|
+
attr_accessor :rel_code7
|
37
|
+
# @return [String] Release code 8
|
38
|
+
attr_accessor :rel_code8
|
39
|
+
# @return [String] Role resolution for workflow for release code 1
|
40
|
+
attr_accessor :rel_wf1
|
41
|
+
# @return [String] Role resolution for workflow for release code 2
|
42
|
+
attr_accessor :rel_wf2
|
43
|
+
# @return [String] Role resolution for workflow for release code 3
|
44
|
+
attr_accessor :rel_wf3
|
45
|
+
# @return [String] Role resolution for workflow for release code 4
|
46
|
+
attr_accessor :rel_wf4
|
47
|
+
# @return [String] Role resolution for workflow for release code 5
|
48
|
+
attr_accessor :rel_wf5
|
49
|
+
# @return [String] Role resolution for workflow for release code 6
|
50
|
+
attr_accessor :rel_wf6
|
51
|
+
# @return [String] Role resolution for workflow for release code 7
|
52
|
+
attr_accessor :rel_wf7
|
53
|
+
# @return [String] Role resolution for workflow for release code 8
|
54
|
+
attr_accessor :rel_wf8
|
55
|
+
end
|
data/lib/rnsap.rb
CHANGED
@@ -2,18 +2,20 @@
|
|
2
2
|
|
3
3
|
require 'nwrfc'
|
4
4
|
require 'read_table/table_column'
|
5
|
-
|
6
|
-
require '
|
7
|
-
|
8
|
-
require 'preq_detail/
|
9
|
-
require '
|
10
|
-
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
|
5
|
+
|
6
|
+
require 'return'
|
7
|
+
|
8
|
+
require 'preq_detail/all'
|
9
|
+
require 'preq_release_info/all'
|
10
|
+
|
11
|
+
require 'po_detail/all'
|
12
|
+
require 'po_release_info/all'
|
13
|
+
|
14
14
|
require 'helper/rfc_helper'
|
15
|
+
require 'helper/util_helper'
|
15
16
|
|
16
17
|
include NWRFC
|
18
|
+
include UtilHelper
|
17
19
|
|
18
20
|
# Module for SAP helper methods. RnSap allows for a simpler
|
19
21
|
# manner to access SAP servers calling RFC BAPIs.
|
@@ -29,6 +31,9 @@ module RnSap
|
|
29
31
|
# keeps the SAP connection alive during the Sap instance lifecycle
|
30
32
|
attr_reader :conn
|
31
33
|
|
34
|
+
INT_TYPES ||= ['b','N']
|
35
|
+
FLOAT_TYPES ||= ['P']
|
36
|
+
DATE_TYPES ||=['D']
|
32
37
|
# Constructor requires to receive connection parameters,
|
33
38
|
# a hash containint necessary information to logon to SAP
|
34
39
|
# @param conn_parms [Hash] SAP Connection Parameters
|
@@ -41,6 +46,28 @@ module RnSap
|
|
41
46
|
conn.disconnect
|
42
47
|
end
|
43
48
|
|
49
|
+
def commit(conn)
|
50
|
+
|
51
|
+
#-- Execute BAPI_TRANSACTION_COMMIT
|
52
|
+
fn_commit = conn.get_function('BAPI_TRANSACTION_COMMIT')
|
53
|
+
fn_commit = fn_commit.get_function_call
|
54
|
+
fn_commit[:WAIT] = 'X'
|
55
|
+
|
56
|
+
fn_commit.invoke
|
57
|
+
|
58
|
+
api_return_success({tb_return: fn_commit[:RETURN]})
|
59
|
+
end
|
60
|
+
|
61
|
+
def rollback(conn)
|
62
|
+
#-- Execute BAPI_TRANSACTION_ROLLBACK
|
63
|
+
fn_rollback = conn.get_function('BAPI_TRANSACTION_ROLLBACK')
|
64
|
+
fn_rollback = fn_rollback.get_function_call
|
65
|
+
|
66
|
+
fn_rollback.invoke
|
67
|
+
|
68
|
+
api_return_success({tb_return: fn_rollback[:RETURN]})
|
69
|
+
end
|
70
|
+
|
44
71
|
# Invokes SAP RFC_READ_TABLE function module remotely, passing
|
45
72
|
# the table to be read and receiving back a list of objects of that
|
46
73
|
# table.
|
@@ -118,13 +145,38 @@ module RnSap
|
|
118
145
|
end
|
119
146
|
|
120
147
|
list = []
|
148
|
+
|
121
149
|
fc_read_table[:DATA].each do |row|
|
122
150
|
obj = base_obj.class.new
|
123
|
-
wa = row[:WA]
|
151
|
+
wa = row[:WA].split('|')
|
152
|
+
pos = -1
|
124
153
|
fields_down.each do |field|
|
154
|
+
pos = pos + 1
|
125
155
|
column = columns_hash[field.upcase]
|
126
|
-
value = wa[column.offset.to_i, column.length.to_i]
|
127
|
-
|
156
|
+
# value = wa[column.offset.to_i, column.length.to_i]
|
157
|
+
if INT_TYPES.include?(column.type)
|
158
|
+
value = wa[pos].to_i
|
159
|
+
eval("obj.#{field} = #{value}")
|
160
|
+
elsif FLOAT_TYPES.include?(column.type)
|
161
|
+
value = wa[pos].to_f
|
162
|
+
eval("obj.#{field} = #{value}")
|
163
|
+
elsif DATE_TYPES.include?(column.type)
|
164
|
+
value = wa[pos].strip
|
165
|
+
if value == '00000000'
|
166
|
+
eval("obj.#{field} = nil")
|
167
|
+
else
|
168
|
+
value = Date.new(
|
169
|
+
value[0..3],
|
170
|
+
value[4..5],
|
171
|
+
value[6..7]
|
172
|
+
)
|
173
|
+
eval("obj.#{field} = #{value}")
|
174
|
+
end
|
175
|
+
else
|
176
|
+
value = wa[pos].strip
|
177
|
+
eval("obj.#{field} = '#{value}'")
|
178
|
+
end
|
179
|
+
|
128
180
|
end
|
129
181
|
list << obj
|
130
182
|
end
|
@@ -146,68 +198,262 @@ module RnSap
|
|
146
198
|
fc_preq_detail.invoke
|
147
199
|
|
148
200
|
#-- Execute conversions for returned tables to a designated list (array)
|
149
|
-
preq_items = get_object_list(fc_preq_detail[:REQUISITION_ITEMS], PreqItem
|
150
|
-
preq_acct_assignment = get_object_list(fc_preq_detail[:REQUISITION_ACCOUNT_ASSIGNMENT], PreqAcctAssignment
|
151
|
-
preq_text = get_object_list(fc_preq_detail[:REQUISITION_TEXT], PreqText
|
152
|
-
preq_limits = get_object_list(fc_preq_detail[:REQUISITION_LIMITS], PreqLimits
|
153
|
-
preq_contract_limits = get_object_list(fc_preq_detail[:REQUISITION_CONTRACT_LIMITS], PreqContractLimits
|
154
|
-
preq_services = get_object_list(fc_preq_detail[:REQUISITION_SERVICES], PreqItem
|
155
|
-
preq_services_texts = get_object_list(fc_preq_detail[:REQUISITION_SERVICES_TEXTS], PreqServicesText
|
156
|
-
preq_srv_accass_values = get_object_list(fc_preq_detail[:REQUISITION_SRV_ACCASS_VALUES], PreqServicesAccassValues
|
157
|
-
|
201
|
+
preq_items = get_object_list(fc_preq_detail[:REQUISITION_ITEMS], PreqItem)
|
202
|
+
preq_acct_assignment = get_object_list(fc_preq_detail[:REQUISITION_ACCOUNT_ASSIGNMENT], PreqAcctAssignment)
|
203
|
+
preq_text = get_object_list(fc_preq_detail[:REQUISITION_TEXT], PreqText)
|
204
|
+
preq_limits = get_object_list(fc_preq_detail[:REQUISITION_LIMITS], PreqLimits)
|
205
|
+
preq_contract_limits = get_object_list(fc_preq_detail[:REQUISITION_CONTRACT_LIMITS], PreqContractLimits)
|
206
|
+
preq_services = get_object_list(fc_preq_detail[:REQUISITION_SERVICES], PreqItem)
|
207
|
+
preq_services_texts = get_object_list(fc_preq_detail[:REQUISITION_SERVICES_TEXTS], PreqServicesText)
|
208
|
+
preq_srv_accass_values = get_object_list(fc_preq_detail[:REQUISITION_SRV_ACCASS_VALUES], PreqServicesAccassValues)
|
209
|
+
tb_return = get_object_list(fc_preq_detail[:RETURN], Return)
|
158
210
|
|
159
|
-
{
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
211
|
+
retcode = tb_return.detect{|r| r.type == 'E'}
|
212
|
+
|
213
|
+
if retcode
|
214
|
+
api_return_error(retcode)
|
215
|
+
else
|
216
|
+
api_return_success({
|
217
|
+
preq_items: preq_items,
|
218
|
+
preq_acct_assignment: preq_acct_assignment,
|
219
|
+
preq_text: preq_text,
|
220
|
+
preq_limits: preq_limits,
|
221
|
+
preq_contract_limits: preq_contract_limits,
|
222
|
+
preq_services: preq_services,
|
223
|
+
preq_services_texts: preq_services_texts,
|
224
|
+
preq_srv_accass_values: preq_srv_accass_values,
|
225
|
+
tb_return: tb_return,
|
226
|
+
})
|
227
|
+
end
|
228
|
+
|
170
229
|
end
|
171
230
|
|
172
|
-
def preq_release_strategy_info(
|
173
|
-
|
231
|
+
def preq_release_strategy_info(preq = 0, item = "00000", rel_code = "")
|
232
|
+
#-- Execute BAPI_REQUISITION_GETRELINFO
|
233
|
+
fn_preq_rel_strat_info = @conn.get_function('BAPI_REQUISITION_GETRELINFO')
|
234
|
+
fn_preq_rel_strat_info = fn_preq_rel_strat_info.get_function_call
|
235
|
+
|
236
|
+
fn_preq_rel_strat_info[:NUMBER] = preq
|
237
|
+
fn_preq_rel_strat_info[:ITEM] = item
|
238
|
+
fn_preq_rel_strat_info[:REL_CODE] = rel_code
|
239
|
+
|
240
|
+
fn_preq_rel_strat_info.invoke
|
241
|
+
|
242
|
+
#-- Execute conversions for returned tables to a designated list (array)
|
243
|
+
preq_gen_release_info = get_object_list(fn_preq_rel_strat_info[:GENERAL_RELEASE_INFO], PreqGenReleaseInfo)
|
244
|
+
preq_release_prerequisites = get_object_list(fn_preq_rel_strat_info[:RELEASE_PREREQUISITES], PreqReleasePrerequisites)
|
245
|
+
preq_release_posted = get_object_list(fn_preq_rel_strat_info[:RELEASE_ALREADY_POSTED], PreqReleasePosted)
|
246
|
+
preq_release_final = get_object_list(fn_preq_rel_strat_info[:RELEASE_FINAL], PreqReleaseFinal)
|
247
|
+
tb_return = get_object_list(fn_preq_rel_strat_info[:RETURN], Return)
|
248
|
+
|
249
|
+
retcode = tb_return.detect{|r| r.type == 'E'}
|
250
|
+
|
251
|
+
if retcode
|
252
|
+
api_return_error(retcode)
|
253
|
+
else
|
254
|
+
api_return_success({
|
255
|
+
preq_gen_release_info: preq_gen_release_info,
|
256
|
+
preq_release_prerequisites: preq_release_prerequisites,
|
257
|
+
preq_release_posted: preq_release_posted,
|
258
|
+
preq_release_final: preq_release_final,
|
259
|
+
tb_return: tb_return,
|
260
|
+
})
|
261
|
+
end
|
174
262
|
end
|
175
263
|
|
176
|
-
def
|
177
|
-
|
264
|
+
def preq_release(preq = 0, rel_code = "", no_commit="", item="00000", use_exceptions="")
|
265
|
+
#Validate if will release by item ou general
|
266
|
+
if item == "00000" or item == nil or item.empty?
|
267
|
+
#-- Execute BAPI_REQUISITION_RELEASE_GEN
|
268
|
+
fn_preq_exec_release = @conn.get_function('BAPI_REQUISITION_RELEASE_GEN')
|
269
|
+
fn_preq_exec_release = fn_preq_exec_release.get_function_call
|
270
|
+
else
|
271
|
+
#-- Execute BAPI_REQUISITION_RELEASE
|
272
|
+
fn_preq_exec_release = @conn.get_function('BAPI_REQUISITION_RELEASE')
|
273
|
+
fn_preq_exec_release = fn_preq_exec_release.get_function_call
|
274
|
+
fn_preq_exec_release[:ITEM] = item
|
275
|
+
fn_preq_exec_release[:USE_EXCEPTIONS] = use_exceptions
|
276
|
+
end
|
277
|
+
|
278
|
+
fn_preq_exec_release[:NUMBER] = preq
|
279
|
+
fn_preq_exec_release[:REL_CODE] = rel_code
|
280
|
+
fn_preq_exec_release[:NO_COMMIT_WORK] = no_commit
|
281
|
+
|
282
|
+
fn_preq_exec_release.invoke
|
283
|
+
|
284
|
+
tb_return = get_object_list(fn_preq_exec_release[:RETURN], Return)
|
285
|
+
|
286
|
+
retcode = tb_return.detect{|r| r.type == 'E'}
|
287
|
+
|
288
|
+
if retcode
|
289
|
+
api_return_error(retcode)
|
290
|
+
else
|
291
|
+
api_return_success({
|
292
|
+
status_new: fn_preq_exec_release[:REL_STATUS_NEW],
|
293
|
+
indicator_new: fn_preq_exec_release[:REL_INDICATOR_NEW],
|
294
|
+
tb_return: tb_return,
|
295
|
+
})
|
296
|
+
end
|
178
297
|
end
|
179
298
|
|
180
|
-
def
|
181
|
-
|
299
|
+
def po_detail(po = 0, acc_assignment = "", item_text = "", header_text = "", delivery_address = "", version = "", services = "", serialnumbers = "", invoiceplan = "")
|
300
|
+
#-- Execute BAPI_PO_GETDETAIL1
|
301
|
+
fn_po_detail = @conn.get_function('BAPI_PO_GETDETAIL1')
|
302
|
+
fc_po_detail = fn_po_detail.get_function_call
|
303
|
+
|
304
|
+
fc_po_detail[:PURCHASEORDER] = po
|
305
|
+
fc_po_detail[:ACCOUNT_ASSIGNMENT] = acc_assignment
|
306
|
+
fc_po_detail[:ITEM_TEXT] = item_text
|
307
|
+
fc_po_detail[:HEADER_TEXT] = header_text
|
308
|
+
fc_po_detail[:DELIVERY_ADDRESS] = delivery_address
|
309
|
+
fc_po_detail[:VERSION] = version
|
310
|
+
fc_po_detail[:SERVICES] = services
|
311
|
+
fc_po_detail[:SERIALNUMBERS] = serialnumbers
|
312
|
+
fc_po_detail[:INVOICEPLAN] = invoiceplan
|
313
|
+
|
314
|
+
fc_po_detail.invoke
|
315
|
+
|
316
|
+
#-- Execute conversions for returned tables to a designated list (array)
|
317
|
+
po_item = get_object_list(fc_po_detail[:POITEM], PoItem)
|
318
|
+
po_addrdelivery = get_object_list(fc_po_detail[:POADDRDELIVERY], PoAddrDelivery)
|
319
|
+
po_schedule = get_object_list(fc_po_detail[:POSCHEDULE], PoSchedule)
|
320
|
+
po_account = get_object_list(fc_po_detail[:POACCOUNT], PoAccount)
|
321
|
+
po_cond_header = get_object_list(fc_po_detail[:POCONDHEADER], PoCondHeader)
|
322
|
+
po_cond = get_object_list(fc_po_detail[:POCOND], PoCond)
|
323
|
+
po_limits = get_object_list(fc_po_detail[:POLIMITS], PoLimits)
|
324
|
+
po_contract_limits = get_object_list(fc_po_detail[:POCONTRACTLIMITS], PoContractLimits)
|
325
|
+
po_services = get_object_list(fc_po_detail[:POSERVICES], PoServices)
|
326
|
+
po_srv_access_values = get_object_list(fc_po_detail[:POSRVACCESSVALUES], PoSrvAccessValues)
|
327
|
+
po_text_header = get_object_list(fc_po_detail[:POTEXTHEADER], PoTextHeader)
|
328
|
+
po_text_item = get_object_list(fc_po_detail[:POTEXTITEM], PoTextItem)
|
329
|
+
po_exp_imp_item = get_object_list(fc_po_detail[:POEXPIMPITEM], PoExpImpItem)
|
330
|
+
po_components = get_object_list(fc_po_detail[:POCOMPONENTS], PoComponents)
|
331
|
+
po_shipping_exp = get_object_list(fc_po_detail[:POSHIPPINGEXP], PoShippingExp)
|
332
|
+
po_history = get_object_list(fc_po_detail[:POHISTORY], PoHistory)
|
333
|
+
po_history_totals = get_object_list(fc_po_detail[:POHISTORY_TOTALS], PoHistoryTotals)
|
334
|
+
po_confirmation = get_object_list(fc_po_detail[:POCONFIRMATION], PoConfirmation)
|
335
|
+
po_all_versions = get_object_list(fc_po_detail[:ALLVERSIONS], PoAllVersions)
|
336
|
+
po_partner = get_object_list(fc_po_detail[:POPARTNER], PoPartner)
|
337
|
+
po_extension_out = get_object_list(fc_po_detail[:EXTENSIONOUT], PoExtensionOut)
|
338
|
+
po_serial_number = get_object_list(fc_po_detail[:SERIALNUMBER], PoSerialNumber)
|
339
|
+
po_inv_plan_header = get_object_list(fc_po_detail[:INVPLANHEADER], PoInvPlanHeader)
|
340
|
+
po_inv_plan_item = get_object_list(fc_po_detail[:INVPLANITEM], PoInvPlanItem)
|
341
|
+
po_history_ma = get_object_list(fc_po_detail[:POHISTORY_MA], PoHistoryMa)
|
342
|
+
po_header = get_object(fc_po_detail[:POHEADER], PoHeader)
|
343
|
+
po_exp_imp_header = get_object(fc_po_detail[:POEXPIMPHEADER], PoExpImpHeader)
|
344
|
+
tb_return = get_object_list(fc_po_detail[:RETURN], Return)
|
345
|
+
|
346
|
+
retcode = tb_return.detect{|r| r.type == 'E'}
|
347
|
+
|
348
|
+
if retcode
|
349
|
+
api_return_error(retcode)
|
350
|
+
else
|
351
|
+
api_return_success({
|
352
|
+
po_item: po_item,
|
353
|
+
po_addrdelivery: po_addrdelivery,
|
354
|
+
po_schedule: po_schedule,
|
355
|
+
po_account: po_account,
|
356
|
+
po_cond_header: po_cond_header,
|
357
|
+
po_cond: po_cond,
|
358
|
+
po_limits: po_limits,
|
359
|
+
po_contract_limits: po_contract_limits,
|
360
|
+
po_services: po_services,
|
361
|
+
po_srv_access_values: po_srv_access_values,
|
362
|
+
po_text_header: po_text_header,
|
363
|
+
po_text_item: po_text_item,
|
364
|
+
po_exp_imp_item: po_exp_imp_item,
|
365
|
+
po_components: po_components,
|
366
|
+
po_shipping_exp: po_shipping_exp,
|
367
|
+
po_history: po_history,
|
368
|
+
po_history_totals: po_history_totals,
|
369
|
+
po_confirmation: po_confirmation,
|
370
|
+
po_all_versions: po_all_versions,
|
371
|
+
po_partner: po_partner,
|
372
|
+
po_extension_out: po_extension_out,
|
373
|
+
po_serial_number: po_serial_number,
|
374
|
+
po_inv_plan_header: po_inv_plan_header,
|
375
|
+
po_inv_plan_item: po_inv_plan_item,
|
376
|
+
po_history_ma: po_history_ma,
|
377
|
+
po_header: po_header,
|
378
|
+
po_exp_imp_header: po_exp_imp_header,
|
379
|
+
tb_return: tb_return,
|
380
|
+
})
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def po_release_strategy_info(po = 0, po_rel_code = "")
|
385
|
+
#-- Execute BAPI_PO_GETRELINFO
|
386
|
+
fn_po_rel_strat_info = @conn.get_function('BAPI_PO_GETRELINFO')
|
387
|
+
fc_po_rel_strat_info = fn_po_rel_strat_info.get_function_call
|
388
|
+
|
389
|
+
fc_po_rel_strat_info[:PURCHASEORDER] = po
|
390
|
+
fc_po_rel_strat_info[:PO_REL_CODE] = po_rel_code
|
391
|
+
|
392
|
+
fc_po_rel_strat_info.invoke
|
393
|
+
|
394
|
+
#-- Execute conversions for returned tables to a designated list (array)
|
395
|
+
po_release_final = get_object_list(fc_po_rel_strat_info[:RELEASE_FINAL], PoReleaseFinal.to_s)
|
396
|
+
tb_return = get_object_list(fc_po_rel_strat_info[:RETURN], Return.to_s)
|
397
|
+
|
398
|
+
retcode = tb_return.detect{|r| r.type == 'E'}
|
399
|
+
|
400
|
+
if retcode
|
401
|
+
api_return_error(retcode)
|
402
|
+
else
|
403
|
+
api_return_success({
|
404
|
+
po_release_final: po_release_final,
|
405
|
+
tb_return: tb_return,
|
406
|
+
})
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
# Performs SAP Authority check on a certain authorization
|
411
|
+
# object. For more details on SAP authorization,
|
412
|
+
# this link will provide good details:
|
413
|
+
# * https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a92195a9-0b01-0010-909c-f330ea4a585c&overridelayout=true
|
414
|
+
# * https://blogs.sap.com/2020/11/14/some-important-information-about-sap-authorization-objects/
|
415
|
+
# @param user [String] SAP userid for which authorization will be performed
|
416
|
+
# @param auth_object [String] Authorization object to be checked in SAP
|
417
|
+
# @param field [String] Authorization field checked within the authorization object
|
418
|
+
# @param value [String] Authorization value to be checked. (i.e. 01 for creation, 02 for change, XX for release code)
|
419
|
+
def authority_check(user, auth_object, field, value)
|
420
|
+
#-- Execute AUTHORITY_CHECK
|
421
|
+
function = @conn.get_function('AUTHORITY_CHECK')
|
422
|
+
fun_call = function.get_function_call
|
423
|
+
|
424
|
+
fun_call[:USER] = user
|
425
|
+
fun_call[:OBJECT] = auth_object
|
426
|
+
fun_call[:FIELD1] = field
|
427
|
+
fun_call[:VALUE1] = value
|
428
|
+
|
429
|
+
begin
|
430
|
+
fun_call.invoke
|
431
|
+
rescue Exception => ex
|
432
|
+
if ex.to_s.include?('USER_IS_AUTHORIZED')
|
433
|
+
api_return(0,'Authorized');
|
434
|
+
else
|
435
|
+
api_return(8,'User is not authorized.')
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
def api_return_success(obj=nil )
|
442
|
+
UtilHelper.api_return(0, 'Success!', obj)
|
443
|
+
end
|
444
|
+
|
445
|
+
def api_return_error(obj={}, exception=nil)
|
446
|
+
UtilHelper.api_return(8, 'Error.', obj, exception)
|
447
|
+
end
|
448
|
+
|
449
|
+
def api_return(rc=0, message ='', obj=nil, exception=nil )
|
450
|
+
UtilHelper.api_return(rc, message, obj, exception)
|
182
451
|
end
|
183
452
|
|
184
453
|
private
|
185
454
|
|
186
455
|
attr_writer :conn
|
187
456
|
|
188
|
-
# def get_object_list(table, klass_name)
|
189
|
-
# list = []
|
190
|
-
# avoid_list = ['!','__','+', '=','!', '?','~','>', '<']
|
191
|
-
# table.each do |row|
|
192
|
-
# byebug
|
193
|
-
# obj = eval("#{klass_name}.new")
|
194
|
-
# obj.class.instance_methods.each do |method_name|
|
195
|
-
# begin
|
196
|
-
# if obj.respond_to?("#{method_name}=")
|
197
|
-
# unless avoid_list.any? { |word| method_name.to_s.include?(word)}
|
198
|
-
# value = row[method_name]
|
199
|
-
# eval("obj.#{method_name} = '#{value}'")
|
200
|
-
# end
|
201
|
-
# end
|
202
|
-
# rescue
|
203
|
-
# end
|
204
|
-
# end
|
205
|
-
# list.push(obj)
|
206
|
-
# end
|
207
|
-
|
208
|
-
# list
|
209
|
-
# end
|
210
|
-
|
211
457
|
# Dumps to the output the content of an object
|
212
458
|
def dump_instance_variables(obj)
|
213
459
|
puts "Class: #{obj.class} -> #{obj}"
|