DBA Data[Home] [Help]

PACKAGE BODY: APPS.GML_RQ_DB_COMMON

Source


1 PACKAGE BODY GML_RQ_DB_COMMON AS
2 /* $Header: GMLRQXCB.pls 115.2 2003/03/17 18:27:48 pbamb noship $ */
3 
4 -- Start of comments
5 --+==========================================================================+
6 --|                   Copyright (c) 1998 Oracle Corporation                  |
7 --|                          Redwood Shores, CA, USA                         |
8 --|                            All rights reserved.                          |
9 --+==========================================================================+
10 --| FILENAME                                                               |
11 --|                                                                        |
12 --|   GMLRQXCB.pls       This package contains db procedures and functions |
13 --|                      required by REQUISITIONS                          |
14 --| DESCRIPTION                                                            |
15 --|                                                                        |
16 --|                                                                        |
17 --| DECLARATION                                                            |
18 --|                                                                        |
19 --|  get_opm_cost_price   Function to get opm cost for internal order for  |
20 --|                       opm item and process org		           |
21 --| MODIFICATION HISTORY                                                   |
22 --|                                                                        |
23 --|    09-JUL-2002      PBamb        Created.    			   |
24 --|                                                                        |
25 --+==========================================================================+
26 -- End of comments
27 
28 --+==========================================================================+
29 --|
30 --|  FUNCTION
31 --|   get_opm_cost_price
32 --|
33 --|  DESCRIPTION
34 --|
35 --|      This function computes the cost price for the item,org and uom.
36 --|
37 --|
38 --| MODIFICATION HISTORY
39 --| 09-JUL-2002  PBamb    Created
40 --|
41 --+==========================================================================+
42 
43 PROCEDURE get_opm_cost_price(	x_item_id IN NUMBER,
44 				x_org_id  IN NUMBER,
45 				x_doc_uom IN VARCHAR2,
46 				x_unit_price IN OUT NOCOPY NUMBER) IS
47 
48 v_whse_code 		VARCHAR2(4);
49 v_orgn_code 		VARCHAR2(4);
50 v_progress 		VARCHAR2(3) := '010';
51 v_primary_uom_price	NUMBER;
52 v_primary_opm_uom	VARCHAR2(4);
53 v_dual_uom_type		NUMBER;
54 v_multiply_factor	NUMBER;
55 v_doc_opm_uom		VARCHAR2(4);
56 
57 BEGIN
58 	IF x_item_id IS NULL
59 	THEN
60 		x_unit_price := 0;
61 		RETURN;
62 	END IF;
63 
64 	/*Get warehouse and organization code*/
65 	select 	whse_code,
66 		orgn_code
67 	into	v_whse_code,
68 		v_orgn_code
69 	from	ic_whse_mst
70 	where	mtl_organization_id = x_org_id;
71 
72       	/*get primary uom and dual uom type for the opm item*/
73 	select 	item_um,
74 		dualum_ind
75 	into	v_primary_opm_uom,
76 		v_dual_uom_type
77 	from	ic_item_mst
78 	where	item_id = x_item_id;
79 
80       	v_primary_uom_price := nvl(gmf_cmcommon.unit_cost(	x_item_id,
81 								v_whse_code,
82 								v_orgn_code,
83 								sysdate),0);
84 
85 	v_doc_opm_uom 	:= po_gml_db_common.get_opm_uom_code(x_doc_uom);
86 
87 	/*If the requisition UOM and the item's primary UOM are same then
88 	  the unit price is same else we need to calculate (derive) the unit price for
89 	  the requisiton uom*/
90 	IF v_doc_opm_uom = v_primary_opm_uom THEN
91 		x_unit_price := v_primary_uom_price;
92 	ELSE
93 		gmicuom.icuomcv ( 	x_item_id,
94 			  		0, -- lot id always 0
95 			  		1, -- pass quantity of 1
96                           		v_doc_opm_uom, -- requisition uom
97                           		v_primary_opm_uom, -- primary uom of item
98 			  		v_multiply_factor );
99 
100 	       	x_unit_price := v_primary_uom_price * nvl(v_multiply_factor,0);
101         END IF;
102 
103 EXCEPTION
104  WHEN OTHERS THEN
105    	x_unit_price	:= 0;
106 
107 END get_opm_cost_price ;
108 
109 END GML_RQ_DB_COMMON;