1 PACKAGE BODY ENG_Default_Sub_Component AS
2 /* $Header: ENGDSBCB.pls 115.9 2002/12/13 00:11:13 bbontemp ship $ */
3
4 -- Global constant holding the package name
5
6 G_PKG_NAME CONSTANT VARCHAR2(30) :=
7 'ENG_Default_Sub_Component';
8 ret_code NUMBER;
9
10 -- Package global used within the package.
11
12 g_sub_component_rec Bom_Bo_Pub.Sub_Component_Rec_Type;
13
14 /******************************************************************
15 * Local Function: Get_Substitute_Item_Quantity
16 * Parameter IN : Substitute Component unexposed Record
17 * Parameter OUT : Return_Status
18 * Mesg_Token_Tbl
19 * Purpose : Function will fetch the item quantity using the
20 * component sequence id key, from bom_inventory_components
21 * table and return it as the default value for
22 * Substitute_Item_Quantity
23 *******************************************************************/
24 FUNCTION Get_Substitute_Item_Quantity
25 ( x_return_status OUT NOCOPY VARCHAR2
26 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
27 , p_Sub_Comp_Unexp_Rec IN Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
28 )
29 RETURN NUMBER
30 IS
31 l_sub_item_quantity NUMBER;
32 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
33 BEGIN
34 --+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35 -- Get Substitute Item quantity from the parent component
36 -- using the component sequence id.
37 ---+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
38 SELECT component_quantity
39 INTO l_sub_item_quantity
40 FROM bom_inventory_components
41 WHERE component_sequence_id =
42 p_Sub_Comp_Unexp_Rec.component_sequence_id;
43
44 RETURN (l_sub_item_quantity);
45
46 EXCEPTION
47 WHEN OTHERS THEN
48 Error_Handler.Add_Error_Token
49 ( x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
50 , p_Mesg_Token_Tbl => l_Mesg_Token_Tbl
51 , p_message_name => NULL
52 , p_message_text =>
53 'Substitute Component Attribute Validation ' ||
54 TO_CHAR(SQLCODE) || ' ' || SUBSTR(SQLERRM, 1, 100)
55 );
56 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
57 RETURN FND_API.G_RET_STS_UNEXP_ERROR;
58
59 END Get_Substitute_Item_Quantity;
60
61 PROCEDURE Get_Flex_Sub_Component
62 IS
63 BEGIN
64
65 -- In the future call Flex APIs for defaults
66
67 IF g_sub_component_rec.attribute_category = FND_API.G_MISS_CHAR THEN
68 g_sub_component_rec.attribute_category := NULL;
69 END IF;
70
71 IF g_sub_component_rec.attribute1 = FND_API.G_MISS_CHAR THEN
72 g_sub_component_rec.attribute1 := NULL;
73 END IF;
74
75 IF g_sub_component_rec.attribute2 = FND_API.G_MISS_CHAR THEN
76 g_sub_component_rec.attribute2 := NULL;
77 END IF;
78
79 IF g_sub_component_rec.attribute4 = FND_API.G_MISS_CHAR THEN
80 g_sub_component_rec.attribute4 := NULL;
81 END IF;
82
83 IF g_sub_component_rec.attribute5 = FND_API.G_MISS_CHAR THEN
84 g_sub_component_rec.attribute5 := NULL;
85 END IF;
86
87 IF g_sub_component_rec.attribute6 = FND_API.G_MISS_CHAR THEN
88 g_sub_component_rec.attribute6 := NULL;
89 END IF;
90
91 IF g_sub_component_rec.attribute8 = FND_API.G_MISS_CHAR THEN
92 g_sub_component_rec.attribute8 := NULL;
93 END IF;
94
95 IF g_sub_component_rec.attribute9 = FND_API.G_MISS_CHAR THEN
96 g_sub_component_rec.attribute9 := NULL;
97 END IF;
98
99 IF g_sub_component_rec.attribute10 = FND_API.G_MISS_CHAR THEN
100 g_sub_component_rec.attribute10 := NULL;
101 END IF;
102
103 IF g_sub_component_rec.attribute12 = FND_API.G_MISS_CHAR THEN
104 g_sub_component_rec.attribute12 := NULL;
105 END IF;
106
107 IF g_sub_component_rec.attribute13 = FND_API.G_MISS_CHAR THEN
108 g_sub_component_rec.attribute13 := NULL;
109 END IF;
110
111 IF g_sub_component_rec.attribute14 = FND_API.G_MISS_CHAR THEN
112 g_sub_component_rec.attribute14 := NULL;
113 END IF;
114
115 IF g_sub_component_rec.attribute15 = FND_API.G_MISS_CHAR THEN
116 g_sub_component_rec.attribute15 := NULL;
117 END IF;
118
119 IF g_sub_component_rec.attribute3 = FND_API.G_MISS_CHAR THEN
120 g_sub_component_rec.attribute3 := NULL;
121 END IF;
122
123 IF g_sub_component_rec.attribute7 = FND_API.G_MISS_CHAR THEN
124 g_sub_component_rec.attribute7 := NULL;
125 END IF;
126
127 IF g_sub_component_rec.attribute11 = FND_API.G_MISS_CHAR THEN
128 g_sub_component_rec.attribute11 := NULL;
129 END IF;
130
131 END Get_Flex_Sub_Component;
132
133 /******************************************************************
134 * Procedure : Attribute_Defaulting
135 * Parameter IN : Substitute Component unexposed Record
136 * Substitute Component Record
137 * Parameter OUT : Return_Status
138 * Mesg_Token_Tbl
139 * Substitute Component Record
140 * Substitute Component Unexposed Record
141 * Purpose : Attributes will call get functions for all columns
142 * that need to be defaulted.
143 * Defualting can happen for exposed as well as
144 * unexposed columns.
145 *******************************************************************/
146
147 PROCEDURE Attribute_Defaulting
148 ( p_sub_component_rec IN Bom_Bo_Pub.Sub_Component_Rec_Type :=
149 Bom_Bo_Pub.G_MISS_SUB_COMPONENT_REC
150 , p_Sub_Comp_Unexp_Rec IN Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
151 , x_sub_component_rec IN OUT NOCOPY Bom_Bo_Pub.Sub_Component_Rec_Type
152 , x_Sub_Comp_Unexp_Rec IN OUT NOCOPY Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
153 , x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
154 , x_return_status OUT NOCOPY VARCHAR2
155 )
156 IS
157 stmt_num NUMBER := 0;
158 l_err_text VARCHAR2(255);
159 l_return_status VARCHAR2(10);
160 l_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
161 BEGIN
162
163 -- Initialize g_sub_component_rec
164
165 stmt_num := 1;
166 g_sub_component_rec := p_sub_component_rec;
167
168 stmt_num := 2;
169 IF g_sub_component_rec.substitute_item_quantity = FND_API.G_MISS_NUM OR
170 g_sub_component_rec.substitute_item_quantity IS NULL THEN
171
172 g_sub_component_rec.substitute_item_quantity :=
173 Get_Substitute_Item_Quantity
174 ( x_return_status => l_return_status
175 , x_Mesg_Token_Tbl => l_Mesg_Token_Tbl
176 , p_Sub_Comp_Unexp_Rec => p_Sub_Comp_Unexp_Rec
177 );
178 --dbms_output.put_line('Quantity Defaulted to : ' ||
179 -- to_char(g_sub_component_rec.substitute_item_quantity)
180 -- );
181
182 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
183 g_sub_component_rec.substitute_item_quantity := 0;
184 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
185 END IF;
186 END IF;
187
188 IF g_sub_component_rec.acd_type = FND_API.G_MISS_NUM THEN
189 g_sub_component_rec.acd_type := NULL;
190 END IF;
191
192 stmt_num :=3;
193 IF g_sub_component_rec.attribute_category = FND_API.G_MISS_CHAR
194 OR g_sub_component_rec.attribute1 = FND_API.G_MISS_CHAR
195 OR g_sub_component_rec.attribute2 = FND_API.G_MISS_CHAR
196 OR g_sub_component_rec.attribute4 = FND_API.G_MISS_CHAR
197 OR g_sub_component_rec.attribute5 = FND_API.G_MISS_CHAR
198 OR g_sub_component_rec.attribute6 = FND_API.G_MISS_CHAR
199 OR g_sub_component_rec.attribute8 = FND_API.G_MISS_CHAR
200 OR g_sub_component_rec.attribute9 = FND_API.G_MISS_CHAR
201 OR g_sub_component_rec.attribute10 = FND_API.G_MISS_CHAR
202 OR g_sub_component_rec.attribute12 = FND_API.G_MISS_CHAR
203 OR g_sub_component_rec.attribute13 = FND_API.G_MISS_CHAR
204 OR g_sub_component_rec.attribute14 = FND_API.G_MISS_CHAR
205 OR g_sub_component_rec.attribute15 = FND_API.G_MISS_CHAR
206 OR g_sub_component_rec.attribute3 = FND_API.G_MISS_CHAR
207 OR g_sub_component_rec.attribute7 = FND_API.G_MISS_CHAR
208 OR g_sub_component_rec.attribute11 = FND_API.G_MISS_CHAR
209 THEN
210
211 Get_Flex_Sub_Component;
212
213 END IF;
214
215 -- Done defaulting attributes
216
217 x_sub_component_rec := g_sub_component_rec;
218 x_Sub_Comp_Unexp_Rec := p_Sub_Comp_Unexp_Rec;
219 EXCEPTION
220
221 WHEN FND_API.G_EXC_ERROR THEN
222 --dbms_output.put_line('default sub_comp : ' || to_char(stmt_num));
223 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
224 x_return_status := FND_API.G_RET_STS_ERROR;
225
226 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
227 --dbms_output.put_line('default sub_comp : ' || to_char(stmt_num));
228 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
229 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
230
231 WHEN OTHERS THEN
232 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
233 x_Mesg_Token_Tbl := l_Mesg_Token_Tbl;
234 --dbms_output.put_line('default sub_comp : ' || to_char(stmt_num));
235
236 END Attribute_Defaulting;
237
238 /******************************************************************************
239 * Procedure : Populate_Null_Columns (earlier called Complete_Record)
240 * Parameters IN : Substitute Component exposed column record
241 * Substitute Component DB record of exposed columns
242 * Substitute Component unexposed column record
243 * Substitute Component DB record of unexposed columns
244 * Parameters OUT: Substitute Component exposed Record
245 * Substitute Component Unexposed Record
246 * Purpose : Complete record will compare the database record with the
247 * user given record and will complete the user record with
248 * values from the database record, for all columns that the
249 * user has left NULL.
250 ******************************************************************************/
251 PROCEDURE Populate_Null_Columns
252 ( p_sub_component_rec IN Bom_Bo_Pub.Sub_Component_Rec_Type
253 , p_old_sub_component_rec IN Bom_Bo_Pub.Sub_Component_Rec_Type
254 , p_sub_Comp_Unexp_Rec IN Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
255 , p_Old_sub_Comp_Unexp_Rec IN Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
256 , x_sub_Component_Rec IN OUT NOCOPY Bom_Bo_Pub.Sub_Component_Rec_Type
257 , x_sub_Comp_Unexp_Rec IN OUT NOCOPY Bom_Bo_Pub.Sub_Comp_Unexposed_Rec_Type
258 )
259 IS
260 l_sub_component_rec Bom_Bo_Pub.Sub_Component_Rec_Type :=
261 p_sub_component_rec;
262 BEGIN
263
264 IF l_sub_component_rec.substitute_item_quantity = FND_API.G_MISS_NUM OR
265 l_sub_component_rec.substitute_item_quantity IS NULL
266 THEN
267 l_sub_component_rec.substitute_item_quantity :=
268 p_old_sub_component_rec.substitute_item_quantity;
269 END IF;
270
271 IF l_sub_component_rec.attribute_category = FND_API.G_MISS_CHAR THEN
272 l_sub_component_rec.attribute_category :=
273 p_old_sub_component_rec.attribute_category;
274 END IF;
275
276 IF l_sub_component_rec.attribute1 = FND_API.G_MISS_CHAR THEN
277 l_sub_component_rec.attribute1 :=
278 p_old_sub_component_rec.attribute1;
279 END IF;
280
281 IF l_sub_component_rec.attribute2 = FND_API.G_MISS_CHAR THEN
282 l_sub_component_rec.attribute2 := p_old_sub_component_rec.attribute2;
283 END IF;
284
285 IF l_sub_component_rec.attribute4 = FND_API.G_MISS_CHAR THEN
286 l_sub_component_rec.attribute4 := p_old_sub_component_rec.attribute4;
287 END IF;
288
289 IF l_sub_component_rec.attribute5 = FND_API.G_MISS_CHAR THEN
290 l_sub_component_rec.attribute5 := p_old_sub_component_rec.attribute5;
291 END IF;
292
293 IF l_sub_component_rec.attribute6 = FND_API.G_MISS_CHAR THEN
294 l_sub_component_rec.attribute6 := p_old_sub_component_rec.attribute6;
295 END IF;
296
297 IF l_sub_component_rec.attribute8 = FND_API.G_MISS_CHAR THEN
298 l_sub_component_rec.attribute8 := p_old_sub_component_rec.attribute8;
299 END IF;
300
301 IF l_sub_component_rec.attribute9 = FND_API.G_MISS_CHAR THEN
302 l_sub_component_rec.attribute9 := p_old_sub_component_rec.attribute9;
303 END IF;
304
305 IF l_sub_component_rec.attribute10 = FND_API.G_MISS_CHAR THEN
306 l_sub_component_rec.attribute10 := p_old_sub_component_rec.attribute10;
307 END IF;
308
309 IF l_sub_component_rec.attribute12 = FND_API.G_MISS_CHAR THEN
310 l_sub_component_rec.attribute12 := p_old_sub_component_rec.attribute12;
311 END IF;
312
313 IF l_sub_component_rec.attribute13 = FND_API.G_MISS_CHAR THEN
314 l_sub_component_rec.attribute13 := p_old_sub_component_rec.attribute13;
315 END IF;
316
317 IF l_sub_component_rec.attribute14 = FND_API.G_MISS_CHAR THEN
318 l_sub_component_rec.attribute14 := p_old_sub_component_rec.attribute14;
319 END IF;
320
321 IF l_sub_component_rec.attribute15 = FND_API.G_MISS_CHAR THEN
322 l_sub_component_rec.attribute15 := p_old_sub_component_rec.attribute15;
323 END IF;
324
325 IF l_sub_component_rec.program_id = FND_API.G_MISS_NUM THEN
326 l_sub_component_rec.program_id := p_old_sub_component_rec.program_id;
327 END IF;
328
329 IF l_sub_component_rec.attribute3 = FND_API.G_MISS_CHAR THEN
330 l_sub_component_rec.attribute3 := p_old_sub_component_rec.attribute3;
331 END IF;
332
333 IF l_sub_component_rec.attribute7 = FND_API.G_MISS_CHAR THEN
334 l_sub_component_rec.attribute7 := p_old_sub_component_rec.attribute7;
335 END IF;
336
337 IF l_sub_component_rec.attribute11 = FND_API.G_MISS_CHAR THEN
338 l_sub_component_rec.attribute11 := p_old_sub_component_rec.attribute11;
339 END IF;
340
341 x_sub_comp_unexp_rec := p_sub_comp_unexp_rec;
342 x_Sub_Component_Rec := l_sub_component_rec;
343
344 END Populate_Null_Columns;
345
346 PROCEDURE Entity_Defaulting
347 ( p_sub_component_rec IN Bom_Bo_Pub.Sub_Component_Rec_Type
348 , p_old_sub_component_rec IN Bom_Bo_Pub.Sub_Component_Rec_Type :=
349 Bom_Bo_Pub.G_MISS_Sub_COMPONENT_REC
350 , x_sub_component_rec IN OUT NOCOPY Bom_Bo_Pub.Sub_Component_Rec_Type
351 )
352 IS
353 BEGIN
354 NULL;
355 END Entity_Defaulting;
356
357 END ENG_Default_Sub_Component;