DBA Data[Home] [Help]

PACKAGE BODY: APPS.RCV_TRANSACTION_PROCESSOR

Source


1 PACKAGE BODY RCV_TRANSACTION_PROCESSOR AS
2 /* $Header: RCVGTPB.pls 120.16.12020000.2 2012/07/10 09:26:46 ptkumar ship $ */
3 
4 	TYPE FlagTabByVC IS TABLE OF VARCHAR2(1) INDEX BY VARCHAR2(256);
5 
6 	g_accounting_info DBMS_SQL.number_table;
7 	g_installed_products FlagTabByVC;
8 	g_conc_request_id NUMBER := -1;
9 	g_conc_login_id NUMBER := -1;
10 	g_conc_program_id NUMBER := -1;
11 	g_prog_appl_id NUMBER := -1;
12 	g_user_id NUMBER := -1;
13 
14 	FUNCTION conc_request_id
15 		RETURN NUMBER IS
16 	BEGIN
17 		IF g_conc_request_id = -1 THEN
18 			g_conc_request_id := FND_GLOBAL.conc_request_id;
19 		END IF;
20 
21 		RETURN g_conc_request_id;
22 	END conc_request_id;
23 
24 	FUNCTION conc_login_id
25 		RETURN NUMBER IS
26 	BEGIN
27 		IF g_conc_login_id = -1 THEN
28 			g_conc_login_id := FND_GLOBAL.conc_login_id;
29 		END IF;
30 
31 		RETURN g_conc_login_id;
32 	END conc_login_id;
33 
34 	FUNCTION conc_program_id
35 		RETURN NUMBER IS
36 	BEGIN
37 		IF g_conc_program_id = -1 THEN
38 			g_conc_program_id := FND_GLOBAL.conc_program_id;
39 		END IF;
40 
41 		RETURN g_conc_program_id;
42 	END conc_program_id;
43 
44 	FUNCTION prog_appl_id
45 		RETURN NUMBER IS
46 	BEGIN
47 		IF g_prog_appl_id = -1 THEN
48 			g_prog_appl_id := FND_GLOBAL.prog_appl_id;
49 		END IF;
50 
51 		RETURN g_prog_appl_id;
52 	END prog_appl_id;
53 
54 	FUNCTION user_id
55 		RETURN NUMBER IS
56 	BEGIN
57 		IF g_user_id = -1 THEN
58 			g_user_id := FND_GLOBAL.user_id;
59 		END IF;
60 
61 		RETURN g_user_id;
62 	END user_id;
63 
64 	FUNCTION get_product_install_status( p_product_name IN VARCHAR2 )
65 		RETURN VARCHAR2 IS
66 	BEGIN
67 		IF NOT g_installed_products.EXISTS(p_product_name) THEN
68 			g_installed_products(p_product_name) := PO_CORE_S.get_product_install_status( p_product_name );
69 		END IF;
70 
71 		RETURN g_installed_products(p_product_name);
72 	END get_product_install_status;
73 
74 	FUNCTION Valid_Accounting_Info( p_org_id NUMBER )
75 		RETURN BOOLEAN IS
76 	BEGIN
77 		IF NOT g_accounting_info.EXISTS(p_org_id) THEN
78 			SELECT COUNT(*)
79 			  INTO g_accounting_info(p_org_id)
80 			  FROM hr_organization_information hoi
81 			     , gl_sets_of_books gsob
82 			     , financials_system_params_all fsp
83              WHERE hoi.organization_id = p_org_id
84 			   AND hoi.org_information_context||'' = 'Accounting Information'
85 			   AND (fsp.org_id IS NULL OR hoi.org_information3 = TO_CHAR(fsp.org_id))
86 			   AND fsp.set_of_books_id = gsob.set_of_books_id;
87 		END IF;
88 
89 		RETURN g_accounting_info(p_org_id) > 0;
90 	END Valid_Accounting_Info;
91 
92 	/*Bug 5517298: Added the function get_acct_period_status*/
93 	FUNCTION get_acct_period_status(p_trx_date IN DATE,
94                               p_org_id   IN NUMBER) RETURN VARCHAR2 IS
95 
96 	l_closing_status  VARCHAR2(1) := NULL;
97 	l_open_flag       VARCHAR2(1) := NULL;
98         l_progress        VARCHAR2(3) := NULL;
99 
100 
101 	BEGIN
102 
103           l_progress := '010';
104 
105 	  SELECT oap.open_flag
106 	  INTO   l_open_flag
107 	  FROM   org_acct_periods oap
108 	  WHERE  oap.organization_id = p_org_id
109 	  AND   (trunc(p_trx_date)
110 		BETWEEN trunc(oap.period_start_date) AND
111 		trunc (oap.schedule_close_date));
112 
113 	  if (l_open_flag = 'Y') then
114 	    l_closing_status := 'O';
115 	  elsif (l_open_flag = 'N') then
116     	    l_closing_status := 'N';
117 	  else
118     	    l_closing_status := 'F';
119 	  end if;
120 
121 	  RETURN l_closing_status;
122 
123 	EXCEPTION
124 	WHEN NO_DATA_FOUND then
125 	    po_message_s.app_error('PO_INV_NO_OPEN_PERIOD');
126 	    RAISE;
127 	WHEN TOO_MANY_ROWS then
128 	    po_message_s.app_error('PO_INV_MUL_PERIODS');
129 	    RAISE;
130 	WHEN OTHERS THEN
131             po_message_s.sql_error('get_acct_period_status', l_progress, sqlcode);
132 	    RAISE;
133 	END get_acct_period_status;
134 
135 	PROCEDURE RVTTHIns
136 		( p_rti_id IN RCV_TRANSACTIONS_INTERFACE.interface_transaction_id%TYPE
137 		, p_transaction_type IN RCV_TRANSACTIONS.transaction_type%TYPE
138 		, p_shipment_header_id IN RCV_SHIPMENT_HEADERS.shipment_header_id%TYPE
139 		, p_shipment_line_id IN RCV_SHIPMENT_LINES.shipment_line_id%TYPE
140 		, p_primary_unit_of_measure IN RCV_TRANSACTIONS.primary_unit_of_measure%TYPE
141 		, p_primary_quantity IN RCV_TRANSACTIONS.primary_quantity%TYPE
142 		, p_source_doc_unit_of_measure IN RCV_TRANSACTIONS.source_doc_unit_of_measure%TYPE
143 		, p_source_doc_quantity IN RCV_TRANSACTIONS.source_doc_quantity%TYPE
144 		, p_parent_id IN RCV_TRANSACTIONS.transaction_id%TYPE
145 		, p_receive_id IN OUT NOCOPY RCV_TRANSACTIONS.transaction_id%TYPE
146 		, p_deliver_id IN OUT NOCOPY RCV_TRANSACTIONS.transaction_id%TYPE
147 		, p_correct_id IN OUT NOCOPY RCV_TRANSACTIONS.transaction_id%TYPE
148 		, p_return_id IN OUT NOCOPY RCV_TRANSACTIONS.transaction_id%TYPE
149 		, x_rt_id OUT NOCOPY RCV_TRANSACTIONS.transaction_id%TYPE
150 		, x_error_message OUT NOCOPY VARCHAR2
151 		) IS
152 			l_rt_row RCV_TRANSACTIONS%ROWTYPE;
153 			l_parent_row RCV_TRANSACTIONS%ROWTYPE;
154 			l_rti_row RCV_TRANSACTIONS_INTERFACE%ROWTYPE;
155 
156 			l_use_ship_to_flag VARCHAR2(1);
157 			l_common_receiving BOOLEAN;
158 
159 		-- Bug 9767933
160  	        l_archive_ext_rev_code VARCHAR2(100);
161 
162 		/*start of bug 13394743*/
163         l_po_auth_status PO_HEADERS_ALL.authorization_status%TYPE :='N';
164         l_po_approved_flag PO_HEADERS_ALL.approved_flag%TYPE :='N';
165         l_pll_approved_flag PO_LINE_LOCATIONS_ALL.approved_flag%TYPE :='N';
166         l_po_unit_price PO_LINE_LOCATIONS_ALL.price_override%TYPE:=-1.0;
167         /*end of bug 13394743*/
168 
169 	/*Bug 5517289-Start*/
170 	CURSOR c_fob_point (l_from_org_id NUMBER,l_to_org_id NUMBER)is
171 
172 	   SELECT fob_point
173 	   FROM   mtl_interorg_parameters
174 	   WHERE  from_organization_id = l_from_org_id
175 	   AND    to_organization_id   = l_to_org_id;
176 
177         l_fob_point number;
178 	/*Bug 5517289-End*/
179 
180 	BEGIN
181 	   asn_debug.put_line('RVTTHIns(p_rti_id:' || p_rti_id
182 				|| ', p_transaction_type: ' || p_transaction_type
183 				|| ', p_shipment_header_id: ' || p_shipment_header_id
184 				|| ', p_shipment_line_id: ' || p_shipment_line_id
185 				|| ', p_primary_unit_of_measure: ' || p_primary_unit_of_measure
186 				|| ', p_primary_quantity: ' || p_primary_quantity
187 				|| ', p_source_doc_unit_of_measure: ' || p_source_doc_unit_of_measure
188 				|| ', p_source_doc_quantity: ' || p_source_doc_quantity
189 				|| ', p_parent_id: ' || p_parent_id
190 				|| ', p_receive_id: ' || p_receive_id
191 				|| ', p_deliver_id: ' || p_deliver_id
192 				|| ', p_correct_id: ' || p_correct_id
193 				|| ', p_return_id: ' || p_return_id
194 				|| ')');
195 
196 		SELECT rcv_transactions_s.NEXTVAL
197 		  INTO l_rt_row.transaction_id
198 		  FROM DUAL;
199 
200 		-- Bug 4401341
201 		/*Commenting the rcv_table_functions.get_rti_frow_from_id call and fetching
202 		  the value from rti table as lpn_id fetched from the cache table does not
203 		  have the value that is updated by Inventory.There may be other fields that
204 		  would have got updated.So fetching all the values directly from rti and then
205 		  use them to populate rcv_transactions table.
206 		*/
207 --		l_rti_row := RCV_TABLE_FUNCTIONS.get_rti_row_from_id( p_rti_id );
208 
209 		select *
210 		into l_rti_row
211 		from rcv_transactions_interface
212 		where interface_transaction_id = p_rti_id;
213 
214 
215 		/*start of bug 13394743:get the latest price from PLL for PO transaction*/
216         Begin
217             IF ( ( l_rti_row.source_document_code = 'PO') and
218                  ( l_rti_row.transaction_type in ( 'RECEIVE', 'DELIVER', 'CORRECT', 'RETURN TO VENDOR',
219                      'RETURN TO RECEIVING', 'ACCEPT', 'REJECT', 'MATCH') ) ) THEN
220                 Begin
221                     select nvl(authorization_status,'N') auth_status, nvl(approved_flag,'N') app_flag
222                         into l_po_auth_status, l_po_approved_flag
223                     from po_headers_all ph
224                     where ph.po_header_id = l_rti_row.po_header_id;
225 
226                     select nvl(approved_flag,'N') app_flag, nvl(price_override, -1.0) new_price
227                         into l_pll_approved_flag, l_po_unit_price
228                     from po_line_locations_all pll
229                     where pll.line_location_id = l_rti_row.po_line_location_id;
230 
231                     IF ( l_po_auth_status <> 'APPROVED' or l_po_approved_flag <> 'Y' or
232                          l_pll_approved_flag <> 'Y' ) THEN
233                         l_po_unit_price := -1.0;
234                     END IF;
235                 Exception
236                     WHEN OTHERS THEN
237                         l_po_unit_price := -1.0;
238                 End;
239 
240                 IF ( (l_po_unit_price <> -1.0) and (l_po_unit_price <> l_rti_row.po_unit_price) ) THEN
241                     -- Change the price for this transaction
242                     l_rti_row.po_unit_price := l_po_unit_price;
243 
244                     -- Change price for later when calculate trx_cost when insert MMTT in rvtii
245                     update rcv_transactions_interface
246                     set po_unit_price = l_po_unit_price
247                     where interface_transaction_id = l_rti_row.interface_transaction_id;
248                 END IF;
249             END IF;
250         End;
251 		/*end of bug 13394743*/
252 
253 		-- default values
254 		l_rt_row.user_entered_flag := 'Y';
255 		l_use_ship_to_flag := 'N';
256 
257 		IF p_transaction_type = 'RECEIVE' THEN
258 			l_rt_row.parent_transaction_id := -1;
259 			p_receive_id := l_rt_row.transaction_id;
260 			IF p_transaction_type = 'SHIP' THEN
261 				l_rt_row.user_entered_flag := 'N';
262 			END IF;
263 			IF l_rti_row.auto_transact_code = 'DELIVER' THEN
264 				l_use_ship_to_flag := 'Y';
265 			END IF;
266 		ELSIF p_transaction_type = 'DELIVER' THEN
267 			p_deliver_id := l_rt_row.transaction_id;
268 			IF l_rti_row.auto_transact_code = 'DELIVER' THEN
269 				l_rt_row.user_entered_flag := 'N';
270 				l_rt_row.parent_transaction_id := p_receive_id;
271 			END IF;
272 		ELSIF p_transaction_type IN ('RETURN TO VENDOR','RETURN TO CUSTOMER') THEN
273 			l_parent_row := RCV_TABLE_FUNCTIONS.get_rt_row_from_id( l_rti_row.parent_transaction_id );
274 			IF l_parent_row.transaction_type = 'DELIVER' THEN
275 				l_rt_row.parent_transaction_id := l_parent_row.parent_transaction_id;
276 				l_use_ship_to_flag := 'Y';
277 			END IF;
278 			p_return_id := l_rt_row.transaction_id;
279 		ELSIF p_transaction_type = 'RETURN TO RECEIVING' THEN
280 			IF l_rti_row.transaction_type IN ('RETURN TO VENDOR','RETURN TO CUSTOMER') THEN
281 				l_rt_row.user_entered_flag := 'N';
282 			END IF;
283 			p_correct_id := l_rt_row.transaction_id;
284 		ELSIF p_transaction_type = 'CORRECT' THEN
285 			p_correct_id := l_rt_row.transaction_id;
286 		END IF;
287 
288 		IF l_rt_row.parent_transaction_id IS NULL THEN
289 			l_rt_row.parent_transaction_id := p_parent_id;
290 		END IF;
291 
292 		IF NOT Valid_Accounting_Info( l_rti_row.to_organization_id ) THEN
293 			x_error_message := 'RCV_INV_ACCT_INVALID';
294 			RETURN;
295 		END IF;
296 
297 	/*
298 	 Bug 6359747
299 	 Changing the Created_by and Last_Updated_by from user_id to whats in RTI record.
300 	 Commented old lines below and add new ones.
301 	*/
302 		l_rt_row.creation_date := SYSDATE;
303 		--l_rt_row.created_by := user_id;
304 		l_rt_row.created_by := l_rti_row.created_by;
305 
306 		l_rt_row.last_update_date := SYSDATE;
307 		--l_rt_row.last_updated_by := user_id;
308 		l_rt_row.last_updated_by := l_rti_row.last_updated_by;
309 
310                 /* Bug# 7343638
311                  * If the processing mode is ONLINE, all the below fields were
312                  * being set as -1.
313                  * Explicitely setting the below fields to 0 in case of ONLINE
314                  * as this was the value set earlier.
315                  */
316 
317                 l_rt_row.last_update_login := l_rti_row.last_update_login;
318 
319                 IF (l_rti_row.processing_mode_code = 'ONLINE') THEN
320                   l_rt_row.request_id := 0;
321                   l_rt_row.program_application_id := 0;
322                   l_rt_row.program_id := 0;
323                 ELSE
324                   l_rt_row.request_id := conc_request_id;
325                   l_rt_row.program_application_id := prog_appl_id;
326                   l_rt_row.program_id := conc_program_id;
327                 END IF;
328                 -- End bug# 7343638
329 
330 		l_rt_row.program_update_date := SYSDATE;
331 		l_rt_row.interface_source_code := l_rti_row.interface_source_code;
332 		l_rt_row.interface_source_line_id := l_rti_row.interface_source_line_id;
333 		l_rt_row.transaction_type := p_transaction_type;
334 		l_rt_row.transaction_date := l_rti_row.transaction_date;
335 		l_rt_row.source_document_code := l_rti_row.source_document_code;
336 		IF l_use_ship_to_flag = 'Y' THEN
337 			l_rt_row.destination_type_code := 'RECEIVING';
338 		ELSE
339 			l_rt_row.destination_type_code := l_rti_row.destination_type_code;
340 		END IF;
341 		l_rt_row.location_id := l_rti_row.location_id;
342 		l_rt_row.quantity := l_rti_row.quantity;
343 		l_rt_row.unit_of_measure := l_rti_row.unit_of_measure;
344 		l_rt_row.uom_code := l_rti_row.uom_code;
345 		l_rt_row.primary_quantity := p_primary_quantity;
346 		l_rt_row.primary_unit_of_measure := p_primary_unit_of_measure;
347 		l_rt_row.source_doc_quantity := p_source_doc_quantity;
348 		l_rt_row.source_doc_unit_of_measure := p_source_doc_unit_of_measure;
349 		l_rt_row.shipment_header_id := p_shipment_header_id;
350 		l_rt_row.shipment_line_id := p_shipment_line_id;
351 		l_rt_row.employee_id := l_rti_row.employee_id;
352 		l_rt_row.po_header_id := l_rti_row.po_header_id;
353 		l_rt_row.po_release_id := l_rti_row.po_release_id;
354 		l_rt_row.po_line_id := l_rti_row.po_line_id;
355 		l_rt_row.po_line_location_id := l_rti_row.po_line_location_id;
356 		l_rt_row.po_distribution_id := l_rti_row.po_distribution_id;
357 		l_rt_row.po_revision_num := l_rti_row.po_revision_num;
358 		l_rt_row.requisition_line_id := l_rti_row.requisition_line_id;
359 		l_rt_row.req_distribution_id := l_rti_row.req_distribution_id;
360 
361                 -- Bug 6265149 : Start
362                 -- It is mandatory to set the following:
363                 -- Purchasing > Setups > Purchasing > Document types (PO/Release) > Archive on => 'Approve'
364                 begin
365                   if (l_rti_row.source_document_code = 'PO' and
366 		      l_rt_row.transaction_type in ('DELIVER', 'ACCEPT', 'REJECT')) then
367                       --
368                      -- Bug 9767933, Changed the below code to handle the case when Archive on => 'Communicate'
369  	                   select archive_external_revision_code
370  	                     into l_archive_ext_rev_code
371  	                     from po_document_types
372  	                    where document_type_code = 'PO'
373  	                      and document_subtype = (select type_lookup_code from po_headers
374  	                                               where po_header_id = l_rti_row.po_header_id);
375 
376  	          if l_archive_ext_rev_code = 'APPROVE' then
377 		      select   price_override
378                       into     l_rt_row.po_unit_price
379                       from     po_line_locations_archive
380                       where    line_location_id = l_rti_row.po_line_location_id
381                       and      nvl(latest_external_flag,'N') = 'Y';
382                       --
383                       asn_debug.put_line('PO Unit Price from pll_archive :' || l_rt_row.po_unit_price);
384                       --
385 		      else
386  	                       l_rt_row.po_unit_price := NULL;
387  	            end if;
388                   end if;
389                 exception
390 		  when others then
391                        asn_debug.put_line('Fetching from pll_archive failed : ' || SQLERRM);
392                        l_rt_row.po_unit_price := NULL;
393                 end;
394                 --
395                 if (l_rt_row.po_unit_price is null) then
396                         l_rt_row.po_unit_price := l_rti_row.po_unit_price;
397                 end if;
398                 asn_debug.put_line('PO Unit Price is :' || l_rt_row.po_unit_price);
399                 --
400                 -- Bug 6265149 : End
401 
402 		IF l_rti_row.currency_code IS NULL THEN
403 
404 		/* Bug 5246147: Removed the function calls rcv_table_functions.get_fspa_row_from_org() and
405 				rcv_table_functions.get_sob_row_from_id() to get the currency_code value and
406 				added the following sql to get the currency_code */
407 			select gsob.currency_code into
408 			       l_rt_row.currency_code
409 			  from hr_organization_information hoi,
410 			       financials_system_params_all fsp,
411 			       gl_sets_of_books gsob
412 			 where hoi.organization_id = l_rti_row.to_organization_id
413 			   and hoi.org_information_context||'' = 'Accounting Information'
414 			   and (fsp.org_id is null OR hoi.org_information3 = to_char(fsp.org_id))
415 			   and hoi.org_information1 = to_char(fsp.set_of_books_id)
416 			   and fsp.set_of_books_id = gsob.set_of_books_id;
417 		ELSE
418 			l_rt_row.currency_code := l_rti_row.currency_code;
419 		END IF;
420 		IF l_rti_row.currency_conversion_rate IS NULL AND l_rti_row.source_document_code <> 'RMA' THEN
421 			l_rt_row.currency_conversion_rate := 1;
422 		ELSE
423 			l_rt_row.currency_conversion_rate := l_rti_row.currency_conversion_rate;
424 		END IF;
425 		l_rt_row.currency_conversion_date := l_rti_row.currency_conversion_date;
426 		l_rt_row.currency_conversion_type := l_rti_row.currency_conversion_type;
427 		l_rt_row.routing_header_id := l_rti_row.routing_header_id;
428 		l_rt_row.routing_step_id := l_rti_row.routing_step_id;
429 		l_rt_row.substitute_unordered_code := l_rti_row.substitute_unordered_code;
430 		l_rt_row.receipt_exception_flag := l_rti_row.receipt_exception_flag;
431 		CASE p_transaction_type
432 			WHEN 'RECEIVE' THEN l_rt_row.inspection_status_code := 'NOT INSPECTED';
433 			WHEN 'ACCEPT' THEN l_rt_row.inspection_status_code := 'ACCEPTED';
434 			WHEN 'REJECT' THEN l_rt_row.inspection_status_code := 'REJECTED';
435 			ELSE l_rt_row.inspection_status_code := l_rti_row.inspection_status_code;
436 		END CASE;
437 		IF p_transaction_type = 'RECEIVE' THEN
438 			l_rt_row.inspection_quality_code := '';
439 		ELSE
440 			l_rt_row.inspection_quality_code := l_rti_row.inspection_quality_code;
441 		END IF;
442 		l_rt_row.vendor_id := l_rti_row.vendor_id;
443 		l_rt_row.vendor_site_id := l_rti_row.vendor_site_id;
444 		l_rt_row.vendor_lot_num := l_rti_row.vendor_lot_num;
445 		l_rt_row.organization_id := l_rti_row.to_organization_id;
446 		l_rt_row.from_subinventory := l_rti_row.from_subinventory;
447 		l_rt_row.from_locator_id := l_rti_row.from_locator_id;
448 		l_rt_row.subinventory := l_rti_row.subinventory;
449 		l_rt_row.locator_id := l_rti_row.locator_id;
450 		IF ( p_transaction_type = 'RECEIVE' AND
451 		     l_rti_row.auto_transact_code = 'DELIVER' ) OR
452 		   p_transaction_type IN ('RETURN TO VENDOR','RETURN TO CUSTOMER')
453 		THEN
454 			l_rt_row.subinventory := NULL;
455 			l_rt_row.locator_id := NULL;
456 		END IF;
457 		IF p_transaction_type IN ('RETURN TO VENDOR','RETURN TO CUSTOMER') AND
458 		   l_parent_row.transaction_type = 'DELIVER'
459 		THEN
460 			l_rt_row.from_subinventory := l_rti_row.subinventory;
461 			l_rt_row.from_locator_id := l_rti_row.locator_id;
462 		END IF;
463 		l_rt_row.rma_reference := l_rti_row.rma_reference;
464 		l_rt_row.deliver_to_person_id := l_rti_row.deliver_to_person_id;
465 		l_rt_row.deliver_to_location_id := l_rti_row.deliver_to_location_id;
466 		l_rt_row.department_code := l_rti_row.department_code;
467 		l_rt_row.wip_entity_id := l_rti_row.wip_entity_id;
468 		l_rt_row.wip_line_id := l_rti_row.wip_line_id;
469 		l_rt_row.wip_repetitive_schedule_id := l_rti_row.wip_repetitive_schedule_id;
470 		l_rt_row.wip_operation_seq_num := l_rti_row.wip_operation_seq_num;
471 		l_rt_row.wip_resource_seq_num := l_rti_row.wip_resource_seq_num;
472 		l_rt_row.bom_resource_id := l_rti_row.bom_resource_id;
473 		IF p_transaction_type IN ('RECEIVE','DELIVER') THEN
474 			l_rt_row.inv_transaction_id := l_rti_row.inv_transaction_id;
475 		ELSE
476 			l_rt_row.inv_transaction_id := '';
477 		END IF;
478 		l_rt_row.reason_id := l_rti_row.reason_id;
479 		IF l_use_ship_to_flag = 'Y' THEN
480 			l_rt_row.destination_context := 'RECEIVING';
481 		ELSE
482 			l_rt_row.destination_context := l_rti_row.destination_context;
483 		END IF;
484 		l_rt_row.comments := l_rti_row.comments;
485 		l_rt_row.interface_transaction_id := l_rti_row.interface_transaction_id;
486 		l_rt_row.group_id := l_rti_row.group_id;
487 		l_rt_row.attribute_category := l_rti_row.attribute_category;
488 		l_rt_row.attribute1 := l_rti_row.attribute1;
489 		l_rt_row.attribute2 := l_rti_row.attribute2;
490 		l_rt_row.attribute3 := l_rti_row.attribute3;
491 		l_rt_row.attribute4 := l_rti_row.attribute4;
492 		l_rt_row.attribute5 := l_rti_row.attribute5;
493 		l_rt_row.attribute6 := l_rti_row.attribute6;
494 		l_rt_row.attribute7 := l_rti_row.attribute7;
495 		l_rt_row.attribute8 := l_rti_row.attribute8;
496 		l_rt_row.attribute9 := l_rti_row.attribute9;
497 		l_rt_row.attribute10 := l_rti_row.attribute10;
498 		l_rt_row.attribute11 := l_rti_row.attribute11;
499 		l_rt_row.attribute12 := l_rti_row.attribute12;
500 		l_rt_row.attribute13 := l_rti_row.attribute13;
501 		l_rt_row.attribute14 := l_rti_row.attribute14;
502 		l_rt_row.attribute15 := l_rti_row.attribute15;
503 		l_rt_row.movement_id := l_rti_row.movement_id;
504 		IF l_rti_row.vendor_site_id IS NOT NULL AND RCV_TABLE_FUNCTIONS.get_pvs_row_from_id(l_rti_row.vendor_site_id).pay_on_code IN ('RECEIPT','RECEIPT_AND_USE') THEN
505 			l_rt_row.invoice_status_code := 'PENDING';
506 		ELSE
507 			l_rt_row.invoice_status_code := '';
508 		END IF;
509 		l_rt_row.qa_collection_id := l_rti_row.qa_collection_id;
510 		l_rt_row.mvt_stat_status := 'NEW';
511 		l_rt_row.country_of_origin_code := l_rti_row.country_of_origin_code;
512 		--bug8920533
513 		IF l_rt_row.country_of_origin_code IS NULL AND l_rt_row.source_document_code = 'PO' AND l_rt_row.parent_transaction_id IS NOT NULL AND l_rt_row.parent_transaction_id > 0 THEN
514 		   SELECT country_of_origin_code
515 		   INTO   l_rt_row.country_of_origin_code
516 		   FROM   rcv_transactions
517 		   WHERE  transaction_id = l_rt_row.parent_transaction_id;
518 		END IF;
519 		--end bug 8920533
520 		l_rt_row.oe_order_header_id := l_rti_row.oe_order_header_id;
521 		l_rt_row.oe_order_line_id := l_rti_row.oe_order_line_id;
522 		l_rt_row.customer_id := l_rti_row.customer_id;
523 		l_rt_row.customer_site_id := l_rti_row.customer_site_id;
524 
525 		IF l_rti_row.validation_flag = 'N' THEN
526 			IF p_transaction_type = 'RECEIVE' THEN
527 				l_rt_row.transfer_lpn_id := null; --bugfix 4473005
528 			ELSE
529 				l_rt_row.lpn_id := l_rti_row.lpn_id;
530 				l_rt_row.transfer_lpn_id := l_rti_row.transfer_lpn_id;
531 			END IF;
532 		ELSE
533 			--Bug 4401341 : If transaction_type is 'SHIP' and auto_transact_code is
534 			--'RECEIVE', then we stamp the lpn_id and transfer_lpn_id columns in
535 			--rcv_transactions table.
536 			IF p_transaction_type = 'DELIVER' AND
537 			   l_rti_row.transaction_type = 'RECEIVE'
538 			THEN
539 				l_rt_row.lpn_id := l_rti_row.transfer_lpn_id;
540 				l_rt_row.transfer_lpn_id := l_rti_row.transfer_lpn_id;
541 			ELSIF p_transaction_type = 'RECEIVE' AND
542 			      l_rti_row.transaction_type = 'SHIP'
543 			THEN
544 				l_rt_row.lpn_id := l_rti_row.transfer_lpn_id;
545 				l_rt_row.transfer_lpn_id := l_rti_row.lpn_id;
546 			ELSE
547 				l_rt_row.lpn_id := l_rti_row.lpn_id;
548 				l_rt_row.transfer_lpn_id := l_rti_row.transfer_lpn_id;
549 			END IF;
550 		END IF;
551 
552 		l_rt_row.mobile_txn := l_rti_row.mobile_txn;
553 		l_rt_row.secondary_quantity := l_rti_row.secondary_quantity;
554 		l_rt_row.secondary_unit_of_measure := l_rti_row.secondary_unit_of_measure;
555 		IF l_rti_row.parent_transaction_id IS NULL THEN
556 			IF l_rti_row.po_line_location_id IS NOT NULL THEN
557 				l_rt_row.consigned_flag := RCV_TABLE_FUNCTIONS.get_pll_row_from_id(l_rti_row.po_line_location_id).consigned_flag;
558 			END IF;
559 		ELSE
560 			l_rt_row.consigned_flag := RCV_TABLE_FUNCTIONS.get_rt_row_from_id(l_rti_row.parent_transaction_id).consigned_flag;
561 		END IF;
562 
563 		l_rt_row.lpn_group_id := l_rti_row.lpn_group_id;
564 		l_rt_row.amount := l_rti_row.amount;
565 		l_rt_row.job_id := l_rti_row.job_id;
566 		l_rt_row.timecard_id := l_rti_row.timecard_id;
567 		l_rt_row.timecard_ovn := l_rti_row.timecard_ovn;
568 		l_rt_row.project_id := l_rti_row.project_id;
569 		l_rt_row.task_id := l_rti_row.task_id;
570 		l_rt_row.requested_amount := l_rti_row.requested_amount;
571 		l_rt_row.material_stored_amount := l_rti_row.material_stored_amount;
572 		l_rt_row.replenish_order_line_id := l_rti_row.replenish_order_line_id;
573 
574 		/*Bug 5517289-Start*/
575 		IF ((l_rti_row.source_document_code = 'INVENTORY') OR (l_rti_row.source_document_code = 'REQ'))  THEN
576 
577   		  OPEN c_fob_point(l_rti_row.from_organization_id,l_rti_row.to_organization_id);
578 		  FETCH c_fob_point INTO l_fob_point;
579 		  CLOSE c_fob_point;
580 
581 		  asn_debug.put_line('FOB Point is :' || l_fob_point);
582 
583 		  BEGIN
584 
585 		    IF (l_fob_point = 2) THEN
586   		      asn_debug.put_line('Validating the INV accouting period for Organization :'||l_rti_row.from_organization_id);
587 		      IF (RCV_TRANSACTION_PROCESSOR.get_acct_period_status(p_trx_date => l_rti_row.transaction_date,
588                                                                            p_org_id   => l_rti_row.from_organization_id)
589                                   NOT IN ('O', 'F')) THEN
590 			asn_debug.put_line('INV accounting period is not opened for the source organization :'|| l_rti_row.from_organization_id);
591 			x_error_message := 'PO_INV_NO_OPEN_PERIOD';
592 			RETURN;
593 		      END IF;
594 		    END IF;
595 		  EXCEPTION
596 		    WHEN OTHERS THEN
597 		      asn_debug.put_line('unexpected error in get_acct_period_status');
598 		      x_error_message := 'PO_INV_NO_OPEN_PERIOD';
599      		      RETURN;
600 		  END;
601 		END IF;
602 		/*Bug 5517289-End*/
603 
604 		/* Bug 5842219:
605 		   source_transaction_num provided in the rti table has to be
606 		   maintained in the rt table. */
607 		l_rt_row.source_transaction_num := l_rti_row.source_transaction_num;
608 		asn_debug.put_line('source_transaction_num:' || l_rt_row.source_transaction_num);
609 
610                 /* lcm changes */
611 		l_rt_row.lcm_shipment_line_id := l_rti_row.lcm_shipment_line_id;
612 		l_rt_row.unit_landed_cost := l_rti_row.unit_landed_cost;
613 		l_rt_row.lcm_adjustment_num := l_rti_row.lcm_adjustment_num; --Changes for LCM-OPM integration project
614 
615 		asn_debug.put_line('lcm_shipment_line_id is ' || l_rt_row.lcm_shipment_line_id);
616 		asn_debug.put_line('unit_landed_cost is ' || l_rt_row.unit_landed_cost);
617 		asn_debug.put_line('lcm_adjustment_num is ' || l_rt_row.lcm_adjustment_num); --Changes for LCM-OPM integration project
618 
619 		asn_debug.put_line('Inserting RT row (' || l_rt_row.transaction_type || ')...');
620 		asn_debug.put_line('transaction_id: ' || l_rt_row.transaction_id
621 			|| ' parent_transaction_id: ' || l_rt_row.parent_transaction_id
622 			|| ' interface_transaction_id: ' || l_rt_row.interface_transaction_id
623 			|| ' group_id: ' || l_rt_row.group_id
624 			|| ' request_id: ' || l_rt_row.request_id
625 			);
626 
627 		/* GSCC errors come up when we use the foll. insert.
628 		 * Changing to use the full insert stmts.
629 		INSERT INTO RCV_TRANSACTIONS
630 		VALUES l_rt_row;
631 		*/
632 	/* Bug: 6487371
633 	 *  Added exception handler to catch the exception when insertion into rcv_transactions
634 	 *  fails due to exception raised in the triggers(for eg; India Localisation triggers) on
635 	 *  rcv_transactions table. Similarly added exception handler for insertion into
636 	 *  po_note_references table. To this rvthinns() function as whole, added one exception handler.
637 	 *  While storing sqlerrm in the x_message_data getting only the first 200 bytes.
638 	 *  without that unhandled exception is raised while copying the sqlerrm. And moreover
639 	 *  in rvtth.lpc rvthinns(), x_msg_data is defined to store only 200 bytes.
640 	 */
641 	      BEGIN --Bug: 6487371
642 		INSERT INTO rcv_transactions
643 		(transaction_id,
644 		last_update_date,
645 		last_updated_by,
646 		created_by,
647 		creation_date,
648 		last_update_login,
649 		request_id,
650 		program_application_id,
651 		program_id,
652 		program_update_date,
653 		interface_source_code,
654 		interface_source_line_id,
655 		user_entered_flag,
656 		transaction_type,
657 		transaction_date,
658 		source_document_code,
659 		destination_type_code,
660 		location_id,
661 		quantity,
662 		unit_of_measure,
663 		uom_code,
664 		primary_quantity,
665 		primary_unit_of_measure,
666 		source_doc_quantity,
667 		source_doc_unit_of_measure,
668 		shipment_header_id,
669 		shipment_line_id,
670 		parent_transaction_id,
671 		employee_id,
672 		po_header_id,
673 		po_release_id,
674 		po_line_id,
675 		po_line_location_id,
676 		po_distribution_id,
677 		po_revision_num,
678 		requisition_line_id,
679 		req_distribution_id,
680 		po_unit_price,
681 		currency_code,
682 		currency_conversion_rate,
683 		currency_conversion_date,
684 		currency_conversion_type,
685 		routing_header_id,
686 		routing_step_id,
687 		substitute_unordered_code,
688 		receipt_exception_flag,
689 		inspection_status_code,
690 		inspection_quality_code,
691 		vendor_id,
692 		vendor_site_id,
693 		vendor_lot_num,
694 		organization_id,
695 		from_subinventory, /*FPJ WMS change */
696 		from_locator_id,
697 		subinventory,
698 		locator_id,
699 		rma_reference,
700 		deliver_to_person_id,
701 		deliver_to_location_id,
702 		department_code,
703 		wip_entity_id,
704 		wip_line_id,
705 		wip_repetitive_schedule_id,
706 		wip_operation_seq_num,
707 		wip_resource_seq_num,
708 		bom_resource_id,
709 		inv_transaction_id,
710 		reason_id,
711 		destination_context,
712 		comments,
713 		interface_transaction_id,
714 		group_id,
715 		attribute_category,
716 		attribute1,
717 		attribute2,
718 		attribute3,
719 		attribute4,
720 		attribute5,
721 		attribute6,
722 		attribute7,
723 		attribute8,
724 		attribute9,
725 		attribute10,
726 		attribute11,
727 		attribute12,
728 		attribute13,
729 		attribute14,
730 		attribute15,
731 		movement_id,
732 		invoice_status_code,  /* BUG 551612 */
733 		qa_collection_id,
734 		mvt_stat_status,
735 		country_of_origin_code,
736 		oe_order_header_id,
737 		oe_order_line_id,
738 		customer_id,
739 		customer_site_id,
740 		lpn_id,
741 		transfer_lpn_id,
742 		mobile_txn,
743 		secondary_quantity,
744 		secondary_unit_of_measure,
745 		secondary_uom_code, --Bug 8273466
746 		consigned_flag, /*<CONSIGNED INV RTP FPI>*/
747 		lpn_group_id, /*FPJ WMS */
748 		amount,
749 		job_id,
750 		timecard_id,
751 		timecard_ovn,
752 		project_id,
753 		task_id,
754 		requested_amount, --Complex work
755 		material_stored_amount, -- Complex Work
756 		replenish_order_line_id, -- Bug 5367699
757 		source_transaction_num, -- Bug 5842219
758 		lcm_shipment_line_id, -- lcm changes
759 		unit_landed_cost,     -- lcm changes
760 		lcm_adjustment_num )  -- changes for LCM-OPM integration project
761 		VALUES
762 		(l_rt_row.transaction_id,
763 		l_rt_row.last_update_date,
764 		l_rt_row.last_updated_by,
765 		l_rt_row.created_by,
766 		l_rt_row.creation_date,
767 		l_rt_row.last_update_login,
768 		l_rt_row.request_id,
769 		l_rt_row.program_application_id,
770 		l_rt_row.program_id,
771 		l_rt_row.program_update_date,
772 		l_rt_row.interface_source_code,
773 		l_rt_row.interface_source_line_id,
774 		l_rt_row.user_entered_flag,
775 		l_rt_row.transaction_type,
776 		l_rt_row.transaction_date,
777 		l_rt_row.source_document_code,
778 		l_rt_row.destination_type_code,
779 		l_rt_row.location_id,
780 		l_rt_row.quantity,
781 		l_rt_row.unit_of_measure,
782 		l_rt_row.uom_code,
783 		l_rt_row.primary_quantity,
784 		l_rt_row.primary_unit_of_measure,
785 		l_rt_row.source_doc_quantity,
786 		l_rt_row.source_doc_unit_of_measure,
787 		l_rt_row.shipment_header_id,
788 		l_rt_row.shipment_line_id,
789 		l_rt_row.parent_transaction_id,
790 		l_rt_row.employee_id,
791 		l_rt_row.po_header_id,
792 		l_rt_row.po_release_id,
793 		l_rt_row.po_line_id,
794 		l_rt_row.po_line_location_id,
795 		l_rt_row.po_distribution_id,
796 		l_rt_row.po_revision_num,
797 		l_rt_row.requisition_line_id,
798 		l_rt_row.req_distribution_id,
799 		l_rt_row.po_unit_price,
800 		l_rt_row.currency_code,
801 		l_rt_row.currency_conversion_rate,
802 		l_rt_row.currency_conversion_date,
803 		l_rt_row.currency_conversion_type,
804 		l_rt_row.routing_header_id,
805 		l_rt_row.routing_step_id,
806 		l_rt_row.substitute_unordered_code,
807 		l_rt_row.receipt_exception_flag,
808 		l_rt_row.inspection_status_code,
809 		l_rt_row.inspection_quality_code,
810 		l_rt_row.vendor_id,
811 		l_rt_row.vendor_site_id,
812 		l_rt_row.vendor_lot_num,
813 		l_rt_row.organization_id,
814 		l_rt_row.from_subinventory, /*FPJ WMS change */
815 		l_rt_row.from_locator_id,
816 		l_rt_row.subinventory,
817 		l_rt_row.locator_id,
818 		l_rt_row.rma_reference,
819 		l_rt_row.deliver_to_person_id,
820 		l_rt_row.deliver_to_location_id,
821 		l_rt_row.department_code,
822 		l_rt_row.wip_entity_id,
823 		l_rt_row.wip_line_id,
824 		l_rt_row.wip_repetitive_schedule_id,
825 		l_rt_row.wip_operation_seq_num,
826 		l_rt_row.wip_resource_seq_num,
827 		l_rt_row.bom_resource_id,
828 		l_rt_row.inv_transaction_id,
829 		l_rt_row.reason_id,
830 		l_rt_row.destination_context,
831 		l_rt_row.comments,
832 		l_rt_row.interface_transaction_id,
833 		l_rt_row.group_id,
834 		l_rt_row.attribute_category,
835 		l_rt_row.attribute1,
836 		l_rt_row.attribute2,
837 		l_rt_row.attribute3,
838 		l_rt_row.attribute4,
839 		l_rt_row.attribute5,
840 		l_rt_row.attribute6,
841 		l_rt_row.attribute7,
842 		l_rt_row.attribute8,
843 		l_rt_row.attribute9,
844 		l_rt_row.attribute10,
845 		l_rt_row.attribute11,
846 		l_rt_row.attribute12,
847 		l_rt_row.attribute13,
848 		l_rt_row.attribute14,
849 		l_rt_row.attribute15,
850 		l_rt_row.movement_id,
851 		l_rt_row.invoice_status_code,  /* BUG 551612 */
852 		l_rt_row.qa_collection_id,
853 		l_rt_row.mvt_stat_status,
854 		l_rt_row.country_of_origin_code,
855 		l_rt_row.oe_order_header_id,
856 		l_rt_row.oe_order_line_id,
857 		l_rt_row.customer_id,
858 		l_rt_row.customer_site_id,
859 		l_rt_row.lpn_id,
860 		l_rt_row.transfer_lpn_id,
861 		l_rt_row.mobile_txn,
862 		l_rt_row.secondary_quantity,
863 		l_rt_row.secondary_unit_of_measure,
864 		l_rti_row.secondary_uom_code,  -- Bug 8273466
865 		l_rt_row.consigned_flag, /*<CONSIGNED INV RTP FPI>*/
866 		l_rt_row.lpn_group_id, /*FPJ WMS */
867 		l_rt_row.amount,
868 		l_rt_row.job_id,
869 		l_rt_row.timecard_id,
870 		l_rt_row.timecard_ovn,
871 		l_rt_row.project_id,
872 		l_rt_row.task_id,
873 		l_rt_row.requested_amount, --Complex work
874 		l_rt_row.material_stored_amount, -- Complex Work
875 		l_rt_row.replenish_order_line_id, -- Bug 5367699
876 		l_rt_row.source_transaction_num, -- Bug 5842219
877 		l_rt_row.lcm_shipment_line_id, -- lcm changes
878 		l_rt_row.unit_landed_cost,      -- lcm changes
879 		decode(l_rt_row.lcm_shipment_line_id, null, null,nvl(l_rt_row.lcm_adjustment_num,0)) );--changes for LCM-OPM integration project
880 	     EXCEPTION --Bug: 6487371
881 	        when others then
882 	           asn_debug.put_line('Error occured while inserting into rcv_transactions...'||sqlerrm);
883 	           x_error_message := substr(sqlerrm,1,200);
884 	           RETURN;
885 	     END;--Bug: 6487371
886 
887 		x_rt_id := l_rt_row.transaction_id;
888 
889 		BEGIN
890 			asn_debug.put_line('Updating child RTI rows');
891 
892 			/* FPJ FASTFORWARD START.
893 			* If this rti row is a parent of any rti rows, then
894 			* we need to update the parent_transaction_id of
895 			* children with this new transaction id since it will
896 			* not be populated at the pre-processor stage.
897 			* Update only those rows which has parent_transaction_id
898 			* as null since if the user has populated parent_transaction_id
899 			* and parent_interface_txn_id, then we dont want to override
900 			* it.
901 			*/
902 			UPDATE rcv_transactions_interface
903 			   SET parent_transaction_id = l_rt_row.transaction_id
904 			     , shipment_line_id = l_rt_row.shipment_line_id
905 			 WHERE parent_interface_txn_id = l_rti_row.interface_transaction_id
906 			   AND parent_transaction_id IS NULL;
907 		EXCEPTION
908 			WHEN NO_DATA_FOUND THEN
909 				NULL;
910 		END;
911 
912 		IF NVL(l_rti_row.qa_collection_id,0) <> 0 THEN
913 			asn_debug.put_line('Enabling Quality Inspection Results');
914 
915 			DECLARE
916 				l_return_status VARCHAR2(1);
917 				l_msg_count NUMBER := 0;
918 				l_msg_data VARCHAR2(2000);
919 			BEGIN
920 				QA_RESULT_GRP.enable
921 					( 1
922 					, 'F'
923 					, 'F'
924 					, 0
925 					, l_rti_row.qa_collection_id
926 					, l_return_status
927 					, l_msg_count
928 					, l_msg_data
929 					);
930 
931 				IF l_msg_count IS NULL OR l_msg_count = -1 THEN
932 					asn_debug.put_line('QA Actions Failed: ' || l_msg_data);
933 					x_error_message := 'QA_ACTIONS_FAILED';
934 					RETURN;
935 				END IF;
936 			EXCEPTION
937 				WHEN OTHERS THEN
938 					asn_debug.put_line('QA Actions Failed: ' || SQLERRM);
939 					x_error_message := 'QA_ACTIONS_FAILED';
940 					RETURN;
941 			END;
942 		END IF;
943 
944 		IF l_rti_row.erecord_id IS NOT NULL AND l_rti_row.erecord_id > 0 THEN
945 			DECLARE
946 				l_event_name VARCHAR2(240);
947 				l_event_key VARCHAR2(240);
948 				l_erecord_id NUMBER;
949 				l_return_status VARCHAR2(1);
950 				l_msg_count NUMBER := 0;
951 				l_msg_data VARCHAR2(2000);
952 			BEGIN
953 				-- FPJ EDR integration
954 				-- get the event name and erecord id
955 				CASE l_rti_row.transaction_type
956 					WHEN 'ACCEPT' THEN l_event_name := 'oracle.apps.po.rcv.inspect';
957 					WHEN 'REJECT' THEN l_event_name := 'oracle.apps.po.rcv.inspect';
958 					WHEN 'DELIVER' THEN l_event_name := 'oracle.apps.po.rcv.deliver';
959 					WHEN 'TRANSFER' THEN l_event_name := 'oracle.apps.po.rcv.transfer';
960 				END CASE;
961 
962 				l_event_key := l_rti_row.parent_transaction_id || '-' || l_rti_row.qa_collection_id;
963 				l_erecord_id := l_rti_row.erecord_id;
964 
965 				-- FPJ EDR integration
966 				-- acknowledge erecord has been enabled
967 			    	QA_EDR_STANDARD.SEND_ACKN
968 					( 1.0
969 					, FND_API.G_FALSE
970 					, l_return_status
971 					, l_msg_count
972 					, l_msg_data
973 					, l_event_name
974 					, l_event_key
975 					, l_rti_row.erecord_id
976 					, 'SUCCESS'
977 					, NULL
978 					, 'Receiving Transaction Processor'
979 					, FND_API.G_TRUE
980 					);
981 
982 				IF l_return_status <> 'S' THEN
983 					asn_debug.put_line('QA_EDR_STANDARD.SEND_ACKN failed with return status: ' || l_return_status);
984 					IF l_msg_count > 0 THEN
985 						asn_debug.put_line(l_msg_data);
986 					END IF;
987 
988 					x_error_message := 'EDR_SEND_ACKN_FAILED';
989 					RETURN;
990 				END IF;
991 			EXCEPTION
992 				WHEN OTHERS THEN
993 					asn_debug.put_line('QA_EDR_STANDARD.SEND_ACKN failed');
994 					IF l_msg_count > 0 THEN
995 						asn_debug.put_line(l_msg_data);
996 					END IF;
997 
998 					asn_debug.put_line(SQLERRM);
999 
1000 					x_error_message := 'EDR_SEND_ACKN_FAILED';
1001 					RETURN;
1002 			END;
1003 		END IF;
1004 
1005 		IF get_product_install_status('CSE') = 'I' THEN
1006 			DECLARE
1007 				l_return_status VARCHAR2(1);
1008 			BEGIN
1009 				asn_debug.put_line('Calling CSE post transaction exit');
1010 				CSE_RCVTXN_PKG.PostTransaction_Exit
1011 					( l_rt_row.transaction_id
1012 					, l_rti_row.interface_transaction_id
1013 					, l_return_status
1014 					);
1015 			EXCEPTION
1016 				WHEN OTHERS THEN
1017 					NULL;
1018 			END;
1019 		END IF;
1020 
1021 		l_common_receiving := p_transaction_type = 'RECEIVE' AND
1022 		                      get_product_install_status('GMI') = 'I' AND
1023 		                      gml_po_for_process.check_po_for_proc;
1024 
1025 		IF l_common_receiving THEN
1026 			BEGIN
1027 				asn_debug.put_line('Performing Common Receiving quality event');
1028 				gml_rcv_db_common.raise_quality_event
1029 					( l_rt_row.transaction_id
1030 					, l_rti_row.item_id
1031 					, l_rti_row.to_organization_id
1032 					);
1033 			EXCEPTION
1034 				WHEN OTHERS THEN
1035 					NULL;
1036 			END;
1037 		END IF;
1038 
1039 		asn_debug.put_line('Updating PO Note References');
1040 
1041 		DECLARE
1042 			l_row_id NUMBER;
1043 		BEGIN
1044 			UPDATE po_note_references
1045 			SET table_name = 'RCV_TRANSACTIONS',
1046 			    column_name = 'TRANSACTION_ID',
1047 			    foreign_id = l_rt_row.transaction_id
1048 			WHERE table_name = 'RCV_TRANSACTIONS_INTERFACE'
1049 			AND   column_name = 'INTERFACE_TRANSACTION_ID'
1050 			AND   foreign_id = l_rti_row.interface_transaction_id;
1051 
1052 			IF SQL%ROWCOUNT > 0 AND
1053 			   p_transaction_type = 'DELIVER' AND
1054 			   l_rti_row.auto_transact_code = 'DELIVER' AND
1055 			   p_receive_id IS NOT NULL
1056 			THEN
1057 				INSERT INTO po_note_references
1058 	                (po_note_reference_id,
1059 	                 last_update_date,
1060 	                 last_updated_by,
1061 	                 last_update_login,
1062 	                 creation_date,
1063 	                 created_by,
1064 	                 po_note_id,
1065 	                 table_name,
1066 	                 column_name,
1067 	                 foreign_id,
1068 	                 sequence_num,
1069 	                 storage_type,
1070 	                 request_id,
1071 	                 program_application_id,
1072 	                 program_id,
1073 	                 program_update_date,
1074 	                 attribute_category,
1075 	                 attribute1,
1076 	                 attribute2,
1077 	                 attribute3,
1078 	                 attribute4,
1079 	                 attribute5,
1080 	                 attribute6,
1081 	                 attribute7,
1082 	                 attribute8,
1083 	                 attribute9,
1084 	                 attribute10,
1085 	                 attribute11,
1086 	                 attribute12,
1087 	                 attribute13,
1088 	                 attribute14,
1089 	                 attribute15)
1090 	           SELECT po_note_references_s.nextval,
1091 	                 last_update_date,
1092 	                 last_updated_by,
1093 	                 last_update_login,
1094 	                 creation_date,
1095 	                 created_by,
1096 	                 po_note_id,
1097 	                 table_name,
1098 	                 column_name,
1099 	                 l_rt_row.transaction_id,
1100 	                 sequence_num,
1101 	                 storage_type,
1102 	                 request_id,
1103 	                 program_application_id,
1104 	                 program_id,
1105 	                 program_update_date,
1106 	                 attribute_category,
1107 	                 attribute1,
1108 	                 attribute2,
1109 	                 attribute3,
1110 	                 attribute4,
1111 	                 attribute5,
1112 	                 attribute6,
1113 	                 attribute7,
1114 	                 attribute8,
1115 	                 attribute9,
1116 	                 attribute10,
1117 	                 attribute11,
1118 	                 attribute12,
1119 	                 attribute13,
1120 	                 attribute14,
1121 	                 attribute15
1122 	            FROM po_note_references
1123 	            WHERE table_name = 'RCV_TRANSACTIONS'
1124 	            AND   column_name = 'TRANSACTION_ID'
1125 	            AND   foreign_id = p_receive_id;
1126 			END IF;
1127 		EXCEPTION--Bug: 6487371
1128 		   when others then
1129 		      asn_debug.put_line('Error while inserting into po_note_references...'||sqlerrm);
1130 		      x_error_message := substr(sqlerrm,1,200);
1131 		      RETURN;--Bug: 6487371
1132 		END;
1133 	EXCEPTION--Bug: 6487371
1134 	   when others then
1135 	      asn_debug.put_line('Unexpected error occured...'||sqlerrm);
1136 	      x_error_message := substr(sqlerrm,1,200);
1137 	      RETURN;--Bug: 6487371
1138 
1139 	asn_debug.put_line('Done with RVTTHIns');
1140 	END RVTTHIns;
1141 
1142 END RCV_TRANSACTION_PROCESSOR;