[Home] [Help]
PACKAGE BODY: APPS.WIP_RESOURCE_DEFAULT
Source
1 Package BODY WIP_RESOURCE_DEFAULT AS
2 /* $Header: wiprsdfb.pls 120.2.12020000.2 2012/07/18 18:15:57 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 x_state_num number := 0;
23 l_scheduled_flag number := 2;
24 l_assigned_units number := 1;
25 l_retStatus varchar2(1);
26 l_logLevel NUMBER := fnd_log.g_current_runtime_level;
27 l_params wip_logger.param_tbl_t;
28
29 BEGIN
30 if (l_logLevel <= wip_constants.trace_logging) then
31 l_params(1).paramName := 'p_group_id';
32 l_params(1).paramValue := p_group_id;
33 l_params(2).paramName := 'p_wip_entity_id';
34 l_params(2).paramValue := p_wip_entity_id;
35 l_params(3).paramName := 'p_organization_id';
36 l_params(3).paramValue := p_organization_id;
37 l_params(4).paramName := 'p_substitution_type';
38 l_params(4).paramValue := p_substitution_type;
39 l_params(5).paramName := 'p_operation_seq_num';
40 l_params(5).paramValue := p_operation_seq_num;
41 l_params(6).paramName := 'p_resource_seq_num';
42 l_params(6).paramValue := p_resource_seq_num;
43 l_params(7).paramName := 'p_resource_id_new';
44 l_params(7).paramValue := p_resource_id_new;
45 wip_logger.entryPoint(p_procName => 'WIP_RESOURCE_DEFAULT.DEFAULT_RESOURCE',
46 p_params => l_params,
47 x_returnStatus => l_retStatus);
48 end if;
49 begin
50 /* Derive resource information */
51 SELECT unit_of_measure, default_basis_type, default_activity_id,
52 autocharge_type, standard_rate_flag
53 INTO x_uom_code, x_basis_type, x_activity_id,
54 x_autocharge_type, x_standard_rate_flag
55 FROM BOM_RESOURCES
56 WHERE resource_id = p_resource_id_new;
57
58 x_state_num := x_state_num + 1;
59
60 /* Derive date_info */
61 SELECT first_unit_start_date, last_unit_completion_date
62 INTO x_start_date, x_completion_date
63 FROM WIP_OPERATIONS
64 WHERE wip_entity_id = p_wip_entity_id
65 AND organization_id = p_organization_id
66 AND operation_seq_num = p_operation_seq_num;
67
68 x_state_num := x_state_num + 1;
69
70 if (x_basis_type IS NULL) then
71 x_basis_type := 1; /* item, from form */
72 End if;
73
74 if (x_standard_rate_flag IS NULL) then
75 x_standard_rate_flag := 1; /* yes */
76 End If;
77
78 /*Bug 13829499: Add select...into to get the values of SF and AU from WOR. If the operation is being newly added
79 then no data will be found and hence the default values of (No and 1) will be defaulted*/
80 begin
81 select
82 SCHEDULED_FLAG, ASSIGNED_UNITS
83 into l_scheduled_flag, l_assigned_units
84 from WIP_OPERATION_RESOURCES
85 where WIP_ENTITY_ID = p_wip_entity_id
86 and OPERATION_SEQ_NUM = p_operation_seq_num
87 and RESOURCE_SEQ_NUM = p_resource_seq_num
88 and ORGANIZATION_ID = p_organization_id;
89 wip_logger.log('scheduled_flag: ' || l_scheduled_flag, l_retStatus);
90 wip_logger.log('assigned_units: ' || l_assigned_units, l_retStatus);
91 exception
92 when no_data_found then
93 wip_logger.log('WIP_RESOURCE_DEFAULT.DEFAULT_RESOURCE...this resouce doesnt currently exist on the job', l_retStatus);
94 end;
95
96 UPDATE WIP_JOB_DTLS_INTERFACE
97 SET scheduled_flag = nvl(scheduled_flag,l_scheduled_flag),
98 assigned_units = nvl(assigned_units,l_assigned_units),
99 applied_resource_units = decode(p_substitution_type,WIP_JOB_DETAILS.WIP_ADD,0,applied_resource_units), /*Bug 3499921*/
100 applied_resource_value = decode(p_substitution_type,WIP_JOB_DETAILS.WIP_ADD,0,applied_resource_value), /*Bug 3499921*/
101 usage_rate_or_amount = decode(usage_rate_or_amount,NULL,NULL,
102 inv_convert.inv_um_convert(0,WIP_CONSTANTS.MAX_DISPLAYED_PRECISION,usage_rate_or_amount,
103 nvl(uom_code,x_uom_code), x_uom_code,
104 null,null)), /* fix for bug#2367650 +APS*/
105 uom_code = x_uom_code,
106 basis_type = nvl(basis_type,x_basis_type),/*Fix for bug 2119945*/
107 activity_id = decode(p_substitution_type,
108 WIP_JOB_DETAILS.WIP_ADD,
109 nvl(activity_id,x_activity_id),
110 activity_id), /*Bug 2683271*/
111 autocharge_type = nvl(autocharge_type,x_autocharge_type), /*Fix for bug 6767640*/
112 standard_rate_flag = nvl(standard_rate_flag,x_standard_rate_flag), /*Fix for bug 6767640*/
113 start_date = nvl(start_date,x_start_date),
114 completion_date = nvl(completion_date,x_completion_date)
115 WHERE group_id = p_group_id
116 AND wip_entity_id = p_wip_entity_id
117 AND organization_id = p_organization_id
118 AND load_type in (WIP_JOB_DETAILS.WIP_RESOURCE,
119 WIP_JOB_DETAILS.WIP_SUB_RES)
120 AND substitution_type = p_substitution_type
121 AND operation_seq_num = p_operation_seq_num
122 AND resource_seq_num = p_resource_seq_num
123 AND resource_id_new = p_resource_id_new
124 -- jy: no need to default if doing res substitution
125 AND not ( load_type = wip_job_details.wip_resource
126 and substitution_type = wip_job_details.wip_change
127 and substitute_group_num is not null
128 and substitute_group_num is not null
129 );
130
131 x_state_num := x_state_num + 1;
132 IF(l_logLevel <= wip_constants.trace_logging) then
133 wip_logger.exitPoint(p_procName => 'WIP_RESOURCE_DEFAULT.DEFAULT_RESOURCE',
134 p_procReturnStatus => l_retStatus,
135 p_msg => 'success',
136 x_returnStatus => l_retStatus);
137 END IF;
138 exception
139 when others then
140 p_err_msg := 'WIPRSDFB(' || x_state_num || '): ' || SQLERRM;
141 p_err_code := SQLCODE;
142 IF(l_logLevel <= wip_constants.trace_logging) then
143 wip_logger.exitPoint(p_procName => 'WIP_RESOURCE_DEFAULT.DEFAULT_RESOURCE',
144 p_procReturnStatus => l_retStatus,
145 p_msg => 'exception error',
146 x_returnStatus => l_retStatus);
147 END IF;
148 end;
149
150 END DEFAULT_RESOURCE;
151
152 END WIP_RESOURCE_DEFAULT;