1 PACKAGE csf_task_assignments_pub AUTHID CURRENT_USER AS
2 /* $Header: CSFPTASS.pls 120.12.12020000.2 2013/04/25 11:28:17 aditysin ship $ */
3
4 /**
5 * Creates a New Task Assignment for the given Task with the given attributes.
6 *
7 * If there exists any Cancelled Task Assignment for the Task with the given
8 * Resource Information, then that Task Assignment is reused rather than creating a
9 * new Task Assignment afresh.
10 * <br>
11 * If the Trip ID corresponding to the Task Assignment is passed as FND_API.G_MISS_NUM
12 * then the user doesnt want to link the Assignment to any Trip. So the Trip ID will
13 * be saved as NULL corresponding to the Task Assignment.
14 * If Trip ID is passed as NULL or not passed at all, then the API will try to find a
15 * Trip corresponding to the Assignment. Since we are dependent on Trips Model, any
16 * Assignment created for a Field Service Task should be linked to a Trip (based on
17 * Actual Date / Scheduled Dates). If there exists no Trip or there exists multiple trips,
18 * then the API will error out. If Assignment shouldnt be linked to any Trip, then
19 * Trip ID should be passed as FND_API.G_MISS_NUM.
20 * <br>
21 * Except for Task ID, Resouce ID, Resource Type Code all other parameters are optional.
22 */
23 PROCEDURE create_task_assignment (
24 p_api_version IN NUMBER
25 , p_init_msg_list IN VARCHAR2 DEFAULT NULL
26 , p_commit IN VARCHAR2 DEFAULT NULL
27 , p_validation_level IN NUMBER DEFAULT NULL
28 , x_return_status OUT NOCOPY VARCHAR2
29 , x_msg_count OUT NOCOPY NUMBER
30 , x_msg_data OUT NOCOPY VARCHAR2
31 , p_task_assignment_id IN NUMBER DEFAULT NULL
32 , p_task_id IN NUMBER
33 , p_task_name IN VARCHAR2 DEFAULT NULL
34 , p_task_number IN VARCHAR2 DEFAULT NULL
35 , p_resource_type_code IN VARCHAR2
36 , p_resource_id IN NUMBER
37 , p_resource_name IN VARCHAR2 DEFAULT NULL
38 , p_actual_effort IN NUMBER DEFAULT NULL
39 , p_actual_effort_uom IN VARCHAR2 DEFAULT NULL
40 , p_schedule_flag IN VARCHAR2 DEFAULT NULL
41 , p_alarm_type_code IN VARCHAR2 DEFAULT NULL
42 , p_alarm_contact IN VARCHAR2 DEFAULT NULL
43 , p_sched_travel_distance IN NUMBER DEFAULT NULL
44 , p_sched_travel_duration IN NUMBER DEFAULT NULL
45 , p_sched_travel_duration_uom IN VARCHAR2 DEFAULT NULL
46 , p_actual_travel_distance IN NUMBER DEFAULT NULL
47 , p_actual_travel_duration IN NUMBER DEFAULT NULL
48 , p_actual_travel_duration_uom IN VARCHAR2 DEFAULT NULL
49 , p_actual_start_date IN DATE DEFAULT NULL
50 , p_actual_end_date IN DATE DEFAULT NULL
51 , p_palm_flag IN VARCHAR2 DEFAULT NULL
52 , p_wince_flag IN VARCHAR2 DEFAULT NULL
53 , p_laptop_flag IN VARCHAR2 DEFAULT NULL
54 , p_device1_flag IN VARCHAR2 DEFAULT NULL
55 , p_device2_flag IN VARCHAR2 DEFAULT NULL
56 , p_device3_flag IN VARCHAR2 DEFAULT NULL
57 , p_resource_territory_id IN NUMBER DEFAULT NULL
58 , p_assignment_status_id IN NUMBER DEFAULT NULL
59 , p_shift_construct_id IN NUMBER DEFAULT NULL
60 , p_object_capacity_id IN NUMBER DEFAULT NULL
61 , p_update_task IN VARCHAR2 DEFAULT NULL
62 , p_attribute1 IN VARCHAR2 DEFAULT NULL
63 , p_attribute2 IN VARCHAR2 DEFAULT NULL
64 , p_attribute3 IN VARCHAR2 DEFAULT NULL
65 , p_attribute4 IN VARCHAR2 DEFAULT NULL
66 , p_attribute5 IN VARCHAR2 DEFAULT NULL
67 , p_attribute6 IN VARCHAR2 DEFAULT NULL
68 , p_attribute7 IN VARCHAR2 DEFAULT NULL
69 , p_attribute8 IN VARCHAR2 DEFAULT NULL
70 , p_attribute9 IN VARCHAR2 DEFAULT NULL
71 , p_attribute10 IN VARCHAR2 DEFAULT NULL
72 , p_attribute11 IN VARCHAR2 DEFAULT NULL
73 , p_attribute12 IN VARCHAR2 DEFAULT NULL
74 , p_attribute13 IN VARCHAR2 DEFAULT NULL
75 , p_attribute14 IN VARCHAR2 DEFAULT NULL
76 , p_attribute15 IN VARCHAR2 DEFAULT NULL
77 , p_attribute_category IN VARCHAR2 DEFAULT NULL
78 , x_task_assignment_id OUT NOCOPY NUMBER
79 , x_ta_object_version_number OUT NOCOPY NUMBER
80 , x_task_object_version_number OUT NOCOPY NUMBER
81 , x_task_status_id OUT NOCOPY NUMBER
82 );
83
84 /**
85 * Update an existing Task Assignment with new Task Attributes
86 *
87 * Given the Task Assignment ID and Task Object Version Number, it calls
88 * JTF Task Assignment API to update the Task Assignment with the new Attributes.
89 * It is actually a two step process
90 * 1. Updating the Task Assignment with the new Task Attributes except Status
91 * 2. Updating the Task Assignment with the new Task Status (if not FND_API.G_MISS_NUM)
92 * by calling UPDATE_ASSIGNMENT_STATUS.
93 * <br>
94 * Because of the two step process, the returned Task Assignment Object
95 * Version Number might be incremented by 2 when user might have expected an
96 * increment of only 1.
97 * <br>
98 * Except Task Assignment ID and Object Version Number parameters, all are optional.
99 * <br>
100 * Note that for parameters starting from P_TASK_NUMBER till P_ABORT_WORKFLOW, the
101 * function CSF_UTIL_PVT.G_MISS_*** is called so that Forms / Libraries calling
102 * the API currently will not be affected by the error "PL/SQL ERROR 512: Implementation
103 * Restriction". Note that CHR(0) can be hardcoded rather than the performance
104 * intensive CSF_UTIL_PVT.GET_MISS_CHAR... but it is resulting in the error
105 * "PL/SQL ERROR 707: unsupported construct or internal error [2601]" when
106 * the parameter's default is CHR(0). Its working for other MISS values..except
107 * for MISS_CHAR.
108 */
109 PROCEDURE update_task_assignment (
110 p_api_version IN NUMBER
111 , p_init_msg_list IN VARCHAR2 DEFAULT NULL
112 , p_commit IN VARCHAR2 DEFAULT NULL
113 , p_validation_level IN NUMBER DEFAULT NULL
114 , x_return_status OUT NOCOPY VARCHAR2
115 , x_msg_count OUT NOCOPY NUMBER
116 , x_msg_data OUT NOCOPY VARCHAR2
117 , p_task_assignment_id IN NUMBER
118 , p_object_version_number IN OUT NOCOPY NUMBER
119 , p_task_id IN NUMBER DEFAULT fnd_api.g_miss_num
120 , p_resource_type_code IN VARCHAR2 DEFAULT fnd_api.g_miss_char
121 , p_resource_id IN NUMBER DEFAULT fnd_api.g_miss_num
122 , p_resource_territory_id IN NUMBER DEFAULT fnd_api.g_miss_num
123 , p_assignment_status_id IN NUMBER DEFAULT fnd_api.g_miss_num
124 , p_actual_start_date IN DATE DEFAULT fnd_api.g_miss_date
125 , p_actual_end_date IN DATE DEFAULT fnd_api.g_miss_date
126 , p_sched_travel_distance IN NUMBER DEFAULT fnd_api.g_miss_num
127 , p_sched_travel_duration IN NUMBER DEFAULT fnd_api.g_miss_num
128 , p_sched_travel_duration_uom IN VARCHAR2 DEFAULT fnd_api.g_miss_char
129 , p_shift_construct_id IN NUMBER DEFAULT fnd_api.g_miss_num
130 , p_object_capacity_id IN NUMBER DEFAULT fnd_api.g_miss_num
131 , p_update_task IN VARCHAR2 DEFAULT NULL
132 , p_task_number IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
133 , p_task_name IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
134 , p_resource_name IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
138 , p_actual_travel_duration IN NUMBER DEFAULT csf_util_pvt.get_miss_num
135 , p_actual_effort IN NUMBER DEFAULT csf_util_pvt.get_miss_num
136 , p_actual_effort_uom IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
137 , p_actual_travel_distance IN NUMBER DEFAULT csf_util_pvt.get_miss_num
139 , p_actual_travel_duration_uom IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
140 , p_attribute1 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
141 , p_attribute2 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
142 , p_attribute3 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
143 , p_attribute4 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
144 , p_attribute5 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
145 , p_attribute6 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
146 , p_attribute7 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
147 , p_attribute8 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
148 , p_attribute9 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
149 , p_attribute10 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
150 , p_attribute11 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
151 , p_attribute12 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
152 , p_attribute13 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
153 , p_attribute14 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
154 , p_attribute15 IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
155 , p_attribute_category IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
156 , p_show_on_calendar IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
157 , p_category_id IN NUMBER DEFAULT csf_util_pvt.get_miss_num
158 , p_schedule_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
159 , p_alarm_type_code IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
160 , p_alarm_contact IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
161 , p_palm_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
162 , p_wince_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
163 , p_laptop_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
164 , p_device1_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
165 , p_device2_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
166 , p_device3_flag IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
167 , p_enable_workflow IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
168 , p_abort_workflow IN VARCHAR2 DEFAULT csf_util_pvt.get_miss_char
169 , x_task_object_version_number OUT NOCOPY NUMBER
170 , x_task_status_id OUT NOCOPY NUMBER
171 );
172
173 /**
174 * Update the Status of the Task Assignment with the given Status and propagate to the
175 * Task also if required.
176 * <br>
177 * Task Assignment is updated with the new Status if the Transition from the current
178 * status to the new status is allowed as determined by
179 * CSF_TASKS_PUB.VALIDATE_STATE_TRANSITION. Transition validation is done only
180 * when Validation Level is passed as FULL.
181 * <br>
182 * In addition to updating the Task Assignment Status, the following operations are also
183 * done
184 * 1. If the Task corresponding to the given Task Assignment has no other
185 * Open / Active Task Assignments other than the given one, then the Assignment
186 * Status is propagated to the Task also. If there exists any other Active
187 * Assignment, then the Task is not updated.
188 * The parameters P_TASK_OBJECT_VERSION_NUMBER and X_TASK_STATUS_ID reflect
189 * the Object Version Number and Task Status ID of the Task in Database
190 * irrespective of the fact whether the update has taken place or not. <br>
191 *
192 * 2. If the Assignment goes to Cancelled (as per the new status), then if any
193 * Spares Order is linked to the Assignment, they are cleaned up by calling
194 * CLEAN_MATERIAL_TRANSACTION of Spares. <br>
195 *
196 * 3. If the Assignment goes to Assigned (as per the new status), and the
197 * old status is not Assigned, then Orders are created and linked to the
198 * Task Assignment. <br>
199 *
200 * 4. If the Assignnment goes to Working (as per the new status), then it means
201 * that the Resource is working on the Task and so his location should be updated
202 * to reflect the location of the Task. This is required by Map Functionality.
203 * THIS IS WRONG AND SHOULD BE REMOVED. MAP SHOULD BE USING HZ_LOCATIONS TABLE. <br>
204 *
205 * @param p_api_version API Version (1.0)
206 * @param p_init_msg_list Initialize Message List
207 * @param p_commit Commit the Work
208 * @param p_validation_level Validate the given Parameters
209 * @param x_return_status Return Status of the Procedure.
210 * @param x_msg_count Number of Messages in the Stack.
211 * @param x_msg_data Stack of Error Messages.
212 * @param p_task_assignment_id Task Assignment ID of the Assignment to be updated
213 * @param p_assignment_status_id New Status ID for the Assignment
214 * @param p_old_assignment_status_id Old Status ID for the Assignment
215 * @param p_show_on_calendar <Dont Know>
216 * @param p_object_version_number Current Task Version and also container for new one.
217 * @param x_task_object_version_number Task Object Version Number (either old or new)
218 * @param x_task_status_id Task Status ID (either old or new)
219 */
220 PROCEDURE update_assignment_status (
221 p_api_version IN NUMBER
222 , p_init_msg_list IN VARCHAR2 DEFAULT NULL
223 , p_commit IN VARCHAR2 DEFAULT NULL
224 , p_validation_level IN NUMBER DEFAULT NULL
225 , x_return_status OUT NOCOPY VARCHAR2
226 , x_msg_count OUT NOCOPY NUMBER
227 , x_msg_data OUT NOCOPY VARCHAR2
228 , p_task_assignment_id IN NUMBER
229 , p_object_version_number IN OUT NOCOPY NUMBER
230 , p_assignment_status_id IN NUMBER
231 , p_update_task IN VARCHAR2 DEFAULT NULL
232 , p_show_on_calendar IN VARCHAR2 DEFAULT 'Y'
233 , x_task_object_version_number OUT NOCOPY NUMBER
234 , x_task_status_id OUT NOCOPY NUMBER
235 );
236
237 PROCEDURE cross_task_validation (x_return_status out nocopy varchar2);
238
239 END;