73: v_oprn_class gmd_operations.oprn_class%TYPE;
74: l_retn_status VARCHAR2(1);
75: my_rsrc_table_type gmd_operation_resources_pub.gmd_oprn_resources_tbl_type;
76: l_api_version NUMBER := 1.0;
77: l_entity_status gmd_api_grp.status_rec_type; ---bug# 3408799
78: default_status_err EXCEPTION;
79: l_resource_count NUMBER;
80:
81: invalid_version EXCEPTION;
102: fnd_msg_pub.initialize;
103: END IF;
104:
105: /* Intializes the setup fields */
106: IF NOT gmd_api_grp.setup_done THEN
107: gmd_api_grp.setup_done := gmd_api_grp.setup;
108: END IF;
109: IF NOT gmd_api_grp.setup_done THEN
110: RAISE setup_failure;
103: END IF;
104:
105: /* Intializes the setup fields */
106: IF NOT gmd_api_grp.setup_done THEN
107: gmd_api_grp.setup_done := gmd_api_grp.setup;
108: END IF;
109: IF NOT gmd_api_grp.setup_done THEN
110: RAISE setup_failure;
111: END IF;
105: /* Intializes the setup fields */
106: IF NOT gmd_api_grp.setup_done THEN
107: gmd_api_grp.setup_done := gmd_api_grp.setup;
108: END IF;
109: IF NOT gmd_api_grp.setup_done THEN
110: RAISE setup_failure;
111: END IF;
112:
113: /* Initially let us assign the return status to success */
135: FND_MESSAGE.SET_TOKEN ('MISSING', 'OPRN_VERS');
136: FND_MSG_PUB.ADD;
137: RAISE ins_operation_err;
138: ELSIF p_operations.oprn_vers < 0 THEN
139: gmd_api_grp.log_message ('GMD_NEGATIVE_FIELDS',
140: 'FIELD', 'OPRN_VERS');
141: RAISE ins_operation_err;
142: END IF;
143:
146: v_oprn_vers := p_operations.oprn_vers;
147: /* call common function which checks for duplicate operation no and vers */
148: P_ret := gmdopval_pub.check_duplicate_oprn(v_oprn_no, v_oprn_vers, 'F');
149: IF p_ret <> 0 THEN
150: gmd_api_grp.log_message('FM_OPER_CODE_EXISTS');
151: RAISE ins_operation_err;
152: END IF;
153:
154: /* Description must be passed, otherwise give error */
173: FND_MESSAGE.SET_TOKEN ('MISSING', 'PROCESS_QTY_UOM');
174: FND_MSG_PUB.ADD;
175: RAISE ins_operation_err;
176: /* call common function to check if um passed is valid */
177: ELSIF (NOT(gmd_api_grp.validate_um(p_operations.PROCESS_QTY_UOM))) THEN
178: IF (l_debug = 'Y') THEN
179: gmd_debug.put_line('process qty uom invalid');
180: END IF;
181:
195: RAISE FND_API.G_EXC_ERROR;
196: END IF;
197:
198: -- Check if organization is accessible to the responsibility
199: IF NOT (GMD_API_GRP.OrgnAccessible (powner_orgn_id => p_operations.owner_organization_id) ) THEN
200: RAISE ins_operation_err;
201: END IF;
202:
203: --Check the organization id passed is process enabled if not raise an error message
200: RAISE ins_operation_err;
201: END IF;
202:
203: --Check the organization id passed is process enabled if not raise an error message
204: IF NOT (gmd_api_grp.check_orgn_status(p_operations.owner_organization_id)) THEN
205: FND_MESSAGE.SET_NAME('GMD', 'GMD_INVALID_ORGANIZATION_ID');
206: FND_MESSAGE.SET_TOKEN('ORGN_ID', p_operations.owner_organization_id);
207: FND_MSG_PUB.Add;
208: RAISE FND_API.G_EXC_ERROR;
228: END IF;
229: END IF;
230:
231: IF p_operations.minimum_transfer_qty < 0 THEN
232: gmd_api_grp.log_message ('GMD_NEGATIVE_FIELDS',
233: 'FIELD', 'MINIMUM_TRANSFER_QTY');
234: RAISE ins_operation_err;
235: END IF;
236:
239: /* calls common funciton which checks if class is valid */
240: v_oprn_class := p_operations.oprn_class;
241: P_ret := gmdopval_pub.check_oprn_class(v_oprn_class, 'F');
242: IF P_ret <> 0 THEN
243: gmd_api_grp.log_message('FM_INV_OPRN_CLASS');
244: END IF;
245: END IF;
246:
247: OPEN Cur_gen_oprn_id;
249: CLOSE cur_gen_oprn_id;
250:
251: /* At least one activity must be passed to add operation */
252: IF (p_oprn_actv_tbl.count = 0) THEN
253: gmd_api_grp.log_message ('GMD_DETAILS_REQUIRED');
254: RAISE ins_operation_err;
255: END IF;
256:
257: IF x_return_status = 'S' THEN
272: /* validate oprn activity info and insert oprn activity */
273: FOR i in 1.. p_oprn_actv_tbl.count LOOP
274: p_oprn_actv_tbl(i).oprn_id := p_operations.oprn_id;
275: --Getting the default status for the owner orgn code fo operation from parameters table w.r.t. bug#3408799
276: gmd_api_grp.get_status_details(v_entity_type => 'OPERATION'
277: ,v_orgn_id => p_operations.owner_organization_id -- w.r.t. 4004501
278: ,x_entity_status => l_entity_status);
279:
280: --Copy the all related resources for the context activity w.r.t. bug#3408799
289: END LOOP; --j in 1 ..p_oprn_rsrc_tbl.count
290:
291: --Raise error if default status is 400/700 and no activites are attached w.r.t. bug#3408799
292: IF l_entity_status.status_type IN (400,700) AND l_resource_count = 0 THEN
293: gmd_api_grp.log_message('GMD_RESOURCE_NOT_ATTACH');
294: RAISE ins_operation_err;
295: END IF; --l_entity_status.status_type IN (400,700) AND l_resource_count = 0
296:
297: GMD_OPERATION_ACTIVITIES_PUB.insert_operation_activity(p_init_msg_list => FALSE,
312: SAVEPOINT default_status_sp;
313:
314: /* -- Why call this again
315: --Getting the default status for the owner orgn code fo operation from parameters table w.r.t. bug#3408799
316: gmd_api_grp.get_status_details(v_entity_type => 'OPERATION'
317: ,v_orgn_code => p_operations.owner_orgn_code
318: ,x_entity_status => l_entity_status);
319:
320: */
436: RAISE invalid_version;
437: END IF;
438:
439: /* Intializes the setup fields */
440: IF NOT gmd_api_grp.setup_done THEN
441: gmd_api_grp.setup_done := gmd_api_grp.setup;
442: END IF;
443: IF NOT gmd_api_grp.setup_done THEN
444: RAISE setup_failure;
437: END IF;
438:
439: /* Intializes the setup fields */
440: IF NOT gmd_api_grp.setup_done THEN
441: gmd_api_grp.setup_done := gmd_api_grp.setup;
442: END IF;
443: IF NOT gmd_api_grp.setup_done THEN
444: RAISE setup_failure;
445: END IF;
439: /* Intializes the setup fields */
440: IF NOT gmd_api_grp.setup_done THEN
441: gmd_api_grp.setup_done := gmd_api_grp.setup;
442: END IF;
443: IF NOT gmd_api_grp.setup_done THEN
444: RAISE setup_failure;
445: END IF;
446:
447: /* Initially let us assign the return status to success */
470: ELSIF p_oprn_id IS NOT NULL THEN
471: OPEN check_oprn_id(p_oprn_id);
472: FETCH check_oprn_id INTO v_oprn_id;
473: IF check_oprn_id%NOTFOUND THEN
474: gmd_api_grp.log_message ('FM_INVOPRN');
475: RAISE upd_oprn_err;
476: END IF;
477: CLOSE check_oprn_id;
478: ELSIF ((p_oprn_no IS NOT NULL) AND (p_oprn_vers IS NOT NULL)) THEN
478: ELSIF ((p_oprn_no IS NOT NULL) AND (p_oprn_vers IS NOT NULL)) THEN
479: OPEN get_oprn_id(p_oprn_no, p_oprn_vers);
480: FETCH get_oprn_id INTO v_oprn_id;
481: IF get_oprn_id%NOTFOUND THEN
482: gmd_api_grp.log_message ('FM_INVOPRN');
483: RAISE upd_oprn_err;
484: END IF;
485: CLOSE get_oprn_id;
486: END IF;
489: -- Added the check for Org Responsibility access.
490: OPEN get_orgn_id(p_oprn_id);
491: FETCH get_orgn_id INTO l_orgn_id;
492: CLOSE get_orgn_id;
493: IF NOT (GMD_API_GRP.OrgnAccessible (powner_orgn_id => l_orgn_id ) ) THEN
494: RAISE upd_oprn_err;
495: END IF;
496:
497: /* Loop thru cols to be updated - verify col and value are present */
506: FND_MESSAGE.SET_TOKEN ('MISSING', 'COL_TO_UPDATE');
507: FND_MSG_PUB.ADD;
508: RAISE upd_oprn_err;
509: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'PROCESS_QTY_UOM' THEN
510: IF (NOT(gmd_api_grp.validate_um(p_update_table(i).p_value))) THEN
511: IF (l_debug = 'Y') THEN
512: gmd_debug.put_line('process qty uom invalid');
513: END IF;
514: FND_MESSAGE.SET_NAME('GMA', 'SY_INVALID_UM_CODE');
516: RAISE upd_oprn_err;
517: END IF;
518: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'MINIMUM_TRANSFER_QTY' THEN
519: IF p_update_table(i).p_value < 0 THEN
520: gmd_api_grp.log_message ('GMD_NEGATIVE_FIELDS',
521: 'FIELD', 'MINIMUM_TRANSFER_QTY');
522: RAISE upd_oprn_err;
523: END IF;
524: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'OPRN_CLASS' THEN
522: RAISE upd_oprn_err;
523: END IF;
524: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'OPRN_CLASS' THEN
525: IF gmdopval_pub.check_oprn_class(p_update_table(i).p_value, 'F') <> 0 THEN
526: gmd_api_grp.log_message('FM_INV_OPRN_CLASS');
527: RAISE upd_oprn_err;
528: END IF;
529: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'OPRN_DESC' THEN
530: IF p_update_table(i).p_value IS NULL THEN
543: END IF;
544: ELSIF UPPER(p_update_table(i).p_col_to_update) = 'OWNER_ORGANIZATION_ID' THEN
545: /* Validation : Check if owner_orgn_idis valid */
546: l_owner_orgn_id := p_update_table(i).p_value;
547: IF NOT GMD_API_GRP.OrgnAccessible(l_owner_orgn_id) THEN
548: RAISE upd_oprn_err;
549: END IF;
550: END IF;
551:
580: COMMIT;
581: END IF;
582:
583: /* Adding message to stack indicating the success of the routine */
584: gmd_api_grp.log_message ('GMD_SAVED_CHANGES');
585: END IF;
586:
587: FND_MSG_PUB.count_and_get(p_count => x_message_count
588: ,p_data => x_message_list);
670: COMMIT;
671: END IF;
672:
673: /* Adding message to stack indicating the success of the routine */
674: gmd_api_grp.log_message ('GMD_SAVED_CHANGES');
675: FND_MSG_PUB.count_and_get(p_count => x_message_count
676: ,p_data => x_message_list);
677:
678: IF (l_debug = 'Y') THEN