[Home] [Help]
PACKAGE BODY: APPS.GMF_ROUTING_STEP_CALC
Source
1 PACKAGE BODY gmf_routing_step_calc AS
2 /* $Header: gmfstepb.pls 120.1 2005/08/30 14:59:50 sschinch noship $ */
3
4 g_step_table GMD_AUTO_STEP_CALC.STEP_REC_TBL;
5
6 /**********************************************************************
7 * NAME
8 * CALC_STEP_QTY
9 *
10 * DESCRIPTION
11 * Wrapper for GMD_AUTO_STEP_CALC.calc_step_qty procedure
12 * Calls the gmd procedure and caches the step table output in
13 * a package variable. The next procedure get_step_qty is
14 * used to retrieve the individual rows from the cost_calc_rout
15 * function of cost rollup and in variances calculation of
16 * subledger.
17 * HISTORY
18 * 12-Apr-2002 Rajesh Seshadri Bug 2269125
19 * 14-May-2002 Rajesh Seshadr Bug 2374512 - added the scale factor
20 * attribute while calling gmd api
21 * 18-Jul-2002 Rajesh Seshadri Bug 2468924 - send process loss to
22 * ASQC routine.
23 * 02-Jan-2003 Venkat Chukkapalli Bug#2700453 Added DEFAULT 0 to
24 * process_loss parameters.
25 **********************************************************************/
26 PROCEDURE calc_step_qty(
27 p_recipe_id IN NUMBER,
28 p_fmeff_id IN NUMBER,
29 p_scale_factor IN NUMBER,
30 p_process_loss IN NUMBER,
31 x_error_code OUT NOCOPY NUMBER,
32 x_error_msg OUT NOCOPY VARCHAR2) AS
33
34 l_msg_count NUMBER(10);
35 l_msg_stack VARCHAR2(240);
36 l_return_status VARCHAR2(1);
37
38 l_idx INTEGER;
39 l_data VARCHAR2(2000);
40 l_concat_data VARCHAR2(200);
41 l_dummy_count NUMBER :=0;
42
43 e_step_calc_error EXCEPTION;
44
45 BEGIN
46 x_error_code := 0;
47
48 /* Clear the cache */
49 g_step_table.DELETE;
50
51 FND_MSG_PUB.Initialize;
52
53 /* Call the gmd procedure */
54 /**
55 * How do we tell it that we need the formula scaled up?
56 * We need to send in the scale_factor - B2374512
57 */
58 GMD_AUTO_STEP_CALC.CALC_STEP_QTY(
59 p_parent_id => p_recipe_id,
60 p_step_tbl => g_step_table,
61 p_msg_count => l_msg_count,
62 p_msg_stack => l_msg_stack,
63 p_return_status => l_return_status,
64 p_scale_factor => p_scale_factor,
65 p_process_loss => p_process_loss,
66 p_organization_id => NULL); /* get back here sschinch INVCONV*/
67
68 /* Handle any errors reported */
69 IF( l_return_status <> FND_API.G_RET_STS_SUCCESS )
70 THEN
71 FOR l_loop_count IN 1..l_msg_count
72 LOOP
73
74 FND_MSG_PUB.Get(
75 p_msg_index => l_loop_count,
76 p_data => l_data,
77 p_encoded => FND_API.G_FALSE,
78 p_msg_index_out => l_dummy_count);
79
80 l_concat_data := substrb(l_concat_data || ' ' || l_data, 1, 200);
81
82 END LOOP;
83
84 x_error_msg := l_concat_data;
85 RAISE e_step_calc_error;
86 END IF;
87
88 x_error_code := 0;
89
90 EXCEPTION
91 WHEN e_step_calc_error THEN
92 x_error_code := 1;
93
94 END calc_step_qty;
95
96 /**********************************************************************
97 * NAME
98 * GET_STEP_QTY
99 *
100 * DESCRIPTION
101 * Used to retrieve the individual step's quantity. Called from
102 * cost_calc_rout of cost rollup and compute_variances of
103 * subledger.
104 *
105 * HISTORY
106 * 12-Apr-2002 Rajesh Seshadri Bug 2269125
107 **********************************************************************/
108 PROCEDURE get_step_qty(
109 p_recipe_id IN NUMBER,
110 p_step_id IN NUMBER,
111 p_step_no IN NUMBER,
112 x_step_qty OUT NOCOPY NUMBER,
113 x_error_code OUT NOCOPY NUMBER) AS
114
115 l_idx INTEGER;
116 l_step_found BOOLEAN;
117 e_step_not_found EXCEPTION;
118
119 BEGIN
120 x_error_code := 0;
121
122 /* loop through the cache and retrieve the step info */
123 l_step_found := FALSE;
124 l_idx := g_step_table.FIRST;
125
126 LOOP
127 IF( NOT g_step_table.EXISTS(l_idx) )
128 THEN
129 RAISE e_step_not_found;
130 END IF;
131
132 IF( g_step_table(l_idx).step_no = p_step_no )
133 THEN
134 /* step found; return the step qty */
135 x_step_qty := g_step_table(l_idx).step_qty;
136 l_step_found := TRUE;
137 END IF;
138
139 EXIT WHEN l_step_found;
140 EXIT WHEN l_idx = g_step_table.LAST;
141 l_idx := g_step_table.NEXT(l_idx);
142 END LOOP;
143
144 IF( NOT l_step_found )
145 THEN
146 x_step_qty := 0.0;
147 RAISE e_step_not_found;
148 END IF;
149
150 x_error_code := 0;
151
152 EXCEPTION
153 WHEN e_step_not_found THEN
154 x_error_code := 1;
155
156 END get_step_qty;
157
158 END gmf_routing_step_calc;