DBA Data[Home] [Help]

PACKAGE BODY: APPS.JMF_SHIKYU_INV_PVT

Source


1 PACKAGE BODY JMF_SHIKYU_INV_PVT AS
2 -- $Header: JMFVSKIB.pls 120.10 2006/06/17 00:26:38 vchu noship $ --
3 --+=======================================================================+
4 --|               Copyright (c) 2005 Oracle Corporation                   |
5 --|                       Redwood Shores, CA, USA                         |
6 --|                         All rights reserved.                          |
7 --+=======================================================================+
8 --| FILENAME                                                              |
9 --|     JMFVSKIB.pls                                                      |
10 --|                                                                       |
11 --| DESCRIPTION                                                           |
12 --|   This package contains INV related calls that the Interlock          |
13 --|   accesses when processing SHIKYU transactions                        |
14 --| HISTORY                                                               |
15 --|     05/09/2005 pseshadr       Created                                 |
16 --|     07/08/2005 vchu           Fixed GSCC error File.Pkg.21.           |
17 --|                               Removed the Init procedure, since GSCC  |
18 --|                               checker requires directly comparing     |
19 --|                               FND_LOG.G_CURRENT_RUNTIME_LEVEL to      |
20 --|                               constants for different levels.         |
21 --|     10/24/2005 vmutyala       Bug:-4670527, Made some changes         |
22 --|                               to Process_Transaction procedure        |
23 --|     01/26/2006 vchu           Bug 4964675.  Populate                  |
24 --|                               transaction_source_id column of         |
25 --|                               mtl_transactions_interface with         |
26 --|                               wip_entity_id for WIP Component Issue   |
27 --|                               and Return.                             |
28 --|     03/07/2006 vchu           Fixed the WIP Component Issue           |
29 --|                               transactions by multiplying the         |
30 --|                               quantity to be issued by -1.  Quantity  |
31 --|                               should be relative to the inventory.    |
32 --|     03/09/2006 vchu           Bug 4869546.  Shortened the transaction |
33 --|                               source name for MISC Issue and Receipt  |
34 --|                               to 'Process SHIKYU RCV Trxns' because   |
35 --|                               of bug 5086940.                         |
36 --|                               Also, stamped wip_entity_type to be 1   |
37 --|                               only if the transaction is WIP related, |
38 --|                               otherwise wip_entity_type should be     |
39 --|                               NULL, such as for MISC Issue and MISC   |
40 --|                               Receipt.                                |
41 --|     03/10/2006 vchu           Removed commented code.                 |
42 --|     03/21/2006 vchu           Changed the source name for MISC Issue  |
43 --|                               and Receipt back to 'Process SHIKYU     |
44 --|                               Receiving Transactions' since INV has   |
45 --|                               fixed bug 5086940                       |
46 --|     03/22/2006 vchu           Added a check in Process_Transaction to |
47 --|                               set x_return_status to                  |
48 --|                               FND_API.G_RET_STS_ERROR if the return   |
49 --|                               status from                             |
50 --|                               INV_TXN_MANAGER_PUB.Process_Transactions|
51 --|                               is NULL                                 |
52 --|     06/16/2006 vchu           Fixed Bug 5337725: Modified the         |
53 --|                               Process_Transaction procedure to get    |
54 --|                               the locator used to supply component to |
55 --|                               WIP, and then pass it to the            |
56 --|                               mtl_transactions_interface table, if    |
57 --|                               the transaction is WIP Component Issue  |
58 --|                               or WIP Component Return.                |
59 --+=======================================================================+
60 
61 --=============================================
62 -- CONSTANTS
63 --=============================================
64 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'JMF_SHIKYU_INV_PVT';
65 G_MODULE_PREFIX CONSTANT VARCHAR2(50) := 'jmf.plsql.' || G_PKG_NAME || '.';
66 
67 --=============================================
68 -- GLOBAL VARIABLES
69 --=============================================
70 
71 --=============================================
72 -- PROCEDURES AND FUNCTIONS
73 --=============================================
74 
75 --========================================================================
76 -- PROCEDURE : Process_Misc_Rcpt     PUBLIC
77 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
78 --             p_quantity                   Quantity
79 --             x_return_status              Return Status
80 -- COMMENT   : This procedure invokes the Process_Transaction
81 --             with the appropriate transaction type to process
82 --             the Misc. rcpt transaction into Inventory.
83 --========================================================================
84 PROCEDURE Process_Misc_Rcpt
85 ( p_subcontract_po_shipment_id IN  NUMBER
86 , p_osa_quantity               IN  NUMBER
87 , p_uom                        IN  VARCHAR2
88 , x_return_status              OUT NOCOPY VARCHAR2
89 )
90 IS
91 
92 l_api_name CONSTANT VARCHAR2(30) := 'Process_Misc_Rcpt';
93 
94 l_osa_item_id NUMBER;
95 
96 BEGIN
97 
98   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
99     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
100                   , G_MODULE_PREFIX || l_api_name || '.begin'
101                   , NULL);
102   END IF;
103 
104   x_return_status := FND_API.G_RET_STS_SUCCESS;
105 
106   SELECT OSA_ITEM_ID
107   INTO l_osa_item_id
108   FROM JMF_SUBCONTRACT_ORDERS
109   WHERE SUBCONTRACT_PO_SHIPMENT_ID = p_subcontract_po_shipment_id
110   AND ROWNUM = 1;
111 
112   Process_Transaction
113   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
114   , p_quantity                   => p_osa_quantity
115   , p_item_id                    => l_osa_item_id
116   , p_transaction_type_id        => 42
117   , p_transaction_action_id      => 27
118   , p_uom                        => p_uom
119   , x_return_status              => x_return_status
120   );
121 
122   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
123     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
124                   , G_MODULE_PREFIX || l_api_name || '.end'
125                   , NULL);
126   END IF;
127 
128 EXCEPTION
129   WHEN NO_DATA_FOUND THEN
130     x_return_status := FND_API.G_RET_STS_ERROR;
131     IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
132       FND_LOG.string( FND_LOG.LEVEL_EXCEPTION
133                     , G_MODULE_PREFIX || l_api_name || '.No Date Found'
134                     , 'Exception - Subcontracting Purchase Order Shipment : '
135                     || p_subcontract_po_shipment_id);
136     END IF;
137   WHEN OTHERS THEN
138     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
139     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
140       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
141                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
142                     , 'Exception');
143     END IF;
144 
145 END Process_Misc_Rcpt;
146 
147 --========================================================================
148 -- PROCEDURE : Process_Misc_Issue     PUBLIC
149 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
150 --             p_quantity                   Quantity
151 --            x_return_status               Return Status
152 -- COMMENT   : This procedure invokes the Process_Transaction
153 --             with the appropriate transaction type to process
154 --             the Misc. issue transaction into Inventory.
155 --========================================================================
156 PROCEDURE Process_Misc_Issue
157 ( p_subcontract_po_shipment_id IN  NUMBER
158 , p_osa_quantity               IN  NUMBER
159 , p_uom                        IN  VARCHAR2
160 , x_return_status              OUT NOCOPY VARCHAR2
161 )
162 IS
163 
164 l_api_name CONSTANT VARCHAR2(30) := 'Process_Misc_Rcpt';
165 
166 l_osa_item_id NUMBER;
167 
168 BEGIN
169   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
170     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
171                   , G_MODULE_PREFIX || l_api_name || '.begin'
172                   , NULL);
173   END IF;
174 
175   x_return_status := FND_API.G_RET_STS_SUCCESS;
176 
177   SELECT OSA_ITEM_ID
178   INTO l_osa_item_id
179   FROM JMF_SUBCONTRACT_ORDERS
180   WHERE SUBCONTRACT_PO_SHIPMENT_ID = p_subcontract_po_shipment_id
181   AND ROWNUM = 1;
182 
183   Process_Transaction
184   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
185   , p_quantity                   => p_osa_quantity
186   , p_item_id                    => l_osa_item_id
187   , p_transaction_type_id        => 32
188   , p_transaction_action_id      => 1
189   , p_uom                        => p_uom
190   , x_return_status              => x_return_status
191   );
192 
193   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
194     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
195                   , G_MODULE_PREFIX || l_api_name || '.end'
196                   , NULL);
197   END IF;
198 
199 EXCEPTION
200   WHEN NO_DATA_FOUND THEN
201     x_return_status := FND_API.G_RET_STS_ERROR;
202     IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
203       FND_LOG.string( FND_LOG.LEVEL_EXCEPTION
204                     , G_MODULE_PREFIX || l_api_name || '.No Date Found'
205                     , 'Exception - Subcontracting Purchase Order Shipment : '
206                     || p_subcontract_po_shipment_id);
207     END IF;
208   WHEN OTHERS THEN
209     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
210     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
211       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
212                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
213                     , 'Exception');
214     END IF;
215 END Process_Misc_Issue;
216 
217 --========================================================================
218 -- PROCEDURE : Process_WIP_Completion     PUBLIC
219 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
220 --             p_quantity                   Quantity
221 --            x_return_status               Return Status
222 -- COMMENT   : This procedure invokes the Process_Transaction
223 --             with the appropriate transaction type to process
224 --             the WIP completion transaction into Inventory.
225 --========================================================================
226 PROCEDURE Process_WIP_Completion
227 ( p_subcontract_po_shipment_id IN  NUMBER
228 , p_osa_quantity               IN  NUMBER
229 , p_uom                        IN  VARCHAR2
230 , x_return_status              OUT NOCOPY VARCHAR2
231 )
232 IS
233 
234 l_api_name CONSTANT VARCHAR2(30) := 'Process_WIP_Completion';
235 
236 l_osa_item_id NUMBER;
237 
238 BEGIN
239   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
240     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
241                   , G_MODULE_PREFIX || l_api_name || '.begin'
242                   , NULL);
243   END IF;
244 
245   x_return_status := FND_API.G_RET_STS_SUCCESS;
246 
247   SELECT OSA_ITEM_ID
248   INTO l_osa_item_id
249   FROM JMF_SUBCONTRACT_ORDERS
250   WHERE SUBCONTRACT_PO_SHIPMENT_ID = p_subcontract_po_shipment_id
251   AND ROWNUM = 1;
252 
253   Process_Transaction
254   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
255   , p_quantity                   => p_osa_quantity
256   , p_item_id                    => l_osa_item_id
257   , p_transaction_type_id        => 44
258   , p_transaction_action_id      => 31
259   , p_uom                        => p_uom
260   , x_return_status              => x_return_status
261   );
262 
263   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
264     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
265                   , G_MODULE_PREFIX || l_api_name || '.end'
266                   , NULL);
267   END IF;
268 
269 EXCEPTION
270   WHEN NO_DATA_FOUND THEN
271     x_return_status := FND_API.G_RET_STS_ERROR;
272     IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
273       FND_LOG.string( FND_LOG.LEVEL_EXCEPTION
274                     , G_MODULE_PREFIX || l_api_name || '.No Date Found'
275                     , 'Exception - Subcontracting Purchase Order Shipment : '
276                     || p_subcontract_po_shipment_id);
277     END IF;
278   WHEN OTHERS THEN
279     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
280     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
281       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
282                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
283                     , 'Exception');
284     END IF;
285 END Process_WIP_Completion;
286 
287 --========================================================================
288 -- PROCEDURE : Process_WIP_Assy_Return     PUBLIC
289 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
290 --             p_quantity                   Quantity
291 --            x_return_status               Return Status
292 -- COMMENT   : This procedure invokes the Process_Transaction
293 --             with the appropriate transaction type to process
294 --             the WIP Assembly return transaction into Inventory.
295 --========================================================================
296 PROCEDURE Process_WIP_Assy_Return
297 ( p_subcontract_po_shipment_id IN  NUMBER
298 , p_osa_quantity               IN  NUMBER
299 , p_uom                        IN  VARCHAR2
300 , x_return_status              OUT NOCOPY VARCHAR2
301 )
302 IS
303 
304 l_api_name CONSTANT VARCHAR2(30) := 'Process_WIP_Assy_Return';
305 
306 l_osa_item_id NUMBER;
307 
308 BEGIN
309   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
310     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
311                   , G_MODULE_PREFIX || l_api_name || '.begin'
312                   , NULL);
313   END IF;
314 
315   x_return_status := FND_API.G_RET_STS_SUCCESS;
316 
317   SELECT OSA_ITEM_ID
318   INTO l_osa_item_id
319   FROM JMF_SUBCONTRACT_ORDERS
320   WHERE SUBCONTRACT_PO_SHIPMENT_ID = p_subcontract_po_shipment_id
321   AND ROWNUM = 1;
322 
323   Process_Transaction
324   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
325   , p_quantity                   => p_osa_quantity
326   , p_item_id                    => l_osa_item_id
327   , p_transaction_type_id        => 17
328   , p_transaction_action_id      => 32
329   , p_uom                        => p_uom
330   , x_return_status              => x_return_status
331   );
332 
333   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
334     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
335                   , G_MODULE_PREFIX || l_api_name || '.end'
336                   , NULL);
337   END IF;
338 
339 EXCEPTION
340   WHEN NO_DATA_FOUND THEN
341     x_return_status := FND_API.G_RET_STS_ERROR;
342     IF (FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
343       FND_LOG.string( FND_LOG.LEVEL_EXCEPTION
344                     , G_MODULE_PREFIX || l_api_name || '.No Date Found'
345                     , 'Exception - Subcontracting Purchase Order Shipment : '
346                     || p_subcontract_po_shipment_id);
347     END IF;
348   WHEN OTHERS THEN
349     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
350     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
351       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
352                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
353                     , 'Exception');
354     END IF;
355 END Process_WIP_Assy_Return;
356 
357 --========================================================================
358 -- PROCEDURE : Process_WIP_Component_Return     PUBLIC
359 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
360 --             p_quantity                   Quantity
361 --             p_component_id               SUbcontract assembly component
362 --            x_return_status               Return Status
363 -- COMMENT   : This procedure invokes the Process_Transaction
364 --             with the appropriate transaction type to process
365 --             the WIP Component_Return transaction into Inventory.
366 --========================================================================
367 PROCEDURE Process_WIP_Component_Return
368 ( p_subcontract_po_shipment_id IN  NUMBER
369 , p_quantity                   IN  NUMBER
370 , p_component_id               IN  NUMBER
371 , p_uom                        IN  VARCHAR2
372 , x_return_status              OUT NOCOPY VARCHAR2
373 )
374 IS
375 
376 l_api_name CONSTANT VARCHAR2(30) := 'Process_WIP_Component_Return';
377 
378 BEGIN
379   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
380     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
381                   , G_MODULE_PREFIX || l_api_name || '.begin'
382                   , NULL);
383   END IF;
384 
385   x_return_status := FND_API.G_RET_STS_SUCCESS;
386 
387   Process_Transaction
388   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
389   , p_quantity                   => p_quantity
390   , p_item_id                    => p_component_id
391   , p_transaction_type_id        => 43
392   , p_transaction_action_id      => 27
393   , p_uom                        => p_uom
394   , x_return_status              => x_return_status
395   );
396 
397   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
398     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
399                   , G_MODULE_PREFIX || l_api_name || '.end'
400                   , NULL);
401   END IF;
402 
403 EXCEPTION
404   WHEN OTHERS THEN
405     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
406     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
407       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
408                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
409                     , 'Exception');
410     END IF;
411 END Process_WIP_Component_Return;
412 
413 --========================================================================
414 -- PROCEDURE : Process_WIP_Component_Issue     PUBLIC
415 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
416 --             p_quantity                   Quantity
417 --             p_component_id               SUbcontract assembly component
418 --             x_return_status               Return Status
419 -- COMMENT   : This procedure invokes the Process_Transaction
420 --             with the appropriate transaction type to process
421 --             the WIP Component Issue transaction into Inventory.
422 --========================================================================
423 PROCEDURE Process_WIP_Component_Issue
424 ( p_subcontract_po_shipment_id IN  NUMBER
425 , p_quantity                   IN  NUMBER
426 , p_component_id               IN  NUMBER
427 , p_uom                        IN  VARCHAR2
428 , x_return_status              OUT NOCOPY VARCHAR2
429 )
430 IS
431 
432 l_api_name CONSTANT VARCHAR2(30) := 'Process_WIP_Component_Issue';
433 
434 BEGIN
435   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
436     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
437                   , G_MODULE_PREFIX || l_api_name || '.begin'
438                   , NULL);
439   END IF;
440 
441   x_return_status := FND_API.G_RET_STS_SUCCESS;
442 
443   Process_Transaction
444   ( p_subcontract_po_shipment_id => p_subcontract_po_shipment_id
445   , p_quantity                   => p_quantity * -1
446   , p_item_id                    => p_component_id
447   , p_transaction_type_id        => 35
448   , p_transaction_action_id      => 1
449   , p_uom                        => p_uom
450   , x_return_status              => x_return_status
451   );
452 
453   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
454     FND_LOG.string( FND_LOG.LEVEL_PROCEDURE
455                   , G_MODULE_PREFIX || l_api_name || '.end'
456                   , NULL);
457   END IF;
458 
459 EXCEPTION
460   WHEN OTHERS THEN
461     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
462     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
463       FND_LOG.string( FND_LOG.LEVEL_UNEXPECTED
464                     , G_MODULE_PREFIX || l_api_name || '.others_exception'
465                     , 'Exception');
466     END IF;
467 END Process_WIP_Component_Issue;
468 
469 
470 --========================================================================
471 -- PROCEDURE : Process_Transaction     PUBLIC
472 -- PARAMETERS: p_subcontract_po_shipment_id OSA PO Shipment Id
473 --             p_quantity                   Quantity
474 --             p_item_id                    SUbcontract assembly component
475 --             p_transaction_type_id        Transaction Type
476 --             p_transaction_action_id      Transaction Action
477 --            x_return_status               Return Status
478 -- COMMENT   : This procedure inserts records in inventory interface
479 --             tables and invokes the Inventory TM to insert into MMT
480 --========================================================================
481 PROCEDURE Process_Transaction
482 ( p_subcontract_po_shipment_id IN  NUMBER
483 , p_quantity                   IN  NUMBER
484 , p_item_id                    IN  NUMBER
485 , p_transaction_type_id        IN  NUMBER
486 , p_transaction_action_id      IN  NUMBER
487 , p_uom                        IN  VARCHAR2
488 , x_return_status              OUT NOCOPY VARCHAR2
489 )
490 IS
491   TYPE l_onhand_rec_Typ IS RECORD
492   ( subinventory_code            VARCHAR2(25)
493   , primary_transaction_quantity NUMBER
494   , inventory_item_id            NUMBER
495   , organization_id              NUMBER
496   , date_received                DATE
497   , insert_flag                  VARCHAR2(1)
498   );
499 
500   l_onhand_rec        l_onhand_rec_Typ;
501   l_header_id         NUMBER;
502   l_line_id           NUMBER;
503   l_source_header_id  NUMBER;
504   l_source_line_id    NUMBER;
505   l_organization_id   NUMBER;
506   l_subinventory_code VARCHAR2(10);
507   l_operation_seq     NUMBER;
508   l_return_status     VARCHAR2(1);
509   l_msg_count         NUMBER;
510   l_trans_count       NUMBER;
511   l_msg_data          VARCHAR2(2000);
512   l_primary_uom       VARCHAR2(3);
513   l_primary_quantity  NUMBER;
514   l_status            NUMBER;
515 
516  /* vmutyala added the following local variables for Bug 4670527*/
517   l_wip_entity_id            NUMBER;        -- will be inserted into mtl_transactions_interface as transaction_source_id
518   l_transaction_quantity     NUMBER;
519   l_distribution_account_id  NUMBER;
520 
521   -- Added for the fix of bug 4869546
522   l_transaction_source_name  VARCHAR2(80);
523 
524   l_wip_entity_type          NUMBER;
525   l_locator_id               NUMBER;
526 
527 BEGIN
528   SELECT tp_organization_id
529   INTO   l_organization_id
530   FROM   jmf_subcontract_orders
531   WHERE  subcontract_po_shipment_id = p_subcontract_po_shipment_id;
532 
533   l_primary_uom:= JMF_SHIKYU_UTIL.Get_Primary_UOM_Code
534                     ( p_item_id , l_organization_id);
535 
536   IF p_uom <> l_primary_uom
537   THEN
538     l_primary_quantity := INV_CONVERT.inv_um_convert
539                           ( item_id             => p_item_id
540                           , precision           => 5
541                           , from_quantity       => p_quantity
542                           , from_unit           => p_uom
543                           , to_unit             => l_primary_uom
544                           , from_name           => null
545                           , to_name             => null
546                           );
547    ELSE
548       l_primary_quantity := p_quantity;
549    END IF;
550 
551   -- Bug 4964675
552   -- If transaction is WIP Component Issue or Return
553   IF p_transaction_type_id IN (35, 43)
554   THEN
555 
556     -- Bug 5337725: Get the locator used to supply component to WIP,
557     -- and pass it to the mtl_Transactions_interface table
558     SELECT wro.supply_subinventory,
559            wro.supply_locator_id
560     INTO   l_subinventory_code,
561            l_locator_id
562     FROM   wip_requirement_operations wro,
563            jmf_subcontract_orders jso
564     WHERE  wro.wip_entity_id = jso.wip_entity_id
565     AND    wro.inventory_item_id = p_item_id
566     AND    wro.organization_id = jso.tp_organization_id
567     AND    jso.subcontract_po_shipment_id = p_subcontract_po_shipment_id;
568 
569   ELSE
570 
571     SELECT DEFAULT_PULL_SUPPLY_SUBINV
572     INTO   l_subinventory_code
573     FROM   WIP_PARAMETERS
574     WHERE  ORGANIZATION_ID = l_organization_id;
575 
576     SELECT wro.supply_locator_id
577     INTO l_locator_id
578     FROM WIP_REQUIREMENT_OPERATIONS wro,
579            jmf_subcontract_orders jso
580     WHERE wro.wip_entity_id = jso.wip_entity_id
581     AND   wro.organization_id = jso.tp_organization_id
582     AND   wro.ORGANIZATION_ID = l_organization_id
583     AND   jso.subcontract_po_shipment_id = p_subcontract_po_shipment_id
584     AND   rownum = 1;
585 
586   END IF;
587 
588    /* vmutyala added the following code to ensure that transaction quantity is
589       negative for Misc. issue transaction, WIP Assembly return, Bug 4670527 */
590    IF (p_transaction_type_id IN (32, 17) AND l_primary_quantity > 0) THEN
591 	l_transaction_quantity := -l_primary_quantity;
592 	l_primary_quantity := -l_primary_quantity;
593     ELSE
594 	l_transaction_quantity := l_primary_quantity;
595     END IF;
596 
597    /* vmutyala added the following code to fetch distribution account and insert
598       into mtl_Transactions_interface Bug 4670527 */
599    IF p_transaction_type_id IN (42, 32)
600     THEN
601        JMF_SHIKYU_UTIL.Get_Shikyu_Offset_Account(p_subcontract_po_shipment_id,l_distribution_account_id);
602    ELSE
603        l_distribution_account_id  := NULL;
604    END IF;
605 
606    /* vmutyala added the following code to fetch wip entity id and insert as
607       transaction_source_id into mtl_Transactions_interface for Bug 4670527 */
608 
609    -- Bug 4964675
610    -- Added transaction types 35 and 43 for WIP Component Issue or Return
611 
612    l_wip_entity_id := NULL;
613    l_wip_entity_type := NULL;
614 
615    IF P_transaction_type_id IN (17, 44, 35, 43)
616     THEN
617     SELECT wdj.wip_entity_id
618     INTO   l_wip_entity_id
619     FROM   wip_discrete_jobs wdj
620        ,   jmf_subcontract_orders jso
621     WHERE  jso.wip_entity_id = wdj.wip_entity_id
622     AND    jso.tp_organization_id = wdj.organization_id
623     AND    wdj.organization_id = l_organization_id
624     AND   jso.subcontract_po_shipment_id = p_subcontract_po_shipment_id;
625 
626     -- Populate the wip_entity_type to be 1, if the transaction is WIP
627     -- related
628     l_wip_entity_type := 1;
629 
630    END IF;
631 
632    -- Bug 4869546
633    -- Added the following logic to stamp the correct transaction source name
634 
635    -- If transaction is Misc. Issue or Misc. Receipt
636    IF P_transaction_type_id IN (32, 42)
637    THEN
638 
639      -- Shortened the transaction source name because of bug 5086940
640      l_transaction_source_name := 'Process SHIKYU Receiving Transactions';
641 
642    -- If transaction is WIP Component Issue or Return
643    ELSIF P_transaction_type_id IN (17, 44, 35, 43)
644    THEN
645 
646      l_transaction_source_name := NULL;
647 
648    ELSE
649 
650      l_transaction_source_name := 'SHIKYU Interlock';
651 
652    END IF;
653 
654    SELECT mtl_material_transactions_s.nextval
655    INTO   l_header_id
656    FROM   sys.dual;
657 
658   /* vmutyala added the following code to initialize l_source_line_id,
659      l_source_header_id before insert for Bug 4670527 */
660 
661    l_source_line_id   := 1;
662    l_source_header_id := 1;
663 
664   /* vmutyala changed the following insert statement to add FINAL_COMPLETION_FLAG,
665      DISTRIBUTION_ACCOUNT_ID, transaction_source_id for insertion Bug 4670527 */
666 
667   INSERT INTO mtl_Transactions_interface
668   ( source_code
669   , source_line_id
670   , source_header_id
671   , process_flag
672   , transaction_mode
673   , inventory_item_id
674   , organization_id
675   , subinventory_code
676   , transaction_quantity
677   , transaction_uom
678   , transaction_date
679   , transaction_source_name
680   , transaction_type_id
681   , wip_entity_type
682   , operation_seq_num
683   , primary_quantity
684   , last_update_date
685   , last_updated_by
686   , creation_date
687   , created_by
688   , transaction_header_id
689   , validation_required
690   , FINAL_COMPLETION_FLAG
691   , DISTRIBUTION_ACCOUNT_ID
692   , transaction_source_id
693   , locator_id
694   )
695   VALUES
696   ( p_subcontract_po_shipment_id
697   , l_source_line_id
698   , l_source_header_id
699   , 1
700   , 2 -- concurrent processing
701   , p_item_id
702   , l_organization_id
703   , l_subinventory_code
704   , l_transaction_quantity
705   , p_uom
706   , sysdate
707   , l_transaction_source_name
708   , p_Transaction_type_id
709   , l_wip_entity_type
710   , 1
711   , l_primary_quantity
712   , sysdate
713   , FND_GLOBAL.user_id
714   , sysdate
715   , FND_GLOBAL.user_id
716   , l_header_id
717   , 2
718   , 'N'
719   , l_distribution_account_id
720   , l_wip_entity_id
721   , l_locator_id
722   );
723 
724   l_status := INV_TXN_MANAGER_PUB.Process_Transactions
725   ( p_api_version        => 1.0
726   , p_header_id          => l_header_id
727   , x_return_status      => l_return_status
728   , x_msg_count          => l_msg_count
729   , x_msg_data           => l_msg_data
730   , x_trans_count        => l_trans_count
731   );
732 
733   IF l_return_status IS NULL
734   THEN
735     x_return_status := FND_API.G_RET_STS_ERROR;
736   ELSE
737     x_return_status := l_return_status;
738   END IF;
739 
740   IF l_return_status <> FND_API.G_RET_STS_SUCCESS
741   THEN
742      FND_MESSAGE.Set_Name('JMF', 'JMF_SHK_INV_PROCESS_FAIL');
743      FND_MSG_PUB.Add;
744   END IF;
745 
746 END Process_Transaction;
747 
748 END JMF_SHIKYU_INV_PVT;