Monday, May 9, 2016
Status of Closed on a task populate an end date automatically
CURSOR c_task_details IS
SELECT jt.task_id,
jt.task_number,
jt.object_version_number,
jt.task_status_id,
jt.owner_id,
jt.customer_id,
jt.last_update_date
FROM jtf_tasks_b jt,
jtf_task_statuses_tl ts
WHERE jt.task_status_id = ts.task_status_id
AND ts.name = 'Closed'
AND jt.scheduled_end_date IS NULL
AND TRUNC(jt.last_update_date) = TRUNC(SYSDATE);
--
BEGIN
--For Each Task
FOR rec_task_details IN c_task_details
LOOP
x_total_count := x_total_count + 1;
x_api_call_status := 'S';
x_error_message := NULL;
x_temp_str := NULL;
--
fnd_msg_pub.Delete_Msg;
--
--Call API to Update Schedule End Date to Sysdate for Today's Closed Task
BEGIN
jtf_tasks_pub.update_task(p_api_version => 1.0,
p_object_version_number => rec_task_details.object_version_number,
p_task_id => rec_task_details.task_id,
p_task_number => rec_task_details.task_number,
p_task_status_id => rec_task_details.task_status_id,
p_owner_id => rec_task_details.owner_id,
p_customer_id => rec_task_details.customer_id,
p_scheduled_end_date => rec_task_details.last_update_date, --Updatable
x_return_status => x_o_return_status,
x_msg_count => x_o_msg_count,
x_msg_data => x_o_msg_data
);
EXCEPTION
WHEN others THEN
x_api_call_status := 'F';
x_failure_count := x_failure_count + 1;
x_error_message := '(Task Number = '||rec_task_details.task_number||')Unknown Error while getting Task Details : '||SUBSTR(SQLERRM,1,100);
fnd_file.put_line(fnd_file.log, x_error_message);
xxcnc_utilities_pkg.xxcnc_insert_error(rec_task_details.task_id,
'Calling API',
'JTF_TASKS_B',
'TASK_NUMBER',
x_error_message);
END;
--
IF x_api_call_status <> 'F' THEN
--Check Status
IF x_o_return_status <> FND_API.G_RET_STS_SUCCESS THEN
x_failure_count := x_failure_count + 1;
--
x_o_msg_count := FND_MSG_PUB.COUNT_MSG;
--Check Message Count
IF x_o_msg_count > 0 THEN
x_temp_str := SUBSTR(FND_MSG_PUB.GET(FND_MSG_PUB.G_FIRST,FND_API.G_FALSE),1,512);
x_error_message := x_temp_str;
--
FOR i in 1..(x_o_msg_count -1)
LOOP
x_temp_str := SUBSTR(FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT, FND_API.G_FALSE),1,512);
x_error_message := x_error_message||' '||x_temp_str;
END LOOP;
END IF;
x_error_message := '(Task Number = '||rec_task_details.task_number||')'||x_error_message;
fnd_file.put_line(fnd_file.log, x_error_message);
--Log appropriate Error Message
xxcnc_utilities_pkg.xxcnc_insert_error(rec_task_details.task_id,
'Return Status = F',
'JTF_TASKS_B',
'TASK_NUMBER',
x_error_message);
--
ELSE --Success
x_success_count := x_success_count + 1;
END IF;
END IF;
--
END LOOP;
COMMIT;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment