DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSD_RECEIVE_PVT

Source


1 PACKAGE BODY csd_receive_pvt AS
2 /* $Header: csdvrcvb.pls 120.5.12020000.2 2013/04/03 07:01:05 subhat ship $ */
3 
4    -- ---------------------------------------------------------
5 -- Define global variables
6 -- ---------------------------------------------------------
7    g_pkg_name    CONSTANT VARCHAR2 (30) := 'CSD_RECEIVE_PVT';
8    g_file_name   CONSTANT VARCHAR2 (12) := 'csdvrcvb.pls';
9    g_debug_level CONSTANT NUMBER        := csd_gen_utility_pvt.g_debug_level;
10    g_prcess_sts_pending CONSTANT  VARCHAR2(10) := 'PENDING';
11    g_rcpt_source_customer CONSTANT VARCHAR2(10)  := 'CUSTOMER';
12    g_txn_type_new     CONSTANT VARCHAR2(10)  := 'NEW';
13 
14    /*****
15    PENDING',
16                    'CUSTOMER', 'NEW'
17    **/
18 
19    FUNCTION check_group_id (
20       p_group_id                 IN       NUMBER
21    )
22       RETURN BOOLEAN;
23 
24    PROCEDURE dump_receive_tbl (
25       p_receive_tbl              IN       csd_receive_util.rcv_tbl_type,
26       p_level                             NUMBER,
27       p_module                            VARCHAR2
28    );
29 
30    PROCEDURE log_error_stack;
31 
32 /*-----------------------------------------------------------------------------------------------------------*/
33 /* procedure name: RECEIVE_ITEM                                                                        */
34 /* description   : Populates the Receive open interface tables and calls the Receive processor. This handles */
35 /*                 all types of receives a) Direct b) Standard                       */
36 /* Called from   : CSDREPLN.pld. logistics tab.*/
37 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
38 /*                 p_init_msg_list       VARCHAR2    Optional Initializes message stack if fnd_api.g_true,   */
39 /*                                                            default value is fnd_api.g_false               */
40 /*                 p_commit              VARCHAR2    Optional Commits in API if fnd_api.g_true, default      */
41 /*                                                            fnd_api.g_false                                */
42 /*                 p_validation_level    NUMBER      Optional API uses this parameter to determine which     */
43 /*                                                            validation steps must be done and which steps  */
44 /*                                                            should be skipped.                             */
45 /*                 p_receive_rec         CSD_RECEIVE_UTIL.RCV_REC_TYPE      Required                             */
46 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
47 /*                                                            fnd_api.g_ret_sts_success (success)            */
48 /*                                                            fnd_api.g_ret_sts_error (error)                */
49 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
50 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
51 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
52 /*                 x_rcv_error_msg_tbl                        Returns table of error messages                */
53 /*-----------------------------------------------------------------------------------------------------------*/
54    PROCEDURE receive_item (
55       p_api_version              IN         NUMBER,
56       p_init_msg_list            IN         VARCHAR2,
57       p_commit                   IN         VARCHAR2,
58       p_validation_level         IN         NUMBER,
59       x_return_status            OUT NOCOPY VARCHAR2,
60       x_msg_count                OUT NOCOPY NUMBER,
61       x_msg_data                 OUT NOCOPY VARCHAR2,
62       x_rcv_error_msg_tbl        OUT NOCOPY csd_receive_util.rcv_error_msg_tbl,
63       p_receive_tbl              IN  OUT NOCOPY csd_receive_util.rcv_tbl_type
64    )
65    IS
66       l_api_version_number   CONSTANT NUMBER        := 1.0;
67       l_api_name             CONSTANT VARCHAR2 (30) := 'RECEIVE_ITEM';
68       l_index                         NUMBER;
69       l_request_group_id              NUMBER;
70       l_retcode                       NUMBER;
71 
72       -- subhat, for bug#9058678
73       l_receive_tbl csd_receive_util.rcv_tbl_type;
74       l_counter number := 1;
75       -- end changes,subhat, for bug#9058678
76    BEGIN
77 
78       -- Standard Start of API savepoint
79       SAVEPOINT sp_receive_item;
80 
81 
82       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
83       THEN
84          fnd_log.STRING (fnd_log.level_procedure,
85                          'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM.BEGIN',
86                          'Entered RECEIVE_ITEM'
87                         );
88       END IF;
89 
90       dump_receive_tbl ( p_receive_tbl,
91                            fnd_log.level_statement,
92                            'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM.BEGIN'
93                           );
94       IF fnd_api.to_boolean (p_init_msg_list)
95       THEN
96          -- initialize message list
97          fnd_msg_pub.initialize;
98       END IF;
99 
100       -- Standard call to check for call compatibility.
101       IF NOT fnd_api.compatible_api_call (l_api_version_number,
102                                           p_api_version,
103                                           l_api_name,
104                                           g_pkg_name
105                                          )
106       THEN
107          RAISE fnd_api.g_exc_unexpected_error;
108       END IF;
109 
110       -- initialize return status
111       x_return_status := fnd_api.g_ret_sts_success;
112 
113       /**********Program logic ******************/
114 
115       --Validate all the records in the input table.
116       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
117       THEN
118          fnd_log.STRING (fnd_log.level_event,
119                          'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
120                          'Validating Input'
121                         );
122       END IF;
123 -------------Validate Input data.
124       FOR l_index IN p_receive_tbl.FIRST .. p_receive_tbl.LAST
125       LOOP
126 	  	 -- subhat, bug#9058678.
127 	  	 -- Dont error out entire transaction if one record errors out.
128 	  	 BEGIN
129 			 csd_receive_util.validate_rcv_input
130 							   (p_validation_level      => fnd_api.g_valid_level_full,
131 								x_return_status         => x_return_status,
132 								p_receive_rec           => p_receive_tbl (l_index)
133 							   );
134 			 IF (x_return_status <> fnd_api.g_ret_sts_success)
135 			 THEN
136 				RAISE fnd_api.g_exc_error;
137 			 END IF;
138 
139 			 p_receive_tbl (l_index).routing_header_id :=
140 				csd_receive_util.is_auto_rcv_available
141 											(p_receive_tbl (l_index).inventory_item_id,
142 											 p_receive_tbl (l_index).to_organization_id,
143 											 p_receive_tbl (l_index).internal_order_flag,
144 											 p_receive_tbl (l_index).from_organization_id
145 											);
146 
147 			 IF (p_receive_tbl (l_index).routing_header_id = -1)
148 			 THEN
149 				fnd_message.set_name ('CSD', 'CSD_AUTO_RECV_NOT_POSSIBLE');
150 				fnd_msg_pub.ADD;
151 				RAISE fnd_api.g_exc_error;
152 			 END IF;
153 
154 		 EXCEPTION
155 		 	 WHEN fnd_api.g_exc_error
156 		 	 THEN
157 		 	 	p_receive_tbl.delete(l_index);
158 		 	 	IF p_receive_tbl.COUNT = 0
159 		 	 	THEN
160 		 	 		RAISE fnd_api.g_exc_error;
161 		 	 	END IF;
162 		 END;
163 		 IF p_receive_tbl.EXISTS(l_index)
164 		 THEN
165 		 	l_receive_tbl(l_counter) := p_receive_tbl(l_index);
166 		 	l_counter := l_counter + 1;
167 		 END IF;
168 		 -- end bug#9058678,subhat.
169       END LOOP;
170 
171 --------POpulate the interface tables.
172       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
173       THEN
174          fnd_log.STRING (fnd_log.level_event,
175                          'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
176                          'Populating Interface tables'
177                         );
178       END IF;
179 
180       populate_rcv_intf_tbls
181                             (p_api_version           => 1.0,
182                              p_init_msg_list         => fnd_api.g_false,
183                              p_validation_level      => fnd_api.g_valid_level_full,
184                              x_return_status         => x_return_status,
185                              x_msg_count             => x_msg_count,
186                              x_msg_data              => x_msg_data,
187                              p_receive_tbl           => l_receive_tbl, -- changed to l_receive_tbl, bug#9058678, subhat
188                              x_request_group_id      => l_request_group_id
189                             );
190 
191       IF (x_return_status <> fnd_api.g_ret_sts_success)
192       THEN
193          RAISE fnd_api.g_exc_error;
194       END IF;
195 
196 -- Call request online to invoke receiving processsor in online mode.
197       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
198       THEN
199          fnd_log.STRING (fnd_log.level_event,
200                          'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
201                          'Calling the receive api online'
202                         );
203       END IF;
204 
205       rcv_req_online (p_api_version           => 1.0,
206                       p_init_msg_list         => fnd_api.g_false,
207                       p_commit                => fnd_api.g_false,
208                       p_validation_level      => fnd_api.g_valid_level_full,
209                       x_return_status         => x_return_status,
210                       x_msg_count             => x_msg_count,
211                       x_msg_data              => x_msg_data,
212                       p_request_group_id      => l_request_group_id
213                      );
214 
215       IF (x_return_status <> fnd_api.g_ret_sts_success)
216       THEN
217          RAISE fnd_api.g_exc_error;
218       END IF;
219 
220       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
221       THEN
222          fnd_log.STRING
223             (fnd_log.level_event,
224              'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
225              'Checking the errors in interface tables after the receive process'
226             );
227       END IF;
228 
229 --Call Check_Rcv_Errors to check the errors in the PO_INTERFACE_ERRORS table.
230       csd_receive_util.check_rcv_errors
231                             (x_return_status         => x_return_status,
232                              x_rcv_error_msg_tbl     => x_rcv_error_msg_tbl,
233                              p_request_group_id      => l_request_group_id
234                             );
235 
236       IF (x_return_status <> fnd_api.g_ret_sts_success)
237       THEN
238          RAISE fnd_api.g_exc_error;
239       END IF;
240 
241 
242  -- Delete the interface table records created.
243  /************8
244 
245     DELETE_INTF_TBLS(
246                    x_return_status    => x_return_status,
247                    p_request_group_id => l_request_group_id
248                    );
249     l_request_group_id := null;
250     IF(x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
251         RAISE FND_API.G_EXC_ERROR;
252     END IF;
253     *****************/
254 
255 
256       -- Standard call to get message count and IF count is  get message info.
257       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
258                                  p_data       => x_msg_data);
259 
260       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
261       THEN
262          fnd_log.STRING (fnd_log.level_procedure,
263                          'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM.END',
264                          'Leaving RECEIVE_ITEM'
265                         );
266       END IF;
267 
268       --Commit the changes.
269       IF (p_commit = fnd_api.g_true)
270       THEN
271          COMMIT;
272       END IF;
273 
274    EXCEPTION
275       WHEN fnd_api.g_exc_error
276       THEN
277          x_return_status := fnd_api.g_ret_sts_error;
278          ROLLBACK TO sp_receive_item;
279          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
280                                     p_data       => x_msg_data);
281 
282                                     /*************************88
283          if(l_request_group_id is not null) then
284              DELETE_INTF_TBLS(
285                             x_return_status    => x_return_status,
286                             p_request_group_id => l_request_group_id
287                             );
288          end if;
289          *****************************/
290 
291          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
292          THEN
293             fnd_log.STRING (fnd_log.level_error,
294                             'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
295                             'EXC_ERROR in Receive_Item[' || x_msg_data || ']'
296                            );
297          END IF;
298       WHEN fnd_api.g_exc_unexpected_error
299       THEN
300          x_return_status := fnd_api.g_ret_sts_unexp_error;
301          ROLLBACK TO sp_receive_item;
302          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
303                                     p_data       => x_msg_data);
304 
305          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
306          THEN
307             fnd_log.STRING (fnd_log.level_exception,
308                             'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
309                             'EXC_UNEXPECTED_ERROR in Receive_Item[' || x_msg_data || ']'
310                            );
311          END IF;
312       WHEN OTHERS
313       THEN
314          x_return_status := fnd_api.g_ret_sts_unexp_error;
315          ROLLBACK TO sp_receive_item;
316 
317          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
318          THEN
319             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
320          END IF;
321 
322          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
323                                     p_data       => x_msg_data);
324 
325          IF (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level)
326          THEN
327             fnd_log.STRING (fnd_log.level_unexpected,
328                             'CSD.PLSQL.CSD_RECEIVE_PVT.RECEIVE_ITEM',
329                             'SQL Message in Receive_Item[' || SQLERRM || ']'
330                            );
331          END IF;
332    END receive_item;
333 
334 /*-----------------------------------------------------------------------------------------------------------*/
335 /* procedure name: POPULATE_INTF_TBLS                                                                          */
336 /* description   : Inserts records into open interface tables for receiving.                                                             */
337 /* Called from   : CSD_RCV_PVT.RECEIVE_ITEM api  */
338 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
339 /*                 p_init_msg_list       VARCHAR2    Optional Initializes message stack if fnd_api.g_true,   */
340 /*                                                            default value is fnd_api.g_false               */
341 /*                 p_commit              VARCHAR2    Optional Commits in API if fnd_api.g_true, default      */
342 /*                                                            fnd_api.g_false                                */
343 /*                 p_validation_level    NUMBER      Optional API uses this parameter to determine which     */
344 /*                                                            validation steps must be done and which steps  */
345 /*                                                            should be skipped.                             */
346 /*                 p_receive_rec         CSD_RECEIVE_UTIL.RCV_REC_TYPE      Required                             */
347 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
348 /*                                                            fnd_api.g_ret_sts_success (success)            */
349 /*                                                            fnd_api.g_ret_sts_error (error)                */
350 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
351 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
352 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
353 /*                 x_request_group_id    NUMBER      Required                                                */
354 /*-----------------------------------------------------------------------------------------------------------*/
355    PROCEDURE populate_rcv_intf_tbls (
356       p_api_version              IN       NUMBER,
357       p_init_msg_list            IN       VARCHAR2,
358       p_validation_level         IN       NUMBER,
359       x_return_status            OUT NOCOPY VARCHAR2,
360       x_msg_count                OUT NOCOPY NUMBER,
361       x_msg_data                 OUT NOCOPY VARCHAR2,
362       p_receive_tbl              IN       csd_receive_util.rcv_tbl_type,
363       x_request_group_id         OUT NOCOPY NUMBER
364    )
365    IS
366       pragma AUTONOMOUS_TRANSACTION;
367       l_api_version_number   CONSTANT NUMBER                        := 1.0;
368       l_api_name             CONSTANT VARCHAR2 (30)
369                                                   := 'Populate_Rcv_Intf_Tbls';
370       l_hdr_intf_id                   NUMBER;
371       i                               NUMBER;
372       p_receive_rec                   csd_receive_util.rcv_rec_type;
373       l_source_code                   VARCHAR2 (240);
374       l_source_line_id                NUMBER  := 1;
375       l_txn_tmp_id                    NUMBER;
376       l_source_header_id              NUMBER   := 1;
377       l_process_sts_pending           CONSTANT VARCHAR2(10) := 'PENDING';
378       l_rcpt_source_customer          CONSTANT VARCHAR2(10) := 'CUSTOMER';
379       l_txn_Type_new                  CONSTANT VARCHAR2(10) := 'NEW';
380       l_validation_flag               CONSTANT VARCHAR2(1)  := 'Y';
381 
382       l_lot_expiration_date           DATE;
383       l_process_flag                  CONSTANT VARCHAR2 (1)  := '1'; -- 1 means process
384       l_intf_txn_id                   NUMBER;
385       sql_str                         VARCHAR2 (2000);
386       exec_flag                       BOOLEAN;
387       l_emp_id                        NUMBER;
388       l_receipt_source_code           VARCHAR2(30);
389       l_source_document_code          VARCHAR2(30);
390       l_org_id                        NUMBER;
391 
392       cursor c_get_org_id (p_order_line_id in number) is
393       select org_id
394       from oe_order_lines_all
395       where line_id = p_order_line_id;
396 
397    BEGIN
398 
399 
400       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
401       THEN
402          fnd_log.STRING
403                    (fnd_log.level_procedure,
404                     'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS.BEGIN',
405                     'Entered Populate_Rcv_Intf_Tbls'
406                    );
407       END IF;
408 
409       l_source_code := 'CSD';
410 
411       IF fnd_api.to_boolean (p_init_msg_list)
412       THEN
413          -- initialize message list
414          fnd_msg_pub.initialize;
415       END IF;
416 
417       -- Standard call to check for call compatibility.
418       IF NOT fnd_api.compatible_api_call (l_api_version_number,
419                                           p_api_version,
420                                           l_api_name,
421                                           g_pkg_name
422                                          )
423       THEN
424          RAISE fnd_api.g_exc_unexpected_error;
425       END IF;
426 
427       -- initialize return status
428       x_return_status := fnd_api.g_ret_sts_success;
429 
430       ---Program logic.......
431       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
432       THEN
433          fnd_log.STRING (fnd_log.level_event,
434                          'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
435                          'Inserting header interface table data'
436                         );
437       END IF;
438 
439        if(p_receive_tbl (1).internal_order_flag = 'Y') then
440            l_source_document_code := 'REQ';
441            l_receipt_source_code  := 'INTERNAL ORDER';
442        else
443            l_source_document_code := 'RMA';
444            l_receipt_source_Code := 'CUSTOMER';
445        end if;
446 
447 --    Insert header record.
448       INSERT INTO rcv_headers_interface
449                   (header_interface_id,
450                    GROUP_ID,
451                    ship_to_organization_id,
452                    expected_receipt_date, last_update_date,
453                    last_updated_by, last_update_login, creation_date,
454                    created_by, validation_flag, processing_status_code,
455                    receipt_source_code, transaction_type,
456                    -- added for internal orders.
457                    shipped_Date,
458                    shipment_num
459                   )
460            VALUES (rcv_headers_interface_s.NEXTVAL,
461                    rcv_interface_groups_s.NEXTVAL,
462                    p_receive_tbl (1).to_organization_id,
463                    p_receive_tbl (1).expected_receipt_date, SYSDATE,
464                    fnd_global.user_id, fnd_global.login_id, SYSDATE,
465                    fnd_global.user_id, l_validation_flag, l_process_sts_pending,
466                    l_receipt_source_code, l_txn_Type_new,
467                    -- added for internal orders.
468                    p_receive_tbl (1).shipped_date,
469                    p_receive_tbl (1).shipment_number
470                   )
471         RETURNING header_interface_id, GROUP_ID
472              INTO l_hdr_intf_id, x_request_group_id;
473 
474 --
475 -- Dynamic sql is being used to ensure that the code is not dependent on
476 -- the 11.5.0 PO code. This will be only run time dependent.(functional dependence)
477       sql_str :=
478          'UPDATE RCV_HEADERS_INTERFACE SET HEADER_INTERFACE_ID=HEADER_INTERFACE_ID';
479       exec_flag := FALSE;
480 
481       IF (p_receive_tbl (1).customer_id IS NOT NULL)
482       THEN
483          sql_str :=
484                sql_str
485             || ',CUSTOMER_ID='
486             || TO_CHAR (p_receive_tbl (1).customer_id);
487          exec_flag := TRUE;
488       END IF;
489 
490       IF (p_receive_tbl (1).customer_site_id IS NOT NULL)
491       THEN
492          sql_str :=
493                sql_str
494             || ',CUSTOMER_SITE_ID = '
495             || TO_CHAR (p_receive_tbl (1).customer_site_id);
496          exec_flag := TRUE;
497       END IF;
498 
499 	 /**********************Commented for 4277749
500       sql_str := sql_str || ' WHERE HEADER_INTERFACE_ID=' || l_hdr_intf_id;
501 	 ***************************************/
502 
503       -- bug fix for performance bug 4277749 begin
504       sql_str := sql_str || ' WHERE HEADER_INTERFACE_ID= :1';
505       -- bug fix for performance bug 4277749 end
506 
507       IF (exec_flag)
508       THEN
509          IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
510          THEN
511             fnd_log.STRING
512                          (fnd_log.level_event,
513                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
514                              'Calling execute immediate with sql['
515                           || sql_str
516                           || ']'
517                          );
518          END IF;
519 
520          -- bug fix for performance bug 4277749 , added using clause
521          EXECUTE IMMEDIATE sql_str using l_hdr_intf_id;
522       END IF;
523 
524       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
525       THEN
526          fnd_log.STRING (fnd_log.level_event,
527                          'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
528                          'Inserting transactions interface table data'
529                         );
530       END IF;
531 
532       csd_receive_util.get_employee_id (fnd_global.user_id, l_emp_id);
533 
534       --Insert data into the transactions interface table.
535       FOR i IN p_receive_tbl.FIRST .. p_receive_tbl.LAST
536       LOOP
537          p_receive_rec := p_receive_tbl (i);
538          p_receive_rec.employee_id := l_emp_id;
539          csd_receive_util.get_rcv_item_params (p_receive_rec);
540 
541          -- Derive the Org id
542          -- MOAC change Bug#4245577
543          OPEN  c_get_org_id (p_receive_rec.order_line_id);
544   	 FETCH c_get_org_id INTO l_org_id;
545 	 CLOSE c_get_org_id;
546 
547          if(p_receive_rec.internal_order_flag = 'Y') then
548              l_source_document_code := 'REQ';
549              l_receipt_source_code  := 'INTERNAL ORDER';
550          else
551              l_source_document_code := 'RMA';
552              l_receipt_source_Code := 'CUSTOMER';
553          end if;
554 -- bug#7509332,12.1 FP, subhat.
555 -- Locator information is not passed to rcv_transactions_interface.
556 -- currently we insert the locator_id into location_id column. Where as locator_id should be
557 -- inserted into locator_id of rcv_transactions_interface.
558 -- the column descriptions from eTRM.
559 -- LOCATOR_ID 	NUMBER Destination locator unique identifier
560 -- LOCATION_ID 	NUMBER Receiving location unique identifier
561 
562          INSERT INTO rcv_transactions_interface
563                      (interface_transaction_id, header_interface_id,
564                       GROUP_ID, transaction_date,
565                       quantity, unit_of_measure,
566                       oe_order_header_id,
567                       document_num,
568                       item_id,
569                       item_revision,
570                       to_organization_id,
571                       ship_to_location_id,
572                       subinventory, last_update_date,
573                       last_updated_by, creation_date, created_by,
574                       last_update_login, validation_flag,
575                       source_document_code, interface_source_code,
576                       auto_transact_code,
577                       receipt_source_code,
578                       transaction_type,
579                       processing_status_code,
580                       processing_mode_code,
581                       transaction_status_code,
582                       -- new columns to be updated,
583                       category_id, uom_code,
584                       employee_id,
585                       primary_quantity,
586                       primary_unit_of_measure,
587                       routing_header_id, routing_step_id,
588                       inspection_status_code,
589                       destination_type_code, expected_receipt_date,
590                       destination_context,
591                       use_mtl_lot,
592                       use_mtl_serial,
593                       source_doc_quantity,
594                       source_doc_unit_of_measure, oe_order_line_id,
595                       --po_unit_price,
596                       currency_code,
597                       customer_id,
598                       customer_site_id,
599                       -- added for internal orders
600                       requisition_line_id,
601                       shipped_date,
602                       shipment_num,
603                       from_organization_id,
604                       --location_id,
605                       locator_id, --bug#7509332, 12.1 FP, subhat
606                       deliver_to_location_id,
607                       shipment_header_id,
608                       shipment_line_id,
609                       org_id,             -- MOAC change Bug#4245577
610                       attribute_category,
611                       attribute1,
612                       attribute2,
613                       attribute3,
614                       attribute4,
615                       attribute5,
616                       attribute6,
617                       attribute7,
618                       attribute8,
619                       attribute9,
620                       attribute10,
621                       attribute11,
622                       attribute12,
623                       attribute13,
624                       attribute14,
625                       attribute15
626                      )
627               VALUES (rcv_transactions_interface_s.NEXTVAL, l_hdr_intf_id,
628                       x_request_group_id, p_receive_rec.transaction_date,
629                       p_receive_rec.quantity, p_receive_rec.unit_of_measure,
630                       p_receive_rec.order_header_id,
631                       p_receive_rec.doc_number,
632                       p_receive_rec.inventory_item_id,
633                       p_receive_rec.item_revision,
634                       p_receive_rec.to_organization_id,
635                       p_receive_rec.ship_to_location_id,
636                       p_receive_rec.subinventory, SYSDATE,
637                       fnd_global.user_id, SYSDATE, fnd_global.user_id,
638                       fnd_global.login_id, 'Y',
639                       l_source_document_code
640                       , 'RCV'                     --Interface_source_Code
641                       , 'DELIVER'                         -- auto _Transact_Code
642                       , l_receipt_source_Code          --receipt_source_code
643                       , 'RECEIVE'                             --Transaction_type
644                       , 'PENDING'                      -- processing_status_Code
645                       --, 'ONLINE'                         --processing_mode _Code
646                       , decode(csd_bulk_receive_pvt.g_bulk_rcv_conc,'Y','IMMEDIATE','ONLINE') --processing_mode _Code
647                       , 'PENDING'                      --transaction_status_Code
648                       , p_receive_rec.category_id
649                       , p_receive_rec.uom_code
650                       , p_receive_rec.employee_id
651                       , p_receive_rec.quantity               -- Primary quantity
652                       , p_receive_rec.primary_unit_of_measure -- primary unit of measure.
653                       , 1------------temp---------  p_receive_rec.routing_header_id
654                       , 1
655                       ,'NOT INSPECTED'                -- inspection status code
656                       ,'INVENTORY'                     -- destination_type code
657                                  , SYSDATE,
658                       'INVENTORY'                       -- destination_context
659                                  ,
660                       p_receive_rec.lot_control_code,
661                       p_receive_rec.serial_control_code,
662                       p_receive_rec.quantity            -- Source doc quantity
663                                             ,
664                       p_receive_rec.unit_of_measure, -- source doc unit_of measure
665                       p_receive_rec.order_line_id,
666                       p_receive_rec.currency_code,
667                       p_receive_rec.customer_id,
668                       p_receive_rec.customer_site_id,
669                       -- added for internal orders
670                       p_receive_rec.requisition_line_id,
671                       p_Receive_rec.shipped_date,
672                       p_Receive_rec.shipment_number,
673                       p_Receive_rec.from_organization_id,
674                       p_Receive_rec.locator_id,
675                       p_Receive_rec.deliver_to_location_id,
676                       p_Receive_rec.shipment_header_id,
677                       p_Receive_rec.shipment_line_id,
678                       l_org_id,                 -- MOAC change Bug#4245577
679                       p_Receive_rec.attribute_category,
680                       p_Receive_rec.attribute1,
681                       p_Receive_rec.attribute2,
682                       p_Receive_rec.attribute3,
683                       p_Receive_rec.attribute4,
684                       p_Receive_rec.attribute5,
685                       p_Receive_rec.attribute6,
686                       p_Receive_rec.attribute7,
687                       p_Receive_rec.attribute8,
688                       p_Receive_rec.attribute9,
689                       p_Receive_rec.attribute10,
690                       p_Receive_rec.attribute11,
691                       p_Receive_rec.attribute12,
692                       p_Receive_rec.attribute13,
693                       p_Receive_rec.attribute14,
694                       p_Receive_rec.attribute15
695                      )
696            RETURNING interface_transaction_id
697                 INTO l_intf_txn_id;
698 
699 --
700 -- Dynamic sql is being used to ensure that the code is not dependent on
701 -- the 11.5.0 PO code. This will be only run time dependent.(functional dependence)
702          sql_str := NULL;
703 
704          IF (p_receive_rec.order_number IS NOT NULL)
705          THEN
706 	    /**********************Commented for 4277749
707             sql_str :=
708                   ' UPDATE RCV_TRANSACTIONS_INTERFACE SET OE_ORDER_NUM ='
709                || p_receive_rec.order_number
710                || ' WHERE INTERFACE_TRANSACTION_ID='
711                || l_intf_txn_id;
712 	   *******************************/
713 			-- bug fix for performance bug 4277749 begin
714                  sql_str :=
715                   ' UPDATE RCV_TRANSACTIONS_INTERFACE SET OE_ORDER_NUM = :1'
716                     || ' WHERE INTERFACE_TRANSACTION_ID=:2' ;
717 
718 			  IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
719 			  THEN
720 				fnd_log.STRING
721 						(fnd_log.level_event,
722 						 'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
723 						    'Calling execute immediate with sql['
724 						 || sql_str
725 						 || ']'
726 						);
727 			  END IF;
728                  EXECUTE IMMEDIATE sql_str using p_receive_rec.order_number,l_intf_txn_id;
729 			-- bug fix for performance bug 4277749 End
730          END IF;
731 
732 	    /**********************Commented for 4277749
733          IF (sql_str IS NOT NULL)
734          THEN
735             IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
736             THEN
737                fnd_log.STRING
738                          (fnd_log.level_event,
739                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
740                              'Calling execute immediate with sql['
741                           || sql_str
742                           || ']'
743                          );
744             END IF;
745 
746             EXECUTE IMMEDIATE sql_str;
747          END IF;
748 	    ************************************************/
749 
750          IF (p_receive_rec.lot_number IS NOT NULL)
751          THEN
752             IF (p_receive_rec.serial_number IS NOT NULL)
753             THEN
754                SELECT mtl_material_transactions_s.NEXTVAL
755                  INTO l_txn_tmp_id
756                  FROM DUAL;
757             ELSE
758                l_txn_tmp_id := l_intf_txn_id;
759             END IF;
760 
761             IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
762             THEN
763                fnd_log.STRING
764                          (fnd_log.level_event,
765                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
766                              'Inserting lot interface table data for ['
767                           || l_intf_txn_id
768                           || ']lot number['
769                           || p_receive_rec.lot_number
770                           || ']'
771                          );
772             END IF;
773 
774             INSERT INTO mtl_transaction_lots_interface
775                         (transaction_interface_id, source_code,
776                          source_line_id, last_update_date, last_updated_by,
777                          creation_date, created_by, last_update_login,
778                          lot_number, lot_expiration_date,
779                          transaction_quantity, primary_quantity,
780                          serial_transaction_temp_id
781                         )
782                  VALUES (l_intf_txn_id, l_source_code,
783                          l_source_line_id, SYSDATE, fnd_global.user_id,
784                          SYSDATE, fnd_global.user_id, fnd_global.login_id,
785                          p_receive_rec.lot_number, l_lot_expiration_date,
786                          p_receive_rec.quantity, p_receive_rec.quantity,
787                          --l_txn_tmp_id
788                          decode(p_receive_rec.serial_number,null, null,l_txn_tmp_id)
789                         );
790        --
791        -- Dynamic sql is being used to ensure that the code is not dependent on
792        -- the 11.5.0 PO code. This will be only run time dependent.(functional dependence)
793              sql_str :=
794                 'UPDATE mtl_transaction_lots_interface SET product_code=''RCV'' ';
795              sql_str :=
796                       sql_str
797                    || ',product_transaction_id='
798                    || l_intf_txn_id
799 			-- bug fix for performance bug 4277749 changed the where clause
800 			-- to use using clause
801                    || ' Where transaction_interface_id = :1';
802 
803              IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
804              THEN
805                 fnd_log.STRING
806                              (fnd_log.level_event,
807                               'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
808                                  'Calling execute immediate with sql['
809                               || sql_str
810                               || ']'
811                              );
812              END IF;
813 
814 			-- bug fix for performance bug 4277749 changed the where clause
815 			-- to use using clause
816              EXECUTE IMMEDIATE sql_str using l_intf_txn_id;
817 
818          END IF;
819 
820          --If the serial controlled rec is not null then insert records
821          -- into the serial numbers interface table
822          IF (p_receive_rec.serial_number IS NOT NULL)
823          THEN
824             IF (p_receive_rec.lot_number IS NULL)
825             THEN
826                l_txn_tmp_id := l_intf_txn_id;
827             END IF;
828 
829             IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
830             THEN
831                fnd_log.STRING
832                          (fnd_log.level_event,
833                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
834                              'Inserting serial interface table data for ['
835                           || l_intf_txn_id
836                           || ']serial number['
837                           || p_receive_rec.serial_number
838                           || ']'
839                          );
840             END IF;
841 
842             INSERT INTO mtl_serial_numbers_interface
843                         (transaction_interface_id, source_code,
844                          source_line_id, last_update_date, last_updated_by,
845                          creation_date, created_by, last_update_login,
846                          fm_serial_number,
847                          to_serial_number,
848                          process_flag
849                         )
850                  VALUES (l_txn_tmp_id, l_source_code,
851                          l_source_line_id, SYSDATE, fnd_global.user_id,
852                          SYSDATE, fnd_global.user_id, fnd_global.login_id,
853                          p_receive_rec.serial_number,
854                          p_receive_rec.serial_number,
855                          l_process_flag
856                         );
857        --
858        -- Dynamic sql is being used to ensure that the code is not dependent on
859        -- the 11.5.0 PO code. This will be only run time dependent.(functional dependence)
860              sql_str :=
861                 'UPDATE mtl_serial_numbers_interface SET product_code=''RCV'' ';
862              sql_str :=
863                       sql_str
864                    || ',product_transaction_id='
865                    || l_intf_txn_id
866 			-- bug fix for performance bug 4277749 changed the where clause
867 			-- to use using clause
868                    || ' Where transaction_interface_id = :1';
869 
870              IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
871              THEN
872                 fnd_log.STRING
873                              (fnd_log.level_event,
874                               'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
875                                  'Calling execute immediate with sql['
876                               || sql_str
877                               || ']'
878                              );
879              END IF;
880 
881 			-- bug fix for performance bug 4277749 changed the where clause
882 			-- to use using clause
883              EXECUTE IMMEDIATE sql_str using l_txn_tmp_id;
884 
885          END IF;
886       END LOOP;
887 
888 
889       -- Standard call to get message count and IF count is  get message info.
890       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
891                                  p_data       => x_msg_data);
892 
893       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
894       THEN
895          fnd_log.STRING (fnd_log.level_procedure,
896                          'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
897                          'Leaving POPULATE_RCV_INTF_TBLS'
898                         );
899       END IF;
900 
901       COMMIT;
902 
903 
904    EXCEPTION
905       WHEN fnd_api.g_exc_error
906       THEN
907          x_return_status := fnd_api.g_ret_sts_error;
908          ROLLBACK ;
909          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
910                                     p_data       => x_msg_data);
911 
912          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
913          THEN
914             fnd_log.STRING
915                          (fnd_log.level_error,
916                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
917                           'EXC_EXC_ERROR in populate rcv intf tbls [' || x_msg_data || ']'
918                          );
919          END IF;
920       WHEN fnd_api.g_exc_unexpected_error
921       THEN
922          x_return_status := fnd_api.g_ret_sts_unexp_error;
923          ROLLBACK ;
924          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
925                                     p_data       => x_msg_data);
926 
927          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
928          THEN
929             fnd_log.STRING
930                          (fnd_log.level_exception,
931                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
932                           'EXC_UNEXPECTED_ERROR in populate rcv intf tbls[' || x_msg_data || ']'
933                          );
934          END IF;
935       WHEN OTHERS
936       THEN
937          x_return_status := fnd_api.g_ret_sts_unexp_error;
938          ROLLBACK ;
939 
940          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
941          THEN
942             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
943          END IF;
944 
945          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
946                                     p_data       => x_msg_data);
947 
948          IF (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level)
949          THEN
950             fnd_log.STRING
951                          (fnd_log.level_unexpected,
952                           'CSD.PLSQL.CSD_RECEIVE_PVT.POPULATE_RCV_INTF_TBLS',
953                           'SQL Message in populate rcv intf tbls[' || SQLERRM || ']'
954                          );
955          END IF;
956    END populate_rcv_intf_tbls;
957 
958 
959 /*-----------------------------------------------------------------------------------------------------------*/
960 /* procedure name: RCV_REQ_ONLINE                                                                          */
961 /* description   : This API will submit the request for receiving in the online mode.                       */
962 /* Called from   : */
963 /* Input Parm    : p_api_version         NUMBER      Required Api Version number                             */
964 /*                 p_init_msg_list       VARCHAR2    Optional Initializes message stack if fnd_api.g_true,   */
965 /*                                                            default value is fnd_api.g_false               */
966 /*                 p_commit              VARCHAR2    Optional Commits in API if fnd_api.g_true, default      */
967 /*                                                            fnd_api.g_false                                */
968 /*                 p_validation_level    NUMBER      Optional API uses this parameter to determine which     */
969 /*                                                            validation steps must be done and which steps  */
970 /*                                                            should be skipped.                             */
971 /*                 p_request_group_id    NUMBER      Required  The request group for which the receiving     */
972 /*                                                             processor
973 /* Output Parm   : x_return_status       VARCHAR2             Return status after the call. The status can be*/
974 /*                                                            fnd_api.g_ret_sts_success (success)            */
975 /*                                                            fnd_api.g_ret_sts_error (error)                */
976 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
977 /*                 x_msg_count           NUMBER               Number of messages in the message stack        */
978 /*                 x_msg_data            VARCHAR2             Message text if x_msg_count >= 1               */
979 /*-----------------------------------------------------------------------------------------------------------*/
980    PROCEDURE rcv_req_online (
981       p_api_version              IN       NUMBER,
982       p_commit                   IN       VARCHAR2,
983       p_init_msg_list            IN       VARCHAR2,
984       p_validation_level         IN       NUMBER,
985       x_return_status            OUT NOCOPY VARCHAR2,
986       x_msg_count                OUT NOCOPY NUMBER,
987       x_msg_data                 OUT NOCOPY VARCHAR2,
988       p_request_group_id         IN       NUMBER
989    )
990    IS
991       --pragma AUTONOMOUS_TRANSACTION;
992       l_api_version_number   CONSTANT NUMBER                           := 1.0;
993       l_api_name             CONSTANT VARCHAR2 (30)       := 'RCV_REQ_ONLINE';
994       l_ret_code                      NUMBER;
995       l_outcome                       VARCHAR2 (200);
996       l_message                       fnd_new_messages.MESSAGE_TEXT%TYPE;
997       r_val1                          VARCHAR2 (200);
998       r_val2                          VARCHAR2 (200);
999       r_val3                          VARCHAR2 (200);
1000       r_val4                          VARCHAR2 (200);
1001       r_val5                          VARCHAR2 (200);
1002       r_val6                          VARCHAR2 (200);
1003       r_val7                          VARCHAR2 (200);
1004       r_val8                          VARCHAR2 (200);
1005       r_val9                          VARCHAR2 (200);
1006       r_val10                         VARCHAR2 (200);
1007       r_val11                         VARCHAR2 (200);
1008       r_val12                         VARCHAR2 (200);
1009       r_val13                         VARCHAR2 (200);
1010       r_val14                         VARCHAR2 (200);
1011       r_val15                         VARCHAR2 (200);
1012       r_val16                         VARCHAR2 (200);
1013       r_val17                         VARCHAR2 (200);
1014       r_val18                         VARCHAR2 (200);
1015       r_val19                         VARCHAR2 (200);
1016       r_val20                         VARCHAR2 (200);
1017       x_progress                      VARCHAR2 (4);
1018       l_TIMEOUT                         NUMBER;
1019       l_str1                          fnd_new_messages.MESSAGE_TEXT%TYPE
1020 ;
1021       l_str2                          fnd_new_messages.MESSAGE_TEXT%TYPE
1022 ;
1023       l_phase                         VARCHAR2 (200);
1024       l_status                        VARCHAR2 (200);
1025       l_dev_phase                     VARCHAR2 (200);
1026       l_dev_status                    VARCHAR2 (200);
1027       l_success                       BOOLEAN;
1028       l_msg_index_out                 NUMBER;
1029       l_index                         NUMBER;
1030       -- 12.1.2 Bulk Receive ER FP, subhat
1031       l_req_id                        NUMBER;
1032    BEGIN
1033 
1034 
1035       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1036       THEN
1037          fnd_log.STRING (fnd_log.level_procedure,
1038                          'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE.BEGIN',
1039                          'Entered RCV_REQ_ONLINE'
1040                         );
1041       END IF;
1042       x_progress := '000';
1043       l_TIMEOUT  := 300;
1044       l_ret_code := 0;
1045 
1046       -- Standard Start of API savepoint
1047       SAVEPOINT sp_rcv_req_online;
1048 
1049       IF fnd_api.to_boolean (p_init_msg_list)
1050       THEN
1051          -- initialize message list
1052          fnd_msg_pub.initialize;
1053       END IF;
1054 
1055       -- Standard call to check for call compatibility.
1056       IF NOT fnd_api.compatible_api_call (l_api_version_number,
1057                                           p_api_version,
1058                                           l_api_name,
1059                                           g_pkg_name
1060                                          )
1061       THEN
1062          RAISE fnd_api.g_exc_unexpected_error;
1063       END IF;
1064 
1065       -- initialize return status
1066       x_return_status := fnd_api.g_ret_sts_success;
1067 
1068       /*
1069       ** Set the cursor style to working
1070       */
1071 
1072       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1073       THEN
1074          fnd_log.STRING (fnd_log.level_event,
1075                          'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1076                             'Calling receiving processor with req group id['
1077                          || p_request_group_id
1078                          || ']'
1079                         );
1080       END IF;
1081 
1082 	-- 12.1.2 Bulk Receive ER FP, subhat.
1083 	-- If the invoking target is bulk receiving, use the IMMEDIATE mode instead of ONLINE mode.
1084 	-- IMMEDIATE mode gives record level control, where in only the errored records are rolled back.
1085 
1086 	if NVL(csd_bulk_receive_pvt.g_bulk_rcv_conc,'N') = 'N' then
1087       l_ret_code :=
1088          fnd_transaction.synchronous (l_TIMEOUT,
1089                                       l_outcome,
1090                                       l_MESSAGE,
1091                                       'PO',
1092                                       'RCVTPO',
1093                                       'ONLINE',
1094                                       p_request_group_id,
1095                                       NULL, NULL, NULL, NULL, NULL, NULL,
1096                                       NULL, NULL, NULL, NULL, NULL, NULL,
1097                                       NULL, NULL, NULL, NULL, NULL, NULL
1098                                      );
1099 
1100       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1101       THEN
1102          fnd_log.STRING (fnd_log.level_event,
1103                          'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1104                             'receiving processor, rc=['
1105                          || l_ret_code
1106                          || '],message['
1107                          || l_MESSAGE
1108                          || ']l_outcome['
1109                          || l_outcome
1110                          || ']'
1111                         );
1112       END IF;
1113 
1114       IF l_ret_code <> 0 THEN
1115          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
1116          THEN
1117             FOR l_index IN 1 .. fnd_msg_pub.count_msg
1118             LOOP
1119                fnd_msg_pub.get (p_msg_index          => l_index,
1120                                 p_encoded            => 'F',
1121                                 p_data               => l_MESSAGE,
1122                                 p_msg_index_out      => l_msg_index_out
1123                                );
1124                fnd_log.STRING (fnd_log.level_error,
1125                                'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1126                                'receiving processor, error[' || l_MESSAGE || ']'
1127                               );
1128             END LOOP;
1129          END IF;
1130       --FND_MESSAGE.SET_NAME('CSD', 'CSD_RECEIVE_ERROR');
1131       --FND_MSG_PUB.ADD;
1132       --RAISE FND_API.G_EXC_ERROR;
1133       END IF;
1134 
1135 --   dbms_output.put_line('outcome=[-'||outcome||'-]');
1136 --   dbms_output.put_line('message=[-'||message||'-]');
1137 
1138       /*
1139       ** E_SUCCESS constant number    := 0;           -- e_code is success
1140       ** E_TIMEOUT constant number    := 1;           -- e_code is timeout
1141       ** E_NOMGR   constant number    := 2;           -- e_code is no manager
1142       ** E_OTHER   constant number    := 3;           -- e_code is other
1143       */
1144       IF (l_ret_code = 0 AND (l_outcome NOT IN ('WARNING', 'ERROR')))
1145       THEN
1146          NULL;
1147       ELSIF (l_ret_code = 1)
1148       THEN
1149          IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1150          THEN
1151             fnd_log.STRING (fnd_log.level_event,
1152                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1153                             'fnd_trnasaction.synchronous  TIMED OUT'
1154                            );
1155          END IF;
1156 
1157          IF (check_group_id (p_request_group_id))
1158          THEN
1159             fnd_message.set_name ('FND', 'TM-TIMEOUT');
1160             l_str1 := fnd_message.get;
1161             fnd_message.CLEAR;
1162             -- use rcv_all_rcvoltm to get translated message
1163             fnd_message.set_name ('PO', 'RCV_ALL_RCVOLTM');
1164             l_str2 := fnd_message.get;
1165             fnd_message.CLEAR;
1166             fnd_message.set_name ('FND', 'CONC-ERROR RUNNING STANDALONE');
1167             fnd_message.set_token ('PROGRAM', l_str2);
1168             fnd_message.set_token ('REQUEST', p_request_group_id);
1169             fnd_message.set_token ('REASON', l_str1);
1170             --fnd_message.show;
1171             fnd_msg_pub.ADD;
1172             x_return_status := fnd_api.g_ret_sts_error;
1173          END IF;
1174       ELSIF (l_Ret_code = 2)
1175       THEN
1176          IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1177          THEN
1178             fnd_log.STRING
1179                (fnd_log.level_event,
1180                 'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1181                    'fnd_trnasaction.synchronous: no concurrent manager available,groupid['
1182                 || TO_CHAR (p_request_group_id)
1183                 || ']'
1184                );
1185          END IF;
1186 
1187          IF (check_group_id (p_request_group_id))
1188          THEN
1189             IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level)
1190             THEN
1191                fnd_log.STRING (fnd_log.level_statement,
1192                                'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1193                                   'Adding FND message, groupid['
1194                                || TO_CHAR (p_request_group_id)
1195                                || ']'
1196                               );
1197             END IF;
1198 
1199             fnd_message.set_name ('FND', 'TM-SVC LOCK HANDLE FAILED');
1200             l_str1 := fnd_message.get;
1201             fnd_message.CLEAR;
1202             fnd_message.set_name ('PO', 'RCV_ALL_RCVOLTM');
1203             l_str2 := fnd_message.get;
1204             fnd_message.CLEAR;
1205             fnd_message.set_name ('FND', 'CONC-ERROR RUNNING STANDALONE');
1206             fnd_message.set_token ('PROGRAM', l_str2);
1207             fnd_message.set_token ('REQUEST', p_request_group_id);
1208             fnd_message.set_token ('REASON', l_str1);
1209 
1210             IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
1211             THEN
1212                fnd_log.MESSAGE (fnd_log.level_error,
1213                                 'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE');
1214             END IF;
1215 
1216             fnd_msg_pub.ADD;
1217             x_return_status := fnd_api.g_ret_sts_error;
1218          END IF;
1219       ELSIF (l_ret_code = 3 OR (l_outcome IN ('WARNING', 'ERROR')))
1220       THEN
1221          IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1222          THEN
1223             fnd_log.STRING (fnd_log.level_event,
1224                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1225                                'fnd_synschronous:rc['
1226                             || l_Ret_code
1227                             || '],outcome['
1228                             || l_outcome
1229                             || '],for request group['
1230                             || p_request_group_id
1231                             || ']'
1232                            );
1233          END IF;
1234 
1235          log_error_stack ();
1236          --IF (check_group_id(p_request_group_id)) THEN
1237          x_progress := '010';
1238          l_Ret_Code :=
1239             fnd_transaction.get_values (r_val1,
1240                                         r_val2,
1241                                         r_val3,
1242                                         r_val4,
1243                                         r_val5,
1244                                         r_val6,
1245                                         r_val7,
1246                                         r_val8,
1247                                         r_val9,
1248                                         r_val10,
1249                                         r_val11,
1250                                         r_val12,
1251                                         r_val13,
1252                                         r_val14,
1253                                         r_val15,
1254                                         r_val16,
1255                                         r_val17,
1256                                         r_val18,
1257                                         r_val19,
1258                                         r_val20
1259                                        );
1260          l_str1 := r_val1;
1261 
1262          IF (r_val2 IS NOT NULL)
1263          THEN
1264             l_str1 := l_str1 || r_val2;
1265          END IF;
1266 
1267          IF (r_val3 IS NOT NULL)
1268          THEN
1269             l_str1 := l_str1 || r_val3;
1270          END IF;
1271 
1272          IF (r_val4 IS NOT NULL)
1273          THEN
1274             l_str1 := l_str1 || r_val4;
1275          END IF;
1276 
1277          IF (r_val5 IS NOT NULL)
1278          THEN
1279             l_str1 := l_str1 || r_val5;
1280          END IF;
1281 
1282          IF (r_val6 IS NOT NULL)
1283          THEN
1284             l_str1 := l_str1 || r_val6;
1285          END IF;
1286 
1287          IF (r_val7 IS NOT NULL)
1288          THEN
1289             l_str1 := l_str1 || r_val7;
1290          END IF;
1291 
1292          IF (r_val8 IS NOT NULL)
1293          THEN
1294             l_str1 := l_str1 || r_val8;
1295          END IF;
1296 
1297          IF (r_val9 IS NOT NULL)
1298          THEN
1299             l_str1 := l_str1 || r_val9;
1300          END IF;
1301 
1302          IF (r_val10 IS NOT NULL)
1303          THEN
1304             l_str1 := l_str1 || r_val10;
1305          END IF;
1306 
1307          IF (r_val11 IS NOT NULL)
1308          THEN
1309             l_str1 := l_str1 || r_val11;
1310          END IF;
1311 
1312          IF (r_val12 IS NOT NULL)
1313          THEN
1314             l_str1 := l_str1 || r_val12;
1315          END IF;
1316 
1317          IF (r_val13 IS NOT NULL)
1318          THEN
1319             l_str1 := l_str1 || r_val13;
1320          END IF;
1321 
1322          IF (r_val14 IS NOT NULL)
1323          THEN
1324             l_str1 := l_str1 || r_val14;
1325          END IF;
1326 
1327          IF (r_val15 IS NOT NULL)
1328          THEN
1329             l_str1 := l_str1 || r_val15;
1330          END IF;
1331 
1332          IF (r_val16 IS NOT NULL)
1333          THEN
1334             l_str1 := l_str1 || r_val16;
1335          END IF;
1336 
1337          IF (r_val17 IS NOT NULL)
1338          THEN
1339             l_str1 := l_str1 || r_val17;
1340          END IF;
1341 
1342          IF (r_val18 IS NOT NULL)
1343          THEN
1344             l_str1 := l_str1 || r_val18;
1345          END IF;
1346 
1347          IF (r_val19 IS NOT NULL)
1348          THEN
1349             l_str1 := l_str1 || r_val19;
1350          END IF;
1351 
1352          IF (r_val20 IS NOT NULL)
1353          THEN
1354             l_str1 := l_str1 || r_val20;
1355          END IF;
1356 
1357          FND_MESSAGE.SET_NAME('CSD','CSD_AUTO_RCV_ERROR');
1358          FND_MESSAGE.SET_TOKEN('RCV_ERROR',l_Str1);
1359          FND_MSG_PUB.add;
1360 
1361          IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1362          THEN
1363             fnd_log.STRING (fnd_log.level_event,
1364                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1365                             'fnd_trnasaction.synchronous:[' || l_str1 || ']'
1366                            );
1367          END IF;
1368 
1369          x_return_status := fnd_api.g_ret_sts_error;
1370       --END IF;
1371       END IF;
1372 	 -- 12.1.2 Bulk Receive ER FP, subhat.
1373 	 -- when the request is submitted from Bulk Receive Page,
1374 	 -- launch the concurrent request in IMMEDIATE mode.
1375 	  else
1376 
1377      	l_req_id := fnd_request.submit_request(application => 'PO',
1378       										   program     => 'RVCTP',
1379       										   sub_request => true,
1380       										   argument1   => 'IMMEDIATE',
1381                             			       argument2   => p_request_group_id
1382 											    );
1383 
1384     	-- after submitting the request, put the parent in the paused status.
1385     	-- if the parent is not put into paused status, child may not get launched properly.
1386     	-- the request group id will be used for post processing.
1387     	fnd_conc_global.set_req_globals(conc_status => 'PAUSED',
1388     								request_data => to_char(p_request_group_id));
1389 
1390 
1391     	-- Put the concurrent Id to global variable. This will be used in process bulk receive API
1392      	csd_bulk_receive_pvt.g_conc_req_id := l_req_id;
1393 
1394       end if;
1395       -- end 12.1.2 Bulk Receive ER FP, subhat..
1396       -- Standard call to get message count and IF count is  get message info.
1397       fnd_msg_pub.count_and_get (p_count      => x_msg_count,
1398                                  p_data       => x_msg_data);
1399 
1400       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1401       THEN
1402          fnd_log.STRING (fnd_log.level_procedure,
1403                          'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE.END',
1404                          'Leaving RCV_REQ_ONLINE'
1405                         );
1406       END IF;
1407    EXCEPTION
1408       WHEN fnd_api.g_exc_error
1409       THEN
1410          x_return_status := fnd_api.g_ret_sts_error;
1411          ROLLBACK TO sp_rcv_req_online;
1412          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
1413                                     p_data       => x_msg_data);
1414 
1415          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
1416          THEN
1417             fnd_log.STRING (fnd_log.level_error,
1418                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1419                             'EXC_ERROR[' || x_msg_data || ']'
1420                            );
1421          END IF;
1422       WHEN fnd_api.g_exc_unexpected_error
1423       THEN
1424          x_return_status := fnd_api.g_ret_sts_unexp_error;
1425          ROLLBACK TO sp_rcv_req_online;
1426          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
1427                                     p_data       => x_msg_data);
1428 
1429          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
1430          THEN
1431             fnd_log.STRING (fnd_log.level_exception,
1432                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1433                             'EXC_UNEXPECTED_ERROR  in RCV_REQ_ONLINE[' || x_msg_data || ']'
1434                            );
1435          END IF;
1436       WHEN OTHERS
1437       THEN
1438          x_return_status := fnd_api.g_ret_sts_unexp_error;
1439          ROLLBACK TO sp_rcv_req_online;
1440 
1441          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
1442          THEN
1443             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1444          END IF;
1445 
1446          fnd_msg_pub.count_and_get (p_count      => x_msg_count,
1447                                     p_data       => x_msg_data);
1448 
1449          IF (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level)
1450          THEN
1451             fnd_log.STRING (fnd_log.level_unexpected,
1452                             'CSD.PLSQL.CSD_RECEIVE_PVT.RCV_REQ_ONLINE',
1453                             'SQL Error MEssage in RCV_REQ_ONLINE[' || SQLERRM || ']'
1454                            );
1455          END IF;
1456    END rcv_req_online;
1457 
1458 /*-----------------------------------------------------------------------------------------------------------*/
1459 /* procedure name: DELETE_INTF_TBLS                                                                          */
1460 /* description   : Deletes records in RCV_HEADERS_INTERFACE, RCV_TRANSACTIONS_INTERFACE., PO_INTERFACE_ERRORS*/
1461 /*                 MTL_TRANSACTION_LOTS_INTERFACE_TBL, MTL_SERIAL_NUMBERS_INTERFACE_TBL tables.                                                                                   */
1462 /* Called from   : receive_item api                                                                          */
1463 /* Input Parm    :                                                                                           */
1464 /*                 p_request_group_id            NUMBER      Required                                                */
1465 /*                 p_interface_transaction_Id    NUMBER      Required                                                */
1466 /*                 p_interface_header_Id         NUMBER      Required                                                */
1467 /* Output Parm   : x_return_status               VARCHAR2    Return status after the call. The status can be*/
1468 /*                                                            fnd_api.g_ret_sts_success (success)            */
1469 /*                                                            fnd_api.g_ret_sts_error (error)                */
1470 /*                                                            fnd_api.g_ret_sts_unexp_error (unexpected)     */
1471 /*-----------------------------------------------------------------------------------------------------------*/
1472    PROCEDURE delete_intf_tbls (
1473       x_return_status      OUT NOCOPY      VARCHAR2,
1474       p_request_group_id   IN              NUMBER
1475    )
1476    IS
1477       pragma AUTONOMOUS_TRANSACTION;
1478       l_api_version_number   CONSTANT NUMBER        := 1.0;
1479       l_api_name             CONSTANT VARCHAR2 (30) := 'Delete_Intf_Tbls';
1480       l_txn_temp_id          NUMBER ;
1481 
1482 --Cursor to get the headers interface records.
1483       CURSOR cur_headers(p_group_Id NUMBER) is
1484         SELECT HEADER_INTERFACE_ID
1485         FROM RCV_HEADERS_INTERFACE
1486         WHERE GROUP_ID = p_group_id;
1487 --Cursor to get the transactions interface records.
1488       CURSOR cur_transactions(p_group_Id NUMBER) is
1489         SELECT INTERFACE_TRANSACTION_ID
1490         FROM RCV_TRANSACTIONS_INTERFACE
1491         WHERE GROUP_ID = p_group_id;
1492    BEGIN
1493 
1494       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1495       THEN
1496          fnd_log.STRING (fnd_log.level_procedure,
1497                          'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS.BEGIN',
1498                          'Entered Delete_Intf_Tbls'
1499                         );
1500       END IF;
1501 
1502       -- initialize return status
1503       x_return_status := fnd_api.g_ret_sts_success;
1504 
1505 
1506       -----------------------------------------------Delete from errors table
1507       FOR l_hdr_rec in cur_headers(p_request_group_id) LOOP
1508           BEGIN
1509              DELETE FROM po_interface_errors err
1510                    WHERE err.interface_header_id = l_hdr_Rec.header_interface_id;
1511 
1512           EXCEPTION
1513              WHEN NO_DATA_FOUND
1514              THEN
1515                 NULL;
1516              WHEN OTHERS
1517              THEN
1518                 RAISE fnd_api.g_exc_unexpected_error;
1519           END;
1520       END LOOP;
1521 
1522       FOR l_txn_rec in cur_transactions(p_request_group_id) LOOP
1523           BEGIN
1524              DELETE FROM po_interface_errors err
1525                    WHERE err.interface_transaction_id = l_txn_rec.interface_transaction_id;
1526 
1527           EXCEPTION
1528              WHEN NO_DATA_FOUND
1529              THEN
1530                 NULL;
1531              WHEN OTHERS
1532              THEN
1533                 RAISE fnd_api.g_exc_unexpected_error;
1534           END;
1535       END LOOP;
1536 
1537       ----------------------------------------------Delete from the MTL lots/MTL serial numbers
1538       --------------------------------------------- interface table.
1539       FOR l_txn_rec in cur_transactions(p_request_group_id) LOOP
1540           BEGIN
1541              DELETE FROM mtl_transaction_lots_interface
1542                    WHERE TRANSACTION_INTERFACE_ID = l_txn_rec.interface_transaction_Id
1543                    RETURNING SERIAL_TRANSACTION_TEMP_ID into l_txn_temp_id;
1544 
1545              DELETE FROM mtl_serial_numbers_interface
1546                    WHERE (TRANSACTION_INTERFACE_ID = l_txn_rec.interface_transaction_Id
1547                          OR TRANSACTION_INTERFACE_ID = l_txn_temp_id);
1548           EXCEPTION
1549              WHEN NO_DATA_FOUND
1550              THEN
1551                 NULL;
1552              WHEN OTHERS
1553              THEN
1554                 RAISE fnd_api.g_exc_unexpected_error;
1555           END;
1556       END LOOP;
1557 
1558       ----------------------------------------------Delete from headers table.
1559       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1560       THEN
1561          fnd_log.STRING (fnd_log.level_event,
1562                          'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS',
1563                          'Deleting from the headers table'
1564                         );
1565       END IF;
1566 
1567       BEGIN
1568          DELETE FROM rcv_headers_interface
1569                WHERE GROUP_ID = p_request_group_id;
1570       EXCEPTION
1571          WHEN NO_DATA_FOUND
1572          THEN
1573             NULL;
1574          WHEN OTHERS
1575          THEN
1576             RAISE fnd_api.g_exc_unexpected_error;
1577       END;
1578       ----------------------------------------------Delete from the detail txn records.
1579       IF (fnd_log.level_event >= fnd_log.g_current_runtime_level)
1580       THEN
1581          fnd_log.STRING (fnd_log.level_event,
1582                          'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS',
1583                          'Deleting from the detail table'
1584                         );
1585       END IF;
1586 
1587       BEGIN
1588          DELETE FROM rcv_transactions_interface
1589                WHERE GROUP_ID = p_request_group_id;
1590       EXCEPTION
1591          WHEN NO_DATA_FOUND
1592          THEN
1593             NULL;
1594          WHEN OTHERS
1595          THEN
1596             RAISE fnd_api.g_exc_unexpected_error;
1597       END;
1598 
1599 
1600       COMMIT;
1601 
1602       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1603       THEN
1604          fnd_log.STRING (fnd_log.level_procedure,
1605                          'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS.END',
1606                          'Leaving DELETE_INTF_TBLS'
1607                         );
1608       END IF;
1609    EXCEPTION
1610       WHEN fnd_api.g_exc_unexpected_error
1611       THEN
1612          x_return_status := fnd_api.g_ret_sts_unexp_error;
1613          ROLLBACK ;
1614          IF (fnd_log.level_exception >= fnd_log.g_current_runtime_level)
1615          THEN
1616             fnd_log.STRING (fnd_log.level_exception,
1617                             'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS',
1618                             'EXC_UNEXPECTED_ERROR in delete_intf_tbls'
1619                            );
1620          END IF;
1621       WHEN OTHERS
1622       THEN
1623          x_return_status := fnd_api.g_ret_sts_unexp_error;
1624          ROLLBACK;
1625 
1626          IF fnd_msg_pub.check_msg_level (fnd_msg_pub.g_msg_lvl_unexp_error)
1627          THEN
1628             fnd_msg_pub.add_exc_msg (g_pkg_name, l_api_name);
1629          END IF;
1630 
1631          IF (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level)
1632          THEN
1633             fnd_log.STRING (fnd_log.level_unexpected,
1634                             'CSD.PLSQL.CSD_RECEIVE_PVT.DELETE_INTF_TBLS',
1635                             'SQL Message in delete_intf_tbls[' || SQLERRM || ']'
1636                            );
1637          END IF;
1638    END delete_intf_tbls;
1639 
1640 
1641 /*=============================================================
1642 
1643   FUNCTION NAME:     check_group_id
1644 
1645 =============================================================*/
1646    FUNCTION check_group_id (
1647       p_group_id                 IN       NUMBER
1648    )
1649       RETURN BOOLEAN
1650    IS
1651       l_rec_count   NUMBER := 0;
1652    BEGIN
1653       IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1654       THEN
1655          fnd_log.STRING (fnd_log.level_procedure,
1656                          'CSD.PLSQL.CSD_RECEIVE_PVT.CHECK_GROUP_ID.BEGIN',
1657                          'Entered check_group_id, groupid[' || p_group_id
1658                          || ']'
1659                         );
1660       END IF;
1661 
1662       SELECT COUNT (1)
1663         INTO l_rec_count
1664         FROM rcv_transactions_interface
1665        WHERE GROUP_ID = p_group_id;
1666 
1667       IF (l_rec_count = 0)
1668       THEN
1669          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1670          THEN
1671             fnd_log.STRING (fnd_log.level_procedure,
1672                             'CSD.PLSQL.CSD_RECEIVE_PVT.CHECK_GROUP_ID.END',
1673                             'returning false from check_group_id'
1674                            );
1675          END IF;
1676 
1677          RETURN (FALSE);
1678       ELSE
1679          IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)
1680          THEN
1681             fnd_log.STRING (fnd_log.level_procedure,
1682                             'CSD.PLSQL.CSD_RECEIVE_PVT.CHECK_GROUP_ID.END',
1683                             'returning true from check_group_id'
1684                            );
1685          END IF;
1686 
1687          RETURN (TRUE);
1688       END IF;
1689 
1690       RETURN NULL;
1691    EXCEPTION
1692       WHEN NO_DATA_FOUND
1693       THEN
1694          RETURN (FALSE);
1695       WHEN OTHERS
1696       THEN
1697          RAISE;
1698    END check_group_id;
1699 
1700 /****************************************************************
1701 Dupms the input receive table records in to log
1702 *****************************************************************/
1703    PROCEDURE dump_receive_tbl (
1704       p_receive_tbl              IN       csd_receive_util.rcv_tbl_type,
1705       p_level                             NUMBER,
1706       p_module                            VARCHAR2
1707    )
1708    IS
1709       i   INTEGER;
1710    BEGIN
1711 	 FOR i IN p_receive_tbl.FIRST .. p_receive_tbl.LAST
1712 	 LOOP
1713 	    IF (p_level >= fnd_log.g_current_runtime_level)
1714 	    THEN
1715 		 fnd_log.STRING (p_level, p_module,
1716 				    TO_CHAR (i)
1717 				 || ':'
1718 				 || TO_CHAR (p_receive_tbl (i).customer_id)
1719 				);
1720 		 fnd_log.STRING (p_level, p_module,
1721 				    TO_CHAR (i)
1722 				 || ':'
1723 				 || TO_CHAR (p_receive_tbl (i).customer_site_id)
1724 				);
1725 		 fnd_log.STRING (p_level, p_module,
1726 				    TO_CHAR (i)
1727 				 || ':'
1728 				 || TO_CHAR (p_receive_tbl (i).employee_id)
1729 				);
1730 		 fnd_log.STRING (p_level,
1731 				 p_module,
1732 				    TO_CHAR (i)
1733 				 || ':'
1734 				 || TO_CHAR (p_receive_tbl (i).quantity)
1735 				);
1736 		 fnd_log.STRING (p_level,
1737 				 p_module,
1738 				 TO_CHAR (i) || ':' || p_receive_tbl (i).uom_code
1739 				);
1740 		 fnd_log.STRING (p_level,
1741 				 p_module,
1742 				    TO_CHAR (i)
1743 				 || ':'
1744 				 || TO_CHAR (p_receive_tbl (i).inventory_item_id)
1745 				);
1746 		 fnd_log.STRING (p_level,
1747 				 p_module,
1748 				 TO_CHAR (i) || ':' || p_receive_tbl (i).item_revision
1749 				);
1750 		 fnd_log.STRING (p_level,
1751 				 p_module,
1752 				    TO_CHAR (i)
1753 				 || ':'
1754 				 || TO_CHAR (p_receive_tbl (i).to_organization_id)
1755 				);
1756 		 fnd_log.STRING (p_level,
1757 				 p_module,
1758 				    TO_CHAR (i)
1759 				 || ':'
1760 				 || p_receive_tbl (i).destination_type_code
1761 				);
1762 		 fnd_log.STRING (p_level,
1763 				 p_module,
1764 				 TO_CHAR (i) || ':' || p_receive_tbl (i).subinventory
1765 				);
1766 		 fnd_log.STRING (p_level,
1767 				 p_module,
1768 				    TO_CHAR (i)
1769 				 || ':'
1770 				 || TO_CHAR (p_receive_tbl (i).locator_id)
1771 				);
1772 		 fnd_log.STRING (p_level,
1773 				 p_module,
1774 				    TO_CHAR (i)
1775 				 || ':'
1776 				 || TO_CHAR (p_receive_tbl (i).deliver_to_location_id)
1777 				);
1778 		 fnd_log.STRING (p_level,
1779 				 p_module,
1780 				    TO_CHAR (i)
1781 				 || ':'
1782 				 || TO_CHAR (p_receive_tbl (i).requisition_number)
1783 				);
1784 		 fnd_log.STRING (p_level,
1785 				 p_module,
1786 				    TO_CHAR (i)
1787 				 || ':'
1788 				 || TO_CHAR (p_receive_tbl (i).order_header_id)
1789 				);
1790 		 fnd_log.STRING (p_level,
1791 				 p_module,
1792 				    TO_CHAR (i)
1793 				 || ':'
1794 				 || TO_CHAR (p_receive_tbl (i).order_line_id)
1795 				);
1796 		 fnd_log.STRING (p_level,
1797 				 p_module,
1798 				 TO_CHAR (i) || ':' || p_receive_tbl (i).order_number
1799 				);
1800 		 fnd_log.STRING (p_level,
1801 				 p_module,
1802 				 TO_CHAR (i) || ':' || p_receive_tbl (i).doc_number
1803 				);
1804 		 fnd_log.STRING (p_level,
1805 				 p_module,
1806 				    TO_CHAR (i)
1807 				 || ':'
1808 				 || p_receive_tbl (i).internal_order_flag
1809 				);
1810 		 fnd_log.STRING (p_level,
1811 				 p_module,
1812 				    TO_CHAR (i)
1813 				 || ':'
1814 				 || TO_CHAR (p_receive_tbl (i).from_organization_id)
1815 				);
1816 		 fnd_log.STRING (p_level,
1817 				 p_module,
1818 				    TO_CHAR (i)
1819 				 || ':'
1820 				 || TO_CHAR (p_receive_tbl (i).expected_receipt_date)
1821 				);
1822 		 fnd_log.STRING (p_level,
1823 				 p_module,
1824 				    TO_CHAR (i)
1825 				 || ':'
1826 				 || TO_CHAR (p_receive_tbl (i).transaction_date)
1827 				);
1828 		 fnd_log.STRING (p_level,
1829 				 p_module,
1830 				    TO_CHAR (i)
1831 				 || ':'
1832 				 || TO_CHAR (p_receive_tbl (i).ship_to_location_id)
1833 				);
1834         END IF;
1835 	 END LOOP;
1836    END dump_receive_tbl;
1837 
1838    /*************procedure to log the error stack..........
1839    ****************/
1840    PROCEDURE log_error_stack
1841    IS
1842       l_count       NUMBER;
1843       l_msg         VARCHAR2 (2000);
1844       l_index_out   NUMBER;
1845    BEGIN
1846       l_count := fnd_msg_pub.count_msg ();
1847 
1848       IF (l_count > 0)
1849       THEN
1850          FOR i IN 1 .. l_count
1851          LOOP
1852             fnd_msg_pub.get (p_msg_index          => i,
1853                              p_encoded            => 'F',
1854                              p_data               => l_msg,
1855                              p_msg_index_out      => l_index_out
1856                             );
1857 
1858             IF (fnd_log.level_error >= fnd_log.g_current_runtime_level)
1859             THEN
1860                fnd_log.STRING (fnd_log.level_error,
1861                                'CSD.PLSQL.CSD_RECEIVE_PVT.log_error_stack',
1862                                'error[' || l_msg || ']'
1863                               );
1864             END IF;
1865          END LOOP;
1866       END IF;
1867    END log_error_stack;
1868 END csd_receive_pvt;