DBA Data[Home] [Help]

PACKAGE BODY: APPS.AMS_BOM_PVT

Source


1 PACKAGE BODY AMS_BOM_PVT as
2 /* $Header: amsvbomb.pls 120.0 2005/05/31 20:43:48 appldev noship $ */
3 -- Start of Comments
4 -- Package name     : AMS_BOM_PVT
5 -- Purpose          : Wrapper around BOM API
6 -- History          : created sept 29 , 2000 abhola
7 --                    10-JUN-2003   MUSMAN   BUG 2993951 Fix, when picking up the effectivity_date
8 --                                           removed truncating it,since the bom api was not able to find the component.
9 --                    kvattiku 09/10/04 Removing trunc and just leaving it as sysdate fix for Bug 3857716
10 --
11 -- NOTE             :
12 -- End of Comments
13 
14 
15 G_PKG_NAME CONSTANT VARCHAR2(30):= 'AMS_BOM_PVT';
16 G_FILE_NAME CONSTANT VARCHAR2(12) := 'amsvbomb.pls';
17 
18 
19 TYPE bill_details_rec_type IS RECORD(
20     Assembly_Item_Id          NUMBER  := FND_API.G_MISS_NUM
21     ,Component_Item_Id        NUMBER  := FND_API.G_MISS_NUM
22     ,Assembly_Item_Name       VARCHAR2(81) := FND_API.G_MISS_CHAR
23     ,Component_Item_Name      VARCHAR2(81) := FND_API.G_MISS_CHAR
24     ,Header_Trans_Type        VARCHAR2(10) := FND_API.G_MISS_CHAR
25     ,Component_Trans_Type   VARCHAR2(10) := FND_API.G_MISS_CHAR
26     ,Header_org_id            NUMBER  :=FND_API.G_MISS_NUM
27     ,Header_org_code          VARCHAR2(3)  :=FND_API.G_MISS_CHAR
28     ,Effectivity_date         DATE         := FND_API.G_MISS_DATE
29     ,Component_Item_Num       NUMBER    := FND_API.G_MISS_NUM
30     ,Object_Id                NUMBER    := FND_API.G_MISS_NUM
31     ,Transaction_Type         VARCHAR2(10) := FND_API.G_MISS_CHAR
32 );
33 
34 G_MISS_BILL_DETAILS_REC  bill_details_rec_type;
35 
36 
37 /***************************************************************************************
38 
39        Get Transaction Type  Procedure
40 
41 ***************************************************************************************/
42 
43 AMS_DEBUG_HIGH_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH);
44 AMS_DEBUG_LOW_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW);
45 AMS_DEBUG_MEDIUM_ON boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM);
46 
47 PROCEDURE get_transaction_type (
48     P_Api_Version_Number         IN   NUMBER,
49     P_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
50     X_Return_Status              OUT NOCOPY  VARCHAR2,
51     X_Msg_Count                  OUT NOCOPY  NUMBER,
52     X_Msg_Data                   OUT NOCOPY  VARCHAR2,
53     P_bill_detls_rec_type_in     IN   BILL_DETAILS_REC_TYPE := G_MISS_BILL_DETAILS_REC,
54     x_bill_detls_rec_type_out    OUT NOCOPY   BILL_DETAILS_REC_TYPE
55     )
56 IS
57 
58  l_head_trans VARCHAR2(10);
59  l_comp_trans VARCHAR2(10);
60 
61 CURSOR check_header ( l_item_id IN NUMBER,
62                       l_org_id IN NUMBER
63                           )
64 IS
65 SELECT DISTINCT 'Y'
66 FROM  bom_bill_of_materials bo
67 WHERE bo.assembly_item_id = l_item_id
68 AND bo.organization_id = l_org_id;
69 
70 
71  l_dummy VARCHAr2(1);
72 
73  CURSOR check_components ( l_item_id IN NUMBER,
74                            l_org_id IN NUMBER,
75                            l_comp_id IN VARCHAR2)
76 IS
77 SELECT 'Y'
78 FROM bom_inventory_components bc,
79      bom_bill_of_materials bo
80 WHERE bc.bill_sequence_id = bo.bill_sequence_id
81 AND bo.assembly_item_id = l_item_id
82 AND bo.organization_id = l_org_id
83 AND bc.component_item_id = l_comp_id;
84 
85 l_comp_dummy VARCHAR2(1);
86 
87 CURSOR count_of_comp( l_item_id IN NUMBER,
88                       l_org_id  IN NUMBER)
89 IS
90 SELECT count(1)
91 FROM bom_inventory_components bc,
92      bom_bill_of_materials bo
93 WHERE bc.bill_sequence_id = bo.bill_sequence_id
94 AND bo.assembly_item_id = l_item_id
95 AND bo.organization_id = l_org_id;
96 
97 l_comp_count NUMBER := 0;
98 
99 
100 BEGIN
101 
102    -- Initialize message list if p_init_msg_list is set to TRUE.
103    IF FND_API.to_Boolean( p_init_msg_list )
104    THEN
105       FND_MSG_PUB.initialize;
106    END IF;
107 
108    -- Initialize API return status to SUCCESS
109     x_return_status := FND_API.G_RET_STS_SUCCESS;
110 
111 
112    l_dummy := 'N';
113    l_comp_dummy := 'N';
114 
115    OPEN  check_header( P_bill_detls_rec_type_in.Assembly_item_id,
116                        P_bill_detls_rec_type_in.Header_org_id);
117       FETCH check_header INTO l_dummy;
118    CLOSE check_header;
119 
120    OPEN check_components(P_bill_detls_rec_type_in.Assembly_Item_id
121                          ,P_bill_detls_rec_type_in.Header_Org_id
122                          ,P_bill_detls_rec_type_in.Component_item_Id);
123       FETCH check_components INTO l_comp_dummy;
124    CLOSE check_components;
125 
126    OPEN  count_of_comp( P_bill_detls_rec_type_in.Assembly_item_id,
127                        P_bill_detls_rec_type_in.Header_org_id);
128    FETCH count_of_comp INTO l_comp_count;
129    CLOSE count_of_comp;
130 
131 
132    IF (p_bill_detls_rec_type_in.transaction_type = 'CREATE')
133    THEN
134       IF  (l_dummy = 'Y' ) THEN
135          l_head_trans := 'UPDATE';
136          l_comp_trans := 'CREATE';
137       ELSE
138          l_head_trans := 'CREATE';
139          l_comp_trans := 'CREATE';
140       END IF;
141    ELSIF (p_bill_detls_rec_type_in.transaction_type = 'UPDATE')
142    THEN
143       IF l_comp_dummy ='Y' THEN
144          l_head_trans := 'UPDATE';
145          l_comp_trans := 'UPDATE';
146       ELSE
147          l_head_trans := 'UPDATE';
148          l_comp_trans := 'CREATE';
149       END IF;
150    ELSIF (p_bill_detls_rec_type_in.transaction_type = 'DELETE')
151    THEN
152       l_comp_trans := 'DELETE';
153       l_head_trans := 'UPDATE';
154       /*
155       -- this way user doesn't have to go and run the DG Conc program and always the component get deleted and
156       -- not the bill that way its consistent also.
157       IF (l_comp_count > 1) THEN
158          l_head_trans := 'UPDATE';
159       ELSE
160          l_head_trans := 'DELETE';
161       END IF;
162       */
163    END IF;
164 
165   x_bill_detls_rec_type_out.Header_trans_type := l_head_trans;
166   x_bill_detls_rec_type_out.Component_trans_type := l_comp_trans;
167 
168 EXCEPTION
169 
170 
171    WHEN FND_API.g_exc_error THEN
172       ROLLBACK TO create_bom;
173       x_return_status := FND_API.g_ret_sts_error;
174 
175       -- Standard call to get message count and if count is 1, get message info.
176       FND_MSG_PUB.count_and_get(
177             p_encoded => FND_API.g_false,
178             p_count   => x_msg_count,
179             p_data    => x_msg_data
180           );
181 
182     -- Debug Message
183     IF (AMS_DEBUG_HIGH_ON) THEN
184 
185     AMS_UTILITY_PVT.debug_message('ERROR IN GETTING TRANSACTION TYPE');
186     END IF;
187   WHEN others THEN
188    Raise fnd_api.g_exc_error;
189 
190 END  get_transaction_type;
191 
192 
193 /**********************************************************************************
194 
195                           Ams Process BOM
196 
197 **********************************************************************************/
198 
199 
200 PROCEDURE Ams_Process_BOM (
201     P_Api_Version_Number         IN   NUMBER,
202     P_Init_Msg_List              IN   VARCHAR2     := FND_API.G_FALSE,
203     P_Commit                     IN   VARCHAR2     := FND_API.G_FALSE,
204     p_validation_level           IN   NUMBER       := FND_API.G_VALID_LEVEL_FULL,
205 
206     X_Return_Status              OUT NOCOPY  VARCHAR2,
207     X_Msg_Count                  OUT NOCOPY  NUMBER,
208     X_Msg_Data                   OUT NOCOPY  VARCHAR2,
209 
210     P_bom_rec_type               IN   BOM_REC_TYPE := G_MISS_BOM_REC_TYPE,
211 
212     P_bom_comp_rec_type          IN    BOM_COMP_REC_TYPE := G_MISS_BOM_COMP_REC_TYPE,
213 
214     P_Last_Update_Date           IN    DATE    := FND_API.G_MISS_DATE,
215     P_Last_Update_By             IN    NUMBER  := FND_API.G_MISS_NUM
216 
217     ) IS
218 
219 l_bom_header_rec       Bom_Bo_Pub.Bom_Head_Rec_Type;
220 l_bom_component_tbl    Bom_Bo_Pub.Bom_Comps_Tbl_Type;
221 
222 x_bom_header_rec       Bom_Bo_Pub.Bom_Head_Rec_Type;
223 x_bom_component_tbl    Bom_Bo_Pub.Bom_Comps_Tbl_Type;
224 x_bom_revision_tbl       Bom_Bo_Pub.Bom_revision_tbl_type;
225 x_bom_ref_designator_tbl Bom_Bo_Pub.Bom_Ref_Designator_tbl_type;
226 x_bom_sub_component_tbl  Bom_Bo_Pub.Bom_Sub_Component_Tbl_type;
227 
228 
229 l_api_name                CONSTANT VARCHAR2(30) := 'Ams_Process_Bom';
230 l_api_version_number      CONSTANT NUMBER   := 1.0;
231 l_return_status           VARCHAR2(1);
232 
233 l_message               varchar2(2000) := NULL;
234 l_entity                varchar2(3) := NULL;
235 l_msg_index             number;
236 l_mesg_type             varchar2(2000);
237 
238 l_bill_details_rec_in      Bill_details_rec_type;
239 l_bill_details_rec_out     Bill_details_rec_type;
240 
241 
242 l_segment               varchar2(45);
243 
244 CURSOR isLock (l_item_id IN NUMBER,
245                l_org_id IN NUMBER,
246                l_comp_id IN VARCHAR )
247 IS
248 SELECT DISTINCT bc.last_update_date,
249        bc.last_updated_by
250 FROM bom_inventory_components bc,
251      bom_bill_of_materials bo
252     -- , mtl_system_items_b i
253     -- fixed bug 3631360
254 WHERE bc.bill_sequence_id = bo.bill_sequence_id
255 AND bo.assembly_item_id = l_item_id
256 AND bo.organization_id = l_org_id
257 AND bc.component_item_id = l_comp_id;
258 -- AND bc.component_item_id =i.inventory_item_id;
259 -- fixed bug 3631360
260 
261 l_isLock isLock%ROWTYPE;
262 
263 
264 CURSOR getSequence( item_id IN NUMBER,
265                      org_id IN NUMBER )
266 IS
267 SELECT max(bc.item_num)
268 FROM bom_inventory_components bc,
269      bom_bill_of_materials bo
270 WHERE bc.bill_sequence_id = bo.bill_sequence_id
271 AND bo.assembly_item_id = item_id
272 AND bo.organization_id = org_id;
273 
274 /*
275 CURSOR get_effectivity_date(l_comp_inv_id NUMBER,
276                             l_header_segment VARCHAR)
277  IS    SELECT DISTINCT trunc(b.effectivity_date)
278        FROM   bom_inventory_components b
279              , mtl_system_items_b  inv
280              , bom_bill_of_materials  bo
281       WHERE  b.component_item_id = l_comp_inv_id
282       AND    b.bill_Sequence_id = bo.bill_Sequence_id
283       AND    inv.segment1 =l_header_segment
284       AND    bo.assembly_item_id = inv.inventory_item_id;
285 */
286 CURSOR get_effectivity_date(l_comp_inv_id NUMBER
287                            ,l_assembly_item_id NUMBER
288                            ,l_org_id NUMBER)
289  IS    SELECT DISTINCT b.effectivity_date
290  -- BUG 2993951 FIX:: trunc(b.effectivity_date)
291        FROM   bom_inventory_components b
292              , bom_bill_of_materials  bo
293       WHERE  b.component_item_id = l_comp_inv_id
294       AND    b.bill_Sequence_id = bo.bill_Sequence_id
295       AND    bo.assembly_item_id =l_assembly_item_id
296       AND    bo.ALTERNATE_BOM_DESIGNATOR is null
297       AND    bo.organization_id = l_org_id;
298 
299    l_effectivity_date DATE;
300 
301 dummy_sequence NUMBER;
302 
303 CURSOR getAsmItemName( l_inv_itm_id IN NUMBER, l_org_id IN NUMBER)
304     IS
305  SELECT concatenated_segments
306    FROM mtl_system_items_b_kfv
307   WHERE inventory_item_id = l_inv_itm_id
308     AND organization_id = l_org_id;
309 
310 
311 CURSOR getOrgCode (l_org_id IN NUMBER )
312     IS
313   SELECT organization_code
314     --FROM org_organization_definitions
315     FROM mtl_parameters
316   WHERE  organization_id = l_org_id;
317 
318   l_asm_item_name VARCHAR2(240);
319   l_org_code      VARCHAR2(240);
320 
321 BEGIN
322 
323    SAVEPOINT create_bom;
324 
325    IF FND_API.to_boolean(p_init_msg_list) THEN
326       FND_MSG_PUB.initialize;
327    END IF;
328 
329    -- get the asm item name
330    OPEN getAsmItemName(P_bom_rec_type.inventory_item_id, P_bom_rec_type.organization_id);
331    FETCH  getAsmItemName INTO l_asm_item_name;
332    CLOSE  getAsmItemName;
333 
334    -- get org code
335    OPEN getOrgCode ( P_bom_rec_type.organization_id );
336    FETCH  getOrgCode INTO l_org_code;
337    CLOSE  getOrgCode;
338 
339    IF (AMS_DEBUG_HIGH_ON) THEN
340    AMS_UTILITY_PVT.debug_message('P_bom_comp_rec_type.component_item_id:'||P_bom_comp_rec_type.component_item_id);
341    END IF;
342 
343    l_bill_details_rec_in.component_item_name := P_bom_comp_rec_type.component_item_name;
344    l_bill_details_rec_in.transaction_type := P_bom_rec_type.transaction_type;
345 
346    l_bill_details_rec_in.assembly_item_name := l_asm_item_name;
347    l_bill_details_rec_in.Header_org_code    := l_org_code;
348 
349    l_bill_details_rec_in.assembly_item_id   := P_bom_rec_type.inventory_item_id;
350    l_bill_details_rec_in.header_org_id      := P_bom_rec_type.organization_id;
351    l_bill_details_rec_in.component_item_id    := P_bom_comp_rec_type.component_item_id ;
352 
353 
354 
355  /* get transaction type */
356    get_transaction_type (
357        P_Api_Version_Number  =>   1.0
358        ,P_Init_Msg_List       =>  P_Init_Msg_List
359        ,X_Return_Status       =>  l_return_status
360        ,X_Msg_Count           =>  x_Msg_Count
361        ,X_Msg_Data            =>  x_Msg_Data
362        ,p_bill_detls_rec_type_in  => l_bill_details_rec_in
363        ,x_bill_detls_rec_type_out => l_bill_details_rec_out
364 
365     );
366    --Dbms_output.put_line('THE RETURN STATUS FROM TRANS '||l_return_status);
367 
368    IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
369         FOR i IN 1..x_Msg_count LOOP
370           --          l_message :=
371           IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_error)
372           THEN
373              FND_MESSAGE.set_name('AMS', 'AMS_GET_TRANSACTION_TYPE_ERR');
374           END IF;
375 
376       END LOOP;
377       RAISE FND_API.g_exc_error;
378     ELSE
379        l_bill_details_rec_in.Component_trans_type := l_bill_details_rec_out.component_trans_type;
380        l_bill_details_rec_in.Header_trans_type := l_bill_details_rec_out.Header_trans_type;
381     END IF;
382 
383  /*********************************************/
384    -- functionality similar to Object ver num implemenetd as INV/ BOM do not have the concept
385    -- of obj ver num
386 
387 --   /*
388 
389     IF (l_bill_details_rec_in.Component_trans_type = 'UPDATE') THEN
390 
391       OPEN  isLock(l_bill_details_rec_in.Assembly_item_id,
392                    l_bill_details_rec_in.Header_org_id,
393                    l_bill_details_rec_in.component_item_id);
394          FETCH isLock into l_isLock;
395       CLOSE isLock;
396 
397       IF (l_isLock.last_updated_by <> P_Last_Update_By)
398       AND (l_isLock.last_update_date <> P_last_Update_Date) THEN
399 
400          IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_error)
401          THEN
402             FND_MESSAGE.set_name('AMS', 'AMS_API_RECORD_NOT_FOUND');
403             FND_MSG_PUB.add;
404          END IF;
405          RAISE FND_API.g_exc_error;
406 
407       END IF;
408 
409    END IF;
410    --*/
411 
412   /********************************************/
413   -- Debug Message
414   IF (AMS_DEBUG_HIGH_ON) THEN
415   AMS_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
416   END IF;
417 
418 
419   /** BOM Header Data **/
420 
421   l_bom_header_rec.assembly_item_name := l_bill_details_rec_in.Assembly_item_name  ;
425   l_bom_header_rec.alternate_bom_code := null;
422   l_bom_header_rec.organization_code := l_bill_details_rec_in.Header_org_code   ;
423   l_bom_header_rec.assembly_type := 1 ;
424   l_bom_header_rec.transaction_type := l_bill_details_rec_in.Header_trans_type ;
426 
427   /** BOM Componenet Data **/
428 
429   l_bom_component_tbl(1).assembly_item_name := l_bill_details_rec_in.Assembly_item_name ;
430   l_bom_component_tbl(1).organization_code := l_bill_details_rec_in.Header_org_code  ;
431   l_bom_component_tbl(1).transaction_type := l_bill_details_rec_in.Component_trans_type ;
432   l_bom_component_tbl(1).component_item_name := P_bom_comp_rec_type.component_item_name   ;
433   l_bom_component_tbl(1).quantity_per_assembly := P_bom_comp_rec_type.quantity_per_assembly;
434   l_bom_component_tbl(1).item_sequence_number := P_bom_comp_rec_type.item_sequence_number;
435 
436 
437   /* Defaults for BOM Componenets */
438 
439   -- kvattiku 09/10/04 Removing trunc and just leaving it as sysdate fix for Bug 3857716
440   --l_bom_component_tbl(1).start_effective_date :=  trunc(sysdate)  ;
441   l_bom_component_tbl(1).start_effective_date :=  sysdate  ;
442 
443   l_bom_component_tbl(1).operation_sequence_number := 1  ;
444   l_bom_component_tbl(1).alternate_bom_code := null;
445   l_bom_component_tbl(1).projected_yield := 1;
446   l_bom_component_tbl(1).quantity_related := 2;
447   l_bom_component_tbl(1).planning_percent := 100;
448   l_bom_component_tbl(1).check_atp := 2;
449   l_bom_component_tbl(1).include_in_cost_rollup := 2;
450   l_bom_component_tbl(1).so_basis := 2;
451   l_bom_component_tbl(1).optional := 2;
452   l_bom_component_tbl(1).mutually_exclusive := 2;
453   l_bom_component_tbl(1).shipping_allowed := 2;
454   l_bom_component_tbl(1).required_to_ship := 2;
455   l_bom_component_tbl(1).required_for_revenue := 2;
456   l_bom_component_tbl(1).include_on_ship_docs := 2;
457   l_bom_component_tbl(1).minimum_allowed_quantity := 0;
458   l_bom_component_tbl(1).location_name := null;
459   l_bom_component_tbl(1).supply_subinventory := null;
460 
461   IF (AMS_DEBUG_HIGH_ON) THEN
462   AMS_UTILITY_PVT.debug_message('Inside  the api  l_comp_trans :'  ||l_bill_details_rec_in.Component_trans_type);
463   AMS_UTILITY_PVT.debug_message('Inside  the api  l_head_trans :'  ||l_bill_details_rec_in.Header_trans_type);
464   END IF;
465 
466   /*** Getting the effectivity date from database for updates and deletes  **/
467   IF l_bill_details_rec_in.Component_trans_type = 'UPDATE'
468   OR l_bill_details_rec_in.Component_trans_type = 'DELETE' THEN
469 
470      OPEN get_effectivity_date(l_bill_details_rec_in.component_item_id,
471                                l_bill_details_rec_in.assembly_item_id  ---name);
472                                ,l_bill_details_rec_in.header_org_id);
473         FETCH get_effectivity_date INTO l_effectivity_date;
474      CLOSE get_effectivity_date;
475 
476      l_bom_component_tbl(1).start_effective_date := l_effectivity_date;
477 
478      IF (AMS_DEBUG_HIGH_ON) THEN
479         AMS_UTILITY_PVT.debug_message('l_effectivity_date:'  || l_effectivity_date);
480      END IF;
481 
482   END IF;
483 
484   /** Delete Group Name should be passed for deleting the Bill. After this user has to
485   query up for this delete_group in the forms under BOM and has to run the delete group
486   concurrent program after running Check group conc program **/
487 
488   IF l_bill_details_rec_in.Component_trans_type = 'DELETE'
489   THEN
490      l_bom_component_tbl(1).delete_group_name := 'AMS-DELGRP';
491      l_bom_component_tbl(1).DG_Description := 'AMS - Delete Group For Components';
492   END IF;
493 
494   IF l_bill_details_rec_in.Header_trans_type  =  'DELETE'
495   THEN
496      l_bom_header_rec.delete_group_name := 'AMS-HEADER' ;
497      l_bom_header_rec.DG_Description := 'AMS - Delete Group For The Bill' ;
498   END IF;
499 
500 
501   /** Cal to BOM API **/
502 
503   Bom_Bo_Pub.Process_Bom
504    (  p_init_msg_list           =>  TRUE
505     , p_bom_header_rec          =>  l_bom_header_rec
506     , p_bom_component_tbl       =>  l_bom_component_tbl
507     , x_bom_header_rec          =>  x_bom_header_rec
508     , x_bom_component_tbl       =>  x_bom_component_tbl
509     , x_bom_revision_tbl => x_bom_revision_tbl
510     , x_bom_ref_designator_tbl => x_bom_ref_designator_tbl
511     , x_bom_sub_component_tbl => x_bom_sub_component_tbl
512     , x_return_status           =>  X_Return_Status
513     , x_msg_count               =>  X_Msg_Count
514     /***
515     -- THESE THREE LINES HAS TO BE REMOVED BEFORE ARCS IN
516     --, p_debug                 => 'Y'
517     --, p_output_dir            => '/sqlcom/log'
518     --, p_debug_filename        => 'musman_run.log'
519      ***/
520     );
521 
522      -- Debug Message
523    IF (AMS_DEBUG_HIGH_ON) THEN
524 
525    AMS_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
526    END IF;
527 
528    FOR i IN 1..x_Msg_count LOOP
529      Error_Handler.Get_Message(x_entity_index => l_msg_index,
530                                x_entity_id => l_entity,
531                                x_message_text => l_message,
532                                X_MESSAGE_TYPE => l_mesg_type);
533 
534      IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.g_msg_lvl_error)
535      THEN
536          FND_MESSAGE.set_name('AMS', 'AMS_BOM_ERROR');
537          FND_MESSAGE.Set_Token ('BOMERR',l_message , FALSE);
538          FND_MSG_PUB.add;
539      END IF;
540 
541    END LOOP;
542 
543    IF (x_return_status <> 'S') THEN
544       RAISE FND_API.g_exc_error;
545    END IF;
546 
547    IF  (FND_API.to_boolean(p_commit)) THEN
548       COMMIT;
549    END IF;
550 
551    FND_MSG_PUB.count_and_get
552            (
553             p_encoded => FND_API.g_false,
554             p_count   => x_msg_count,
555             p_data    => x_msg_data
556          );
557 
558 EXCEPTION
559 
560    WHEN FND_API.g_exc_error THEN
561       ROLLBACK TO create_bom;
562       x_return_status := FND_API.g_ret_sts_error;
563       FND_MSG_PUB.count_and_get(
564             p_encoded => FND_API.g_false,
565             p_count   => x_msg_count,
566             p_data    => x_msg_data
567           );
568 
569 END Ams_Process_BOM;
570 
571 
572 End AMS_BOM_PVT;