1 PACKAGE BODY qa_mqa_results AS
2 /* $Header: qaresb.pls 120.2 2006/08/22 11:46:14 ntungare noship $ */
3
4
5 -- R12 Project MOAC 4637896
6 --
7 -- Moved several validation related functions and procedures to
8 -- qa_validation_api where they belong so that they can be
9 -- shared by other packages such as qa_ss_results. These are:
10 --
11 -- parse_id
12 -- parse_value
13 -- result_to_array (2 variants)
14 -- set_validation_flag (2 variants)
15 --
16
17 -- Bug 2701777
18 -- This function sets all elements as valid and action fired and is used
19 -- to insert records into qa_results without any validations.
20 -- The change is done for History plans.
21
22 PROCEDURE set_validation_flag_valid(
23 elements IN OUT NOCOPY qa_validation_api.ElementsArray) IS
24 i INTEGER := elements.FIRST;
25 BEGIN
26 WHILE i <= elements.LAST LOOP
27 elements(i).validation_flag := qa_validation_api.valid_element ||
28 qa_validation_api.action_fired;
29
30 i := elements.NEXT(i);
31 END LOOP;
32 END set_validation_flag_valid;
33
34
35 --
36 -- Post a result to the database. This is a wrapper to the QA API
37 -- qa_results_api.insert_row
38 -- Return 0 if OK
39 -- Return -1 if error.
40 --
41 FUNCTION post_result(
42 x_occurrence OUT NOCOPY NUMBER,
43 x_org_id IN NUMBER,
44 x_plan_id IN NUMBER,
45 x_spec_id IN NUMBER,
46 x_collection_id IN NUMBER,
47 x_result IN VARCHAR2,
48 x_result1 IN VARCHAR2, -- R12 Project MOAC 4637896, ID passing
49 x_result2 IN VARCHAR2, -- not used yet, for future expansion
50 x_enabled IN INTEGER,
51 x_committed IN INTEGER,
52 x_messages OUT NOCOPY VARCHAR2,
53 p_txn_header_id IN NUMBER DEFAULT NULL)
54 RETURN INTEGER IS
55
56 BEGIN
57 --
58 -- R12 Project MOAC 4637896
59 -- There is no difference between this method and
60 -- qa_ss_results.nontxn_post_result
61 -- The param p_txn_header_id is never used.
62 -- bso Sat Oct 1 18:05:47 PDT 2005
63 --
64
65 RETURN qa_ss_results.nontxn_post_result(
66 x_occurrence => x_occurrence,
67 x_org_id => x_org_id,
68 x_plan_id => x_plan_id,
69 x_spec_id => x_spec_id,
70 x_collection_id => x_collection_id,
71 x_result => x_result,
72 x_result1 => x_result1,
73 x_result2 => x_result2,
74 x_enabled => x_enabled,
75 x_committed => x_committed,
76 x_messages => x_messages);
77
78 END post_result;
79
80 -- anagarwa Thu Dec 19 15:43:27 PST 2002
81 -- Bug 2701777
82 -- This function is defined to insert records into qa_results without
83 -- any validations. The change is done for History plans.
84 -- It is an exact copy of post_result above with one difference:
85 -- It calls set_validation_flag_valid instead of set_validation_flag.
86 -- set_validation_flag_valid marks all elements as valid elements with
87 -- actions already fired.
88
89 FUNCTION post_result_with_no_validation(
90 x_occurrence OUT NOCOPY NUMBER,
91 x_org_id IN NUMBER,
92 x_plan_id IN NUMBER,
93 x_spec_id IN NUMBER,
94 x_collection_id IN NUMBER,
95 x_result IN VARCHAR2,
96 x_result1 IN VARCHAR2, -- R12 Project MOAC 4637896, ID passing
97 x_result2 IN VARCHAR2, -- not used yet, for future expansion
98 x_enabled IN INTEGER,
99 x_committed IN INTEGER,
100 x_messages OUT NOCOPY VARCHAR2,
101 p_txn_header_id IN NUMBER DEFAULT NULL)
102 RETURN INTEGER IS
103 elements qa_validation_api.ElementsArray;
104 error_array qa_validation_api.ErrorArray;
105 message_array qa_validation_api.MessageArray;
106 return_status VARCHAR2(1);
107 action_result VARCHAR2(1);
108 msg_count NUMBER;
109 msg_data VARCHAR2(2000);
110 y_spec_id NUMBER;
111 y_collection_id NUMBER;
112 y_committed VARCHAR2(1);
113 BEGIN
114 IF x_result IS NULL AND x_result1 IS NULL THEN
115 RETURN -1;
116 END IF;
117
118 IF x_committed = 1 THEN
119 y_committed := fnd_api.g_true;
120 ELSE
121 y_committed := fnd_api.g_false;
122 END IF;
123
124 --
125 -- Some input can be -1, if that's the case, set to null
126 --
127 IF x_collection_id = -1 THEN
128 y_collection_id := NULL;
129 ELSE
130 y_collection_id := x_collection_id;
131 END IF;
132 IF x_spec_id = -1 THEN
133 y_spec_id := NULL;
134 ELSE
135 y_spec_id := x_spec_id;
136 END IF;
137
138 --
139 -- The flatten string is a representation that looks like this:
140 --
141 -- 10=Item@101=Defected@102=20 ...
142 --
143 -- namely, it is an @ separated list of charID=value. In case
144 -- value contains @, then it is doubly encoded.
145 --
146 -- First task is to decode this string into the row_element
147 -- array.
148 --
149 elements := qa_validation_api.result_to_array(x_result);
150 set_validation_flag_valid(elements);
151
152 --
153 -- Bug 5383667
154 -- Shifted the id processing after the
155 -- set validation flag proc
156 -- ntungare
157 --
158 elements := qa_validation_api.id_to_array(x_result1, elements);
159
160 -- Bug 2290747.Added parameter p_txn_header_id to enable
161 -- history plan record when parent plan gets updated
162 -- rponnusa Mon Apr 1 22:25:49 PST 2002
163
164 qa_results_pub.insert_row(
165 p_api_version => 1.0,
166 p_org_id => x_org_id,
167 p_plan_id => x_plan_id,
168 p_spec_id => y_spec_id,
169 p_transaction_number => null,
170 p_transaction_id => null,
171 p_enabled_flag => x_enabled,
172 p_commit => y_committed,
173 x_collection_id => y_collection_id,
174 x_occurrence => x_occurrence,
175 x_row_elements => elements,
176 x_msg_count => msg_count,
177 x_msg_data => msg_data,
178 x_error_array => error_array,
179 x_message_array => message_array,
180 x_return_status => return_status,
181 x_action_result => action_result,
182 p_txn_header_id => p_txn_header_id);
183
184 IF qa_validation_api.no_errors(error_array) AND
185 return_status <> FND_API.G_RET_STS_ERROR AND
186 return_status <> FND_API.G_RET_STS_UNEXP_ERROR THEN
187 RETURN 0;
188 ELSE
189 qa_ss_results.get_error_messages(
190 error_array, x_plan_id, x_messages);
191 END IF;
192
193 RETURN -1;
194 END post_result_with_no_validation;
195
196
197 --
198 -- This overloaded method is for transaction only
199 -- Post a result to the database. This is a wrapper to the QA API
200 -- qa_results_api.insert_row
201 -- Return 0 if OK
202 -- Return -1 if error.
203 --
204 FUNCTION post_result(
205 x_occurrence OUT NOCOPY NUMBER,
206 x_org_id IN NUMBER,
207 x_plan_id IN NUMBER,
208 x_spec_id IN NUMBER,
209 x_collection_id IN NUMBER,
210 x_result IN VARCHAR2,
211 x_result1 IN VARCHAR2, -- R12 Project MOAC 4637896, ID passing
212 x_result2 IN VARCHAR2, -- not used yet, for future expansion
213 x_enabled IN INTEGER,
214 x_committed IN INTEGER,
215 x_transaction_number IN NUMBER,
216 x_messages OUT NOCOPY VARCHAR2,
217 p_txn_header_id IN NUMBER DEFAULT NULL)
218 RETURN INTEGER IS
219
220 BEGIN
221
222 --
223 -- R12 Project MOAC 4637896
224 -- There is no difference between this method and
225 -- qa_ss_results.post_result
226 -- The param p_txn_header_id is never used.
227 -- bso Sat Oct 1 18:05:47 PDT 2005
228 --
229
230 RETURN qa_ss_results.post_result(
231 x_occurrence => x_occurrence,
232 x_org_id => x_org_id,
233 x_plan_id => x_plan_id,
234 x_spec_id => x_spec_id,
235 x_collection_id => x_collection_id,
236 x_result => x_result,
237 x_result1 => x_result1,
238 x_result2 => x_result2,
239 x_enabled => x_enabled,
240 x_committed => x_committed,
241 x_transaction_number => x_transaction_number,
242 x_messages => x_messages);
243
244 END post_result;
245
246
247 --
248 -- Delete a result.
249 --
250 PROCEDURE delete_result(
251 x_plan_id IN NUMBER,
252 x_collection_id IN NUMBER,
253 x_occurrence IN NUMBER) IS
254 BEGIN
255 qa_ss_results.delete_result(
256 x_plan_id => x_plan_id,
257 x_collection_id => x_collection_id,
258 x_occurrence => x_occurrence);
259 END delete_result;
260
261 --
262 -- Batch delete a set of results (supply occurrences in
263 -- comma-separated list.)
264 --
265 PROCEDURE delete_results(
266 x_plan_id IN NUMBER,
267 x_collection_id IN NUMBER,
268 x_occurrences IN VARCHAR2) IS
269
270 BEGIN
271 qa_ss_results.delete_results(
272 x_plan_id => x_plan_id,
273 x_collection_id => x_collection_id,
274 x_occurrences => x_occurrences);
275 END delete_results;
276
277 --
278 -- Perform database commit. Do not use in transaction integration,
279 -- otherwise we will be committing the parent's data without their
280 -- knowing!
281 --
282 PROCEDURE commit_results IS
283 BEGIN
284 commit;
285 --
286 -- work on action later.
287 --
288 END commit_results;
289
290 END qa_mqa_results;