[Home] [Help]
PACKAGE BODY: APPS.CS_SR_MASS_UPDATE_PKG
Source
1 PACKAGE BODY cs_sr_mass_update_pkg as
2 /* $Header: cssrmub.pls 120.0.12010000.11 2009/10/07 05:03:16 mkundali noship $ */
3
4 procedure sr_mass_update(p_incident_id_arr in SYSTEM.IBU_NUM_TBL_TYPE,
5 p_status_id in NUMBER,
6 p_resolution_code in VARCHAR2,
7 p_owner_id in NUMBER,
8 p_owner_group_id in NUMBER,
9 p_note_type in VARCHAR2,
10 p_noteVisibility in VARCHAR2,
11 p_noteDetails in VARCHAR2,
15 x_param_incident_id out NOCOPY CS_KB_NUMBER_TBL_TYPE,
12 p_last_updated_by in NUMBER,
13 auto_assign_group_flag in VARCHAR2,
14 auto_assign_owner_flag in VARCHAR2,
16 x_param_status out NOCOPY JTF_VARCHAR2_TABLE_4000,
17 x_param_msg_data out NOCOPY JTF_VARCHAR2_TABLE_4000
18 )
19
20 IS
21 x_return_status VARCHAR2(1);
22 x_msg_count NUMBER;
23 x_msg_data VARCHAR2(2000);
24 l_last_update_date DATE := SYSDATE;
25 l_object_version_number NUMBER;
26 l_sr_rec CS_SERVICEREQUEST_PVT.service_request_rec_type;
27 l_notes_table CS_SERVICEREQUEST_PVT.notes_table;
28 l_contacts_table CS_SERVICEREQUEST_PVT.contacts_table;
29 l_validate_sr_closure VARCHAR2(1) := 'N';
30 l_auto_close_child_entities VARCHAR2(1) := 'N';
31 l_temp_close_value VARCHAR2(100);
32 l_responsibility_id NUMBER;
33 l_sr_update_out_rec CS_ServiceRequest_PVT.sr_update_out_rec_type;
34 l_cs_auto_assignment VARCHAR2(1) := 'N';
35 p_auto_assign VARCHAR2(1) := 'N';
36 l_data varchar2(2000);
37 l_msg_index number := 1;
38 l_msg_index_out number;
39 l_count number;
40 l_status_msg varchar2(1000);
41
42 BEGIN
43 /*Trap the error message for SRs which are closed and have the Disallow SR Update
44 Check box as checked bug 8726256*/
45 FND_MESSAGE.Set_Name('CS','CS_API_SR_ONLY_STATUS_UPDATED');
46 FND_MSG_PUB.Add;
47 l_status_msg := FND_MSG_PUB.GET(FND_MSG_pub.Count_Msg,FND_API.G_FALSE);
48 l_Status_msg:=substr(l_status_msg,instr(l_status_msg,':')+1);
49 /*bug 8726256* ends here*/
50 if (p_note_type is NOT NULL ) THEN
51 l_notes_table(1).note_type := p_note_type;
52 end if;
53 if (p_noteVisibility is NOT NULL ) THEN
54 l_notes_table(1).note_status := p_noteVisibility;
55 end if;
56 if (p_noteDetails is NOT NULL ) THEN
57 l_notes_table(1).note := p_noteDetails;
58 end if;
59 x_param_incident_id := CS_KB_NUMBER_TBL_TYPE();
60 x_param_status := JTF_VARCHAR2_TABLE_4000();
61 x_param_msg_data := JTF_VARCHAR2_TABLE_4000();
62
63 CS_SERVICEREQUEST_PVT.INITIALIZE_REC(p_sr_record => l_sr_rec);
64
65 Select nvl(fnd_profile.value('CS_AUTO_ASSIGN_OWNER_FORMS'), 'N')
66 Into l_cs_auto_assignment From dual;
67
68 if(l_cs_auto_assignment = 'Y') then
69 if (p_owner_group_id is not NULL and p_owner_id is not NULL) then
70 l_sr_rec.owner_group_id := p_owner_group_id;
71 l_sr_rec.owner_id := p_owner_id;
72 elsif(p_owner_group_id is NULL and p_owner_id is NULL and auto_assign_owner_flag='on' and auto_assign_group_flag='off') then
73 l_sr_rec.owner_group_id := FND_API.G_MISS_NUM;
74 l_sr_rec.owner_id := null;
75 p_auto_assign :='Y';
76 elsif(p_owner_group_id is NULL and p_owner_id is NULL and (auto_assign_group_flag='on' or auto_assign_owner_flag='on')) then
77 l_sr_rec.owner_group_id := null;
78 l_sr_rec.owner_id := null;
79 p_auto_assign :='Y';
80 elsif(p_owner_group_id is not NULL and p_owner_id is NULL and auto_assign_owner_flag='on') then
81 l_sr_rec.owner_group_id := p_owner_group_id;
82 l_sr_rec.owner_id := null;
83 p_auto_assign :='Y';
84 elsif(p_owner_group_id is not NULL) then
85 l_sr_rec.owner_group_id := p_owner_group_id;
86 l_sr_rec.owner_id := null;
87 elsif(p_owner_id is not NULL) then
88 l_sr_rec.owner_group_id := FND_API.G_MISS_NUM;
89 l_sr_rec.owner_id := p_owner_id;
90 elsif(p_owner_group_id is NULL and p_owner_id is NULL and auto_assign_group_flag='off' and auto_assign_owner_flag='off') then
91 p_auto_assign:='N';
92 end if;
93 elsif(l_cs_auto_assignment = 'N') then
94 if (p_owner_group_id is not NULL and p_owner_id is not NULL) then
95 l_sr_rec.owner_group_id := p_owner_group_id;
96 l_sr_rec.owner_id := p_owner_id;
97 elsif(p_owner_group_id is not NULL) then
98 l_sr_rec.owner_group_id := p_owner_group_id;
99 l_sr_rec.owner_id := null;
100 elsif(p_owner_id is not NULL) then
101 l_sr_rec.owner_group_id:= FND_API.G_MISS_NUM;
102 l_sr_rec.owner_id := p_owner_id;
103 elsif(p_owner_group_id is NULL and p_owner_id is NULL) then
104 p_auto_assign:='N';
105 end if;
106 end if;
107
108 l_sr_rec.language := 'US';
109 if (p_status_id > 0) then
110 l_sr_rec.status_id := p_status_id;
111 end if;
112 if (p_resolution_code is NOT NULL ) THEN
113 l_sr_rec.resolution_code := p_resolution_code;
114 end if;
115 select fnd_global.resp_id into l_responsibility_id from dual;
116
117 l_temp_close_value := FND_PROFILE.VALUE('CS_SR_AUTO_CLOSE_CHILDREN');
118 if (l_temp_close_value = 'CS_SR_VALIDATE_AND_CLOSE') then
119 l_auto_close_child_entities := 'Y';
120 l_validate_sr_closure := 'Y';
121 end if;
122
123 if (l_temp_close_value = 'CS_SR_NONE') then
124 l_auto_close_child_entities := 'N';
125 l_validate_sr_closure := 'N';
126 end if;
127
128
129 for i in p_incident_id_arr.first..p_incident_id_arr.last
130 loop
131 if p_incident_id_arr(i) is not NULL then
132 select OBJECT_VERSION_NUMBER
133 into l_object_version_number
134 from CS_INCIDENTS_ALL_B
135 where INCIDENT_ID = p_incident_id_arr(i);
136
137 CS_SERVICEREQUEST_PVT.UPDATE_SERVICEREQUEST(
138 p_api_version => 4.0,
139 p_init_msg_list => fnd_api.g_true,
140 p_resp_id => l_responsibility_id,
141 p_commit => fnd_api.g_true,
142 p_validation_level => 100,
143 p_request_id => p_incident_id_arr(i),
144 p_object_version_number => l_object_version_number,
145 p_last_updated_by => p_last_updated_by,
146 p_last_update_date => l_last_update_date,
147 p_service_request_rec => l_sr_rec,
148 p_notes => l_notes_table,
149 p_contacts => l_contacts_table,
150 p_validate_sr_closure => l_validate_sr_closure,
151 p_auto_close_child_entities => l_auto_close_child_entities,
152 x_msg_count => x_msg_count,
153 p_auto_assign =>p_auto_assign,
154 x_return_status => x_return_status,
155 x_msg_data => x_msg_data,
156 x_sr_update_out_rec => l_sr_update_out_rec);
157
158 if(x_return_status = 'S' OR x_return_status = 'E') then
159 l_count := FND_MSG_PUB.Count_Msg;
160 FND_MSG_PUB.Get(p_msg_index => l_msg_index,
161 p_encoded => 'F',
162 p_data => l_data,
163 p_msg_index_out => l_msg_index_out
164 );
165 /*Trap the error message for SRs which are closed and have the Disallow SR Update
166 Check box as checked bug 8726256*/
167 if (l_status_msg=substr(l_data,instr(l_data,':')+1) and p_status_id is null) then
168 x_return_status:='E';
169 end if;
170 end if;
171
172 x_param_incident_id.Extend;
173 x_param_status.Extend;
174 x_param_msg_data.Extend;
175 x_param_incident_id(i) := p_incident_id_arr(i);
176 x_param_status(i) := x_return_status;
177
178 if(x_return_status = 'S' OR x_return_status = 'E') then
179 x_param_msg_data(i) := l_data;
180 else
181 x_param_msg_data(i) := x_msg_data;
182 end if;
183
184
185 end if;
186
187 end loop;
188 exception
189 WHEN OTHERS THEN
190 raise;
191
192 end sr_mass_update;
193
194 END cs_sr_mass_update_pkg;