[Home] [Help]
PACKAGE BODY: APPS.WIP_RESOURCE_DEFAULT
Source
1 Package BODY WIP_RESOURCE_DEFAULT AS
2 /* $Header: wiprsdfb.pls 120.1.12010000.2 2008/09/19 00:28:11 ankohli ship $ */
3
4 Procedure DEFAULT_RESOURCE(
5 p_group_id number,
6 p_wip_entity_id number,
7 p_organization_id number,
8 p_substitution_type number,
9 p_operation_seq_num number,
10 p_resource_seq_num number,
11 p_resource_id_new number,
12 p_err_code out nocopy varchar2,
13 p_err_msg out nocopy varchar2) IS
14
15 x_uom_code varchar2(3);
16 x_basis_type number;
17 x_activity_id number;
18 x_autocharge_type number;
19 x_standard_rate_flag number;
20 x_start_date date;
21 x_completion_date date;
22
23 x_state_num number := 0;
24
25 BEGIN
26
27 begin
28 /* Derive resource information */
29 SELECT unit_of_measure, default_basis_type, default_activity_id,
30 autocharge_type, standard_rate_flag
31 INTO x_uom_code, x_basis_type, x_activity_id,
32 x_autocharge_type, x_standard_rate_flag
33 FROM BOM_RESOURCES
34 WHERE resource_id = p_resource_id_new;
35
36 x_state_num := x_state_num + 1;
37
38 /* Derive date_info */
39 SELECT first_unit_start_date, last_unit_completion_date
40 INTO x_start_date, x_completion_date
41 FROM WIP_OPERATIONS
42 WHERE wip_entity_id = p_wip_entity_id
43 AND organization_id = p_organization_id
44 AND operation_seq_num = p_operation_seq_num;
45
46 x_state_num := x_state_num + 1;
47
48 if (x_basis_type IS NULL) then
49 x_basis_type := 1; /* item, from form */
50 End if;
51
52 if (x_standard_rate_flag IS NULL) then
53 x_standard_rate_flag := 1; /* yes */
54 End If;
55
56
57 UPDATE WIP_JOB_DTLS_INTERFACE
58 SET scheduled_flag = nvl(scheduled_flag,2),
59 assigned_units = nvl(assigned_units,1),
60 applied_resource_units = decode(p_substitution_type,WIP_JOB_DETAILS.WIP_ADD,0,applied_resource_units), /*Bug 3499921*/
61 applied_resource_value = decode(p_substitution_type,WIP_JOB_DETAILS.WIP_ADD,0,applied_resource_value), /*Bug 3499921*/
62 usage_rate_or_amount = decode(usage_rate_or_amount,NULL,NULL,
63 inv_convert.inv_um_convert(0,WIP_CONSTANTS.MAX_DISPLAYED_PRECISION,usage_rate_or_amount,
64 nvl(uom_code,x_uom_code), x_uom_code,
65 null,null)), /* fix for bug#2367650 +APS*/
66 uom_code = x_uom_code,
67 basis_type = nvl(basis_type,x_basis_type),/*Fix for bug 2119945*/
68 activity_id = decode(p_substitution_type,
69 WIP_JOB_DETAILS.WIP_ADD,
70 nvl(activity_id,x_activity_id),
71 activity_id), /*Bug 2683271*/
72 autocharge_type = nvl(autocharge_type,x_autocharge_type), /*Fix for bug 6767640*/
73 standard_rate_flag = nvl(standard_rate_flag,x_standard_rate_flag), /*Fix for bug 6767640*/
74 start_date = nvl(start_date,x_start_date),
75 completion_date = nvl(completion_date,x_completion_date)
76 WHERE group_id = p_group_id
77 AND wip_entity_id = p_wip_entity_id
78 AND organization_id = p_organization_id
79 AND load_type in (WIP_JOB_DETAILS.WIP_RESOURCE,
80 WIP_JOB_DETAILS.WIP_SUB_RES)
81 AND substitution_type = p_substitution_type
82 AND operation_seq_num = p_operation_seq_num
83 AND resource_seq_num = p_resource_seq_num
84 AND resource_id_new = p_resource_id_new
85 -- jy: no need to default if doing res substitution
86 AND not ( load_type = wip_job_details.wip_resource
87 and substitution_type = wip_job_details.wip_change
88 and substitute_group_num is not null
89 and substitute_group_num is not null
90 );
91
92 x_state_num := x_state_num + 1;
93
94 exception
95 when others then
96 p_err_msg := 'WIPRSDFB(' || x_state_num || '): ' || SQLERRM;
97 p_err_code := SQLCODE;
98 end;
99
100 END DEFAULT_RESOURCE;
101
102 END WIP_RESOURCE_DEFAULT;