DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_BOMROUTINGUTIL_PVT

Source


1 package body wip_bomRoutingUtil_pvt as
2  /* $Header: wipbmrub.pls 120.28.12020000.2 2012/07/18 07:50:32 ankohli ship $ */
3 
4   g_pkgName constant varchar2(30) := 'wip_bomRoutingUtil_pvt';
5 
6   procedure explodeRouting(p_orgID       in number,
7                            p_wipEntityID in number,
8                            p_repSchedID  in number,
9                            p_itemID      in number,
10                            p_altRouting  in varchar2,
11                            p_routingRevDate in date,
12                            p_qty         in number,
13                            p_startDate   in date,
14                            p_endDate     in date,
15                            x_serStartOp   out nocopy number,
16                            x_returnStatus out nocopy varchar2,
17                            x_errorMsg     out nocopy varchar2) is
18     l_params wip_logger.param_tbl_t;
19     l_procName varchar2(30) := 'explodeRouting';
20     l_logLevel number := to_number(fnd_log.g_current_runtime_level);
21     l_retStatus varchar2(1);
22     l_msg varchar2(240);
23 
24     l_routingSeqID number;
25     l_excludeECO number;
26     l_maxSeq number;
27 
28     cursor op_attachments(p_org_id number, p_wip_entity_id number) is
29       select wo.operation_seq_num,
30              wo.operation_sequence_id
31         from wip_operations wo
32        where wo.organization_id = p_org_id
33          and wo.wip_entity_id = p_wip_entity_id
34          and exists (select fad.pk1_value
35                        from fnd_attached_documents fad
36                       where fad.pk1_value = to_char(wo.operation_sequence_id)
37                         and fad.entity_name = 'BOM_OPERATION_SEQUENCES');
38   begin
39     x_returnStatus := fnd_api.g_ret_sts_success;
40     if (l_logLevel <= wip_constants.trace_logging) then
41       l_params(1).paramName := 'p_orgID';
42       l_params(1).paramValue := p_orgID;
43       l_params(2).paramName := 'p_wipEntityID';
44       l_params(2).paramValue := p_wipEntityID;
45       l_params(3).paramName := 'p_repSchedID';
46       l_params(3).paramValue := p_repSchedID;
47       l_params(4).paramName := 'p_itemID';
48       l_params(4).paramValue := p_itemID;
49       l_params(5).paramName := 'p_altRouting';
50       l_params(5).paramValue := p_altRouting;
51       l_params(6).paramName := 'p_routingRevDate';
52       l_params(6).paramValue := p_routingRevDate;
53       l_params(7).paramName := 'p_qty';
54       l_params(7).paramValue := p_qty;
55       l_params(8).paramName := 'p_startDate';
56       l_params(8).paramValue := p_startDate;
57       l_params(9).paramName := 'p_endDate';
58       l_params(9).paramValue := p_endDate;
59       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
60                             p_params       => l_params,
61                             x_returnStatus => x_returnStatus);
62       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
63         raise fnd_api.g_exc_unexpected_error;
64       end if;
65     end if;
66 
67     begin
68       select common_routing_sequence_id,
69              serialization_start_op
70         into l_routingSeqID,
71              x_serStartOp
72         from bom_operational_routings
73        where organization_id = p_orgID
74          and assembly_item_id = p_itemID
75          and nvl(alternate_routing_designator, '@@@^@@@') = nvl(p_altRouting, '@@@^@@@')
76          and nvl(cfm_routing_flag, 2) = 2;
77     exception
78       when NO_DATA_FOUND then
79         if(l_logLevel <= wip_constants.trace_logging) then
80            wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
81                                 p_procReturnStatus => 'true',
82                                 p_msg              => 'this item does not have a routing',
83                                 x_returnStatus     => l_retStatus);
84           wip_logger.cleanup(l_retStatus);
85         end if;
86         return;
87     end;
88     -- Added For Bug 12861546. This was moved from wipbmrtb.pls to here.
89     -- So that deletion is there only when routing exists.
90     wip_update_setup_resources.delete_setup_resources_pub(
91              p_wip_entity_id => p_wipEntityID,
92              p_organization_id => p_orgID);
93 
94     delete from wip_operations
95        where wip_entity_id = p_wipEntityID
96        and organization_id = p_orgID;
97 
98     delete from wip_operation_resources
99        where wip_entity_id = p_wipEntityID
100        and organization_id = p_orgID;
101 
102     delete from wip_sub_operation_resources
103        where wip_entity_id = p_wipEntityID
104        and organization_id = p_orgID;
105 
106     fnd_attached_documents2_pkg.delete_attachments(
107         x_entity_name => 'WIP_DISCRETE_OPERATIONS',
108         x_pk1_value => to_char(p_wipEntityID),
109         x_pk3_value => to_char(p_orgID),
110         x_delete_document_flag => 'Y');
111 
112 
116       wip_logger.log('exclude ECO is: ' || l_excludeECO, l_retStatus);
113     l_excludeECO := fnd_profile.value('WIP_RELEASED_REVS');
114 
115     if ( l_logLevel <= wip_constants.full_logging ) then
117       wip_logger.log('RoutingSeqID is: ' || l_routingSeqID, l_retStatus);
118     end if;
119 
120     insert into wip_operations
121       (wip_entity_id,
122        operation_seq_num,
123        organization_id,
124        repetitive_schedule_id,
125        last_update_date,
126        last_updated_by,
127        creation_date,
128        created_by,
129        last_update_login,
130        request_id,
131        program_application_id,
132        program_id,
133        program_update_date,
134        operation_sequence_id,
135        department_id,
136        scheduled_quantity,
137        quantity_in_queue,
138        quantity_running,
139        quantity_waiting_to_move,
140        quantity_rejected,
141        quantity_scrapped,
142        quantity_completed,
143        cumulative_scrap_quantity,
144        count_point_type,
145        backflush_flag,
146        minimum_transfer_quantity,
147        first_unit_start_date,
148        first_unit_completion_date,
149        last_unit_start_date,
150        last_unit_completion_date,
151        standard_operation_id,
152        description,
153        long_description,
154        attribute_category,
155        attribute1,
156        attribute2,
157        attribute3,
158        attribute4,
159        attribute5,
160        attribute6,
161        attribute7,
162        attribute8,
163        attribute9,
164        attribute10,
165        attribute11,
166        attribute12,
167        attribute13,
168        attribute14,
169        attribute15,
170                                                         check_skill)
171     select p_wipEntityID,
172            bos.operation_seq_num,
173            p_orgID,
174            p_repSchedID,
175            sysdate,
176            fnd_global.user_id,
177            sysdate,
178            fnd_global.user_id,
179            fnd_global.login_id,
180            fnd_global.conc_request_id,
181            fnd_global.prog_appl_id,
182            fnd_global.conc_program_id,
183            sysdate,
184            min(bos.operation_sequence_id),
185            bos.department_id,
186            round(p_qty, 6),
187            0, 0, 0, 0, 0, 0, 0,
188            bos.count_point_type,
189            bos.backflush_flag,
190            nvl(bos.minimum_transfer_quantity, 0),
191            p_startDate, p_endDate,
192            p_startDate, p_endDate,
193            bos.standard_operation_id,
194            bos.operation_description,
195            bos.long_description,
196            bos.attribute_category,
197            bos.attribute1,
198            bos.attribute2,
199            bos.attribute3,
200            bos.attribute4,
201            bos.attribute5,
202            bos.attribute6,
203            bos.attribute7,
204            bos.attribute8,
205            bos.attribute9,
206            bos.attribute10,
207            bos.attribute11,
208            bos.attribute12,
209            bos.attribute13,
210            bos.attribute14,
211            bos.attribute15,
212                                                                                         nvl(bos.check_skill,2)
213       from bom_operation_sequences bos
214      where bos.routing_sequence_id = l_routingSeqID
215        and nvl(bos.operation_type, 1) = 1
216        and bos.effectivity_date <= p_routingRevDate
217        and nvl(bos.disable_date, p_routingRevDate+1) >= p_routingRevDate
218        and (   bos.implementation_date is not null
219             or exists (select 1
220                          from eng_revised_items eng
221                         where eng.change_notice = bos.change_notice
222                           and eng.organization_id = p_orgID
223                           and eng.routing_sequence_id = l_routingSeqID
224                           and ((eng.status_type in (4, 7) and l_excludeECO = 1) or
225                                (eng.status_type in (1, 4, 7) and l_excludeECO = 2))))
226       and not exists (select 1
227                         from bom_operation_sequences bos2
228                        where bos2.routing_sequence_id = bos.routing_sequence_id
229                          and bos2.effectivity_date <= p_routingRevDate
230                          and bos2.operation_seq_num = bos.operation_seq_num
231                          and exists
232                               (select 1
233                                 from eng_revised_items eng
234                                where eng.change_notice = bos2.change_notice
235                                  and eng.organization_id = p_orgID
236                                  and eng.routing_sequence_id = l_routingSeqID
237                                  and ((eng.status_type in (4, 7) and l_excludeECO = 1) or
238                                       (eng.status_type in (1, 4, 7) and l_excludeECO = 2)))
239                          and bos2.acd_type = 3)
240     group by bos.operation_seq_num,
241              bos.department_id, bos.count_point_type, bos.backflush_flag, bos.minimum_transfer_quantity,
242              p_orgID, p_wipEntityID, p_repSchedID, p_qty, p_startDate, p_endDate, sysdate, fnd_global.user_id,
243              fnd_global.login_id, fnd_global.conc_request_id, fnd_global.prog_appl_id,
244              fnd_global.conc_program_id, bos.standard_operation_id, bos.operation_description,
245              bos.long_description, bos.attribute_category, bos.attribute1, bos.attribute2,
249 
246              bos.attribute3, bos.attribute4, bos.attribute5, bos.attribute6, bos.attribute7, bos.attribute8,
247              bos.attribute9, bos.attribute10, bos.attribute11, bos.attribute12, bos.attribute13,
248              bos.attribute14, bos.attribute15, bos.check_skill;
250 
251     update wip_operations wo
252        set previous_operation_seq_num = (select max(operation_seq_num)
253                                            from wip_operations
254                                           where wip_entity_id = p_wipEntityID
255                                             and organization_id = p_orgID
256                                             and operation_seq_num < wo.operation_seq_num),
257            next_operation_seq_num = (select min(operation_seq_num)
258                                        from wip_operations
259                                       where wip_entity_id = p_wipEntityID
260                                         and organization_id = p_orgID
261                                         and operation_seq_num > wo.operation_seq_num)
262      where wo.wip_entity_id = p_wipEntityID
263        and wo.organization_id = p_orgID;
264 
265     if ( l_logLevel <= wip_constants.full_logging ) then
266       wip_logger.log('begin to load resources', l_retStatus);
267     end if;
268 
269 
270     insert into wip_operation_resources
271       (wip_entity_id,
272        operation_seq_num,
273        resource_seq_num,
274        organization_id,
275        repetitive_schedule_id,
276        last_update_date,
277        last_updated_by,
278        creation_date,
279        created_by,
280        last_update_login,
281        request_id,
282        program_application_id,
283        program_id,
284        program_update_date,
285        resource_id,
286        uom_code,
287        basis_type,
288        usage_rate_or_amount,
289        activity_id,
290        scheduled_flag,
291        assigned_units,
292        autocharge_type,
293        standard_rate_flag,
294        applied_resource_units,
295        applied_resource_value,
296        start_date,
297        completion_date,
298        schedule_seq_num,
299        substitute_group_num,
300        replacement_group_num,
301        principle_flag,
302        setup_id,
303        attribute_category,
304        attribute1,
305        attribute2,
306        attribute3,
307        attribute4,
308        attribute5,
309        attribute6,
310        attribute7,
311        attribute8,
312        attribute9,
313        attribute10,
314        attribute11,
315        attribute12,
316        attribute13,
317        attribute14,
318        attribute15)
319     select p_wipEntityID,
320            bos.operation_seq_num,
321            bor.resource_seq_num,
322            p_orgID,
323            p_repSchedID,
324            sysdate,
325            fnd_global.user_id,
326            sysdate,
327            fnd_global.user_id,
328            fnd_global.login_id,
329            fnd_global.conc_request_id,
330            fnd_global.prog_appl_id,
331            fnd_global.conc_program_id,
332            sysdate,
333            bor.resource_id,
334            br.unit_of_measure,
335            bor.basis_type,
336            bor.usage_rate_or_amount,
337            bor.activity_id,
338            bor.schedule_flag,
339            bor.assigned_units,
340            bor.autocharge_type,
341            bor.standard_rate_flag,
342            0, 0,
343            p_startDate,
344            p_endDate,
345            bor.schedule_seq_num,
346            bor.substitute_group_num,
347            0,
348            bor.principle_flag,
349            bor.setup_id,
350            bor.attribute_category,
351            bor.attribute1,
352            bor.attribute2,
353            bor.attribute3,
354            bor.attribute4,
355            bor.attribute5,
356            bor.attribute6,
357            bor.attribute7,
358            bor.attribute8,
359            bor.attribute9,
360            bor.attribute10,
361            bor.attribute11,
362            bor.attribute12,
363            bor.attribute13,
364            bor.attribute14,
365            bor.attribute15
366       from bom_operation_sequences bos,
367            bom_operation_resources bor,
368            bom_resources br
369      where bos.routing_sequence_id = l_routingSeqID
370        and bos.effectivity_date <= p_routingRevDate
371        and nvl(bos.disable_date, p_routingRevDate+1) >= p_routingRevDate
372        and bos.operation_sequence_id = bor.operation_sequence_id
373        and bor.resource_id = br.resource_id
374        and nvl(bor.acd_type, 0) <> 3
375        and bos.effectivity_date =
376                     (select max(effectivity_date)
377                        from bom_operation_sequences bos2,
378                             bom_operation_resources bor2
379                       where bos2.routing_sequence_id = l_routingSeqID
380                         and bos2.operation_sequence_id = bor2.operation_sequence_id
381                         and bos2.operation_seq_num = bos.operation_seq_num
382                         and bor2.resource_seq_num = bor.resource_seq_num
383                         and nvl(bos2.operation_type, 1) = 1
384                         and bos2.effectivity_date <= p_routingRevDate
385                         and (   bos2.implementation_date is not null
386                              or exists (select 1
387                                           from eng_revised_items eng
391                                            and ((eng.status_type in (4, 7) and l_excludeECO = 1) or
388                                          where eng.change_notice = bos2.change_notice
389                                            and eng.organization_id = p_orgID
390                                            and eng.routing_sequence_id = l_routingSeqID
392                                                 (eng.status_type in (1, 4, 7) and l_excludeECO = 2)))));
393 
394     if ( l_logLevel <= wip_constants.full_logging ) then
395       wip_logger.log('begin to load substitute resources', l_retStatus);
396     end if;
397 
398     select max(resource_seq_num)
399       into l_maxSeq
400       from wip_operation_resources
401      where organization_id = p_orgID
402        and wip_entity_id = p_wipEntityID;
403 
404 
405     insert into wip_sub_operation_resources
406       (wip_entity_id,
407        operation_seq_num,
408        resource_seq_num,
409        organization_id,
410        repetitive_schedule_id,
411        last_update_date,
412        last_updated_by,
413        creation_date,
414        created_by,
415        last_update_login,
416        request_id,
417        program_application_id,
418        program_id,
419        program_update_date,
420        resource_id,
421        uom_code,
422        basis_type,
423        usage_rate_or_amount,
424        activity_id,
425        scheduled_flag,
426        assigned_units,
427        autocharge_type,
428        standard_rate_flag,
429        applied_resource_units,
430        applied_resource_value,
431        start_date,
432        completion_date,
433        schedule_seq_num,
434        substitute_group_num,
435        replacement_group_num,
436        principle_flag,
437        setup_id,
438        attribute_category,
439        attribute1,
440        attribute2,
441        attribute3,
442        attribute4,
443        attribute5,
444        attribute6,
445        attribute7,
446        attribute8,
447        attribute9,
448        attribute10,
449        attribute11,
450        attribute12,
451        attribute13,
452        attribute14,
453        attribute15)
454     select wo.wip_entity_id,
455            wo.operation_seq_num,
456            l_maxSeq + ROWNUM,
457            wo.organization_id,
458            wo.repetitive_schedule_id,
459            wo.last_update_date,
460            wo.last_updated_by,
461            wo.creation_date,
462            wo.created_by,
463            wo.last_update_login,
464            wo.request_id,
465            wo.program_application_id,
466            wo.program_id,
467            wo.program_update_date,
468            bsor.resource_id,
469            br.unit_of_measure,
470            bsor.basis_type,
471            bsor.usage_rate_or_amount,
472            bsor.activity_id,
473            bsor.schedule_flag,
474            bsor.assigned_units,
475            bsor.autocharge_type,
476            bsor.standard_rate_flag,
477            0, 0,
478            wo.first_unit_start_date,
479            wo.last_unit_completion_date,
480            bsor.schedule_seq_num,
481            bsor.substitute_group_num,
482            bsor.replacement_group_num,
483            bsor.principle_flag,
484            bsor.setup_id,
485            bsor.attribute_category,
486            bsor.attribute1,
487            bsor.attribute2,
488            bsor.attribute3,
489            bsor.attribute4,
490            bsor.attribute5,
491            bsor.attribute6,
492            bsor.attribute7,
493            bsor.attribute8,
494            bsor.attribute9,
495            bsor.attribute10,
496            bsor.attribute11,
497            bsor.attribute12,
498            bsor.attribute13,
499            bsor.attribute14,
500            bsor.attribute15
501       from bom_resources br,
502            bom_sub_operation_resources bsor,
503            wip_operations wo
504      where wo.organization_id = p_orgID
505        and wo.wip_entity_id = p_wipEntityID
506        and wo.operation_sequence_id = bsor.operation_sequence_id
507        and bsor.resource_id = br.resource_id
508        and nvl(bsor.acd_type, 0) <> 3;
509 
510     if ( l_logLevel <= wip_constants.full_logging ) then
511       wip_logger.log('begin to load attachment', l_retStatus);
512     end if;
513 
514 
515     FOR op_attach IN op_attachments(p_orgID, p_wipEntityID) LOOP
516       fnd_attached_documents2_pkg.copy_attachments(
517         x_from_entity_name => 'BOM_OPERATION_SEQUENCES',
518         x_from_pk1_value => to_char(op_attach.operation_sequence_id),
519         x_to_entity_name => 'WIP_DISCRETE_OPERATIONS',
520         x_to_pk1_value => to_char(p_wipEntityID),
521         x_to_pk2_value => to_char(op_attach.operation_seq_num),
522         x_to_pk3_value => to_char(p_orgID),
523         x_created_by => fnd_global.user_id,
524         x_last_update_login => fnd_global.login_id,
525         x_program_application_id => fnd_global.prog_appl_id,
526         x_program_id => fnd_global.conc_program_id,
527         x_request_id => fnd_global.conc_request_id);
528     END LOOP;
529 
530     /* Added for 12.1.1 Skills Validation project.*/
531     if ( l_logLevel <= wip_constants.full_logging ) then
532       wip_logger.log('begin to load competence', l_retStatus);
533     end if;
537     AND ORGANIZATION_ID = p_orgID;
534 
535     DELETE FROM WIP_OPERATION_COMPETENCIES
536     WHERE WIP_ENTITY_ID = p_wipEntityID
538 
539 
540     INSERT INTO WIP_OPERATION_COMPETENCIES
541         (LEVEL_ID,          ORGANIZATION_ID,
542          WIP_ENTITY_ID,           OPERATION_SEQ_NUM, OPERATION_SEQUENCE_ID,
543          STANDARD_OPERATION_ID,   COMPETENCE_ID,     RATING_LEVEL_ID,
544          QUALIFICATION_TYPE_ID,   LAST_UPDATE_DATE,  LAST_UPDATED_BY,
545          LAST_UPDATE_LOGIN,       CREATED_BY,        CREATION_DATE)
546     SELECT
547          3,                    WO.ORGANIZATION_ID,
548          WO.WIP_ENTITY_ID,               WO.OPERATION_SEQ_NUM, BOS.OPERATION_SEQUENCE_ID,
549          BOS.STANDARD_OPERATION_ID,      BOS.COMPETENCE_ID,    BOS.RATING_LEVEL_ID,
550          BOS.QUALIFICATION_TYPE_ID,      WO.LAST_UPDATE_DATE,  WO.LAST_UPDATED_BY,
551          WO.LAST_UPDATE_LOGIN,           WO.CREATED_BY,        WO.CREATION_DATE
552     FROM BOM_OPERATION_SKILLS BOS,
553          WIP_OPERATIONS WO,
554          WIP_ENTITIES WE
555     WHERE
556          WE.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
557          AND WO.ORGANIZATION_ID = WO.ORGANIZATION_ID
558          AND WE.ENTITY_TYPE = 1
559          AND WO.ORGANIZATION_ID = p_orgID
560          AND WO.WIP_ENTITY_ID = p_wipEntityID
561          AND WO.ORGANIZATION_ID = BOS.ORGANIZATION_ID
562          AND BOS.OPERATION_SEQUENCE_ID = WO.OPERATION_SEQUENCE_ID
563          AND BOS.LEVEL_ID = 2;
564 
565     if (l_logLevel <= wip_constants.trace_logging) then
566       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
567                            p_procReturnStatus => x_returnStatus,
568                            p_msg              => 'success',
569                            x_returnStatus     => l_retStatus);
570     end if;
571   exception
572   when others then
573     if(l_logLevel <= wip_constants.trace_logging) then
574       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
575                            p_procReturnStatus => x_returnStatus,
576                            p_msg              => 'unexp error:' || SQLERRM,
577                            x_returnStatus     => l_retStatus);
578     end if;
579     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
580     fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkgName,
581                             p_procedure_name => l_procName,
582                             p_error_text => SQLERRM);
583     wip_utilities.get_message_stack(p_msg => l_msg);
584     x_errorMsg := substrb(l_msg, 1, 240);
585   end explodeRouting;
586 
587 
588   procedure explodeBOM(p_orgID       in number,
589                        p_wipEntityID in number,
590                        p_jobType     in number,
591                        p_repSchedID  in number,
592                        p_itemID      in number,
593                        p_altBOM      in varchar2,
594                        p_bomRevDate  in date,
595                        p_altRouting  in varchar2,
596                        p_routingRevDate in date,
597                        p_qty         in number,
598                        p_jobStartDate in date,
599                        p_projectID   in number,
600                        p_taskID      in number,
601                        p_unitNumber  in varchar2 DEFAULT '', /* added for bug 5332615 */
602                        x_returnStatus out nocopy varchar2,
603                        x_errorMsg     out nocopy varchar2) is
604     l_procName varchar2(30) := 'explodeBOM';
605     l_params wip_logger.param_tbl_t;
606     l_logLevel number := to_number(fnd_log.g_current_runtime_level);
607     l_retStatus varchar2(1);
608     l_msg varchar2(240);
609 
610     l_compTbl system.wip_component_tbl_t;
611     l_mrpFlag number;
612     l_count number;
613 
614     l_entityType number;
615     l_usePhantomRouting number;
616     l_minOp number;
617     l_exists number;
618     l_opSeq number;
619     l_multipleFactor number;
620 
621     l_diff_basis number;
622     l_basis number;
623     l_wro_op number;
624 
625     l_primary_item number; --add for 12355035;
626 
627     cursor c_phantoms is
628       select inventory_item_id,
629              -1*operation_seq_num operation_seq_num
630         from wip_requirement_operations
631        where organization_id = p_orgID
632          and wip_entity_id = p_wipEntityID
633          and nvl(repetitive_schedule_id, -1) = nvl(p_repSchedID, -1)
634          and operation_seq_num < 0
635          and wip_supply_type = wip_constants.phantom;
636 
637   begin
638     x_returnStatus := fnd_api.g_ret_sts_success;
639     if (l_logLevel <= wip_constants.trace_logging) then
640       l_params(1).paramName := 'p_orgID';
641       l_params(1).paramValue := p_orgID;
642       l_params(2).paramName := 'p_wipEntityID';
643       l_params(2).paramValue := p_wipEntityID;
644       l_params(3).paramName := 'p_jobType';
645       l_params(3).paramValue := p_jobType;
646       l_params(4).paramName := 'p_repSchedID';
647       l_params(4).paramValue := p_repSchedID;
648       l_params(5).paramName := 'p_itemID';
649       l_params(5).paramValue := p_itemID;
650       l_params(6).paramName := 'p_altBOM';
651       l_params(6).paramValue := p_altBOM;
655       l_params(8).paramValue := p_altRouting;
652       l_params(7).paramName := 'p_bomRevDate';
653       l_params(7).paramValue := p_bomRevDate;
654       l_params(8).paramName := 'p_altRouting';
656       l_params(9).paramName := 'p_routingRevDate';
657       l_params(9).paramValue := p_routingRevDate;
658       l_params(10).paramName := 'p_qty';
659       l_params(10).paramValue := p_qty;
660       l_params(11).paramName := 'p_jobStartDate';
661       l_params(11).paramValue := p_jobStartDate;
662       l_params(12).paramName := 'p_projectID';
663       l_params(12).paramValue := p_projectID;
664       l_params(13).paramName := 'p_taskID';
665       l_params(13).paramValue := p_taskID;
666       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
667                             p_params       => l_params,
668                             x_returnStatus => x_returnStatus);
669       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
670         raise fnd_api.g_exc_unexpected_error;
671       end if;
672     end if;
673 
674     l_entityType := wip_constants.discrete;
675     if ( p_repSchedID is not null ) then
676       l_entityType := wip_constants.repetitive;
677     end if;
678 
679     l_mrpFlag := wip_constants.yes;
680     /*If non-standard job, set mrpFlag based on WIP: Enable MRP Net for Non-standard Job Requirements profile value for bug 7719689 (FP of bug 7506349) */
681     if ( p_jobType = wip_constants.nonstandard ) then
682        l_mrpFlag := TO_NUMBER(FND_PROFILE.value('WIP_NON_STD_MRP_NET')); /*code changed for bug 7719689 (FP of bug 7506349) */
683     end if;
684 
685   /*
686     wip_bflProc_priv.explodeRequirements(
687                        p_itemID => p_itemID,
688                        p_orgID => p_orgID,
689                        p_qty => 1,
690                        p_altBomDesig => p_altBOM,
691                        p_altOption => 2,
692                        p_bomRevDate => p_bomRevDate,
693                        p_txnDate => null,
694                        p_projectID => p_projectID,
695                        p_taskID => p_taskID,
696                        p_initMsgList => fnd_api.g_false,
697                        p_endDebug => fnd_api.g_false,
698                        x_compTbl => l_compTbl,
699                        x_returnStatus => x_returnStatus);
700    */
701 
702     wip_flowUtil_priv.explodeRequirementsAndDefault(
703                        p_assyID => p_itemID,
704                        p_orgID => p_orgID,
705                        p_qty => 1,
706                        p_altBomDesig => p_altBOM,
707                        p_altOption => 2,
708                        p_bomRevDate => p_bomRevDate,
709                        p_txnDate => p_jobStartDate,
710                        p_implFlag => 2,    /* for bug 5383135 */
711                        p_projectID => p_projectID,
712                        p_taskID => p_taskID,
713                        p_toOpSeqNum => null,
714                        p_altRoutDesig => p_altRouting,
715                        p_txnFlag => false, /* for bug4538135 */ /* ER 4369064 */
716                        p_unitNumber => p_unitNumber, /* added for bug 5332615 */
717                        x_compTbl => l_compTbl,
718                        x_returnStatus => x_returnStatus);
719     if ( x_returnStatus <> fnd_api.g_ret_sts_success ) then
720       raise fnd_api.g_exc_unexpected_error;
721     end if;
722 
723     begin
724       select nvl(min(operation_seq_num), 1)
725         into l_minOp
726         from wip_operations
727        where wip_entity_id = p_wipEntityID;
728     exception
729     when others then
730       l_minOp := 1;
731     end;
732 
733     l_count := l_compTbl.first;
734     while ( l_count is not null ) loop
735       -- here, we need to make sure that the op exists. This might happen if the user use an alternate
736       -- routing to create the job so the op exploded might not exists. In that case, we will assign this component
737       -- to the first operation
738       begin
739         select 1 into l_exists
740           from wip_operations
741          where wip_entity_id = p_wipEntityID
742            and operation_seq_num = l_compTbl(l_count).operation_seq_num;
743         l_opSeq := l_compTbl(l_count).operation_seq_num;
744       exception
745       when others then
746         l_opSeq := l_minOp;
747 
748         /* Fix for bug 8588333: If routing or the specific operation doesn't exists then only
749            Op pull components should become Assy Pull. */
750         if (l_opSeq = 1 AND l_compTbl(l_count).wip_supply_type = WIP_CONSTANTS.OP_PULL) then
751             l_compTbl(l_count).wip_supply_type := WIP_CONSTANTS.ASSY_PULL;
752         end if;
753 
754       end;
755 
756 
757        /*Add for 12355035: below check exsits for 11.5.10 in wilmeb.ppc, method wilmeb_explode_bom.
758         But missing in R12 code*/
759        select primary_item_id
760        into l_primary_item
761        from wip_discrete_jobs
762        where organization_id = p_orgID
763          and wip_entity_id = p_wipEntityID;
764 
765       if(l_primary_item is null AND (l_compTbl(l_count).wip_supply_type = WIP_CONSTANTS.OP_PULL or
766           l_compTbl(l_count).wip_supply_type = WIP_CONSTANTS.ASSY_PULL)) then
767               l_compTbl(l_count).wip_supply_type := WIP_CONSTANTS.PUSH;
768       end if;
769       /*End for 12355035*/
770 
771       if( l_compTbl(l_count).basis_type = WIP_CONSTANTS.LOT_BASED_MTL) then
772           l_multipleFactor := 1 ;
773       else
774           l_multipleFactor := p_qty ;
775       end if;
776 
780          l_compTbl(l_count).wip_supply_type := WIP_CONSTANTS.ASSY_PULL;
777       /* Moved This fix inside exception block of SQL on wip_operations.
778       /* Fix for bug 4703486. If no rtg exists, Op pull components should become Assy Pull
779       if (l_opSeq = 1 AND l_compTbl(l_count).wip_supply_type = WIP_CONSTANTS.OP_PULL) then
781       end if;
782       */
783 
784 
785       /* bug 4688276 - if the same component in op 1 and op 10, for example, we'll try
786          to merge the qties into op 10, as long as their baisis type is the same */
787       if( l_compTbl(l_count).wip_supply_type = wip_constants.phantom) then
788         l_wro_op := -1*l_opSeq;
789       else
790         l_wro_op := l_opSeq;
791       end if;
792 
793       select count(distinct nvl(basis_type, 1)), min(distinct nvl(basis_type, 1) )
794       into l_diff_basis, l_basis
795       from wip_requirement_operations wro
796       where wro.inventory_item_id = l_compTbl(l_count).inventory_item_id
797         and wro.organization_id = p_orgID
798         and wro.wip_entity_id = p_wipEntityID
799         and wro.operation_seq_num = l_wro_op;
800 
801       if( l_diff_basis > 1 ) then
802         raise fnd_api.g_exc_unexpected_error;
803       elsif( l_diff_basis = 1 ) then
804         if(  (l_compTbl(l_count).basis_type is null and l_basis = 1 )
805              or l_compTbl(l_count).basis_type = l_basis ) then
806           update wip_requirement_operations wro
807           set wro.quantity_per_assembly = l_compTbl(l_count).primary_quantity + wro.quantity_per_assembly,/*Bug 13527184*/
808             wro.required_quantity = round( l_compTbl(l_count).primary_quantity*l_multipleFactor/l_compTbl(l_count).component_yield_factor,
809                                     wip_constants.max_displayed_precision) + wro.required_quantity /*Bug 13527184*/
810           where wro.inventory_item_id = l_compTbl(l_count).inventory_item_id
811             and wro.organization_id = p_orgID
812             and wro.wip_entity_id = p_wipEntityID
813             and wro.operation_seq_num = l_wro_op;
814 
815           update wip_requirement_operations wro
816           /*Fix for bug 7486594*/
817           set wro.component_yield_factor = decode(wro.quantity_per_assembly,0,1,round( wro.quantity_per_assembly * l_multipleFactor / wro.required_quantity,
818                                                   wip_constants.max_displayed_precision))
819           where wro.inventory_item_id = l_compTbl(l_count).inventory_item_id
820             and wro.organization_id = p_orgID
821             and wro.wip_entity_id = p_wipEntityID
822             and wro.operation_seq_num = l_wro_op;
823         else
824           x_returnStatus := fnd_api.g_ret_sts_error;
825           fnd_message.set_name('WIP', 'WIP_COMP_DUP_OP_ONE');
826           fnd_msg_pub.add;
827           if (l_logLevel <= wip_constants.full_logging) then
828             wip_logger.log(p_msg => 'Item ' || l_compTbl(l_count).inventory_item_id ||
829                                     ' has duplicates in op 1, failed explosion!',
830                            x_returnStatus => x_returnStatus);
831 
832 
833           end if;
834           return;
835         end if;
836       else  /* --> end of bug fix 4688276 */
837 
838 
839       insert into wip_requirement_operations
840         (inventory_item_id,
841          organization_id,
842          wip_entity_id,
843          operation_seq_num,
844          repetitive_schedule_id,
845          last_update_date,
846          last_updated_by,
847          creation_date,
848          created_by,
849          last_update_login,
850          request_id,
851          program_application_id,
852          program_id,
853          program_update_date,
854          component_sequence_id,
855          wip_supply_type,
856          date_required,
857          required_quantity,
858          quantity_issued,
859          quantity_per_assembly,
860          component_yield_factor, /*For Component Yield Enhancement(Bug 4369064) */
861          basis_type,
862          supply_subinventory,
863          supply_locator_id,
864          mrp_net_flag)
865       values(
866          l_compTbl(l_count).inventory_item_id,
867          p_orgID,
868          p_wipEntityID,
869          decode(l_compTbl(l_count).wip_supply_type,
870                 wip_constants.phantom, -1*l_opSeq, l_opSeq),
871          null,
872          sysdate,
873          fnd_global.user_id,
874          sysdate,
875          fnd_global.user_id,
876          fnd_global.login_id,
877          fnd_global.conc_request_id,
878          fnd_global.prog_appl_id,
879          fnd_global.conc_program_id,
880          sysdate,
881          l_compTbl(l_count).component_sequence_id,
882          l_compTbl(l_count).wip_supply_type,
883          p_jobStartDate,
884          round(l_compTbl(l_count).primary_quantity*l_multipleFactor/
885                      l_compTbl(l_count).component_yield_factor, wip_constants.max_displayed_precision),/*Bug 13527184*/
886                      /*For Component Yield Enhancement(Bug 4369064)->Always need to consider yield factor*/
887          0,
888          l_compTbl(l_count).primary_quantity,/*Bug 13527184*/
889          l_compTbl(l_count).component_yield_factor, /*For Component Yield Enhancement(Bug 4369064) */
890          decode(l_compTbl(l_count).basis_type,WIP_CONSTANTS.LOT_BASED_MTL,2,NULL),
891          l_compTbl(l_count).supply_subinventory,
892          l_compTbl(l_count).supply_locator_id,
893          decode(l_compTbl(l_count).wip_supply_type, 5, 2,
894                 decode(sign(l_compTbl(l_count).primary_quantity), -1, 2, l_mrpFlag)));
895 
896       end if; /* end insert */
897 
898       l_count := l_compTbl.next(l_count);
899     end loop;
900 
904         wip_explode_phantom_rtgs.explode_resources(
901     l_usePhantomRouting := wip_globals.use_phantom_routings(p_orgID);
902     if ( l_usePhantomRouting = wip_constants.yes ) then
903       for phan in c_phantoms loop
905             p_wip_entity_id => p_wipEntityID,
906             p_sched_id => p_repSchedID,
907             p_org_id => p_orgID,
908             p_entity_type => l_entityType,
909             p_phantom_item_id => phan.inventory_item_id,
910             p_op_seq_num => phan.operation_seq_num,
911             p_rtg_rev_date => p_routingRevDate);
912       end loop;
913     end if;
914 
915     -- bug 5527438 added call to the following API to enable defaulting of supply subinventory
916     -- and locator from the resource definition.
917 
918     wip_picking_pvt.Post_Explosion_CleanUp(     p_wip_entity_id => p_wipEntityID,
919                                                 p_repetitive_schedule_id => null,
920                                                 p_org_id =>   p_orgID,
921                                                 x_return_status => x_returnStatus,
922                                                 x_msg_data => x_errorMsg );
923 
924     if (x_returnStatus <> fnd_api.g_ret_sts_success) then
925              if (l_logLevel <= wip_constants.full_logging) then
926                      wip_logger.log(p_msg => 'Post_Explosion_Cleanup failed for  wip_entity_id '||p_wipEntityID,
927                                     x_returnStatus => x_returnStatus);
928              end if;
929              return;
930     end if;
931 
932     -- bug 5527438 end of changes for this fix
933 
934     update wip_requirement_operations wro
935        set (date_required,
936             department_id,
937             wip_supply_type) =
938            (select nvl(max(wo.first_unit_start_date), wro.date_required),
939                    max(department_id),
940                    decode(wro.wip_supply_type, wip_constants.assy_pull,
941                           decode(nvl(max(wo.count_point_type), 0),
942                                  wip_constants.no_manual, wip_constants.op_pull,
943                                  wro.wip_supply_type),
944                           wro.wip_supply_type)
945               from wip_operations wo
946              where wo.organization_id = wro.organization_id
947                and wo.wip_entity_id  = wro.wip_entity_id
948                and nvl(wo.repetitive_schedule_id, -1) = nvl(wro.repetitive_schedule_id, -1)
949                and wo.operation_seq_num = abs(wro.operation_seq_num)),
950            (comments,
951             attribute_category,
952             attribute1,
953             attribute2,
954             attribute3,
955             attribute4,
956             attribute5,
957             attribute6,
958             attribute7,
959             attribute8,
960             attribute9,
961             attribute10,
962             attribute11,
963             attribute12,
964             attribute13,
965             attribute14,
966             attribute15) =
967            (select bic.component_remarks,
968                    bic.attribute_category,
969                    bic.attribute1,
970                    bic.attribute2,
971                    bic.attribute3,
972                    bic.attribute4,
973                    bic.attribute5,
974                    bic.attribute6,
975                    bic.attribute7,
976                    bic.attribute8,
977                    bic.attribute9,
978                    bic.attribute10,
979                    bic.attribute11,
980                    bic.attribute12,
981                    bic.attribute13,
982                    bic.attribute14,
983                    bic.attribute15
984               from bom_inventory_components bic
985              where bic.component_sequence_id = wro.component_sequence_id),
986            (segment1,
987             segment2,
988             segment3,
989             segment4,
990             segment5,
991             segment6,
992             segment7,
993             segment8,
994             segment9,
995             segment10,
996             segment11,
997             segment12,
998             segment13,
999             segment14,
1000             segment15,
1001             segment16,
1002             segment17,
1003             segment18,
1004             segment19,
1005             segment20) =
1006            (select msi.segment1,
1007                    msi.segment2,
1008                    msi.segment3,
1009                    msi.segment4,
1010                    msi.segment5,
1011                    msi.segment6,
1012                    msi.segment7,
1013                    msi.segment8,
1014                    msi.segment9,
1015                    msi.segment10,
1016                    msi.segment11,
1017                    msi.segment12,
1018                    msi.segment13,
1019                    msi.segment14,
1020                    msi.segment15,
1021                    msi.segment16,
1022                    msi.segment17,
1023                    msi.segment18,
1024                    msi.segment19,
1025                    msi.segment20
1026               from mtl_system_items msi
1027              where msi.inventory_item_id = wro.inventory_item_id
1028                and msi.organization_id = wro.organization_id)
1029      where wro.wip_entity_id = p_wipEntityID
1030        and nvl(wro.repetitive_schedule_id, -1) = nvl(p_repSchedID, -1)
1031        and wro.organization_id = p_orgID;
1032 
1033     if (l_logLevel <= wip_constants.trace_logging) then
1034       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1038     end if;
1035                            p_procReturnStatus => x_returnStatus,
1036                            p_msg              => 'success',
1037                            x_returnStatus     => l_retStatus);
1039   exception
1040   when fnd_api.g_exc_unexpected_error then
1041     if (l_logLevel <= wip_constants.trace_logging) then
1042       wip_logger.exitPoint(p_procName => g_pkgName || '.' || l_procName,
1043                            p_procReturnStatus => x_returnStatus,
1044                            p_msg => 'failed at exploding requirements',
1045                            x_returnStatus => l_retStatus); --discard logging return status
1046     end if;
1047   when others then
1048     if(l_logLevel <= wip_constants.trace_logging) then
1049       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1050                            p_procReturnStatus => x_returnStatus,
1051                            p_msg              => 'unexp error:' || SQLERRM,
1052                            x_returnStatus     => l_retStatus);
1053     end if;
1054     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
1055     fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkgName,
1056                             p_procedure_name => l_procName,
1057                             p_error_text => SQLERRM);
1058     wip_utilities.get_message_stack(p_msg => l_msg);
1059     x_errorMsg := substrb(l_msg, 1, 240);
1060   end explodeBOM;
1061 
1062 
1063   procedure adjustQtyChange(p_orgID       in number,
1064                             p_wipEntityID in number,
1065                             p_qty         in number,
1066                             x_returnStatus out nocopy varchar2,
1067                             x_errorMsg     out nocopy varchar2) is
1068     l_params wip_logger.param_tbl_t;
1069     l_procName varchar2(30) := 'adjustQtyChange';
1070     l_logLevel number := to_number(fnd_log.g_current_runtime_level);
1071     l_msg varchar2(240);
1072     l_retStatus varchar2(1);
1073 
1074     l_jobQty number;
1075     l_jobStatus number;
1076     l_minOp number;
1077     l_updateFlag number :=0;/* add for Bug 8413228 (FP of 8392916).*/
1078   begin
1079 
1080     x_returnStatus := fnd_api.g_ret_sts_success;
1081     if (l_logLevel <= wip_constants.trace_logging) then
1082       l_params(1).paramName := 'p_orgID';
1083       l_params(1).paramValue := p_orgID;
1084       l_params(2).paramName := 'p_wipEntityID';
1085       l_params(2).paramValue := p_wipEntityID;
1086       l_params(3).paramName := 'p_qty';
1087       l_params(3).paramValue := p_qty;
1088       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
1089                             p_params       => l_params,
1090                             x_returnStatus => x_returnStatus);
1091       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
1092         raise fnd_api.g_exc_unexpected_error;
1093       end if;
1094     end if;
1095 
1096 
1097     select start_quantity,
1098            status_type
1099       into l_jobQty,
1100            l_jobStatus
1101       from wip_discrete_jobs
1102      where organization_id = p_orgID
1103        and wip_entity_id = p_wipEntityID;
1104 
1105     if ( p_qty is null or
1106          l_jobStatus not in (wip_constants.unreleased,
1107                              wip_constants.released,
1108                              wip_constants.comp_chrg,
1109                              wip_constants.hold) ) then
1110       if(l_logLevel <= wip_constants.trace_logging) then
1111         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1112                              p_procReturnStatus => x_returnStatus,
1113                              p_msg              => 'no qty change or job status is not right',
1114                              x_returnStatus     => l_retStatus);
1115       end if;
1116       return;
1117     end if;
1118 
1119 
1120     if ( l_jobStatus <> wip_constants.unreleased ) then
1121       select nvl(min(operation_seq_num), fnd_api.g_miss_num)
1122         into l_minOp
1123         from wip_operations
1124        where organization_id = p_orgID
1125          and wip_entity_id = p_wipEntityID;
1126 
1127       if ( l_minOp = fnd_api.g_miss_num ) then
1128          /*  Fix bug 9540544 */
1129          update wip_requirement_operations
1130          set required_quantity = decode(basis_type,
1131                                         2,  /* basis is lot */
1132              round(quantity_per_assembly/nvl(component_yield_factor,1), 6),/*For Component Yield Enhancement(Bug 4369064) */
1133                                         round(quantity_per_assembly/nvl(component_yield_factor,1) * p_qty, 6))
1134          where organization_id = p_orgID
1135          and wip_entity_id = p_wipEntityID;
1136         /*  End of Fix bug 9540544 */
1137         if(l_logLevel <= wip_constants.trace_logging) then
1138           wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1139                                p_procReturnStatus => x_returnStatus,
1140                                p_msg              => 'no operation exist',
1141                                x_returnStatus     => l_retStatus);
1142         end if;
1143         return;
1144       end if;
1145 
1146        update wip_operations
1147          set quantity_in_queue = quantity_in_queue - (scheduled_quantity - p_qty)
1148        where organization_id = p_orgID
1149          and wip_entity_id = p_wipEntityID
1150          and operation_seq_num = l_minOp /* Fix for Bug 6639146 */
1151              and quantity_in_queue <> 0 /*Bug 13030393: Reverted the fix for Bug 11686971*/
1152          and (scheduled_quantity - p_qty) <= quantity_in_queue; /* add for Bug  8413228 (FP of 8392916).quantity_in_queue can be lower to 0 */
1153 
1154                   /* add for Bug 8413228 (FP of 8392916).*/
1158 
1155                  if SQL%FOUND then
1156                   l_updateFlag :=1;
1157                  end if;
1159        /* Fix for bug 6954115 */
1160            /*Bug 13030393: changing the where condition from 'quantity_completed+quantity_running+quantity_in_queue' to
1161            scheduled_quantity. Reason is because in some cases (bug 11686971), there can be overcompletion happening
1162            at an operation level, if overcompletion percent is specified. In that case this statement will not update
1163            quantity_in_queue = 0. But idea is to just check for total scheduled quantity at the operation if everything
1164            is moved out of first operation.
1165 
1166            Also, the SQL for quantity_in_queue = 0, is split into 2.
1167            1. Released jobs that have First Operation complete (quantity_completed+quantity_running+quantity_in_queue) > 0
1168            2. Unreleased job is just now released with Start quantity change. Thus no quantity in any step of the operation
1169                         (quantity_completed+quantity_running+quantity_in_queue) = 0*/
1170        update wip_operations
1171          set quantity_in_queue = CASE WHEN p_qty -(quantity_completed+quantity_running+quantity_in_queue) <0 THEN 0
1172                                   ELSE p_qty -(quantity_completed+quantity_running+quantity_in_queue) END --Bug#13655641- Qty_in_queue cannot be less than 0
1173        where organization_id = p_orgID
1174          and wip_entity_id = p_wipEntityID
1175          and operation_seq_num = l_minOp
1176          and quantity_in_queue = 0
1177          and scheduled_quantity <= p_qty /*Fix for Bug 8413228 (FP of 8392916). quantity_in_queue can be lower to 0 */
1178                  and (quantity_completed+quantity_running+quantity_in_queue) > 0; /*Moved away from first operation*/
1179 
1180                  if SQL%FOUND then
1181                   l_updateFlag :=1;
1182                  end if;
1183 
1184        update wip_operations
1185          set quantity_in_queue = p_qty
1186        where organization_id = p_orgID
1187          and wip_entity_id = p_wipEntityID
1188          and operation_seq_num = l_minOp
1189          and quantity_in_queue = 0
1190                  and (quantity_completed+quantity_running+quantity_in_queue) = 0; /*Unreleased job is just now released with Start quantity change*/
1191 
1192                    /* add for Bug 8413228 (FP of 8392916). If both update statements have no rows to update, that means
1193                    that the quantity was lowered below what was already past queue of the first op.
1194                     This is an error. */
1195                   if (SQL%NOTFOUND and l_updateFlag = 0) then
1196                    fnd_message.set_name('WIP', 'WIP_LOWER_JOB_QTY');
1197                    x_returnStatus := fnd_api.g_ret_sts_unexp_error;
1198                    x_errorMsg := fnd_message.get;
1199                    return;
1200                  end if;
1201 
1202     end if;
1203 
1204       update wip_operations
1205        set scheduled_quantity = p_qty
1206      where organization_id = p_orgID
1207        and wip_entity_id = p_wipEntityID;
1208 
1209     update wip_requirement_operations
1210        set required_quantity = decode(basis_type,
1211                                       2,  /* basis is lot */
1212                                       round(quantity_per_assembly/nvl(component_yield_factor,1), 6),/*For Component Yield Enhancement(Bug 4369064) */
1213                                       round(quantity_per_assembly/nvl(component_yield_factor,1) * p_qty, 6))
1214      where organization_id = p_orgID
1215        and wip_entity_id = p_wipEntityID;
1216 
1217     if (l_logLevel <= wip_constants.trace_logging) then
1218       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1219                            p_procReturnStatus => x_returnStatus,
1220                            p_msg              => 'success',
1221                            x_returnStatus     => l_retStatus);
1222     end if;
1223 
1224   exception
1225   when others then
1226     if(l_logLevel <= wip_constants.trace_logging) then
1227       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
1228                            p_procReturnStatus => x_returnStatus,
1229                            p_msg              => 'unexp error:' || SQLERRM,
1230                            x_returnStatus     => l_retStatus);
1231     end if;
1232     x_returnStatus := fnd_api.g_ret_sts_unexp_error;
1233     fnd_msg_pub.add_exc_msg(p_pkg_name => g_pkgName,
1234                             p_procedure_name => l_procName,
1235                             p_error_text => SQLERRM);
1236     wip_utilities.get_message_stack(p_msg => l_msg);
1237     x_errorMsg := substrb(l_msg, 1, 240);
1238   end adjustQtyChange;
1239 
1240 end wip_bomRoutingUtil_pvt;