DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_REQIMP_S

Source


1 PACKAGE BODY PO_REQIMP_S AS
2 /* $Header: POXRQIMB.pls 120.6 2011/05/17 11:25:59 uchennam ship $*/
3 
4 --< Bug 3540365 Start >
5 g_bulk_limit CONSTANT NUMBER := 1000;  -- Bulk collect limit in number of rows
6 --< Bug 3540365 End >
7 
8 PROCEDURE get_list_price_conversion(x_request_id IN NUMBER,x_currency_code IN VARCHAR2,x_set_of_books_id IN NUMBER) IS
9 
10 x_progress	VARCHAR2(3)  := NULL ;
11 x_rowid 	VARCHAR2(250) := '';
12 x_item_id	NUMBER;
13 x_source_org_id	NUMBER := NULL;
14 x_rate_date	DATE;
15 x_gl_date	DATE;
16 x_creation_date	DATE;
17 x_list_price_conv_temp NUMBER;
18 
19 CURSOR inv_lines IS
20     select rowid, item_id,rate_date, gl_date, creation_date, source_organization_id
21     from po_requisitions_interface
22     where source_type_code = 'INVENTORY'
23     and unit_price is NULL
24     and item_id is not NULL
25     and source_organization_id is not null
26     and request_id = x_request_id;
27 
28 BEGIN
29     x_progress := '010';
30     OPEN inv_lines;
31     LOOP
32       FETCH inv_lines into
33 		x_rowid,
34                 x_item_id,
35                 x_rate_date,
36                 x_gl_date,
37                 x_creation_date,
38                 x_source_org_id;
39     EXIT WHEN inv_lines%NOTFOUND;
40 
41     begin
42        Select round(gl_currency_api.get_closest_rate_sql(x_set_of_books_id,glsob.currency_code,
43            trunc(nvl(nvl(nvl(x_rate_date,x_gl_date),x_creation_date),sysdate)),
44                        psp.DEFAULT_RATE_TYPE, 30),10)
45 	INTO x_list_price_conv_temp
46 	FROM gl_sets_of_books glsob,org_organization_definitions ood,po_system_parameters psp
47 	WHERE  x_currency_code <> glsob.currency_code
48 	    AND  glsob.set_of_books_id = ood.set_of_books_id
49 	    AND ood.organization_id = x_source_org_id
50 	    AND psp.DEFAULT_RATE_TYPE in (select DEFAULT_RATE_TYPE from po_system_parameters);
51        EXCEPTION
52          WHEN NO_DATA_FOUND THEN
53          x_list_price_conv_temp := 1;
54          WHEN OTHERS THEN
55          x_list_price_conv_temp := 1;
56        END;
57 
58       If (x_list_price_conv_temp < 0) then
59 
60      	update po_requisitions_interface
61 	     set unit_price = (select  msi.list_price_per_unit
62                          FROM mtl_system_items msi
63                         WHERE msi.inventory_item_id = x_item_id
64                           AND msi.organization_id = x_source_org_id)
65 		where rowid = x_rowid;
66 
67       else
68 
69 	update po_requisitions_interface
70 	     set unit_price = (select ( msi.list_price_per_unit * x_list_price_conv_temp)
71                          FROM mtl_system_items msi
72                         WHERE msi.inventory_item_id = x_item_id
73                           AND msi.organization_id = x_source_org_id)
74      		where rowid = x_rowid;
75       end if;
76 
77   END LOOP;
78   CLOSE inv_lines;
79 
80   EXCEPTION
81   WHEN OTHERS THEN
82     po_message_s.sql_error('get_list_price', x_progress, sqlcode);
83     RAISE;
84 END get_list_price_conversion;
85 
86 
87 PROCEDURE get_uom_conversion(x_request_id IN NUMBER,x_inventory_org_id IN NUMBER) IS
88 
89   x_progress		VARCHAR2(3)  := NULL ;
90   x_rowid			VARCHAR2(250) := '';
91   x_item_id			NUMBER;
92   x_uom				VARCHAR2(30);
93   x_uom_conversion_temp		NUMBER := 1;
94   --Bug#11668528
95   x_list_price NUMBER;
96   x_destination_org_id NUMBER;
97   x_line_type_id number;
98   --Bug#11668528
99 CURSOR vendor_lines IS
100     select rowid, item_id,unit_of_measure,
101     DESTINATION_ORGANIZATION_ID,line_type_id --Bug#11668528
102     from po_requisitions_interface
103     where source_type_code = 'VENDOR'
104     and unit_price is NULL
105     and request_id = x_request_id;
106 
107 BEGIN
108 
109     x_progress := '010';
110     OPEN vendor_lines;
111     LOOP
112       FETCH vendor_lines into
113 		x_rowid,
114                 x_item_id,
115                 x_uom,
116                 x_destination_org_id ,x_line_type_id;  --Bug#11668528
117     EXIT WHEN vendor_lines%NOTFOUND;
118 
119     begin
120        --Bug# 1347733
121        --togeorge 12/05/2000
122        --Switched the first two arguments in the call to the procedure po_uom_convert.
123        --This is done to avoid inaccurate value after conversion.
124        --SELECT  round(po_uom_s.po_uom_convert(msi.primary_unit_of_measure,  x_uom,  x_item_id),10)
125        SELECT  round(po_uom_s.po_uom_convert(x_uom, msi.primary_unit_of_measure, x_item_id),10)
126 	INTO x_uom_conversion_temp
127              FROM mtl_system_items msi
128             WHERE msi.inventory_item_id = x_item_id
129             AND  x_inventory_org_id = msi.organization_id
130             AND msi.primary_unit_of_measure <> x_uom;
131        EXCEPTION
132          WHEN NO_DATA_FOUND THEN
133 	 x_uom_conversion_temp := 1;
134          WHEN OTHERS THEN
135 	 x_uom_conversion_temp := 1;
136        END;
137        --Bug#11668528 Start
138        BEGIN
139        	   SELECT round(msi.list_price_per_unit * (x_uom_conversion_temp),10)
140        	   INTO x_list_price
141            FROM mtl_system_items msi,
142                 po_line_types plt
143            WHERE msi.inventory_item_id = x_item_id
144            AND msi.organization_id = x_destination_org_id
145            AND plt.line_type_id = x_line_type_id
146            AND plt.order_type_lookup_code = 'QUANTITY';
147         EXCEPTION
148           WHEN OTHERS THEN
149              X_LIST_PRICE := NULL;
150         END;
151 
152         IF x_list_price IS NULL THEN
153             BEGIN
154 			       	   SELECT round(msi.list_price_per_unit * (x_uom_conversion_temp),10)
155 			       	   INTO x_list_price
156 			           FROM mtl_system_items msi,
157 			                po_line_types plt
158 			           WHERE msi.inventory_item_id = x_item_id
159 			           AND msi.organization_id = x_inventory_org_id
160 			           AND plt.line_type_id = x_line_type_id
161 			           AND plt.order_type_lookup_code = 'QUANTITY';
162 		        EXCEPTION
163 			          WHEN OTHERS THEN
164 			             X_LIST_PRICE := NULL;
165 		        END;
166 		     END IF;
167        -->Bug# 1347733 End
168        UPDATE po_requisitions_interface pri
169        --Bug# 1347733
170        --togeorge 12/05/2000
171        --List price is multiplied with uom conversion instead of dividing.
172        --This is done to avoid inaccurate value after conversion.
173        --SET pri.unit_price = (SELECT round(msi.list_price_per_unit / (x_uom_conversion_temp),10)
174        --Commented below to update price with x_list_price Bug# 11668528
175        /*        SET pri.unit_price = (SELECT round(msi.list_price_per_unit * (x_uom_conversion_temp),10)
176                              FROM mtl_system_items msi,
177                                   po_line_types plt
178                             WHERE msi.inventory_item_id = pri.item_id
179                               AND pri.DESTINATION_ORGANIZATION_ID
180                                          = msi.organization_id
181                               AND pri.line_type_id = plt.line_type_id
182                               AND plt.order_type_lookup_code = 'QUANTITY') Bug# 1347733 */
183            SET  pri.unit_price = x_list_price
184              WHERE rowid = x_rowid;
185   END LOOP;
186   CLOSE vendor_lines;
187 
188   EXCEPTION
189   WHEN OTHERS THEN
190     po_message_s.sql_error('get_uom', x_progress, sqlcode);
191     RAISE;
192 END get_uom_conversion;
193 
194 --< Bug 3540365 Start >
195 --------------------------------------------------------------------------------
196 --Start of Comments
197 --Name: default_trx_reason_codes
198 --Pre-reqs:
199 --  None.
200 --Modifies:
201 --  PO_REQUISITIONS_INTERFACE
202 --Locks:
203 --  None.
204 --Function:
205 --  Defaults transaction reason codes based upon req line data in the interface
206 --  table only if defaulting is supported in the current installation.
207 --  Defaulting logic implemented by JL team. Writes to concurrent log file
208 --  when unexpected errors occur.
209 --Parameters:
210 --IN:
211 --p_request_id
212 --  The ID for the current requistion import request.
213 --End of Comments
214 --------------------------------------------------------------------------------
215 PROCEDURE default_trx_reason_codes( p_request_id IN NUMBER )
216 IS
217 
218 CURSOR l_null_pri_trx_csr IS
219     SELECT transaction_id
220          , destination_organization_id
221          , item_id
222       FROM po_requisitions_interface
223      WHERE request_id = p_request_id
224        AND transaction_reason_code IS NULL;
225 
226 l_return_status          VARCHAR2(1);
227 l_default_supported_flag VARCHAR2(1);
228 l_progress               VARCHAR2(3);
229 
230 l_fsp_inv_org_id FINANCIALS_SYSTEM_PARAMS_ALL.inventory_organization_id%TYPE;
231 l_org_id         FINANCIALS_SYSTEM_PARAMS_ALL.org_id%TYPE;
232 
233 /*Bug#4430300 Replaced the references to JLBR data types with the po standard data types */
234 l_transaction_id_tbl  po_tbl_number;
235 l_dest_org_id_tbl     po_tbl_number;
236 l_item_id_tbl         po_tbl_number;
237 l_trx_reason_code_tbl po_tbl_varchar100;
238 l_error_code_tbl      po_tbl_number;
239 
240 BEGIN
241     l_progress := '000';
242 
243     -- Only proceed if defaulting of transaction reason is supported
244     PO_JL_INTERFACE_PVT.chk_def_trx_reason_flag
245         ( x_return_status       => l_return_status
246         , x_def_trx_reason_flag => l_default_supported_flag
247         );
248     IF (l_return_status <> FND_API.g_ret_sts_success) THEN
249         RAISE FND_API.g_exc_unexpected_error;
250     ELSIF (NVL(l_default_supported_flag,'N') <> 'Y') THEN
251         -- Exit procedure because defaulting is not supported.
252         RETURN;
253     END IF;
254 
255     l_progress := '010';
256     -- Get data needed to call defaulting logic. This data is the same for each
257     -- call to the defaulting API, so retrieve it outside the loop.
258     SELECT org_id
259          , inventory_organization_id
260       INTO l_org_id
261          , l_fsp_inv_org_id
262       FROM financials_system_parameters;
263 
264     l_progress := '020';
265     -- Bulk collect data from req lines for defaulting. Bulk process in a loop
266     -- to ensure we do not take up too much memory for the collections.
267     OPEN l_null_pri_trx_csr;
268     LOOP
269         FETCH l_null_pri_trx_csr BULK COLLECT
270          INTO l_transaction_id_tbl
271             , l_dest_org_id_tbl
272             , l_item_id_tbl
273         LIMIT g_bulk_limit;
274 
275         EXIT WHEN (l_transaction_id_tbl IS NULL) OR
276                   (l_transaction_id_tbl.COUNT = 0);
277 
278         l_progress := '030';
279         -- Derive transaction reasons for each req line
280         PO_JL_INTERFACE_PVT.get_trx_reason_code
281             ( p_fsp_inv_org_id       => l_fsp_inv_org_id
282             , p_inventory_org_id_tbl => l_dest_org_id_tbl
283             , p_item_id_tbl          => l_item_id_tbl
284             , p_org_id               => l_org_id
285             , x_return_status        => l_return_status
286             , x_trx_reason_code_tbl  => l_trx_reason_code_tbl
287             , x_error_code_tbl       => l_error_code_tbl
288             );
289         IF (l_return_status <> FND_API.g_ret_sts_success) THEN
290             RAISE FND_API.g_exc_unexpected_error;
291         END IF;
292 
293         -- Defaulting call was successful. Only update records if the API
294         -- populated the output tables with values
295         IF (l_trx_reason_code_tbl IS NOT NULL) AND
296            (l_error_code_tbl IS NOT NULL)
297         THEN
298             l_progress := '040';
299             -- Update the interface table with the derived transaction reasons.
300             -- Do not update those lines with a non-zero error code; those lines
301             -- failed defaulting, so the trx reason should be left NULL.
302             FORALL i IN l_transaction_id_tbl.FIRST..l_transaction_id_tbl.LAST
303                 UPDATE po_requisitions_interface
304                    SET transaction_reason_code = l_trx_reason_code_tbl(i)
305                  WHERE transaction_id = l_transaction_id_tbl(i)
306                    AND l_error_code_tbl(i) = 0;
307         END IF;
308 
309         -- Need to exit when all records have been fetched
310         EXIT WHEN l_null_pri_trx_csr%NOTFOUND;
311 
312     END LOOP;
313 EXCEPTION
314     WHEN FND_API.g_exc_unexpected_error THEN
315         -- Unexpected error status returned from our API calls. Write to log.
316         FOR i IN 1..FND_MSG_PUB.count_msg LOOP
317             FND_FILE.put_line(FND_FILE.LOG, l_progress||': '||FND_MSG_PUB.get(i,'F'));
318         END LOOP;
319     WHEN OTHERS THEN
320         -- Any other exception should be written to log with generic error msg.
321         FND_MSG_PUB.build_exc_msg
322             ( p_pkg_name       => 'PO_REQIMP_S'
323             , p_procedure_name => 'default_trx_reason_codes-'||l_progress
324             );
325         FND_FILE.put_line(FND_FILE.log, FND_MESSAGE.get);
326 END default_trx_reason_codes;
327 --< Bug 3540365 End >
328 
329 
330 --<INVCONV R12 START>
331 --------------------------------------------------------------------------------
332 --Start of Comments
333 --Name: REQIMPORT_DEF_VALIDATE_SEC_QTY
334 --Pre-reqs:
335 --  None.
336 --Modifies:
337 --  PO_REQUISITIONS_INTERFACE
338 --Locks:
339 --  None.
340 --Function:
341 --  Validates (deviation), Derives Secondary Quantities in  Req Import Tables for dual uom
342 --  controlled items. For internal orders it checks deviation for both source and
343 --  destination organization.
344 --Parameters:
345 --IN:
346 --p_request_id
347 --  The ID for the current requistion import request.
348 --End of Comments
349 --------------------------------------------------------------------------------
350 
351 PROCEDURE REQIMPORT_DEF_VALIDATE_SEC_QTY
352 ( p_request_id		IN 		 NUMBER
353 )
354 
355 
356 IS
357 
358   l_progress               VARCHAR2(3);
359 
360   l_rec PO_INTERFACE_ERRORS%ROWTYPE;
361   l_rtn_status VARCHAR2(1);
362   l_msg_count NUMBER;
363   l_msg_data VARCHAR2(2000);
364   l_row_id ROWID;
365 
366 
367   l_item_um2		MTL_UNITS_OF_MEASURE.UOM_CODE%TYPE;
368   l_item_id		MTL_SYSTEM_ITEMS.INVENTORY_ITEM_ID%TYPE;
369   l_tracking_qty_ind	MTL_SYSTEM_ITEMS.TRACKING_QUANTITY_IND%TYPE;
370   l_secondary_default_ind MTL_SYSTEM_ITEMS.SECONDARY_DEFAULT_IND%TYPE;
371 
372 
373   l_item_unit_of_measure_s	MTL_UNITS_OF_MEASURE.UNIT_OF_MEASURE%TYPE;
374   l_item_um2_s		MTL_UNITS_OF_MEASURE.UOM_CODE%TYPE;
375   l_tracking_qty_ind_s	MTL_SYSTEM_ITEMS.TRACKING_QUANTITY_IND%TYPE;
376   l_secondary_default_ind_s MTL_SYSTEM_ITEMS.SECONDARY_DEFAULT_IND%TYPE;
377   l_unit_of_measure_s   MTL_UNITS_OF_MEASURE.UNIT_OF_MEASURE%TYPE;
378 
379   l_sec_qty_source      NUMBER;
380 
381 Cursor Cr_int_req IS
382 Select	pri.rowid,
383         pri.transaction_id,
384         pri.source_type_code,
385 	pri.source_organization_id,
386 	pri.destination_organization_id,
387 	pri.item_id,
388 	pri.secondary_unit_of_measure,
389 	pri.secondary_uom_code,
390 	pri.secondary_quantity,
391 	pri.quantity,
392 	pri.unit_of_measure,
393 	pri.preferred_grade
394 From	po_requisitions_interface pri
395 Where   pri.request_id = p_request_id
396 FOR UPDATE OF pri.secondary_unit_of_measure;
397 
398 Cursor Cr_item_attr(p_inv_item_id IN NUMBER,p_organization_id IN NUMBER) IS
399 Select	m.tracking_quantity_ind,
400 	m.secondary_uom_code,
401 	m.secondary_default_ind
402 From	mtl_system_items m
403 Where	m.inventory_item_id = p_inv_item_id
404 And     m.organization_id = p_organization_id;
405 
406 BEGIN
407 l_progress := '000';
408 --Loop for every record in the interface table for the current concurrent request.
409 FOR Cr_rec IN Cr_int_req LOOP
410 
411   l_item_um2		:= NULL;
412   l_tracking_qty_ind	:= NULL;
413   l_secondary_default_ind := NULL;
414 
415   l_tracking_qty_ind_s	       := NULL;
416   l_item_um2_s		       := NULL;
417   l_secondary_default_ind_s    := NULL;
418   l_unit_of_measure_s          := NULL;
419   l_sec_qty_source	:= NULL;
420 
421   --Only where item_id is specified.
422   IF Cr_rec.item_id IS NOT NULL THEN
423 
424     -- Get Item Attributes
425     BEGIN
426        OPEN Cr_item_attr(cr_rec.item_id, cr_rec.destination_organization_id);
427        FETCH Cr_item_attr INTO  l_tracking_qty_ind,
428   	       			l_item_um2		,
429   	       			l_secondary_default_ind;
430        CLOSE Cr_item_attr;
431     END;
432     l_progress := '010';
433     --If secondary quantity is not provided then compute it and update interface table.
434     IF cr_rec.secondary_unit_of_measure IS NOT NULL AND
435        l_tracking_qty_ind = 'PS' THEN
436 
437        IF (cr_rec.secondary_quantity IS NULL OR
438            l_secondary_default_ind = 'F')
439        THEN
440 
441           cr_rec.secondary_quantity := INV_CONVERT.inv_um_convert(
442                                                   item_id        =>  cr_rec.item_id,
443                                                   precision	 =>  6,
444                                                   from_quantity  =>  cr_rec.quantity,
445                                                   from_unit      => NULL,
446                                                   to_unit        => NULL,
447                                                   from_name	 =>  cr_rec.unit_of_measure ,
448                                                   to_name	 =>  cr_rec.secondary_unit_of_measure );
449           l_progress := '020';
450           IF cr_rec.secondary_quantity <=0 THEN
451                 l_rec.interface_type     := 'REQIMPORT';
452                 l_rec.interface_transaction_id := cr_rec.transaction_id;
453                 l_rec.column_name        := 'SECONDARY_QUANTITY';
454                 l_rec.table_name         := 'PO_REQUISITIONS_INTERFACE';
455                 l_rec.error_message_name := 'INV_NO_CONVERSION_ERR';
456 
457                 fnd_message.set_name('INV', l_rec.error_message_name);
458                 l_rec.error_message := FND_MESSAGE.get;
459 
460                 PO_INTERFACE_ERRORS_GRP.log_error
461                  ( p_api_version => 1.0,
462                    p_init_msg_list => FND_API.G_TRUE,
463                    x_return_status => l_rtn_status,
464                    x_msg_count => l_msg_count,
465                    x_msg_data => l_msg_data,
466                    p_rec => l_rec,
467                    x_row_id => l_row_id);
468 
469                 IF (l_rtn_status <> FND_API.G_RET_STS_SUCCESS) THEN
470                    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
471                 END IF;
472           ELSE
473              UPDATE po_requisitions_interface
474              SET    secondary_quantity = cr_rec.secondary_quantity
475              WHERE  rowid = cr_rec.rowid;
476           END IF;
477           l_progress := '030';
478        --If secondary quantity is specified then check deviation for type Default and No Default items
479        --for fixed type items do the conversion and update interface table.
480        ELSE
481           l_progress := '040';
482 
483           IF INV_CONVERT.within_deviation(
484                       p_organization_id      =>  cr_rec.destination_organization_id ,
485                       p_inventory_item_id    =>  cr_rec.item_id,
486                       p_lot_number           =>  null ,
487                       p_precision            =>  6 ,
488                       p_quantity             =>  cr_rec.quantity,
489                       p_unit_of_measure1     =>  cr_rec.unit_of_measure ,
490                       p_quantity2            =>  cr_rec.secondary_quantity ,
491                       p_unit_of_measure2     =>  cr_rec.secondary_unit_of_measure,
492                       p_uom_code1            =>  NULL,
493                       p_uom_code2            =>  NULL) = 0 THEN
494 
495              l_rec.interface_type     := 'REQIMPORT';
496              l_rec.interface_transaction_id := cr_rec.transaction_id;
497              l_rec.column_name        := 'SECONDARY_QUANTITY';
498              l_rec.table_name         := 'PO_REQUISITIONS_INTERFACE';
499              l_rec.error_message      := FND_MSG_PUB.GET(p_msg_index => FND_MSG_PUB.G_LAST,p_encoded => 'F');
500 
501              l_progress := '050';
502 
503              PO_INTERFACE_ERRORS_GRP.log_error
504                  ( p_api_version => 1.0,
505                    p_init_msg_list => FND_API.G_TRUE,
506                    x_return_status => l_rtn_status,
507                    x_msg_count => l_msg_count,
508                    x_msg_data => l_msg_data,
509                    p_rec => l_rec,
510                    x_row_id => l_row_id);
511 
512                 IF (l_rtn_status <> FND_API.G_RET_STS_SUCCESS) THEN
513                    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
514                 END IF;
515              l_progress := '060';
516           END IF; /*NOT INV_CONVERT.within_deviation( */
517        END IF; /*cr_rec.secondary_quantity IS NULL*/
518     --Since item is not dual um controlled update all secondary attributes to NULL
519     /*ELSIF l_tracking_qty_ind = 'P' THEN
520        UPDATE po_requisitions_interface
521        SET    secondary_quantity = NULL,
522               secondary_uom_code = NULL,
523               secondary_unit_of_measure = NULL
524        WHERE  rowid = cr_rec.rowid;    */
525     END IF; /*cr_rec.secondary_unit_of_measure IS NOT NULL*/
526 
527     l_progress := '070';
528     --Internal Orders
529     --Validate that quantity is within deviation for both source and destination organization
530     --only if item is dual uom controlled in destination organization
531     IF cr_rec.source_type_code = 'INVENTORY' AND
532        cr_rec.source_organization_id IS NOT NULL AND
533        cr_rec.secondary_unit_of_measure IS NOT NULL THEN
534 
535        -- Get Item Attributes for source organization
536        BEGIN
537           OPEN Cr_item_attr(cr_rec.item_id, cr_rec.source_organization_id);
538           FETCH Cr_item_attr INTO  l_tracking_qty_ind_s,
539   	       			   l_item_um2_s		,
540   	       			   l_secondary_default_ind_s;
541           CLOSE Cr_item_attr;
542        END;
543        l_progress := '080';
544        IF l_tracking_qty_ind_s = 'PS' THEN
545 
546           IF l_item_um2_s <> l_item_um2 THEN
547 
548              l_sec_qty_source := INV_CONVERT.inv_um_convert(
549                                         item_id   =>  cr_rec.item_id,
550                                         precision =>  6,
551                                         from_quantity  => cr_rec.secondary_quantity,
552                                         from_unit =>  l_item_um2 ,
553                                         to_unit	  =>  l_item_um2_s,
554                                         from_name =>  NULL ,
555                                         to_name	 =>   NULL
556                                          );
557 
558              select unit_of_measure
559              into   l_unit_of_measure_s
560              from   mtl_units_of_measure
561              where  uom_code = l_item_um2_s;
562 
563              l_progress := '090';
564 
565           ELSE
566              l_sec_qty_source := cr_rec.secondary_quantity;
567              l_unit_of_measure_s := cr_rec.secondary_unit_of_measure;
568           END IF;
569 
570           IF INV_CONVERT.within_deviation(
571                          p_organization_id   	=>  cr_rec.source_organization_id ,
572                          p_inventory_item_id    =>  cr_rec.item_id,
573                          p_lot_number           =>  null ,
574                          p_precision            =>  6 ,
575                          p_quantity             =>  cr_rec.quantity,
576                          p_unit_of_measure1     =>  cr_rec.unit_of_measure  ,
577                          p_quantity2            =>  l_sec_qty_source ,
578                          p_unit_of_measure2     =>  l_unit_of_measure_s,
579                          p_uom_code1            =>  NULL,
580                          p_uom_code2            =>  NULL) = 0 THEN
581 
582              l_rec.interface_type     := 'REQIMPORT';
583              l_rec.interface_transaction_id := cr_rec.transaction_id;
584              l_rec.column_name        := 'SECONDARY_QUANTITY';
585              l_rec.table_name         := 'PO_REQUISITIONS_INTERFACE';
586              l_rec.error_message_name := 'PO_SRCE_ORG_OUT_OF_DEV';
587 
588              l_progress := '100';
589 
590              fnd_message.set_name('PO', l_rec.error_message_name);
591              l_rec.error_message := FND_MESSAGE.get;
592 
593              PO_INTERFACE_ERRORS_GRP.log_error
594               ( p_api_version => 1.0,
595                 p_init_msg_list => FND_API.G_TRUE,
596                 x_return_status => l_rtn_status,
597                 x_msg_count => l_msg_count,
598                 x_msg_data => l_msg_data,
599                 p_rec => l_rec,
600                 x_row_id => l_row_id);
601 
602              IF (l_rtn_status <> FND_API.G_RET_STS_SUCCESS) THEN
603                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
604              END IF;
605           END IF; /*NOT INV_CONVERT.within_deviation( */
606        END IF; /*l_tracking_qty_ind_s = 'PS'*/
607     END IF; /*cr_rec.source_type_code = 'INVENTORY'*/
608 
609     l_progress := '110';
610   ELSIF cr_rec.item_id IS NULL  THEN
611     l_progress := '120';
612        --since its a one time item update all process attributes to NULL.
613        UPDATE po_requisitions_interface
614        SET    secondary_quantity = NULL,
615               secondary_uom_code = NULL,
616               secondary_unit_of_measure = NULL,
617               preferred_grade = NULL
618        WHERE  rowid = cr_rec.rowid;
619   END IF;
620   l_progress := '130';
621 END LOOP;
622 
623 EXCEPTION
624   WHEN OTHERS THEN
625      po_message_s.sql_error('reqimport_def_validate_sec_qty', l_progress, sqlcode);
626      RAISE;
627 
628 END REQIMPORT_DEF_VALIDATE_SEC_QTY;
629 --<INVCONV R12 END>
630 
631 END PO_REQIMP_S;
632