[Home] [Help]
PACKAGE BODY: APPS.WIP_MOVPROC_PUB
Source
1 PACKAGE BODY wip_movProc_pub AS
2 /* $Header: wipmvpbb.pls 120.0 2005/05/24 18:03:19 appldev noship $*/
3
4 /*************************************************************************
5 * This procedure should be called if caller want to process one record
6 * at a time.
7 *************************************************************************/
8 PROCEDURE processInterface(p_txn_id IN NUMBER,
9 p_do_backflush IN VARCHAR2 := NULL,
10 p_commit IN VARCHAR2,
11 x_returnStatus OUT NOCOPY VARCHAR2,
12 x_errorMsg OUT NOCOPY VARCHAR2) IS
13
14 CURSOR c_errors(p_transaction_id NUMBER) IS
15 SELECT error_column,
16 error_message
17 FROM wip_txn_interface_errors
18 WHERE transaction_id = p_transaction_id;
19
20 l_returnStatus VARCHAR2(1);
21 l_do_backflush VARCHAR2(1);
22 l_params wip_logger.param_tbl_t;
23 l_groupID NUMBER;
24 l_logLevel NUMBER := fnd_log.g_current_runtime_level;
25 l_errors c_errors%ROWTYPE;
26 BEGIN
27
28 IF(l_logLevel <= WIP_CONSTANTS.TRACE_LOGGING) THEN
29 l_params(1).paramName := 'p_txn_id';
30 l_params(1).paramValue := p_txn_id;
31 wip_logger.entryPoint(p_procName => 'wip_movProc_pub.processInterface',
32 p_params => l_params,
33 x_returnStatus => l_returnStatus);
34
35 END IF;
36
37 SELECT group_id
38 INTO l_groupID
39 FROM wip_move_txn_interface
40 WHERE transaction_id = p_txn_id
41 AND process_phase = WIP_CONSTANTS.MOVE_VAL
42 AND process_status = WIP_CONSTANTS.RUNNING
43 AND group_id IS NOT NULL;
44
45 IF (p_do_backflush = fnd_api.g_false) THEN
46 l_do_backflush := fnd_api.g_false;
47 ELSE
48 l_do_backflush := fnd_api.g_true;
49 END IF;
50
51 wip_movProc_priv.processIntf(p_group_id => l_groupID,
52 p_child_txn_id => -1,
53 p_mtl_header_id => -1,
54 p_proc_phase => WIP_CONSTANTS.MOVE_VAL,
55 p_time_out => 0,
56 p_move_mode => WIP_CONSTANTS.BACKGROUND,
57 p_bf_mode => WIP_CONSTANTS.ONLINE,
58 p_mtl_mode => WIP_CONSTANTS.ONLINE,
59 p_endDebug => fnd_api.g_false,
60 p_initMsgList => fnd_api.g_true,
61 p_insertAssy => fnd_api.g_true,
62 p_do_backflush => l_do_backflush,
63 x_returnStatus => x_returnStatus);
64
65 IF(x_returnStatus <> fnd_api.g_ret_sts_success) THEN
66 raise fnd_api.g_exc_error;
67 END IF;
68
69 IF(fnd_api.to_boolean(p_commit)) THEN
70 COMMIT;
71 END IF;
72
73 IF (l_logLevel <= wip_constants.trace_logging) THEN
74 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
75 p_procReturnStatus => x_returnStatus,
76 p_msg => 'procedure complete',
77 x_returnStatus => l_returnStatus);
78 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
79 END IF;
80 EXCEPTION
81 WHEN fnd_api.g_exc_error THEN
82 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
83
84 FOR l_errors IN c_errors(p_transaction_id => p_txn_id) LOOP
85 x_errorMsg := x_errorMsg || l_errors.error_column ||':' ||
86 l_errors.error_message || '; ';
87 END LOOP;
88 x_errorMsg := substr(x_errorMsg, 1, 1000);
89
90 IF (l_logLevel <= wip_constants.trace_logging) THEN
91 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
92 p_procReturnStatus => x_returnStatus,
93 p_msg => 'wip_movProc_priv.processIntf failed',
94 x_returnStatus => l_returnStatus);
95 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
96 END IF;
97
98 WHEN TOO_MANY_ROWS THEN
99 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
100 fnd_message.set_name('WIP', 'WIP_NOT_VALID');
101 fnd_message.set_token('ENTITY', 'TRANSACTION_ID');
102 x_errorMsg := substr(fnd_message.get, 1, 1000);
103
104 IF (l_logLevel <= wip_constants.trace_logging) THEN
105 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
106 p_procReturnStatus => x_returnStatus,
107 p_msg => 'to many rows: ' || SQLERRM,
108 x_returnStatus => l_returnStatus);
109 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
110 END IF;
111
112 WHEN NO_DATA_FOUND THEN
113 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
114 fnd_message.set_name('WIP', 'WIP_NOT_VALID');
115 fnd_message.set_token('ENTITY',
116 'TRANSACTION_ID/GROUP_ID/PROCESS_PHASE/PROCESS_STATUS');
117 x_errorMsg := substr(fnd_message.get, 1, 1000);
118
119 IF (l_logLevel <= wip_constants.trace_logging) THEN
120 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
121 p_procReturnStatus => x_returnStatus,
122 p_msg => 'no data found: ' || SQLERRM,
123 x_returnStatus => l_returnStatus);
124 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
125 END IF;
126
127 WHEN others THEN
128 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
129 x_errorMsg := 'unexpected error: ' || SQLERRM || 'SQLCODE = ' || SQLCODE;
130 IF (l_logLevel <= wip_constants.trace_logging) THEN
131 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
132 p_procReturnStatus => x_returnStatus,
133 p_msg => x_errorMsg,
134 x_returnStatus => l_returnStatus);
135 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
136 END IF;
137
138 END processInterface;
139
140 /*************************************************************************
141 * This procedure should be called if caller want to do batch processing
142 * for multiple records in WMTI.
143 *************************************************************************/
144 PROCEDURE processInterface(p_group_id IN NUMBER,
145 p_do_backflush IN VARCHAR2 := NULL,
146 p_commit IN VARCHAR2,
147 x_returnStatus OUT NOCOPY VARCHAR2) IS
148 l_returnStatus VARCHAR2(1);
149 l_do_backflush VARCHAR2(1);
150 l_params wip_logger.param_tbl_t;
151 l_groupID NUMBER;
152 l_logLevel NUMBER := fnd_log.g_current_runtime_level;
153 BEGIN
154
155 IF(l_logLevel <= WIP_CONSTANTS.TRACE_LOGGING) THEN
156 l_params(1).paramName := 'p_group_id';
157 l_params(1).paramValue := p_group_id;
158 wip_logger.entryPoint(p_procName => 'wip_movProc_pub.processInterface',
159 p_params => l_params,
160 x_returnStatus => l_returnStatus);
161
162 END IF;
163
164 IF (p_do_backflush = fnd_api.g_false) THEN
165 l_do_backflush := fnd_api.g_false;
166 ELSE
167 l_do_backflush := fnd_api.g_true;
168 END IF;
169
170 wip_movProc_priv.processIntf(p_group_id => p_group_id,
171 p_child_txn_id => -1,
172 p_mtl_header_id => -1,
173 p_proc_phase => WIP_CONSTANTS.MOVE_VAL,
174 p_time_out => 0,
175 p_move_mode => WIP_CONSTANTS.BACKGROUND,
176 p_bf_mode => WIP_CONSTANTS.ONLINE,
177 p_mtl_mode => WIP_CONSTANTS.ONLINE,
178 p_endDebug => fnd_api.g_false,
179 p_initMsgList => fnd_api.g_true,
180 p_insertAssy => fnd_api.g_true,
181 p_do_backflush => l_do_backflush,
182 x_returnStatus => x_returnStatus);
183
184 IF(x_returnStatus <> fnd_api.g_ret_sts_success) THEN
185 raise fnd_api.g_exc_error;
186 END IF;
187
188 IF(fnd_api.to_boolean(p_commit)) THEN
189 COMMIT;
190 END IF;
191
192 IF (l_logLevel <= wip_constants.trace_logging) THEN
193 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
194 p_procReturnStatus => x_returnStatus,
195 p_msg => 'no record in this group error out',
196 x_returnStatus => l_returnStatus);
197 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
198 END IF;
199 EXCEPTION
200
201 WHEN fnd_api.g_exc_error THEN
202 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
203
204 IF (l_logLevel <= wip_constants.trace_logging) THEN
205 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
206 p_procReturnStatus => x_returnStatus,
207 p_msg => 'some records in this group error out',
208 x_returnStatus => l_returnStatus);
209 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
210 END IF;
211
212 WHEN others THEN
213 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
214
215 IF (l_logLevel <= wip_constants.trace_logging) THEN
216 wip_logger.exitPoint(p_procName => 'wip_movProc_pub.processInterface',
217 p_procReturnStatus => x_returnStatus,
218 p_msg => 'unexpected error: ' || SQLERRM,
219 x_returnStatus => l_returnStatus);
220 wip_logger.cleanUp(x_returnStatus => l_returnStatus);
221 END IF;
222 END processInterface;
223
224 END wip_movProc_pub;