DBA Data[Home] [Help]

PACKAGE BODY: APPS.WSH_TRANSACTIONS_HISTORY_PKG

Source


1 PACKAGE BODY WSH_TRANSACTIONS_HISTORY_PKG  as
2 /* $Header: WSHTXHSB.pls 120.1 2005/06/01 16:27:52 appldev  $ */
3 
4 --
5 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_TRANSACTIONS_HISTORY_PKG';
6 --
7 PROCEDURE Create_Update_Txns_History(
8 p_txns_history_rec	IN OUT NOCOPY  Txns_History_Record_Type,
9 x_txns_id		OUT NOCOPY 	NUMBER,
10 x_return_status		OUT NOCOPY 	VARCHAR2
11 ) IS
12 
13 -- local variables
14 l_txns_id 		NUMBER;
15 l_exist_check 		NUMBER := 0;
16 
17 l_transaction_id	NUMBER;
18 x_transaction_id 	NUMBER;
19 l_transaction_status 	VARCHAR2(2);
20 
21 --exceptions
22 invalid_status 		exception;
23 invalid_action 		exception;
24 invalid_entity_type 	exception;
25 invalid_direction 	exception;
26 invalid_document_type 	exception;
27 
28 --cursors
29 CURSOR txn_cur IS
30 SELECT transaction_id, transaction_status
31 FROM wsh_transactions_history
32 WHERE	document_type = p_txns_history_rec.document_type  AND
33      	document_number = p_txns_history_rec.document_number  AND
34      	document_direction = p_txns_history_rec.document_direction  AND
35 	action_type = p_txns_history_rec.action_type  AND
36 	entity_number = p_txns_history_rec.entity_number  AND
37 	entity_type = p_txns_history_rec.entity_type  AND
38 	trading_partner_id = p_txns_history_rec.trading_partner_id
39 FOR UPDATE NOWAIT;
40      --k proj bmso
41 
42      l_status_code  VARCHAR2(5);
43      l_trans_status  VARCHAR2(5);
44      l_loc_interface_error_rec WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_type;
45      l_msg_data              VARCHAR2(3000);
46      l_number_of_warnings    NUMBER := 0;
47      l_number_of_errors      NUMBER := 0;
48      l_return_status         VARCHAR2(2);
49 
50      CURSOR c_get_del_status (v_doc_number varchar2) IS
51      SELECT wnd.status_code
52      FROM   wsh_new_deliveries wnd,
53             wsh_transactions_history wth
54      WHERE  wth.document_number = v_doc_number
55      AND wth.entity_type = 'DLVY'
56      AND wth.document_type = 'SR'
57      AND wth.document_direction = 'O'
58      AND wth.action_type = 'A'
59      AND wth.entity_number = wnd.name
60      ORDER BY wth.transaction_id desc;
61 
62 --
63 l_debug_on BOOLEAN;
64 --
65 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_UPDATE_TXNS_HISTORY';
66 --
67 BEGIN
68       --
69       l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
70       --
71       IF l_debug_on IS NULL
72       THEN
73           l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
74       END IF;
75       --
76       IF l_debug_on THEN
77 	wsh_debug_sv.push(l_module_name,'Create_Update_Txns_History');
78 	wsh_debug_sv.log (l_module_name, 'Transaction ID', p_txns_history_Rec.transaction_id);
79 	wsh_debug_sv.log (l_module_name, 'document Type', p_txns_history_rec.document_type);
80 	wsh_debug_sv.log (l_module_name, 'Doc Direction', p_txns_history_Rec.document_direction);
81 	wsh_debug_sv.log (l_module_name, 'Doc number', p_txns_history_Rec.document_number);
82 	wsh_debug_sv.log (l_module_name, 'Orig doc num', p_txns_history_Rec.orig_document_number);
83 	wsh_debug_sv.log (l_module_name, 'Entity Type', p_txns_history_Rec.entity_type);
84 	wsh_debug_sv.log (l_module_name, 'Entity number', p_txns_history_Rec.entity_number);
85 	wsh_debug_sv.log (l_module_name, 'TP id', p_txns_history_Rec.trading_partner_id);
86 	wsh_debug_sv.log (l_module_name, 'Action type', p_txns_history_Rec.action_type);
87 	wsh_debug_sv.log (l_module_name, 'Transaction status', p_txns_history_Rec.transaction_status);
88 	wsh_debug_sv.log (l_module_name, 'ECX Message ID', p_txns_history_Rec.ecx_message_id);
89 	wsh_debug_sv.log (l_module_name, 'Event Name', p_txns_history_Rec.event_name);
90 	wsh_debug_sv.log (l_module_name, 'Event Key', p_txns_history_Rec.event_key);
91 	wsh_debug_sv.log (l_module_name, 'Item Type', p_txns_history_Rec.item_type);
92 	wsh_debug_sv.log (l_module_name, 'In. control num', p_txns_history_Rec.internal_control_number);
93      END IF;
94 
95 	x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
96 
97 	-- First check for null values
98 	IF (
99 	     p_txns_history_rec.document_type IS NOT NULL AND
100 	     p_txns_history_rec.document_number IS NOT NULL AND
101 	     p_txns_history_rec.document_direction IS NOT NULL AND
102 	     p_txns_history_rec.transaction_status IS NOT NULL AND
103 	     p_txns_history_rec.entity_type IS NOT NULL AND
104              p_txns_history_rec.entity_number IS NOT NULL AND
105              p_txns_history_rec.action_type IS NOT NULL AND
106              p_txns_history_rec.trading_partner_id IS NOT NULL
107 	   ) THEN
108 
109 		-- validate the values
110 		--Added Document Type SS for ShipScreening for ITM -AJPRABHA
111 		IF(p_txns_history_rec.document_type NOT IN('SR', 'SA', 'SS')) THEN
112 			raise invalid_document_type;
113 		END IF;
114 
115 		IF(p_txns_history_rec.document_direction NOT IN('I', 'O')) THEN
116 			raise invalid_direction;
117 		END IF;
118 
119 		IF(p_txns_history_rec.entity_type NOT IN('DLVY', 'DLVY_INT')) THEN
120 			raise invalid_entity_type;
121 		END IF;
122 
123 		IF(p_txns_history_rec.action_type NOT IN('A', 'D')) THEN
124 			raise invalid_action;
125 		END IF;
126 
127 		IF(p_txns_history_rec.transaction_status NOT IN('ST', 'IP', 'ER', 'SC')) THEN
128 			raise invalid_status;
129 		END IF;
130 
131 		-- Check if a record already exists
132 
133 		OPEN txn_cur;
134 
135 		FETCH txn_cur INTO l_transaction_id,l_transaction_status;
136 
137 		IF (txn_cur%NOTFOUND) THEN
138                     IF l_debug_on THEN
139 	             wsh_debug_sv.log (l_module_name,'Record does not exist.
140                                         So create a new record in wsh_transactions_history');
141 	             wsh_debug_sv.log (l_module_name,'document_direction ',
142                                       p_txns_history_rec.document_direction);
143 	             wsh_debug_sv.log (l_module_name,'document_type ',
144                                       p_txns_history_rec.document_type);
145 	             wsh_debug_sv.log (l_module_name,'entity_number ',
146                                       p_txns_history_rec.entity_number);
147                     END IF;
148                     --bmso k proj
149                         l_trans_status :=
150                                      p_txns_history_rec.transaction_status;
151                         IF p_txns_history_rec.document_type = 'SA'
152                           AND p_txns_history_rec.document_direction = 'I'
153                         THEN --{
154                            --
155                            OPEN c_get_del_status(to_number(p_txns_history_rec.orig_document_number));
156                            FETCH c_get_del_status INTO l_status_code;
157                            CLOSE c_get_del_status;
158                            --
159                            IF l_debug_on THEN
160 	                      wsh_debug_sv.log (l_module_name,
161                                        'entity_number ',
162                                           p_txns_history_rec.entity_number);
163 	                      wsh_debug_sv.log (l_module_name,
164                                        'l_status_code ', l_status_code);
165                            END IF;
166                            --
167                            IF l_status_code NOT IN ('SC','SR') THEN --{
168 
169                              -- the delivery has been unlocked , set the status
170                              -- to error and insert an error message.
171 
172                              l_trans_status := 'SX';
173                              l_loc_interface_error_rec.p_interface_table_name
174                                                    := 'WSH_NEW_DEL_INTERFACE';
175                              l_loc_interface_error_rec.p_interface_id :=
176                                    to_number(p_txns_history_rec.entity_number);
177                              l_msg_data :=  FND_MESSAGE.GET_STRING('WSH',
178                                     'WSH_DEL_OPEN');
179 
180                              WSH_INTERFACE_VALIDATIONS_PKG.Log_Interface_Errors(
181                                    p_interface_errors_rec   =>
182                                                    l_loc_interface_error_rec,
183                                    p_msg_data      => l_msg_data,
184                                    p_api_name      => 'WSH_TRANSACTIONS_HISTORY_PKG.Create_Update_Txns_History',
185                                    x_return_status => l_return_status);
186 
187                              wsh_util_core.api_post_call(
188                                   p_return_status => l_return_status,
189                                   x_num_warnings       => l_number_of_warnings,
190                                   x_num_errors         => l_number_of_errors);
191 
192                            END IF; --}
193                            --
194                         END IF; --}
195 			-- Record does not exist. So create a new record
196 
197 			-- Before Insert Check for validity of data
198 			-- Need to validate document_direction, entity_type, action_type
199 			-- ctd.. transaction_status, document_type
200 
201 			SELECT WSH_TRANSACTION_S.nextval
202 			INTO x_transaction_id
203 			FROM dual;
204 
205 			INSERT INTO wsh_transactions_history(
206 			TRANSACTION_ID,
207 			DOCUMENT_TYPE,
208 			DOCUMENT_NUMBER,
209 			ORIG_DOCUMENT_NUMBER,
210 			DOCUMENT_DIRECTION,
211 			TRANSACTION_STATUS,
212 			ACTION_TYPE,
213 			ENTITY_NUMBER,
214 			ENTITY_TYPE,
215 			TRADING_PARTNER_ID,
216 			ECX_MESSAGE_ID,
217 			EVENT_NAME,
218 			EVENT_KEY,
219 			ITEM_TYPE,
220 			INTERNAL_CONTROL_NUMBER,
221 			CREATION_DATE,
222 			CREATED_BY,
223 			LAST_UPDATE_DATE,
224 			LAST_UPDATED_BY,
225 			LAST_UPDATE_LOGIN,
226 			ATTRIBUTE_CATEGORY,
227 			ATTRIBUTE1,
228 			ATTRIBUTE2,
229 			ATTRIBUTE3,
230 			ATTRIBUTE4,
231 			ATTRIBUTE5,
232 			ATTRIBUTE6,
233 			ATTRIBUTE7,
234 			ATTRIBUTE8,
235 			ATTRIBUTE9,
236 			ATTRIBUTE10,
237 			ATTRIBUTE11,
238 			ATTRIBUTE12,
239 			ATTRIBUTE13,
240 			ATTRIBUTE14,
241 			ATTRIBUTE15)
242 			VALUES( x_transaction_id,
243 				p_txns_history_rec.document_type,
244 				p_txns_history_rec.document_number,
245 				p_txns_history_rec.orig_document_number,
246 				p_txns_history_rec.document_direction,
247 				-- k proj bmso p_txns_history_rec.transaction_status,
248                                 l_trans_status,
249 				p_txns_history_rec.action_type,
250 				p_txns_history_rec.entity_number,
251 				p_txns_history_rec.entity_type,
252 				p_txns_history_rec.trading_partner_id,
253 				p_txns_history_rec.ECX_MESSAGE_ID,
254 				p_txns_history_rec.EVENT_NAME,
255 				p_txns_history_rec.EVENT_KEY,
256 				p_txns_history_rec.ITEM_TYPE,
257 				p_txns_history_rec.INTERNAL_CONTROL_NUMBER,
258 				SYSDATE,
259 				FND_GLOBAL.USER_ID,
260 				SYSDATE,
261 				FND_GLOBAL.USER_ID,
262 				FND_GLOBAL.USER_ID,
263 				p_txns_history_rec.ATTRIBUTE_CATEGORY,
264 				p_txns_history_rec.ATTRIBUTE1,
265 				p_txns_history_rec.ATTRIBUTE2,
266 				p_txns_history_rec.ATTRIBUTE3,
267 				p_txns_history_rec.ATTRIBUTE4,
268 				p_txns_history_rec.ATTRIBUTE5,
269 				p_txns_history_rec.ATTRIBUTE6,
270 				p_txns_history_rec.ATTRIBUTE7,
271 				p_txns_history_rec.ATTRIBUTE8,
272 				p_txns_history_rec.ATTRIBUTE9,
273 				p_txns_history_rec.ATTRIBUTE10,
274 				p_txns_history_rec.ATTRIBUTE11,
275 				p_txns_history_rec.ATTRIBUTE12,
276 				p_txns_history_rec.ATTRIBUTE13,
277 				p_txns_history_rec.ATTRIBUTE14,
278 				p_txns_history_rec.ATTRIBUTE15);
279 
280 			x_txns_id := x_transaction_id;
281 
282 		ELSE
283                     IF l_debug_on THEN
284 	             wsh_debug_sv.log (l_module_name,'Record already exists. So Need to Update
285                                                         in wsh_transactions_history');
286                     END IF;
287 			-- Record already exists. So Need to Update
288 			-- Before Update Check for validity of status
289 
290 			IF(l_transaction_status = 'ST' AND p_txns_history_rec.transaction_status <> 'SC') THEN
291 
292 				raise invalid_status;
293 
294 			ELSIF(l_transaction_status = 'IP' AND p_txns_history_rec.transaction_status NOT IN('ER', 'SC', 'ST')) THEN
295 				raise invalid_status;
296 
297 			ELSIF(l_transaction_status = 'ER' AND p_txns_history_rec.transaction_status NOT IN('IP','ER', 'SC')) THEN
298 				raise invalid_status;
299 			ELSIF(l_transaction_status = 'SC') THEN
300 				raise invalid_status;
301 
302 			END IF; -- if l_transaction_status checks
303 
304 
305 			UPDATE wsh_transactions_history
306 			SET	entity_number 	= p_txns_history_rec.entity_number,
307 				entity_type   	= p_txns_history_rec.entity_type,
308 				transaction_status = p_txns_history_rec.transaction_status,
309 				ecx_message_id 	= p_txns_history_rec.ecx_message_id,
310 				event_name    	= p_txns_history_rec.event_name,
311 				event_key     	= p_txns_history_rec.event_key,
312 				internal_control_number = p_txns_history_rec.internal_control_number,
313 				item_type	= p_txns_history_rec.item_type,
314 				last_update_date = SYSDATE,
315 				last_updated_by = 1,
316 				attribute_category = p_txns_history_rec.ATTRIBUTE_CATEGORY,
317 				attribute1 	= p_txns_history_rec.ATTRIBUTE1,
318 				attribute2	= p_txns_history_rec.ATTRIBUTE2,
319 				attribute3	= p_txns_history_rec.ATTRIBUTE3,
320 				attribute4	= p_txns_history_rec.ATTRIBUTE4,
321 				attribute5	= p_txns_history_rec.ATTRIBUTE5,
322 				attribute6	= p_txns_history_rec.ATTRIBUTE6,
323 				attribute7	= p_txns_history_rec.ATTRIBUTE7,
324 				attribute8	= p_txns_history_rec.ATTRIBUTE8,
325 				attribute9	= p_txns_history_rec.ATTRIBUTE9,
326 				attribute10	= p_txns_history_rec.ATTRIBUTE10,
327 				attribute11	= p_txns_history_rec.ATTRIBUTE11,
328 				attribute12	= p_txns_history_rec.ATTRIBUTE12,
329 				attribute13	= p_txns_history_rec.ATTRIBUTE13,
330 				attribute14	= p_txns_history_rec.ATTRIBUTE14,
331 				attribute15	= p_txns_history_rec.ATTRIBUTE15
332 			WHERE transaction_id = l_transaction_id;
333 
334 
335 		END IF; -- if txn_cur%notfound
336 
337 		IF(txn_cur%ISOPEN) THEN
338 			CLOSE txn_cur;
339 		END IF;
340 	ELSE
341 
342 		-- Not Null checks failed. Return Error
343 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
344 
345 	END IF; -- if p_txns_history_rec columns are not null
346 
347         IF l_debug_on THEN
348 	 wsh_debug_sv.pop(l_module_name);
349         END IF;
350 EXCEPTION
351 	WHEN invalid_status THEN
352 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
353                 IF l_debug_on THEN
354                  WSH_DEBUG_SV.logmsg(l_module_name,'invalid_status exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
355                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:invalid_status');
356                 END IF;
357 	WHEN invalid_action THEN
358 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
359                 IF l_debug_on THEN
360                  WSH_DEBUG_SV.logmsg(l_module_name,'invalid_action exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
361                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:invalid_action');
362                 END IF;
363 	WHEN invalid_entity_type THEN
364 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
365                 IF l_debug_on THEN
366                  WSH_DEBUG_SV.logmsg(l_module_name,'invalid_entity_type exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
367                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:invalid_entity_type');
368                 END IF;
369 	WHEN invalid_direction THEN
370 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
371                 IF l_debug_on THEN
372                  WSH_DEBUG_SV.logmsg(l_module_name,'invalid_direction exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
373                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:invalid_direction');
374                 END IF;
375 	WHEN invalid_document_type THEN
376 		x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
377                 IF l_debug_on THEN
378                  WSH_DEBUG_SV.logmsg(l_module_name,'invalid_document_type exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
379                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:invalid_document_type');
380                 END IF;
381 	WHEN Others THEN
382 		x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
383                 IF l_debug_on THEN
384                  WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,
385                                                                           WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
386                  WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
387                 END IF;
388 
389 END Create_Update_Txns_History;
390 
391 
392 PROCEDURE Get_Txns_History(
393 p_item_type		IN	VARCHAR2,
394 p_event_key		IN	VARCHAR2,
395 p_direction		IN	VARCHAR2,
396 p_document_type		IN	VARCHAR2,
397 p_txns_history_rec	OUT NOCOPY 	Txns_History_Record_Type,
398 x_return_status		OUT NOCOPY 	VARCHAR2
399 ) IS
400 
401 CURSOR txns_history_cur IS
402 SELECT transaction_id,
403 	document_type,
404 	document_direction,
405 	document_number,
406 	orig_document_number,
407 	entity_number,
408 	entity_type,
409 	trading_partner_id,
410 	action_type,
411 	transaction_status,
412 	ecx_message_id,
413 	event_name,
414 	event_key ,
415 	item_type,
416 	internal_control_number,
417 	attribute_category,
418 	attribute1,
419 	attribute2,
420 	attribute3,
421 	attribute4,
422 	attribute5,
423 	attribute6,
424 	attribute7,
425 	attribute8,
426 	attribute9,
427 	attribute10,
428 	attribute11,
429 	attribute12,
430 	attribute13,
431 	attribute14,
432 	attribute15
433 FROM wsh_transactions_history
434 WHERE item_type 	= p_item_type
435 and event_key		= p_event_key
436 and document_direction 	= p_direction
437 and document_type	= p_document_type;
438 
439 --exceptions
440 no_record_found exception;
441 
442 --
443 l_debug_on BOOLEAN;
444 --
445 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'GET_TXNS_HISTORY';
446 --
447 BEGIN
448        --
449        l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
450        --
451        IF l_debug_on IS NULL
452        THEN
453            l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
454        END IF;
455        --
456        IF l_debug_on THEN
457 	wsh_debug_sv.push(l_module_name,'Get_Txns_History');
458 	wsh_debug_sv.log (l_module_name, 'Item Type', p_item_type);
459 	wsh_debug_sv.log (l_module_name, 'Event Key', p_event_key);
460 	wsh_debug_sv.log (l_module_name, 'Direction' , p_direction);
461 	wsh_debug_sv.log (l_module_name, 'Document Type', p_document_type);
462        END IF;
463 
464 	x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
465 
466 	OPEN txns_history_cur;
467 	FETCH txns_history_cur INTO p_txns_history_rec;
468 
469 	IF(txns_history_cur%NOTFOUND) THEN
470 		raise no_record_found;
471 	END IF;
472 
473 	CLOSE txns_history_cur;
474 
475        IF l_debug_on THEN
476 	wsh_debug_sv.pop(l_module_name);
477        END IF;
478 
479 EXCEPTION
480 WHEN no_record_found THEN
481 
482 	IF(txns_history_cur%ISOPEN) THEN
483 		CLOSE txns_history_cur;
484 	END IF;
485 
486 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
487         IF l_debug_on THEN
488          WSH_DEBUG_SV.logmsg(l_module_name,'RECORD_LOCKED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
489          WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:RECORD_LOCKED');
490         END IF;
491 WHEN Others THEN
492 	x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
493         IF l_debug_on THEN
494          WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,
495                                                                           WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
496          WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
497         END IF;
498 END Get_Txns_History;
499 
500 /*
501 -----------------------------------------------------------------------------
502    PROCEDURE  : Create_Txns_History
503    PARAMETERS :
504   DESCRIPTION : This procedure is written for use by the inbound mapping.
505 Since XML gateway does not support calls to procedures with record types as
506 parameters, we need this wrapper. This takes in the individual columns,
507 creates a txns-history record and calls the create_update_txns_history
508 procedure with that record
509 -----------------------------------------------------------------------------
510 */
511 
512 PROCEDURE Create_Txns_History(
513 	p_transaction_id	IN	NUMBER,
514 	p_document_type		IN	VARCHAR2,
515 	p_document_direction 	IN	VARCHAR2,
516 	p_document_number 	IN	VARCHAR2,
517 	p_orig_document_number 	IN	VARCHAR2,
518 	p_entity_number		IN	VARCHAR2,
519 	p_entity_type		IN 	VARCHAR2,
520 	p_trading_partner_id 	IN	NUMBER,
521 	p_action_type 		IN	VARCHAR2,
522 	p_transaction_status 	IN	VARCHAR2,
523 	p_ecx_message_id	IN	VARCHAR2,
524 	p_event_name  		IN	VARCHAR2,
525 	p_event_key 		IN	VARCHAR2,
526 	p_item_type		IN	VARCHAR2,
527 	p_internal_control_number IN	VARCHAR2,
528 	x_return_status		OUT NOCOPY 	VARCHAR2) IS
529 
530 l_txn_hist_rec 		Txns_History_Record_Type;
531 l_return_status 	VARCHAR2(30);
532 l_txn_id 		NUMBER;
533 
534 create_update_failed	exception;
535 
536 --
537 l_debug_on BOOLEAN;
538 --
539 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'CREATE_TXNS_HISTORY';
540 --
541 BEGIN
542 	--
543 	l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
544 	--
545 	IF l_debug_on IS NULL
546 	THEN
547 	    l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
548 	END IF;
549 	--
550         IF l_debug_on THEN
551 	wsh_debug_sv.push(l_module_name,'Get_Txns_History');
552 	wsh_debug_sv.log (l_module_name, 'Transaction ID', p_transaction_id);
553 	wsh_debug_sv.log (l_module_name, 'document Type', p_document_type);
554 	wsh_debug_sv.log (l_module_name, 'Doc Direction', p_document_direction);
555 	wsh_debug_sv.log (l_module_name, 'Doc number', p_document_number);
556 	wsh_debug_sv.log (l_module_name, 'Orig doc num', p_orig_document_number);
557 	wsh_debug_sv.log (l_module_name, 'Entity Type', p_entity_type);
558 	wsh_debug_sv.log (l_module_name, 'Entity number', p_entity_number);
559 	wsh_debug_sv.log (l_module_name, 'TP id', p_trading_partner_id);
560 	wsh_debug_sv.log (l_module_name, 'Action type', p_action_type);
561 	wsh_debug_sv.log (l_module_name, 'Transaction status', p_transaction_status);
562 	wsh_debug_sv.log (l_module_name, 'ECX Message ID', p_ecx_message_id);
563 	wsh_debug_sv.log (l_module_name, 'Event Name', p_event_name);
564 	wsh_debug_sv.log (l_module_name, 'Event Key', p_event_key);
565 	wsh_debug_sv.log (l_module_name, 'Item Type', p_item_type);
566 	wsh_debug_sv.log (l_module_name, 'In. control num', p_internal_control_number);
567         END IF;
568 
569 	x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
570 
571 	l_txn_hist_rec.transaction_id 	:= p_transaction_id;
572 	l_txn_hist_rec.document_type	:= p_document_type;
573 	l_txn_hist_rec.document_direction := p_document_direction;
574 	l_txn_hist_rec.document_number	:= p_document_number;
575 	l_txn_hist_rec.orig_document_number := p_orig_document_number;
576 	l_txn_hist_rec.entity_number 	:= p_entity_number;
577 	l_txn_hist_rec.entity_type	:= p_entity_type;
578 	l_txn_hist_rec.trading_partner_id := p_trading_partner_id;
579 	l_txn_hist_rec.action_type	:= p_action_type;
580 	l_txn_hist_rec.transaction_status := p_transaction_status;
581 	l_txn_hist_rec.ecx_message_id	:= p_ecx_message_id;
582 	l_txn_hist_rec.event_name	:= p_event_name;
583 	l_txn_hist_rec.event_key	:= p_event_key;
584 	l_txn_hist_rec.item_type	:= p_item_type;
585 	l_txn_hist_rec.internal_control_number := p_internal_control_number;
586 
587 	Create_Update_Txns_History(
588 	p_txns_history_rec	=> l_txn_hist_rec,
589 	x_txns_id		=> l_txn_id,
590 	x_return_status		=> l_return_status);
591 
592         IF l_debug_on THEN
593 	  wsh_debug_sv.log (l_module_name, 'Return status from 	Create_Update_Txns_History', l_return_status);
594         END IF;
595 
596 	IF(l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS) THEN
597 		raise create_update_failed;
598 	END IF;
599 	IF l_debug_on THEN
600            wsh_debug_sv.pop(l_module_name);
601         END IF;
602 EXCEPTION
603 WHEN create_update_failed THEN
604 	x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
605         IF l_debug_on THEN
606 	  wsh_debug_sv.pop(l_module_name);
607         END IF;
608 WHEN Others THEN
609         x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
610         IF l_debug_on THEN
611 	  wsh_debug_sv.pop(l_module_name,'EXCEPTION: '||SUBSTR(SQLERRM,1,200));
612         END IF;
613 END Create_Txns_History;
614 
615 
616 END WSH_TRANSACTIONS_HISTORY_PKG;