23:
24: /* First check if there are any rows to process */
25:
26: Select count(*) into l_cdoi_count
27: from CST_DEPT_OVERHEADS_INTERFACE cdoi
28: WHERE cdoi.group_id = SEQ_NEXTVAL
29: AND cdoi.error_flag is null
30: AND cdoi.process_flag = 1
31: AND rownum = 1;
30: AND cdoi.process_flag = 1
31: AND rownum = 1;
32:
33: If l_cdoi_count = 0 then
34: fnd_file.put_line(fnd_file.log,'no rows to process in CST_DEPT_OVERHEADS_INTERFACE, quiting....');
35: return;
36: end If;
37:
38: fnd_file.put_line(fnd_file.log,'---------at the start of validating CST_DEPT_OVERHEADS_INTERFACE-------------');
34: fnd_file.put_line(fnd_file.log,'no rows to process in CST_DEPT_OVERHEADS_INTERFACE, quiting....');
35: return;
36: end If;
37:
38: fnd_file.put_line(fnd_file.log,'---------at the start of validating CST_DEPT_OVERHEADS_INTERFACE-------------');
39:
40: /* check for both the organization_id and code to be null */
41: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
42: SET error_flag = 'E',
37:
38: fnd_file.put_line(fnd_file.log,'---------at the start of validating CST_DEPT_OVERHEADS_INTERFACE-------------');
39:
40: /* check for both the organization_id and code to be null */
41: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
42: SET error_flag = 'E',
43: error_code = 'CST_NULL_ORGANIZATION',
44: error_explanation = substrb(fnd_message.get_string('BOM','CST_NULL_ORGANIZATION'),1,240)
45: where (Organization_id is null AND organization_code is null)
50: fnd_file.put_line(fnd_file.log,'done checking for null org id and code');
51:
52: /* check to see if the input organization_id or code is valid */
53:
54: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
55: SET error_flag = 'E',
56: error_code = 'CST_INVALID_ORGANIZATION',
57: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_ORGANIZATION'),1,240)
58: WHERE cdoi.error_flag is null
65: fnd_file.put_line(fnd_file.log,'done checking for invalid org id and code ');
66:
67: /*Get the Organization_id from the code */
68:
69: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
70: SET organization_id = (select organization_id
71: FROM mtl_parameters mp
72: WHERE mp.organization_code = cdoi.organization_code
73: AND cdoi.error_flag is null
81: **/
82:
83: l_stmt_no := 30;
84:
85: Update CST_DEPT_OVERHEADS_INTERFACE ct
86: SET error_flag = 'E',
87: error_code = 'CST_PROCESS_ORG_ERROR',
88: error_explanation =
89: substrb(fnd_message.get_string(
102: fnd_file.put_line(fnd_file.log,'done getting the org_id from the code if it is not provided');
103:
104: /* Set the unique transaction_id for each row */
105:
106: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
107: SET transaction_id = CST_ITEM_CST_DTLS_INTERFACE_S.NEXTVAL,
108: request_id = FND_GLOBAL.CONC_REQUEST_ID,
109: error_code = null,
110: error_explanation = null,
122: fnd_file.put_line(fnd_file.log,'done setting the transaction_id');
123:
124: /* Now check for the organization to be a costing org */
125:
126: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
127: set cdoi.error_flag = 'E',
128: cdoi.error_code = 'CST_NOT_COSTINGORG',
129: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_NOT_COSTINGORG'),1,240)
130: WHERE cdoi.group_id = SEQ_NEXTVAL
137: fnd_file.put_line(fnd_file.log,'done checking for the org to be a costing org');
138:
139:
140:
141: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
142: SET cdoi.cost_type_id = (select cost_type_id from CST_COST_TYPES cct
143: where cct.cost_type = i_new_csttype
144: ),
145: cdoi.cost_type = i_new_csttype
150: fnd_file.put_line(fnd_file.log,'done setting the cost type ');
151:
152: /* check for both department and department_id to be null */
153:
154: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
155: SET cdoi.error_flag = 'E',
156: cdoi.error_code = 'CST_NULL_DEPARTMENT',
157: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_NULL_DEPARTMENT'),1,240)
158: WHERE cdoi.error_flag is null
163: fnd_file.put_line(fnd_file.log,'done checking for null department ID and code');
164:
165: /* check for overhead_id and overhead to be null */
166:
167: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
168: SET cdoi.error_flag = 'E',
169: cdoi.error_code = 'CST_NULL_OVERHEAD',
170: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_NULL_OVERHEAD'),1,240)
171: WHERE cdoi.error_flag is null
178: l_stmt_no := 110;
179:
180: /* check for the entered department_id and department to be valid */
181:
182: Update CST_DEPT_OVERHEADS_INTERFACE cdoi set
183: error_flag = 'E',
184: error_code = 'CST_INVALID_DEPTS',
185: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_DEPTS'),1,240)
186: WHERE cdoi.error_flag is null
195: fnd_file.put_line(fnd_file.log,'done checking for invalid department Id and code ');
196:
197: /* Get the department_id from the department_code */
198:
199: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
200: set cdoi.department_id = (select bd.department_id from bom_departments bd
201: WHERE cdoi.department_code = bd.department_code
202: AND bd.organization_id = cdoi.organization_id
203: )
208: l_stmt_no := 130;
209: fnd_file.put_line(fnd_file.log,'done setting the department ID from the department code if it has not been provided');
210:
211: /* check if the entered overhead_id or code is actually valid */
212: Update CST_DEPT_OVERHEADS_INTERFACE cdoi set
213: error_flag = 'E',
214: error_code = 'CST_INVALID_OVERHEAD',
215: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_OVERHEAD'),1,240)
216: WHERE cdoi.error_flag is null
224:
225: l_stmt_no := 140;
226: fnd_file.put_line(fnd_file.log,'done checking for invalid overhead ID and overhead');
227:
228: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
229: set cdoi.overhead_id = (select bm.resource_id from bom_resources bm
230: WHERE cdoi.overhead = bm.resource_code
231: AND bm.organization_id = cdoi.organization_id
232: AND (bm.cost_element_id = 5)
239: fnd_file.put_line(fnd_file.log,'done setting the overhead ID from the code if it has not been provided');
240:
241: /* check for the overhead_id to be within the validity date */
242:
243: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
244: set cdoi.error_flag = 'E',
245: cdoi.error_code = 'CST_EXP_SUBELEMENT',
246: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_EXP_SUBELEMENT'),1,240)
247: WHERE cdoi.error_flag is null
257: l_stmt_no := 155;
258:
259: /* check for the basis type to be between 1 and 6 */
260:
261: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
262: set error_flag = 'E',
263: error_code = 'CST_INVALID_BASISTYPE',
264: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_BASISTYPE'),1,240)
265: where error_flag is null
268:
269: l_stmt_no := 160;
270: fnd_file.put_line(fnd_file.log,'done checking for the basis type flag to be valid');
271:
272: Update CST_DEPT_OVERHEADS_INTERFACE cdoi set
273: error_flag = 'E',
274: error_code = 'CST_INVALID_RESRATE',
275: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_RESRATE'),1,240)
276: where error_flag is null
281: fnd_file.put_line(fnd_file.log,'done checking for null resource rates');
282:
283: /* checking for the validity of activity id and name if provided */
284:
285: Update CST_DEPT_OVERHEADS_INTERFACE cdoi set
286: error_flag = 'E',
287: error_code = 'CST_INVALID_ACTIVITY',
288: error_explanation = substrb(fnd_message.get_string('BOM','CST_INVALID_ACTIVITY'),1,240)
289: where group_id = SEQ_NEXTVAL
295: AND cdoi.organization_id = NVL(ca.organization_id,cdoi.organization_id)
296: AND NVL(ca.disable_date,sysdate + 1) > sysdate
297: );
298:
299: Update CST_DEPT_OVERHEADS_INTERFACE cdoi set
300: cdoi.activity_id = (select ca.activity_id from cst_activities ca
301: where ca.activity = cdoi.activity
302: AND NVL(ca.organization_id,cdoi.organization_id) = cdoi.organization_id
303: )
309: fnd_file.put_line(fnd_file.log,'done checking for validity of activity id');
310: l_stmt_no := 180;
311:
312:
313: Update CST_DEPT_OVERHEADS_INTERFACE
314: set process_flag = 3
315: where process_flag = 2
316: and error_flag is null
317: and group_id = SEQ_NEXTVAL;
319: COMMIT;
320:
321: /* Now check for the duplicate rows for the same dep/cost type/overhead combo */
322:
323: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
324: set cdoi.error_flag = 'E',
325: cdoi.error_code = 'CST_DUPL_ROWS',
326: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_DUPL_ROWS'),1,240)
327: where cdoi.error_flag is null
325: cdoi.error_code = 'CST_DUPL_ROWS',
326: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_DUPL_ROWS'),1,240)
327: where cdoi.error_flag is null
328: AND cdoi.group_id = SEQ_NEXTVAL
329: AND EXISTS( Select 1 from CST_DEPT_OVERHEADS_INTERFACE cdoi2
330: where cdoi2.organization_id = cdoi.organization_id
331: AND cdoi2.department_id = cdoi.department_id
332: AND cdoi2.cost_type_id = cdoi.cost_type_id
333: AND cdoi2.overhead_id = cdoi.overhead_id
335: AND cdoi2.rowid <> cdoi.rowid);
336:
337: fnd_file.put_line(fnd_file.log,'done checking for duplicate rows');
338:
339: Update CST_DEPT_OVERHEADS_INTERFACE
340: set process_flag = 4
341: where process_flag = 3
342: and error_flag is null
343: and group_id = SEQ_NEXTVAL;
352: /* first check for the run option and error out the rows or delete from the base tables */
353:
354: If i_run_option = 2 then
355: delete from CST_DEPARTMENT_OVERHEADS cdo
356: where exists (select 1 from CST_DEPT_OVERHEADS_INTERFACE cdoi
357: where cdoi.department_id = cdo.department_id
358: AND cdoi.cost_type_id = cdo.cost_type_id
359: AND cdoi.overhead_id = cdo.overhead_id
360: AND cdoi.organization_id = cdo.organization_id
362: AND cdoi.group_id = SEQ_NEXTVAL
363: );
364:
365: elsif i_run_option = 1 then
366: Update CST_DEPT_OVERHEADS_INTERFACE cdoi
367: set cdoi.error_flag = 'E',
368: cdoi.error_code = 'CST_CANT_INSERT',
369: cdoi.error_explanation = substrb(fnd_message.get_string('BOM','CST_CANT_INSERT'),1,240)
370: where cdoi.error_flag is null
444: FND_GLOBAL.CONC_REQUEST_ID,
445: FND_GLOBAL.PROG_APPL_ID,
446: FND_GLOBAL.CONC_PROGRAM_ID,
447: sysdate
448: FROM CST_DEPT_OVERHEADS_INTERFACE cdoi
449: WHERE cdoi.error_flag is null
450: AND cdoi.group_id = SEQ_NEXTVAL;
451: fnd_file.put_line(fnd_file.log,'done inserting ' || to_char(SQL%ROWCOUNT) || ' rows into the base table CST_DEPARTMENT_OVERHEADS');
452:
451: fnd_file.put_line(fnd_file.log,'done inserting ' || to_char(SQL%ROWCOUNT) || ' rows into the base table CST_DEPARTMENT_OVERHEADS');
452:
453: l_stmt_no := 200;
454:
455: Update CST_DEPT_OVERHEADS_INTERFACE set
456: process_flag = 5
457: where process_flag = 4
458: AND error_flag is null
459: AND group_id = SEQ_NEXTVAL;
458: AND error_flag is null
459: AND group_id = SEQ_NEXTVAL;
460:
461: IF i_del_option = 1 then
462: delete from CST_DEPT_OVERHEADS_INTERFACE
463: WHERE error_flag is null
464: AND group_id = SEQ_NEXTVAL
465: AND process_flag = 5;
466:
907: BEGIN
908:
909: Error_number := 0;
910: IF i_Next_value is null then
911: UPDATE CST_DEPT_OVERHEADS_INTERFACE cdoi
912: SET group_id = i_grp_id
913: where process_flag = 1
914: AND error_flag is null;
915:
931: IF Err = 1 then
932: raise CST_ERR_EXCEPTION;
933: END IF;
934:
935: Select count(*) into i_count from CST_DEPT_OVERHEADS_INTERFACE
936: where group_id = i_grp_id
937: and error_flag = 'E';
938:
939: if i_count > 0 then