[Home] [Help]
PACKAGE BODY: APPS.EAM_COPY_BOM_PKG
Source
1 PACKAGE BODY EAM_COPY_BOM_PKG as
2 /* $Header: EAMCPBMB.pls 120.0.12000000.2 2007/04/09 10:10:32 rasahoo ship $ */
3
4 /*
5 Procedure to copy materials from workorder to bom
6 -- p_organization_id Organization Id
7 -- p_organization_code Organization Code
8 -- p_asset_number Asset Number
9 -- p_asset_group_id Inventory Item Id
10 -- p_component_table Table of workorder materials
11 -- x_error_code 0 success
12 1 some of components are already in the asset bom
13 2 error in the bom api
14 */
15 PROCEDURE copy_to_bom(
16 p_organization_id IN NUMBER,
17 p_organization_code IN VARCHAR2,
18 p_asset_number IN VARCHAR2,
19 p_asset_group_id IN NUMBER,
20 p_component_table IN t_component_table,
21 x_error_code OUT NOCOPY NUMBER)
22 IS
23 l_component_table EAM_WORKORDER_UTIL_PKG.t_component_table;
24 l_index NUMBER;
25 i NUMBER;
26 l_error_code NUMBER;
27 BEGIN
28
29 i:= 1;
30
31 --Copy the information from the input table to table type of EAM_WORKORDER_UTIL_PKG.t_component_table
32 l_index := p_component_table.FIRST;
33 loop
34
35 l_component_table(i).component_item := p_component_table(l_index).component_item;
36 l_component_table(i).component_item_id:= p_component_table(l_index).component_item_id;
37 l_component_table(i).start_effective_date:= SYSDATE;
38 l_component_table(i).operation_sequence_number:= p_component_table(l_index).operation_sequence_number;
39 l_component_table(i).quantity_per_assembly:= p_component_table(l_index).quantity_per_assembly;
40 l_component_table(i).wip_supply_type:= p_component_table(l_index).wip_supply_type;
41 l_component_table(i).supply_subinventory := p_component_table(l_index).supply_subinventory;
42 l_component_table(i).supply_locator_id:= p_component_table(l_index).supply_locator_id;
43 l_component_table(i).supply_locator_name:= p_component_table(l_index).supply_locator_name;
44
45 exit when l_index = p_component_table.LAST;
46 l_index := p_component_table.NEXT(l_index);
47 i := i+1;
48 end loop;
49
50
51 EAM_WORKORDER_UTIL_PKG.copy_to_bom(
52 p_organization_id,
53 p_organization_code,
54 p_asset_number,
55 p_asset_group_id,
56 l_component_table,
57 x_error_code);
58
59 END copy_to_bom;
60
61 /*
62 Procedure to copy materials from the asset bom to workorder
63 -- p_organization_id Organization Id
64 -- p_wip_entity_id Wip Entity Id
65 -- p_operation_seq_num Operation to which materials are to be copied
66 -- p_department_id Department
67 -- p_bom_table Table of bom materials
68 -- x_error_code S success
69 U error
70 E error
71 */
72 PROCEDURE retrieve_asset_bom(
73 p_organization_id IN NUMBER,
74 p_wip_entity_id IN NUMBER,
75 p_operation_seq_num IN NUMBER,
76 p_department_id IN NUMBER,
77 p_bom_table IN t_bom_table,
78 x_error_code OUT NOCOPY VARCHAR2)
79 IS
80 l_index NUMBER;
81 l_msg_count NUMBER;
82 i NUMBER;
83 l_output_dir VARCHAR2(512);
84
85 l_material_req_table EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type;
86
87 l_eam_wo_tbl EAM_PROCESS_WO_PUB.eam_wo_tbl_type;
88 l_eam_op_tbl EAM_PROCESS_WO_PUB.eam_op_tbl_type;
89 l_eam_op_network_tbl EAM_PROCESS_WO_PUB.eam_op_network_tbl_type;
90 l_eam_res_tbl EAM_PROCESS_WO_PUB.eam_res_tbl_type;
91 l_eam_res_inst_tbl EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type;
92 l_eam_sub_res_tbl EAM_PROCESS_WO_PUB.eam_sub_res_tbl_type;
93 l_eam_res_usage_tbl EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type;
94 l_eam_di_tbl EAM_PROCESS_WO_PUB.eam_direct_items_tbl_type;
95 l_eam_wo_comp_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_tbl_type;
96 l_eam_wo_quality_tbl EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type;
97 l_eam_meter_reading_tbl EAM_PROCESS_WO_PUB.eam_meter_reading_tbl_type;
98 l_eam_wo_comp_rebuild_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_rebuild_tbl_type;
99 l_eam_wo_comp_mr_read_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_mr_read_tbl_type;
100 l_eam_op_comp_tbl EAM_PROCESS_WO_PUB.eam_op_comp_tbl_type;
101 l_eam_request_tbl EAM_PROCESS_WO_PUB.eam_request_tbl_type;
102 l_eam_counter_prop_tbl EAM_PROCESS_WO_PUB.eam_counter_prop_tbl_type;
103
104
105 l_out_eam_wo_tbl EAM_PROCESS_WO_PUB.eam_wo_tbl_type;
106 l_out_eam_op_tbl EAM_PROCESS_WO_PUB.eam_op_tbl_type;
107 l_out_eam_op_network_tbl EAM_PROCESS_WO_PUB.eam_op_network_tbl_type;
108 l_out_eam_res_tbl EAM_PROCESS_WO_PUB.eam_res_tbl_type;
109 l_out_eam_res_inst_tbl EAM_PROCESS_WO_PUB.eam_res_inst_tbl_type;
110 l_out_eam_sub_res_tbl EAM_PROCESS_WO_PUB.eam_sub_res_tbl_type;
111 l_out_eam_res_usage_tbl EAM_PROCESS_WO_PUB.eam_res_usage_tbl_type;
112 l_out_eam_mat_req_tbl EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type;
113 l_out_eam_di_tbl EAM_PROCESS_WO_PUB.eam_direct_items_tbl_type;
114 l_eam_wo_relations_tbl EAM_PROCESS_WO_PUB.eam_wo_relations_tbl_type;
115 l_eam_wo_relations_tbl1 EAM_PROCESS_WO_PUB.eam_wo_relations_tbl_type;
116 l_out_eam_wo_comp_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_tbl_type;
117 l_out_eam_wo_quality_tbl EAM_PROCESS_WO_PUB.eam_wo_quality_tbl_type;
118 l_out_eam_meter_reading_tbl EAM_PROCESS_WO_PUB.eam_meter_reading_tbl_type;
119 l_out_eam_wo_comp_rebuild_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_rebuild_tbl_type;
120 l_out_eam_wo_comp_mr_read_tbl EAM_PROCESS_WO_PUB.eam_wo_comp_mr_read_tbl_type;
121 l_out_eam_op_comp_tbl EAM_PROCESS_WO_PUB.eam_op_comp_tbl_type;
122 l_out_eam_request_tbl EAM_PROCESS_WO_PUB.eam_request_tbl_type;
123 l_out_eam_counter_prop_tbl EAM_PROCESS_WO_PUB.eam_counter_prop_tbl_type;
124
125 BEGIN
126 /* get output directory path from database */
127 EAM_WORKORDER_UTIL_PKG.log_path(l_output_dir);
128
129
130 i := 1;
131
132 --Copy the information from the input table to table type of EAM_PROCESS_WO_PUB.eam_mat_req_tbl_type
133 l_index := p_bom_table.FIRST;
134 loop
135
136 l_material_req_table(i).batch_id := 1;
137 l_material_req_table(i).header_id :=p_wip_entity_id;
138 l_material_req_table(i).transaction_type := EAM_PROCESS_WO_PUB.G_OPR_CREATE;
139 l_material_req_table(i).wip_entity_id := p_wip_entity_id;
140 l_material_req_table(i).organization_id := p_organization_id;
141 l_material_req_table(i).operation_seq_num := p_operation_seq_num;
142 l_material_req_table(i).inventory_item_id :=p_bom_table(l_index).component_item_id;
143 l_material_req_table(i).quantity_per_assembly := p_bom_table(l_index).component_quantity;
144 l_material_req_table(i).department_id :=p_department_id;
145 l_material_req_table(i).wip_supply_type := p_bom_table(l_index).wip_supply_type;
146
147 /* Added for bug#5679199 Start */
148 BEGIN
149 SELECT first_unit_start_date
150 INTO l_material_req_table(i).date_required
151 FROM wip_operations
152 WHERE wip_entity_id = p_wip_entity_id
153 AND operation_seq_num = p_operation_seq_num
154 AND organization_id = p_organization_id;
155 EXCEPTION
156 WHEN NO_DATA_FOUND THEN
157 l_material_req_table(i).date_required :=SYSDATE;
158 END;
159
160 /* Added for bug#5679199 End */
161
162 l_material_req_table(i).required_quantity := p_bom_table(l_index).component_quantity;
163
164
165 exit when l_index = p_bom_table.LAST;
166 l_index := p_bom_table.NEXT(l_index);
167 i := i+1;
168 end loop;
169
170
171 EAM_PROCESS_WO_PUB.Process_Master_Child_WO
172 ( p_bo_identifier => 'EAM'
173 , p_init_msg_list => TRUE
174 , p_api_version_number => 1.0
175 , p_eam_wo_tbl => l_eam_wo_tbl
176 , p_eam_wo_relations_tbl => l_eam_wo_relations_tbl
177 , p_eam_op_tbl => l_eam_op_tbl
178 , p_eam_op_network_tbl => l_eam_op_network_tbl
179 , p_eam_res_tbl => l_eam_res_tbl
180 , p_eam_res_inst_tbl => l_eam_res_inst_tbl
181 , p_eam_sub_res_tbl => l_eam_sub_res_tbl
182 , p_eam_mat_req_tbl => l_material_req_table
183 , p_eam_direct_items_tbl => l_eam_di_tbl
184 , p_eam_res_usage_tbl => l_eam_res_usage_tbl
185 , p_eam_wo_comp_tbl => l_eam_wo_comp_tbl
186 , p_eam_wo_quality_tbl => l_eam_wo_quality_tbl
187 , p_eam_meter_reading_tbl => l_eam_meter_reading_tbl
188 , p_eam_counter_prop_tbl => l_eam_counter_prop_tbl
189 , p_eam_wo_comp_rebuild_tbl => l_eam_wo_comp_rebuild_tbl
190 , p_eam_wo_comp_mr_read_tbl => l_eam_wo_comp_mr_read_tbl
191 , p_eam_op_comp_tbl => l_eam_op_comp_tbl
192 , p_eam_request_tbl => l_eam_request_tbl
193 , x_eam_wo_tbl => l_out_eam_wo_tbl
194 , x_eam_wo_relations_tbl => l_eam_wo_relations_tbl1
195 , x_eam_op_tbl => l_out_eam_op_tbl
196 , x_eam_op_network_tbl => l_out_eam_op_network_tbl
197 , x_eam_res_tbl => l_out_eam_res_tbl
198 , x_eam_res_inst_tbl => l_out_eam_res_inst_tbl
199 , x_eam_sub_res_tbl => l_out_eam_sub_res_tbl
200 , x_eam_mat_req_tbl => l_out_eam_mat_req_tbl
201 , x_eam_direct_items_tbl => l_out_eam_di_tbl
202 , x_eam_res_usage_tbl => l_out_eam_res_usage_tbl
203 , x_eam_wo_comp_tbl => l_out_eam_wo_comp_tbl
204 , x_eam_wo_quality_tbl => l_out_eam_wo_quality_tbl
205 , x_eam_meter_reading_tbl => l_out_eam_meter_reading_tbl
206 , x_eam_counter_prop_tbl => l_out_eam_counter_prop_tbl
207 , x_eam_wo_comp_rebuild_tbl => l_out_eam_wo_comp_rebuild_tbl
208 , x_eam_wo_comp_mr_read_tbl => l_out_eam_wo_comp_mr_read_tbl
209 , x_eam_op_comp_tbl => l_out_eam_op_comp_tbl
210 , x_eam_request_tbl => l_out_eam_request_tbl
211 , x_return_status => x_error_code
212 , x_msg_count => l_msg_count
213 , p_debug => NVL(fnd_profile.value('EAM_DEBUG'), 'N')
214 , p_debug_filename => 'copytoreq.log'
215 , p_output_dir => l_output_dir
216 , p_commit => 'N'
217 , p_debug_file_mode => 'W'
218 );
219 IF(x_error_code='S') THEN
220 COMMIT;
221 END IF;
222
223 END retrieve_asset_bom;
224
225
226 END EAM_COPY_BOM_PKG;