DBA Data[Home] [Help]

PACKAGE BODY: APPS.CS_SERVICEREQUEST_PVT

Source


1 PACKAGE BODY CS_ServiceRequest_PVT AS
2 /* $Header: csvsrb.pls 120.93.12020000.11 2013/05/30 22:05:55 siahmed ship $ */
3 
4 G_PKG_NAME          CONSTANT VARCHAR2(30) := 'CS_ServiceRequest_PVT';
5 G_INITIALIZED       CONSTANT VARCHAR2(1)  := 'R';
6 G_SR_SUBTYPE        CONSTANT VARCHAR2(5)  := 'INC';
7 G_API_REVISION      CONSTANT NUMBER       := 1.0;
8 G_TABLE_NAME        CONSTANT VARCHAR2(40) := 'CS_INCIDENTS_ALL_B';
9 G_TL_TABLE_NAME     CONSTANT VARCHAR2(40) := 'CS_INCIDENTS_ALL_TL';
10 
11 --siahmed added for 12.1.2 project where
12 --to prevent multiple query to check weather we are updating onetime address or not
13 G_ONETIME_ADD_CNT     NUMBER := 0;
14 --end of siahmed
15 
16 --
17 --This procedure checks if an attribute is g_miss_char, if no then it returns.
18 --otherwise it checks if the given attribute is part of
19 --global context, if yes then it sets attribute value to value from old record
20 --otherwise it sets attribute to null.
21 PROCEDURE set_attribute_value(x_attr_val     in out nocopy varchar2,
22                               p_attr_val_old in            varchar2,
23                               p_ff_name      in            varchar2,
24                               p_attr_col     in            varchar2);
25 --============================================================================
26 -- PROCEDURE : Get_incident_type_details   PRIVATE
27 -- PARAMETERS: p_incident_typeId           Incicent Type identifier
28 -- COMMENT   : This procedure gets business process associated with incident type.
29 --           :
30 -- PRE-COND  : Incident Type is assumed to be valid
31 --           :
32 -- EXCEPTIONS: None
33 -- Modification History:
34 -- Date     Name     Desc
35 -- ------- -------- ------------------------------------------------------------
36 -- 07/11/05 smisra   Added abort workflow, launch workflow, workflow columns
37 --                   to select statement and out parameters to this procedure
38 -- -----------------------------------------------------------------------------
39 PROCEDURE get_incident_type_details
40 ( p_incident_type_id          IN         NUMBER
41 , x_business_process_id       OUT NOCOPY NUMBER
42 , x_autolaunch_workflow_flag  OUT NOCOPY VARCHAR2
43 , x_abort_workflow_close_flag OUT NOCOPY VARCHAR2
44 , x_workflow                  OUT NOCOPY VARCHAR2
45 , x_return_status             OUT NOCOPY VARCHAR2
46 )
47 IS
48 BEGIN
49   x_return_status := FND_API.G_RET_STS_SUCCESS;
50 
51   SELECT
52     business_process_id
53   , autolaunch_workflow_flag
54   , abort_workflow_close_flag
55   , workflow
56   INTO
57     x_business_process_id
58   , x_autolaunch_workflow_flag
59   , x_abort_workflow_close_flag
60   , x_workflow
61   FROM
62     cs_incident_types_b
63   WHERE incident_type_id = p_incident_type_id;
64 
65 EXCEPTION
66   WHEN no_data_found THEN
67     x_workflow                  := NULL;
68     x_business_process_id       := NULL;
69     x_autolaunch_workflow_flag  := NULL;
70     x_abort_workflow_close_flag := NULL;
71     x_return_status             := FND_API.G_RET_STS_ERROR;
72   WHEN others THEN
73     x_return_status             := FND_API.G_RET_STS_UNEXP_ERROR;
74     FND_MESSAGE.set_name ('CS', 'CS_API_SR_UNKNOWN_ERROR');
75     FND_MESSAGE.set_token
76     ('P_TEXT'
77     , 'CS_SERVICEREQUEST_UTIL.get_incident_type_details'||'-'||SQLERRM
78     );
79     FND_MSG_PUB.ADD;
80 END get_incident_type_details;
81 -- -----------------------------------------------------------------------------
82 -- PROCEDURE : Get_default_contract   PRIVATE
83 -- PARAMETERS: p_business_process_id  Business Process associayed with incident type
84 --           : p_customer_id          Service Request customer
85 --           : p_install_site_use_id  Install site
86 --           : p_account_id           Customer Account
87 --           : p_system_id            System Id
88 --           : p_inventory_item_id    Inventory Item
89 --           : p_customer_product_id  Customer Product
90 --           : p_request_date         Service Request Date
91 --           : p_severity_id          Service Request Severity
92 --           : p_time_zone_id         Time Zone
93 --           : p_incident_location_type     Service request location type
94 --           : p_incident_location_id       Service Request Location Id
95 --           : p_primary_contact_party_id   party id of the SR primary contact
96 --           : p_primary_contact_point_id   contact point id of the SR primary contact
97 --           : p_incident_id                Request Identifier
98 -- COMMENT   : This procedure gets a contract applicable to service request attributes
99 --           :
100 --           :
101 -- PRE-COND  : All input parameters are process for g_miss values
102 --           :
103 -- EXCEPTIONS: None
104 -- Modification History:
105 -- Date     Name     Desc
106 -- ------- -------- ------------------------------------------------------------
107 -- 07/11/05 smisra   added new parameters primary contact, contact point,
108 --                   location id, location type and incident id to this
109 --                   procedure for timezone changes
110 --                   Called  CS_TZ_GET_DETAILS_PVT.customer_preferred_time_zone
111 --                   to get customer preferred time zone. This time zone is
112 --                   passed to contract API.
113 -- 08/03/05 smisra   added a new paramter p_incident_occurred_date
114 --                   passed incident_occurred_date, time_zone_id and
115 --                   dates_in_input_tz to contract record.
116 -- 12/23/05 smisra   Bug 4894942
117 --                   Added a new parameter p_default_coverage_template_id
118 --                   Moved the logic based on default coverage template from
119 --                   Create service request to this procedure
120 -- -----------------------------------------------------------------------------
121 PROCEDURE get_default_contract
122 ( p_business_process_id        IN NUMBER
123 , p_customer_id                IN NUMBER
124 , p_install_site_use_id        IN NUMBER
125 , p_account_id                 IN NUMBER
126 , p_system_id                  IN NUMBER
127 , p_inventory_item_id          IN NUMBER
128 , p_customer_product_id        IN NUMBER
129 , p_request_date               IN DATE
130 , p_incident_occurred_date     IN DATE
131 , p_severity_id                IN NUMBER
132 , p_time_zone_id               IN NUMBER
133 , p_incident_location_type     IN VARCHAR2
134 , p_incident_location_id       IN NUMBER
135 , p_primary_contact_party_id   IN NUMBER
136 , p_primary_contact_point_id   IN NUMBER
137 , p_incident_id                IN NUMBER
138 , p_default_coverage_template_id   IN      NUMBER
139 , x_return_status              OUT NOCOPY VARCHAR2
140 , x_contract_id                OUT NOCOPY NUMBER
141 , x_contract_number            OUT NOCOPY VARCHAR2
142 , x_contract_service_id        OUT NOCOPY NUMBER
143 , x_exp_resolution_date        OUT NOCOPY DATE
144 , x_obligation_date            OUT NOCOPY DATE
145 )
146 IS
147   px_inp_rec      OKS_ENTITLEMENTS_PUB.get_contin_rec;
148   l_inp_rec       OKS_COV_ENT_PUB.gdrt_inp_rec_type;
149   l_react_rec     OKS_COV_ENT_PUB.rcn_rsn_rec_type;
150   l_resolve_rec   OKS_COV_ENT_PUB.rcn_rsn_rec_type;
151   l_ent_contracts OKS_ENTITLEMENTS_PUB.get_contop_tbl;
152   Li_TableIdx     BINARY_INTEGER;
153   l_msg_count     NUMBER;
154   l_msg_data      VARCHAR2(2000);
155   lx_timezone_id       NUMBER;
156   lx_timezone_name     VARCHAR2(80);
157   l_server_timezone_id NUMBER;
158   l_log_module         VARCHAR2(255);
159   --Changes for 9648141
160   l_default_coverage_template_id NUMBER;
161 BEGIN
162   l_log_module                := 'cs.plsql.' || 'CS_SERVICEREQUEST_PVT.get_default_contract' || '.';
163   px_inp_rec.contract_number          := NULL;
164   px_inp_rec.contract_number_modifier := NULL;
165   px_inp_rec.service_line_id          := NULL;
166   px_inp_rec.party_id                 := p_customer_id;
167   px_inp_rec.site_id                  := p_install_site_use_id;
168   px_inp_rec.cust_acct_id             := p_account_id;
169   px_inp_rec.system_id                := p_system_id;
170   px_inp_rec.item_id                  := p_inventory_item_id;
171   px_inp_rec.product_id               := p_customer_product_id;
172   px_inp_rec.request_date             := p_request_date;
173   px_inp_rec.incident_date            := p_incident_occurred_date;
174   px_inp_rec.severity_id              := p_severity_id;
175   px_inp_rec.time_zone_id             := p_time_zone_id;
176   px_inp_rec.business_process_id      := p_business_process_id;
177   px_inp_rec.calc_resptime_flag       := 'Y';
178   px_inp_rec.validate_flag            := 'Y';
179   px_inp_rec.dates_in_input_tz        := 'N';
180 
181   -- 12.1.2-srt order issue, sanjana rao
182   --px_inp_rec.sort_key                 := 'RSN';
183 
184 --The value set in this profile option will be passed to the contracts API to
185 --return the contract lines sorted based on Reaction Rime(RCN)/ Resolution Time(RSN)/
186 --Importance Level(COVTYP_IMP).
187 --Default value: Resolution time (to be backward compatible)
188 
189 
190    px_inp_rec.sort_key := fnd_profile.value('CS_SR_CONTRACT_SORT_ORDER');
191    if  px_inp_rec.sort_key is null then
192       px_inp_rec.sort_key := 'RSN';
193    end if;
194 
195 -- 12.1.2 sort order issue, sanjana rao
196 
197 
198   CS_TZ_GET_DETAILS_PVT.customer_preferred_time_zone
199   ( p_incident_id             => p_incident_id
200   , p_task_id                 => NULL
201   , p_resource_id             => NULL
202   , p_incident_location_id    => p_incident_location_id
203   , p_incident_location_type  => p_incident_location_type
204   , p_contact_party_id        => p_primary_contact_party_id
205   , p_contact_phone_id        => p_primary_contact_point_id
206   , p_customer_id             => p_customer_id
207   , x_timezone_id             => lx_timezone_id
208   , x_timezone_name           => lx_timezone_name
209   );
210 
211 
212   IF lx_timezone_id IS NOT NULL
213   THEN
214     px_inp_rec.time_zone_id := lx_timezone_id;
215   ELSE
216     px_inp_rec.time_zone_id := p_time_zone_id;
217   END IF ;
218 
219 --------------------Call to Get contracts Starts Here--------------------------
220   IF ((px_inp_rec.business_process_id IS NULL) OR
221       (px_inp_rec.severity_id         IS NULL) OR
222       (px_inp_rec.time_zone_id        IS NULL) )
223   THEN
224     FND_MESSAGE.SET_NAME      ('CS','CS_SR_DEF_SLA_INSUFF_PARAMS');
225     FND_MSG_PUB.ADD_DETAIL    (p_message_type=>FND_MSG_PUB.G_INFORMATION_MSG);
226     --FND_MSG_PUB.Count_And_Get (p_count => x_msg_count, p_data  => x_msg_data);
227   ELSE
228     OKS_ENTITLEMENTS_PUB.get_contracts
229          (p_api_version              => 1.0,
230           p_init_msg_list            => fnd_api.g_false ,
231           p_inp_rec                  => px_inp_rec,
232           x_return_status            => x_return_status,
233           x_msg_count                => l_msg_count,
234           x_msg_data                 => l_msg_data,
235           x_ent_contracts            => l_ent_contracts);
236     IF (x_return_status = 'S' AND l_ent_contracts.count > 0)
237     THEN
238       Li_TableIdx           := l_ent_contracts.FIRST                           ;
239       x_contract_id         := l_ent_contracts(Li_TableIdx).contract_id        ;
240       x_contract_number     := l_ent_contracts(Li_TableIdx).contract_number    ;
241       x_contract_service_id := l_ent_contracts(Li_TableIdx).service_line_id    ;
242       x_exp_resolution_date := l_ent_contracts(Li_TableIdx).exp_resolution_time;
243       x_obligation_date     := l_ent_contracts(Li_TableIdx).exp_reaction_time  ;
244     ELSE
245       x_contract_id         := null ;
246       x_contract_number     := null ;
247       x_contract_service_id := null ;
248       x_exp_resolution_date := null ;
249       x_obligation_date     := null ;
250 
251       FND_MESSAGE.set_name('CS','CS_SR_UNABLE_DEF_CONTR');
252       FND_MSG_PUB.add_detail(p_message_type=>FND_MSG_PUB.G_INFORMATION_MSG);
253       -- in case of update API, this param is always passed as NULL
254       -- so this will not execute for update API
255 
256       -- Start changes for bug 9648141. If p_default_coverage_template_id is passed, use the same
257       -- otherwise get it from profile
258       IF p_default_coverage_template_id is NOT NULL THEN
259 	l_default_coverage_template_id := p_default_coverage_template_id;
260       ELSE
261 	l_default_coverage_template_id := fnd_profile.value('CS_SR_DEFAULT_COVERAGE');
262       END IF;
263 
264       IF l_default_coverage_template_id is NOT NULL
265       THEN
266         l_inp_rec.Coverage_template_id := l_default_coverage_template_id ;
267         l_inp_rec.Business_process_id  := p_business_process_id;
268         l_inp_rec.request_date         := p_request_date ;
269         l_inp_rec.Severity_id          := p_severity_id;
270         l_inp_rec.Time_zone_id         := lx_timezone_id;
271         l_inp_rec.dates_in_input_tz    := 'N';
272         OKS_COV_ENT_PUB.Get_default_react_resolve_by
273         ( p_api_version          =>1.0
274         , p_init_msg_list        => FND_API.G_FALSE
275         , p_inp_rec              => l_inp_rec
276         , x_return_status        => x_return_status
277         , x_msg_count            => l_msg_count
278         , x_msg_data             => l_msg_data
279         , x_react_rec            => l_react_rec
280         , x_resolve_rec          => l_resolve_rec
281         );
282         IF l_react_rec.by_date_end   IS NOT NULL            AND
283            l_resolve_rec.by_date_end IS NOT NULL            AND
284            l_react_rec.by_date_end   <> FND_API.G_MISS_DATE AND
285            l_resolve_rec.by_date_end <> FND_API.G_MISS_DATE
286         THEN
287           x_obligation_date     := l_react_rec.by_date_end;
288           x_exp_resolution_date := l_resolve_rec.by_date_end;
289           --
290           IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
291           THEN
292             FND_LOG.String
293             ( FND_LOG.level_procedure , L_LOG_MODULE || ''
294              , 'The defaulted value of parameter exp_resolution_date :' || x_exp_resolution_date
295             );
296             FND_LOG.String
297             ( FND_LOG.level_procedure , L_LOG_MODULE || ''
298             , 'The defaulted value of parameter obligation_date :' || x_obligation_date
299             );
300 	  END IF;
301         END IF; -- Returned value of dates are not null
302       END IF; -- if p_default_coverage is not null
303     END IF; -- else return status = 'S'
304   END IF;  -- all required param are available
305 ---------------------Call to Get contracts end Here-----------------------------
306 END get_default_contract;
307 -- -----------------------------------------------------------------------------
308 -- PROCEDURE : vldt_sr_rec            PRIVATE
309 -- PARAMETERS: p_sr_rec               Service Requesr Record after processing for
310 --                                    G_miss values
311 --           : p_sr_rec_inp           Service Requesr Record as input to API
312 --           : p_sr_related_data      This record hold SR related values such as
313 --                                    status flags, workflow flag, business
314 --                                    process id etc.
315 --           : p_mode                 it can 2 values 'CREATE' or 'UPDATE'
316 --                                    indicating SR creation or update
317 --           : p_request_id           SR identifier
318 --           : p_object_version_number SR object version
319 --           : p_last_updated_by       User Id
320 --           : p_validation_level      Validation level passed to SR API
321 --           : p_default_contract_sla_ind Default contract SLA indicator
322 --           : p_auto_assign              Auto assignment flag passed to API
323 --           : p_old_xxxx             these parameters hold old value of
324 --                                    corresponding SR attributes
325 --           : x_return_status        Indicates success or failure
326 --                                    encountered by the procedure
327 -- COMMENT   : This procedure validates following attributes
328 --             1. incident location
329 --             2. incident owner
330 --             3. Service contract
331 --             This procedure derives follwing attribute
332 --             1. incident country
333 --             2. resource type
334 --             3. service contract if p_default_contract_sla_ind is passed as Y
335 --             4. incident owner if p_auto_assign is passed as 'Y'
336 --             5. incident owner group if p_auto_assign is passed as 'Y'
337 --             6. Determines coverage if contract is available to SR
338 --
339 -- PRE-COND  : All input parameters are processed for g_miss values i.e SR Rec
340 --             should not have any G_MISS values
341 --           :
342 -- EXCEPTIONS: None
343 -- Modification History:
344 -- Date     Name     Desc
345 -- ------- -------- ------------------------------------------------------------
346 -- 12/14/05 smisra   Created
347 --                   Bug 4386870. Added call to validate_inc_location_id
348 -- 12/23/05 smisra   Bug 4894942, 4892782
349 --                   Added following calls
350 --                   1. Validate contract service id
351 --                   2. Call to default contract
352 --                   3. Call to determine coverage type based on contract
353 --                      service identifier
354 --                   4. Service request auto assignment
355 -- 12/30/05 smisra   Bug 4773215
356 --                   Added two parameters:
357 --                   1. p_old_site_id and
358 --                   2. p_old_resource_type
359 --                   Added validation of resource id. This will set resource
360 --                   type and site id based on resource
361 -- 11/14/08 Ranjan  Bug 7561640
362 --            in vldt_sr_rec it is overiding resource type value with party site
363 --            id
364 -- ------- -------- ------------------------------------------------------------
365 PROCEDURE  vldt_sr_rec
366 ( p_sr_rec                     IN OUT NOCOPY service_request_rec_type
367 , p_sr_rec_inp                 IN            service_request_rec_type
368 , p_sr_related_data            IN            RELATED_DATA_TYPE
369 , p_mode                       IN            VARCHAR2 DEFAULT NULL
370 , p_request_id                 IN            NUMBER   DEFAULT NULL
371 , p_object_version_number      IN            NUMBER   DEFAULT NULL
372 , p_last_updated_by            IN            NUMBER
373 , p_validation_level           IN            NUMBER   DEFAULT NULL
374 , p_default_contract_sla_ind   IN            VARCHAR2
375 , p_default_coverage_template_id IN      NUMBER DEFAULT NULL
376 , p_auto_assign                  IN      VARCHAR2
377 , p_old_incident_location_id   IN            NUMBER   DEFAULT NULL
378 , p_old_incident_location_type IN            VARCHAR2 DEFAULT NULL
379 , p_old_incident_country       IN            VARCHAR2 DEFAULT NULL
380 , p_old_incident_owner_id      IN            NUMBER   DEFAULT NULL
381 , p_old_owner_group_id         IN            NUMBER   DEFAULT NULL
382 , p_old_resource_type          IN            VARCHAR2 DEFAULT NULL
383 , p_old_site_id                IN            NUMBER   DEFAULT NULL
384 , p_old_obligation_date          IN          DATE   DEFAULT NULL
385 , p_old_expected_resolution_date IN          DATE   DEFAULT NULL
386 , p_old_contract_id              IN          NUMBER DEFAULT NULL
387 , p_old_contract_service_id      IN          NUMBER DEFAULT NULL
388 , p_old_install_site_id          IN          NUMBER DEFAULT NULL
389 , p_old_system_id                IN          NUMBER DEFAULT NULL
390 , p_old_account_id               IN          NUMBER DEFAULT NULL
391 , p_old_inventory_item_id        IN          NUMBER DEFAULT NULL
392 , p_old_customer_product_id      IN          NUMBER DEFAULT NULL
393 , p_old_incident_type_id         IN          NUMBER DEFAULT NULL
394 , p_old_time_zone_id             IN          NUMBER DEFAULT NULL
395 , p_old_incident_severity_id     IN          NUMBER DEFAULT NULL
396 , x_contract_number            IN OUT NOCOPY VARCHAR2
397 , x_return_status                 OUT NOCOPY VARCHAR2
398 ) IS
399 l_return_status             VARCHAR2(1);
400 l_contract_service_id_valid VARCHAR2(1);
401 l_api_name                  VARCHAR2(80);
402 l_log_module                VARCHAR2(255) ;
403 l_contract_defaulted        VARCHAR2(1);
404 l_msg_count                 NUMBER;
405 l_msg_data                  VARCHAR2(2000);
406 l_auto_assign_level         fnd_profile_option_values.profile_option_value % TYPE;
407 l_asgn_owner_id             cs_incidents_all_b.incident_owner_id           % TYPE;
408 l_asgn_resource_type        cs_incidents_all_b.resource_type               % TYPE;
409 l_asgn_owner_group_id       cs_incidents_all_b.owner_group_id              % TYPE;
410 l_asgn_owner_type           cs_incidents_all_b.resource_type               % TYPE;
411 l_territory_id              NUMBER;
412 l_orig_group_type_null varchar2(1) := 'N';
413 l_owner_id                  CS_INCIDENTS_ALL_B.incident_owner_id   % TYPE;
414 l_owner_name                jtf_rs_resource_extns_tl.resource_name % TYPE;
415 --siahmed 12.1.2 project
416 l_request_date              DATE;
417 -- end of addition by siahmed
418 BEGIN
419   l_api_name                  := 'CS_SERVICEREQUEST_PVT.vldt_sr_rec';
420   l_log_module                := 'cs.plsql.' || l_api_name || '.';
421   l_contract_service_id_valid := 'Y';
422   l_contract_defaulted        := 'N';
423   x_return_status             := FND_API.G_RET_STS_SUCCESS;
424 
425   IF p_validation_level = FND_API.G_VALID_LEVEL_FULL
426   THEN
427     --
428     --  incident location validation
429     --
430     -- siahmed adding for 12.1.2 project added the additional condition
431     -- where we are only goiung to do this validation if the address
432     -- is not a onetime address
433     IF (p_sr_rec.incident_location_id IS NOT NULL) AND (G_ONETIME_ADD_CNT <1)
434     THEN
435       IF p_sr_rec.incident_location_id            <> NVL(p_old_incident_location_id,-9) OR
436          NVL(p_sr_rec.incident_location_type,'X') <> NVL(p_old_incident_location_type,'Y') OR
437          p_old_incident_country IS NULL
438       THEN
439         CS_ServiceRequest_UTIL.Validate_Inc_Location_Id
440         ( p_api_name                 => l_api_name
441         , p_parameter_name           => 'p_incident_location_id'
442         , p_incident_location_type   => p_sr_rec.incident_location_type
443         , p_incident_location_id     => p_sr_rec.incident_location_id
444         , x_incident_country         => p_sr_rec.incident_country
445         , x_return_status            => x_return_status
446         );
447         IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
448           RETURN;
449         END IF;
450       END IF;  -- check on change in other related parameters
451     END IF;  -- null check on incident location
452     --
453     -- Incident Owner Validation
454     --
455     IF p_sr_rec.owner_id IS NULL
456     THEN
457       p_sr_rec.resource_type := NULL;
458       p_sr_rec.site_id       := NULL;
459     ELSE
460       -- if new owner is same as old owner then set resource type as old resource type
461       IF p_sr_rec.owner_id = p_old_incident_owner_id
462       THEN
463         p_sr_rec.resource_type := p_old_resource_type;
464 -- fix for   Bug 7561640
465         p_sr_rec.site_id := p_old_site_id;
466 -- end fix for   Bug 7561640
467       END IF;
468       -- Validate owner id and set resource type if it is not null
469       IF p_sr_rec.owner_id               <> NVL(p_old_incident_owner_id, -1) OR
470          p_sr_rec.type_id                <> NVL(p_old_incident_type_id , -9) OR
471          NVL(p_sr_rec.owner_group_id,-1) <> NVL(p_old_owner_group_id   , -1) OR
472          NVL(p_sr_rec.resource_type ,'Y')<> NVL(p_old_resource_type    ,'x')
473       THEN
474         CS_SERVICEREQUEST_UTIL.validate_owner
475         ( p_api_name             => NULL
476         , p_parameter_name       => 'owner id'
477         , p_owner_id             => p_sr_rec.owner_id
478         , p_group_type           => p_sr_rec.group_type
479         , p_owner_group_id       => p_sr_rec.owner_group_id
480         , p_org_id               => NULL -- not used in validation
481         , p_incident_type_id     => p_sr_rec.type_id
482         , p_mode                 => p_mode
483         , x_owner_name           => l_owner_name
484         , x_owner_id             => l_owner_id
485         , x_resource_type        => p_sr_rec.resource_type
486         , x_support_site_id      => p_sr_rec.site_id
487         , x_return_status        => l_return_status
488         );
489         IF l_return_status <> FND_API.G_RET_STS_SUCCESS
490         THEN
491           x_return_status := FND_API.G_RET_STS_ERROR;
492           RETURN;
493         END IF;
494         IF p_mode = 'CREATE'
495         THEN
496           p_sr_rec.owner_id := l_owner_id;
497         END IF;
498       END IF;
499     END IF;
500     --
501     -- Contract Service Id Validation
502     --
503     IF p_sr_rec.contract_service_id IS NOT NULL
504     THEN
505       IF p_sr_rec.contract_service_id         <> NVL(p_old_contract_service_id,-9) OR
506          NVL(p_sr_rec.type_id            ,-9) <> NVL(p_old_incident_type_id   ,-9) OR
507          NVL(p_sr_rec.system_id          ,-9) <> NVL(p_old_system_id          ,-9) OR
508          NVL(p_sr_rec.account_id         ,-9) <> NVL(p_old_account_id         ,-9) OR
509          NVL(p_sr_rec.contract_id        ,-9) <> NVL(p_old_contract_id        ,-9) OR
510          NVL(p_sr_rec.install_site_id    ,-9) <> NVL(p_old_install_site_id    ,-9) OR
511          NVL(p_sr_rec.inventory_item_id  ,-9) <> NVL(p_old_inventory_item_id  ,-9) OR
512          NVL(p_sr_rec.customer_product_id,-9) <> NVL(p_old_customer_product_id,-9)
513       THEN
514 	CS_SERVICEREQUEST_UTIL.Validate_Contract_Service_Id
515         ( p_api_name            => l_api_name
516         , p_parameter_name      => 'p_contract_service_id'
517         , p_contract_service_id => p_sr_rec.contract_service_id
518         , x_contract_id         => p_sr_rec.contract_id
519         , x_contract_number     => x_contract_number
520         , x_return_status       => l_return_status
521         );
522         IF l_return_status <> FND_API.G_RET_STS_SUCCESS
523         THEN
524           l_contract_service_id_valid := 'N';
525         ELSE
526           CS_SERVICEREQUEST_UTIL.contracts_cross_val
527           ( p_parameter_name        => 'contract_service_id'
528           , p_contract_service_id   => p_sr_rec.contract_service_id
529           , p_busiproc_id           => p_sr_related_data.business_process_id
530           , p_request_date          => p_sr_rec.request_date
531           , p_inventory_item_id     => p_sr_rec.inventory_item_id
532           , p_inv_org_id            => p_sr_rec.inventory_org_id
533           , p_install_site_id       => p_sr_rec.install_site_id
534           , p_customer_product_id   => p_sr_rec.customer_product_id
535           , p_account_id            => p_sr_rec.account_id
536           , p_customer_id           => p_sr_rec.customer_id
537 	  , p_system_id             => p_sr_rec.system_id
538           , x_return_status         => l_return_status
539           );
540           IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
541           THEN
542 	    l_contract_service_id_valid := 'N';
543 	    p_sr_rec.contract_id        := NULL;
544 	    x_contract_number           := NULL;
545           END IF;
546         END IF; -- end of else after validate_contract_service_id procedure
547       END IF;  --  Some of contract related attributes changes
548     END IF;  -- Check for contract service id is not null
549     --
550     --
551     --
552   END IF; -- check on validation level parameter
553   --
554   -- Get Default contract
555   --
556   IF (p_default_contract_sla_ind = 'Y')
557   THEN
558     IF p_sr_rec_inp.obligation_date     = FND_API.G_MISS_DATE AND
559        p_sr_rec_inp.exp_resolution_date = FND_API.G_MISS_DATE AND
560        p_sr_rec_inp.contract_id         = FND_API.G_MISS_NUM  AND
561        p_sr_rec_inp.contract_service_id = FND_API.G_MISS_NUM  AND
562        ( p_mode = 'CREATE' OR
563           (l_contract_service_id_valid = 'N' OR
564              (p_old_obligation_date          IS NULL AND
565               p_old_expected_resolution_date IS NULL AND
566               p_old_contract_id              IS NULL AND
567               p_old_contract_service_id      IS NULL
568              ) OR
569              ( p_old_contract_service_id IS NULL AND
570                (NVL(p_sr_rec.install_site_id,-9)     <> NVL(p_old_install_site_id,-9)     OR
571                 NVL(p_sr_rec.system_id,-9)           <> NVL(p_old_system_id,-9)           OR
572                 NVL(p_sr_rec.account_id,-9)          <> NVL(p_old_account_id,-9)          OR
573                 NVL(p_sr_rec.inventory_item_id,-9)   <> NVL(p_old_inventory_item_id,-9)   OR
574                 NVL(p_sr_rec.customer_product_id,-9) <> NVL(p_old_customer_product_id,-9) OR
575                 NVL(p_sr_rec.type_id,-9)             <> NVL(p_old_incident_type_id,-9)    OR
576                 NVL(p_sr_rec.time_zone_id,-9)        <> NVL(p_old_time_zone_id,-9)        OR
577                 NVL(p_sr_rec.severity_id,-9)         <> NVL(p_old_incident_severity_id,-9)
578                )
579              )
580           )
581        )
582     THEN
583       l_contract_defaulted        := 'Y';
584 
585       --12.1.2 siahmed changes for the
586       -- Provide option to start SLA calculations during default contract processing
587       --Bug 9905665 ,Profile name CS_SR_SLA_CALCULATE_DATE is incorrect.
588       -- The correct profile name is CS_SR_SLA_CAL_DATE
589       IF (fnd_profile.value('CS_SR_SLA_CAL_DATE') = 'CREATED_ON_DATE') THEN
590         l_request_date := p_sr_rec.creation_date;
591       ELSE
592         l_request_date := p_sr_rec.request_date;
593       END IF;
594       -- end of addition siahmed and added the value in the api call below before it was passing p_sr_rec.request_date directly.
595 
596       CS_SERVICEREQUEST_PVT.get_default_contract
597       ( p_business_process_id       => p_sr_related_data.business_process_id
598       , p_customer_id               => p_sr_rec.customer_id
599       , p_install_site_use_id       => p_sr_rec.install_site_use_id
600       , p_account_id                => p_sr_rec.account_id
601       , p_system_id                 => p_sr_rec.system_id
602       , p_inventory_item_id         => p_sr_rec.inventory_item_id
603       , p_customer_product_id       => p_sr_rec.customer_product_id
604       , p_request_date              => l_request_date
605       , p_incident_occurred_date    => p_sr_rec.incident_occurred_date
606       , p_severity_id               => p_sr_rec.severity_id
607       , p_time_zone_id              => p_sr_rec.time_zone_id
608       , p_incident_location_type    => p_sr_rec.incident_location_type
609       , p_incident_location_id      => p_sr_rec.incident_location_id
610       , p_primary_contact_party_id  => p_sr_related_data.primary_party_id
611       , p_primary_contact_point_id  => p_sr_related_data.primary_contact_point_id
612       , p_incident_id               => p_request_id
613       , p_default_coverage_template_id => p_default_coverage_template_id
614       , x_return_status             => x_return_status
615       , x_contract_id               => p_sr_rec.contract_id
616       , x_contract_number           => x_contract_number
617       , x_contract_service_id       => p_sr_rec.contract_service_id
618       , x_exp_resolution_date       => p_sr_rec.exp_resolution_date
619       , x_obligation_date           => p_sr_rec.obligation_date
620       ) ;
621       IF ( x_return_status <> FND_API.G_RET_STS_SUCCESS )
622       THEN
623         RAISE FND_API.G_EXC_ERROR;
624       END IF;
625       IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
626       THEN
627         FND_LOG.String
628         ( FND_LOG.level_procedure , L_LOG_MODULE || ''
629         , 'The defaulted value of parameter contra_id :' || p_sr_rec.contract_id
630         );
631         FND_LOG.String
632         ( FND_LOG.level_procedure , L_LOG_MODULE || ''
633         , 'The defaulted value of parameter contract_number :' || x_contract_number
634         );
635         FND_LOG.String
636         ( FND_LOG.level_procedure , L_LOG_MODULE || ''
637         , 'The defaulted value of parameter contract_service_id :' || p_sr_rec.contract_service_id
638         );
639         FND_LOG.String
640         ( FND_LOG.level_procedure , L_LOG_MODULE || ''
641         , 'The defaulted value of parameter exp_resolution_date :' || p_sr_rec.exp_resolution_date
642         );
643         FND_LOG.String
644         ( FND_LOG.level_procedure , L_LOG_MODULE || ''
645         , 'The defaulted value of parameter obligation_date :' || p_sr_rec.obligation_date
646         );
647       END IF; -- check of FND_LOG.level_procedure
648       IF p_old_contract_service_id IS NOT NULL AND
649          NVL(p_sr_rec.contract_service_id,-99) <> p_old_contract_service_id
650       THEN
651         FND_MESSAGE.SET_NAME('CS','CS_SR_CONTRACT_ASSIGN_CHANGED');
652         FND_MSG_PUB.ADD_DETAIL(p_message_type=>FND_MSG_PUB.G_INFORMATION_MSG);
653       END IF ;
654     END IF; -- contract service or related attributes are null
655      -- move the above part to get_default_contract
656   END IF;  -- if default contrct sla ind is 'Y'
657   IF l_contract_service_id_valid <> 'Y' AND
658      l_contract_defaulted <> 'Y'
659   THEN
660     FND_MESSAGE.set_name ('CS', 'CS_SR_CONTRACT_INVALID');
661     FND_MESSAGE.set_token('API_NAME', 'CS_SERVICEREQUEST_UTIL.contracts_cross_val' );
662     FND_MSG_PUB.add;
663     RAISE FND_API.G_EXC_ERROR;
664   END IF;
665   -- End of Default contract SLA processing
666   --
667   -- Get Coverage Type
668   --
669   IF p_sr_rec.contract_service_id IS NOT NULL
670   THEN
671     IF p_validation_level > FND_API.G_VALID_LEVEL_NONE   OR
672        (p_validation_level = FND_API.G_VALID_LEVEL_NONE  AND
673         p_sr_rec.coverage_type IS NULL)
674     THEN
675       OKS_ENTITLEMENTS_PUB.Get_Coverage_Type
676       ( p_api_version      => 2.0
677       , p_init_msg_list    => FND_API.G_FALSE
678       , p_contract_line_id => p_sr_rec.contract_service_id
679       , x_return_status    => l_return_status
680       , x_msg_count        => l_msg_count
681       , x_msg_data         => l_msg_data
682       , x_coverage_type    => coverage_type_rec
683       );
684       IF l_return_status <> FND_API.G_RET_STS_SUCCESS
685       THEN
686         RAISE FND_API.G_EXC_ERROR;
687       END IF;
688       IF coverage_type_rec.code IS NOT NULL AND
689          coverage_type_rec.code <> FND_API.G_MISS_CHAR
690       THEN
691         p_sr_rec.coverage_type := coverage_type_rec.code ;
692       END IF ;
693     END IF ;
694   END IF;
695   --
696   -- Start of owner assignment to service request
697   --
698   IF p_auto_assign NOT IN ('Y','N','y','n')
699   THEN
700     FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_AUTOASSIGN_PARAM');
701     FND_MESSAGE.Set_Token('API_NAME', l_api_name);
702     FND_MSG_PUB.ADD;
703   END IF;
704   IF p_sr_rec.owner_id IS NULL AND
705      LOWER(p_auto_assign) = 'y' AND
706      NVL(p_sr_related_data.old_disallow_request_update,'N') = 'N'
707   THEN
708     l_auto_assign_level := fnd_profile.value('CS_SR_OWNER_AUTO_ASSIGN_LEVEL');
709     -- For bug 3702091 - AM API should not be called even if the Auto Assignment is ON
710     -- and the Assignment level is Group and Owner is passed
711     IF ((l_auto_assign_level = 'INDIVIDUAL' AND NVL(p_sr_related_data.old_disallow_owner_update,'N') = 'N') OR
712         (l_auto_assign_level = 'GROUP'      AND p_sr_rec.owner_group_id is null))
713     THEN
714       p_sr_rec.load_balance := 'Y';
715       p_sr_rec.assign_owner := 'Y';
716       IF p_sr_rec.group_type IS NULL
717       THEN
718         p_sr_rec.group_type    := 'RS_GROUP';
719         l_orig_group_type_null := 'Y';
720       END IF;
721       CS_Assign_Resource_PKG.Assign_ServiceRequest_Main
722       ( p_api_name              => 'Assign_ServiceRequest_Main'
723       , p_api_version           => 1.0
724       , p_init_msg_list         => fnd_api.g_false
725       , p_commit                => fnd_api.g_false
726       , p_incident_id           => p_request_id
727       , p_object_version_number => p_object_version_number
728       , p_last_updated_by       => p_last_updated_by
729       , p_service_request_rec   => p_sr_rec
730       , x_owner_id              => l_asgn_owner_id
731       , x_owner_type            => l_asgn_resource_type
732       , x_territory_id          => l_territory_id
733       , x_return_status         => l_return_status
734       , x_msg_count             => l_msg_count
735       , x_msg_data              => l_msg_data
736       , x_owner_group_id        => l_asgn_owner_group_id
737       );
738       IF l_return_status <> FND_API.G_RET_STS_SUCCESS
739       THEN
740         FND_MSG_PUB.Count_And_Get
741         ( p_count => l_msg_count
742         , p_data  => l_msg_data
743         );
744         IF (l_orig_group_type_null = 'Y') then
745           p_sr_rec.group_type := NULL;
746         END IF;
747       ELSE
748         IF l_asgn_owner_group_id IS NOT NULL AND
749            NVL(p_sr_rec.owner_group_id,-1) <> l_asgn_owner_group_id
750         THEN
751           p_sr_rec.owner_group_id := l_asgn_owner_group_id;
752           IF p_sr_rec.group_type IS NULL
753           THEN
754             p_sr_rec.group_type := 'RS_GROUP';
755             -- this is needed otherwise combination of group id and group type will
756             -- becomes invalid 12/9/03 smisra
757           END IF;
758         END IF;
759         IF l_asgn_owner_id IS NOT NULL AND
760            NVL(p_sr_rec.owner_id,-1) <> l_asgn_owner_id
761         THEN
762           p_sr_rec.owner_id      := l_asgn_owner_id;
763           p_sr_rec.resource_type := l_asgn_resource_type;
764         END IF;
765         -- Add information message if AM API does not return anything
766         IF l_asgn_owner_group_id IS NULL AND l_asgn_owner_id IS NULL
767         THEN
768           FND_MESSAGE.Set_Name('CS', 'CS_SR_AM_API_RETURNED_NULL');
769           FND_MESSAGE.Set_Token('API_NAME', l_api_name);
770           FND_MSG_PUB.ADD;
771         END IF;
772         p_sr_rec.territory_id := l_territory_id;
773       END IF; -- AM API returned with success
774     END IF; -- is call to assign_servicerequest needed?
775   END IF; -- if p_auto_assign is 'Y'
776   --
777   --
778   --
779 EXCEPTION
780   WHEN FND_API.G_EXC_ERROR THEN
781     x_return_status := FND_API.G_RET_STS_ERROR;
782   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
783     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
784   WHEN OTHERS THEN
785     x_return_status             := FND_API.G_RET_STS_UNEXP_ERROR;
786     FND_MESSAGE.set_name ('CS', 'CS_API_SR_UNKNOWN_ERROR');
787     FND_MESSAGE.set_token
788     ('P_TEXT'
789     , 'CS_SERVICEREQUEST_UTIL.vldt_sr_rec'||'-'||SQLERRM
790     );
791     FND_MSG_PUB.ADD;
792 END vldt_sr_rec;
793 --============================================================================
794 -- PROCEDURE : set_time_zone        PRIVATE
795 -- PARAMETERS: p_contact_party_id   Contact party
796 --           : p_contact_point_type it could PHONE or EMAIL
797 --           : p_contact_point_id   primary key to hz_contact_points
798 --           : p_incident_id        primary key to incidents table
799 -- COMMENT   : This procedure will determine timezone based on primary contact's
800 --           : phone or identifying address and update incidents table
801 --           : If no timezone is found then incidents table is not updated
802 -- PRE-COND  : contact party and contact point type, contact point id and incident
803 --           : id must be valid
804 -- EXCEPTIONS: None
805 --============================================================================
806 PROCEDURE set_time_zone(p_contact_party_id              NUMBER,
807                         p_contact_point_type            VARCHAR2,
808                         p_contact_point_id              NUMBER,
809                         p_incident_id                   NUMBER) IS
810   CURSOR c_phone_timezone IS
811     SELECT
812       timezone_id
813     FROM
814       hz_contact_points
815     WHERE contact_point_id = p_contact_point_id;
816 
817   CURSOR c_addr_timezone IS
818     SELECT
819       loc.timezone_id
820     FROM
821       hz_party_sites site
822     , hz_locations loc
823     WHERE site.location_id              = loc.location_id
824       AND site.party_id                 = p_contact_party_id
825       AND site.identifying_address_flag = 'Y'
826       AND site.status                   = 'A';
827   l_timezone_id NUMBER;
828 BEGIN
829   l_timezone_id := null;
830   IF (p_contact_point_type = 'PHONE') THEN
831     OPEN c_phone_timezone;
832     FETCH c_phone_timezone INTO l_timezone_id;
833     IF (c_phone_timezone % NOTFOUND)
834     THEN
835       l_timezone_id := null;
836     END IF;
837     CLOSE c_phone_timezone;
838   END IF;
839   --
840   -- either primary contact point type is not a phone or no timezone is
841   -- associated with primary phone. So get it from primary contact's
842   -- identifying address.`
843   --
844   IF (l_timezone_id IS NULL)
845   THEN
846     OPEN c_addr_timezone;
847     FETCH c_addr_timezone INTO l_timezone_id;
848     IF (c_addr_timezone % NOTFOUND)
849     THEN
850       l_timezone_id := null;
851     END IF;
852     CLOSE c_addr_timezone;
853   END IF;
854   --
855   -- update incidents table only if timezone is found
856   --
857   IF (l_timezone_id IS NOT NULL)
858   THEN
859     UPDATE CS_INCIDENTS_ALL_B
860        SET time_zone_id = l_timezone_id
861      WHERE incident_id  = p_incident_id;
862   END IF;
863 
864   EXCEPTION
865     WHEN OTHERS THEN
866       NULL;
867 END set_time_zone;
868 --
869 -- This procedure is defined only in body
870 -- if x_new_value is g_miss_char then x_new_value is set to p_old_value
871 PROCEDURE handle_missing_value(x_new_value in out nocopy varchar2,
872                                p_old_value in            varchar2);
873 -- Added dj
874 -- Local procedure to get the business usage of the responsibility that is
875 -- attempting to create/update the SR.
876 PROCEDURE GET_BUSINESS_USAGE (
877    p_responsibility_id     IN           NUMBER,
878    p_application_id        IN           NUMBER,
879    x_business_usage        OUT  NOCOPY  VARCHAR2 )
880 IS
881 BEGIN
882    select business_usage
883    into   x_business_usage
884    from   cs_service_responsibility
885    where  responsibility_id = p_responsibility_id
886    and    application_id    = p_application_id;
887 
888 EXCEPTION
889    when others then
890       x_business_usage := NULL;
891 END GET_BUSINESS_USAGE;
892 
893 -- Local procedure to get the attribute that indicates if security is enabled
894 -- for self service responsibilities
895 PROCEDURE GET_SS_SEC_ENABLED (
896    x_ss_sr_type_restrict      OUT  NOCOPY  VARCHAR2 )
897 IS
898 BEGIN
899    select ss_srtype_restrict
900    into   x_ss_sr_type_restrict
901    from   cs_system_options;
902 EXCEPTION
903    when others then
904       x_ss_sr_type_restrict := NULL;
905 END GET_SS_SEC_ENABLED;
906 
907 PROCEDURE Create_SR_Validation
908 ( p_api_name             IN      VARCHAR2,
909   p_service_request_rec  IN      service_request_rec_type,
910   p_contacts             IN      contacts_table,
911   p_resp_id              IN      NUMBER    DEFAULT NULL,
912   p_resp_appl_id         IN      NUMBER    DEFAULT NULL,
913   p_user_id              IN      NUMBER,
914   p_login_id             IN      NUMBER    DEFAULT NULL,
915   p_org_id               IN      NUMBER    DEFAULT NULL,
916   p_request_id           IN      NUMBER    DEFAULT NULL,
917   p_request_number       IN      VARCHAR2  DEFAULT NULL,
918   p_validation_level     IN      NUMBER    DEFAULT fnd_api.g_valid_level_full,
919   p_commit               IN      VARCHAR2  DEFAULT fnd_api.g_false,
920   x_msg_count            OUT     NOCOPY NUMBER,
921   x_msg_data             OUT     NOCOPY VARCHAR2,
922   x_return_status        OUT     NOCOPY VARCHAR2,
923   x_contra_id            OUT     NOCOPY NUMBER,
924   x_contract_number      OUT     NOCOPY VARCHAR2,
925   x_owner_assigned_flag  OUT     NOCOPY VARCHAR2,
926   x_req_id               OUT     NOCOPY NUMBER,
927   x_request_id           OUT     NOCOPY NUMBER,
928   x_req_num              OUT     NOCOPY VARCHAR2,
929   x_request_number       OUT     NOCOPY VARCHAR2,
930   x_autolaunch_wkf_flag  OUT     NOCOPY VARCHAR2,
931   x_abort_wkf_close_flag OUT     NOCOPY VARCHAR2,
932   x_wkf_process_name     OUT     NOCOPY VARCHAR2,
933   x_audit_vals_rec	 OUT	 NOCOPY	sr_audit_rec_type,
934   x_service_request_rec  OUT     NOCOPY service_request_rec_type,
935   p_cmro_flag            IN     VARCHAR2,
936   p_maintenance_flag     IN     VARCHAR2,
937   p_auto_assign           IN     VARCHAR2 := 'N',
938   --15995804. Add price_list_header_id
939   p_price_list_header_id  IN     NUMBER
940 );
941 
942 
943 PROCEDURE Update_SR_Validation
944 ( p_api_version           IN     VARCHAR2,
945   p_init_msg_list         IN     VARCHAR2 DEFAULT fnd_api.g_false,
946   p_service_request_rec   IN     service_request_rec_type,
947   p_invocation_mode       IN     VARCHAR2 := 'NORMAL',
948   p_notes                 IN     notes_table,
949   p_contacts              IN     contacts_table,
950   p_audit_comments        IN     VARCHAR2 DEFAULT NULL,
951   p_resp_id               IN     NUMBER    DEFAULT NULL,
952   p_resp_appl_id          IN     NUMBER    DEFAULT NULL,
953   p_request_id            IN     NUMBER,
954   p_validation_level      IN     NUMBER    DEFAULT fnd_api.g_valid_level_full,
955   p_commit                IN     VARCHAR2  DEFAULT fnd_api.g_false,
956   p_last_updated_by       IN     NUMBER,
957   p_last_update_login     IN     NUMBER    DEFAULT NULL,
958   p_last_update_date      IN     DATE,
959   p_object_version_number IN     NUMBER,
960   x_return_status         OUT    NOCOPY VARCHAR2,
961   x_contra_id             OUT    NOCOPY NUMBER,
962   x_contract_number       OUT    NOCOPY VARCHAR2,
963   x_owner_assigned_flag   OUT    NOCOPY VARCHAR2,
964   x_msg_count             OUT    NOCOPY NUMBER,
965   x_msg_data              OUT    NOCOPY VARCHAR2,
966   x_audit_vals_rec	  OUT	 NOCOPY	sr_audit_rec_type,
967   x_service_request_rec   OUT    NOCOPY service_request_rec_type,
968   x_autolaunch_wkf_flag   OUT    NOCOPY VARCHAR2,
969   x_abort_wkf_close_flag  OUT    NOCOPY VARCHAR2,
970   x_wkf_process_name      OUT    NOCOPY VARCHAR2,
971   x_workflow_process_id   OUT    NOCOPY NUMBER,
972   x_interaction_id        OUT    NOCOPY NUMBER,
973   p_update_desc_flex      IN     VARCHAR2  DEFAULT fnd_api.g_false,
974   p_called_by_workflow    IN     VARCHAR2  DEFAULT fnd_api.g_false,
975   p_workflow_process_id   IN     NUMBER    DEFAULT NULL,
976   p_cmro_flag             IN     VARCHAR2,
977   p_maintenance_flag      IN     VARCHAR2,
978   p_auto_assign           IN     VARCHAR2 := 'N'
979 );
980 
981 PROCEDURE Validate_ServiceRequest_Record
982 ( p_api_name                IN  VARCHAR2,
983   p_service_request_rec     IN  Request_Validation_Rec_Type,
984   p_request_date            IN  DATE                := FND_API.G_MISS_DATE,
985   p_org_id                  IN  NUMBER              := NULL,
986   p_resp_appl_id            IN  NUMBER              := NULL,
987   p_resp_id                 IN  NUMBER              := NULL,
988   p_user_id                 IN  NUMBER              := NULL,
989   p_operation               IN  VARCHAR2            := NULL,
990   p_close_flag              OUT NOCOPY VARCHAR2,
991   p_disallow_request_update OUT NOCOPY VARCHAR2,
992   p_disallow_owner_update   OUT NOCOPY VARCHAR2,
993   p_disallow_product_update OUT NOCOPY VARCHAR2,
994   p_employee_name   	    OUT NOCOPY VARCHAR2,
995   p_inventory_item_id       OUT NOCOPY NUMBER,
996   p_contract_id             OUT NOCOPY NUMBER,
997   p_contract_number         OUT NOCOPY VARCHAR2,
998   x_bill_to_site_id         OUT NOCOPY NUMBER,
999   x_ship_to_site_id         OUT NOCOPY NUMBER,
1000   x_bill_to_site_use_id     OUT NOCOPY NUMBER,
1001   x_ship_to_site_use_id     OUT NOCOPY NUMBER,
1002   x_return_status   	    OUT NOCOPY VARCHAR2,
1003   x_group_name              OUT NOCOPY VARCHAR2,
1004   x_owner_name              OUT NOCOPY VARCHAR2,
1005   x_product_revision        OUT NOCOPY VARCHAR2,
1006   x_component_version       OUT NOCOPY VARCHAR2,
1007   x_subcomponent_version    OUT NOCOPY VARCHAR2,
1008   p_cmro_flag               IN  VARCHAR2,
1009   p_maintenance_flag        IN  VARCHAR2,
1010   p_sr_mode                 IN  VARCHAR2
1011 );
1012 
1013 
1014 FUNCTION Get_Importance_Level(P_Severity_Id IN NUMBER) RETURN NUMBER;
1015 
1016 FUNCTION Get_Old_Importance_level(p_incident_id IN NUMBER) RETURN NUMBER;
1017 
1018 FUNCTION Get_Title(P_Object_Code IN VARCHAR2) RETURN VARCHAR2;
1019 
1020 FUNCTION Get_Message(p_message_code IN VARCHAR2) RETURN VARCHAR2;
1021 
1022 FUNCTION Get_Owner_id(p_incident_id IN NUMBER) RETURN NUMBER;
1023 
1024 --------------------------------------------------------------------------
1025 -- Procedure Log_SR_PVT_Parameters
1026 -- Description:
1027 --   This procedure used to log the parameters of service_request_type_rec,
1028 --   Notes table and the Contacts table
1029 --   This procedure is only going to be called from the Create_ServiceRequest
1030 --   and Update_ServiceRequest procedure.
1031 --------------------------------------------------------------------------
1032 
1033  PROCEDURE Log_SR_PVT_Parameters
1034 ( p_service_request_rec   	  IN         service_request_rec_type
1035 ,p_notes                 	  IN         notes_table
1036 ,p_contacts              	  IN         contacts_table
1037 );
1038 
1039 ----------------anmukher--------------07/31/03
1040 -- Overloaded procedure added for backward compatibility in 11.5.10
1041 -- since several new OUT parameters have been added to the 11.5.9 signature
1042 -- in the form of a new record type, sr_create_out_rec_type
1043 PROCEDURE Create_ServiceRequest
1044   ( p_api_version            IN    NUMBER,
1045     p_init_msg_list          IN    VARCHAR2 DEFAULT fnd_api.g_false,
1046     p_commit                 IN    VARCHAR2 DEFAULT fnd_api.g_false,
1047     p_validation_level       IN    NUMBER   DEFAULT fnd_api.g_valid_level_full,
1048     x_return_status          OUT   NOCOPY VARCHAR2,
1049     x_msg_count              OUT   NOCOPY NUMBER,
1050     x_msg_data               OUT   NOCOPY VARCHAR2,
1051     p_resp_appl_id           IN    NUMBER   DEFAULT NULL,
1052     p_resp_id                IN    NUMBER   DEFAULT NULL,
1053     p_user_id                IN    NUMBER,
1054     p_login_id               IN    NUMBER   DEFAULT NULL,
1055     p_org_id                 IN    NUMBER   DEFAULT NULL,
1056     p_request_id             IN    NUMBER   DEFAULT NULL,
1057     p_request_number         IN    VARCHAR2 DEFAULT NULL,
1058     p_invocation_mode        IN    VARCHAR2 := 'NORMAL',
1059     p_service_request_rec    IN    service_request_rec_type,
1060     p_notes                  IN    notes_table,
1061     p_contacts               IN    contacts_table,
1062   -- Added for Assignment Manager 11.5.9 change
1063   p_auto_assign                   IN      VARCHAR2  Default 'N',
1064   p_default_contract_sla_ind      IN      VARCHAR2 Default 'N',
1065   x_request_id			  OUT     NOCOPY NUMBER,
1066   x_request_number		  OUT     NOCOPY VARCHAR2,
1067   x_interaction_id                OUT     NOCOPY NUMBER,
1068   x_workflow_process_id           OUT     NOCOPY NUMBER,
1069   -- These 3 parameters are added for Assignment Manager 115.9 changes.
1070   x_individual_owner              OUT   NOCOPY NUMBER,
1071   x_group_owner                   OUT   NOCOPY NUMBER,
1072   x_individual_type               OUT   NOCOPY VARCHAR2
1073  )
1074 IS
1075   l_api_version        CONSTANT NUMBER          := 3.0;
1076   l_api_name           CONSTANT VARCHAR2(30)    := 'Create_ServiceRequest';
1077   l_api_name_full      CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
1078   l_return_status               VARCHAR2(1);
1079   -- Added for making call to 11.5.10 signature of Create SR private API
1080   l_sr_create_out_rec	sr_create_out_rec_type;
1081 BEGIN
1082   -- Standard start of API savepoint
1083   SAVEPOINT Create_ServiceRequest_PVT;
1084 
1085   -- Standard call to check for call compatibility
1086   IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
1087                                      G_PKG_NAME) THEN
1088     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1089   END IF;
1090 
1091   -- Initialize message list if p_init_msg_list is set to TRUE
1092   IF FND_API.To_Boolean(p_init_msg_list) THEN
1093     FND_MSG_PUB.Initialize;
1094   END IF;
1095 
1096   -- Initialize API return status to success
1097   x_return_status := FND_API.G_RET_STS_SUCCESS;
1098 
1099  CS_ServiceRequest_PVT.Create_ServiceRequest
1100     ( p_api_version                  => 4.0,
1101       p_init_msg_list                => fnd_api.g_false ,
1102       p_commit                       => p_commit,
1103       p_validation_level	     => p_validation_level,
1104       x_return_status                => l_return_status,
1105       x_msg_count                    => x_msg_count,
1106       x_msg_data                     => x_msg_data,
1107       p_resp_appl_id                 => p_resp_appl_id,
1108       p_resp_id                      => p_resp_id,
1109       p_user_id                      => p_user_id,
1110       p_login_id                     => p_login_id,
1111       p_org_id                       => p_org_id,
1112       p_request_id                   => p_request_id,
1113       p_request_number               => p_request_number,
1114       p_invocation_mode		     => p_invocation_mode,
1115       p_service_request_rec          => p_service_request_rec,
1116       p_notes                        => p_notes,
1117       p_contacts                     => p_contacts,
1118       p_auto_assign                  => p_auto_assign,
1119       p_auto_generate_tasks	     => 'N',
1120       p_default_contract_sla_ind     => p_default_contract_sla_ind,
1121       p_default_coverage_template_id => NULL,
1122       x_sr_create_out_rec      	     => l_sr_create_out_rec
1123     );
1124 
1125   x_return_status	:= l_return_status;
1126 
1127   x_request_id		:= l_sr_create_out_rec.request_id;
1128   x_request_number	:= l_sr_create_out_rec.request_number;
1129   x_interaction_id	:= l_sr_create_out_rec.interaction_id;
1130   x_workflow_process_id	:= l_sr_create_out_rec.workflow_process_id;
1131   x_individual_owner	:= l_sr_create_out_rec.individual_owner;
1132   x_group_owner		:= l_sr_create_out_rec.group_owner;
1133   x_individual_type	:= l_sr_create_out_rec.individual_type;
1134 
1135   IF (l_return_status = FND_API.G_RET_STS_ERROR) THEN
1136     RAISE FND_API.G_EXC_ERROR;
1137   ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
1138     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1139   END IF;
1140 
1141 EXCEPTION
1142   WHEN FND_API.G_EXC_ERROR THEN
1143     ROLLBACK TO Create_ServiceRequest_PVT;
1144     x_return_status := FND_API.G_RET_STS_ERROR;
1145     FND_MSG_PUB.Count_And_Get
1146       ( p_count => x_msg_count,
1147         p_data  => x_msg_data
1148       );
1149   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1150     ROLLBACK TO Create_ServiceRequest_PVT;
1151     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1152     FND_MSG_PUB.Count_And_Get
1153       ( p_count => x_msg_count,
1154         p_data  => x_msg_data
1155       );
1156   WHEN OTHERS THEN
1157     ROLLBACK TO Create_ServiceRequest_PVT;
1158     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1159     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1160       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
1161     END IF;
1162     FND_MSG_PUB.Count_And_Get
1163       ( p_count => x_msg_count,
1164         p_data  => x_msg_data
1165       );
1166 
1167 END Create_ServiceRequest;
1168 
1169 --------------------------------------------------------------------------
1170 -- Create_ServiceRequest
1171 --------------------------------------------------------------------------
1172 -- Modification History:
1173 -- Date     Name     Desc
1174 ---------- -------- ------------------------------------------------------------
1175 -- 04/29/05 smisra   removed contact point logic and replacd it with procedures
1176 --                   cs_srcontact_pkg.process to validate contact points and
1177 --                   cs_srcontact_pkg.create_update to insert or update
1178 --                   service request contact points
1179 -- 05/09/05 smisra   Added defaulting of org_id before call to
1180 --                   creat_sr_validation.
1181 --                   modified insert to cs_incidents_all_b and passed values for
1182 --                   columns org_id and maint_organization_id
1183 -- 05/27/05 smisra   Bug 4227769
1184 --                   Removed owner and group_owner columns from insert into
1185 --                   cs_incidents_all_tl table.
1186 -- 06/07/05 smisra   Release 12 changes
1187 --                   Raised error msg when maint_organization_id is passed for
1188 --                   Non EAM service requests
1189 --                   Raised error msg when maint_organization_id is NOT passed
1190 --                   for EAM SRs with customer product
1191 -- 07/11/05 smisra   Release 12 changes
1192 --                   Called  CS_TZ_GET_DETAILS_PVT.customer_preferred_time_zone
1193 --                   to get customer preferred time zone. This time zone is
1194 --                   passed to contract API
1195 --                   Modified call to cs_srcontact_pkg.process and received two
1196 --                   new parameters primary contact id and primary contact point
1197 --                   id
1198 --                   Moved contact point creation after SR audit creation so
1199 --                   that SR audit has audit for SR creation first then child
1200 --                   audit for contacts
1201 -- 07/21/05 smisra   Added code to set expected resolution and obligation dates
1202 --                   in audit record just before call to create audit rec
1203 --                   procedure. This was needed because call to get contract may
1204 --                   set these dates.
1205 -- 07/26/05 smisra   Added code to set expected resolution and obligation dates
1206 --                   modified create_servicerequest procedure and moved
1207 --                   check on value of maint_organization inside if
1208 --                   condition of p_validation_level so that this check
1209 --                   is not made when PVT API is called with validation
1210 --                   level NONE.
1211 -- 08/06/05 smisra   correct multi org OU name
1212 -- 08/03/05 smisra   Contract Time zone changes
1213 --                   passed incident_occurred_date, time_zone_id and
1214 --                   dates_in_input_tz to contract record.
1215 --                   Raised error if item_serial_number is passed to this proc
1216 -- 08/16/05 smisra   set last_update_program_code in audit record to
1217 --                   creation_program_code value
1218 -- 08/17/05 smisra   changed org id profile name from CS_SR_DEFAULT_MULTI_ORG_OU
1219 --                   to CS_SR_ORG_ID
1220 -- 10/03/05 smisra   moved create SR audit and create contact points call before
1221 --                   raising business events.
1222 -- 11/16/05 smisra   Set coverage_type of audit record using SR Rec column
1223 -- 12/14/05 smisra   Bug 4386870. Called vldt_sr_rec after create_sr_validation
1224 --                   set incident_country, incident_location_id and
1225 --                   incident_locatiomn_type attribute of audit record just-
1226 --                   before call to create audit
1227 -- 12/23/05 smisra   Bug 4894942, 4892782
1228 --                   1. Called get_incident_type_details if def contr sla is Y
1229 --                      because contract defaulting needs business process id
1230 --                   2. Passed additional parameters to vldt_sr_rec call
1231 --                   3. Removed the code to get coverage type. This code is
1232 --                      moved to vldt_sr_rec
1233 --                   4. Removed the code to default contract service id, Now
1234 --                      this code is part of vldt_sr_rec.
1235 --                   5. Removed the code to get SLA dates. Now this code is part
1236 --                      of get_default_contract procedure.
1237 --                   6. Added auditing of following attributes just before call
1238 --                      to create audit
1239 --                      a. resource_type
1240 --                      b. group_type
1241 --                      c. incident_owner_id
1242 --                      d. group_owner_id
1243 --                      e. owner_assigned_time
1244 --                      f. territory_id
1245 -- 12/30/05 smisra   Bug 4869065
1246 --                   Set site_id cols of audit record just before call to
1247 --                   create audit
1248 --------------------------------------------------------------------------------
1249 PROCEDURE Create_ServiceRequest
1250   ( p_api_version            IN    NUMBER,
1251     p_init_msg_list          IN    VARCHAR2 DEFAULT fnd_api.g_false,
1252     p_commit                 IN    VARCHAR2 DEFAULT fnd_api.g_false,
1253     p_validation_level       IN    NUMBER   DEFAULT fnd_api.g_valid_level_full,
1254     x_return_status          OUT   NOCOPY VARCHAR2,
1255     x_msg_count              OUT   NOCOPY NUMBER,
1256     x_msg_data               OUT   NOCOPY VARCHAR2,
1257     p_resp_appl_id           IN    NUMBER   DEFAULT NULL,
1258     p_resp_id                IN    NUMBER   DEFAULT NULL,
1259     p_user_id                IN    NUMBER,
1260     p_login_id               IN    NUMBER   DEFAULT NULL,
1261     p_org_id                 IN    NUMBER   DEFAULT FND_API.G_MISS_NUM,
1262     p_request_id             IN    NUMBER   DEFAULT NULL,
1263     p_request_number         IN    VARCHAR2 DEFAULT NULL,
1264     p_invocation_mode        IN    VARCHAR2 := 'NORMAL',
1265     p_service_request_rec    IN    service_request_rec_type,
1266     p_notes                  IN    notes_table,
1267     p_contacts               IN    contacts_table ,
1268     -- Added for Assignment Manager 11.5.9 change
1269     p_auto_assign            IN    VARCHAR2  DEFAULT 'N',
1270     --------------anmukher----------------------07/31/03
1271     -- Added for 11.5.10 projects (AutoTask, Miscellaneous ERs)
1272     p_auto_generate_tasks		IN		VARCHAR2 Default 'N',
1273     p_default_contract_sla_ind		IN		VARCHAR2 Default 'N',
1274     p_default_coverage_template_id	IN		NUMBER Default NULL,
1275     x_sr_create_out_rec			OUT NOCOPY	sr_create_out_rec_type
1276     ---------------anmukher----------------------08/07/03
1277     -- The following OUT parameters have been added to the record type sr_create_out_rec_type
1278     -- and have therefore been commented out. This will allow avoidance of future overloading
1279     -- if a new OUT parameter were to be needed, since it can be added to the same record type.
1280     -- x_request_id             OUT   NOCOPY NUMBER,
1281     -- x_request_number         OUT   NOCOPY VARCHAR2,
1282     -- x_interaction_id         OUT   NOCOPY NUMBER,
1283     -- x_workflow_process_id    OUT   NOCOPY NUMBER,
1284     -- These 3 parameters are added for Assignment Manager 115.9 changes.
1285     -- x_individual_owner       OUT   NOCOPY NUMBER,
1286     -- x_group_owner            OUT   NOCOPY NUMBER,
1287     -- x_individual_type        OUT   NOCOPY VARCHAR2
1288   )
1289   IS
1290      l_api_name                   CONSTANT VARCHAR2(30)    := 'Create_ServiceRequest';
1291 -- changed the version from 3.0 to 4.0 anmukher aug 11 2003
1292      l_api_version                CONSTANT NUMBER          := 4.0;
1293      l_api_name_full              CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
1294      l_log_module         CONSTANT VARCHAR2(255)   := 'cs.plsql.' || l_api_name_full || '.';
1295      l_return_status              VARCHAR2(1);
1296 ---  AUDIT
1297      l_audit_vals_rec		      sr_audit_rec_type;
1298      l_service_request_val_rec    Request_Validation_Rec_Type;
1299      l_service_request_rec        service_request_rec_type DEFAULT p_service_request_rec;
1300      x_service_request_rec        service_request_rec_type DEFAULT p_service_request_rec;
1301      l_transaction_type           CONSTANT VARCHAR2(61)    := G_PKG_NAME||'_'||l_api_name;
1302      l_message_revision           NUMBER;
1303      l_maintenance_mode           VARCHAR2(30);
1304      l_sr_contact_point_id        NUMBER DEFAULT NULL;
1305      l_contacts                   contacts_table := p_contacts;
1306      p_update_desc_flex           VARCHAR2(1);
1307      p_object_version_number      NUMBER;
1308      l_audit_id                   NUMBER;
1309      l_enqueue_number             VARCHAR2(64);
1310      -- Added for automatic assignment
1311      l_owner_assign_forms         VARCHAR2(1);
1312      l_owner_assign_html          VARCHAR2(1);
1313      l_load_balance_forms         VARCHAR2(1);
1314      l_load_balance_html          VARCHAR2(1);
1315      l_temp_owner_id              NUMBER;
1316      l_temp_owner_type            VARCHAR2(30);
1317      l_object_version_number      NUMBER;
1318      l_jtf_note_id                NUMBER ;
1319      l_owner_assigned_flag        VARCHAR2(1);
1320      l_employee_name              VARCHAR(240);
1321      l_contra_id                  NUMBER;
1322      l_contract_number            VARCHAR2(120);
1323      l_request_id                 NUMBER         := p_request_id;
1324      l_request_number             VARCHAR2(64)   := p_request_number;
1325      l_req_id                     NUMBER;
1326      l_req_num                    VARCHAR2(64);
1327      l_temp_id                    NUMBER;
1328      l_temp_num                   VARCHAR2(64);
1329 
1330      l_note_index                 BINARY_INTEGER;
1331      l_note_id                    NUMBER;
1332      l_note_context_id            NUMBER;
1333      l_notes_detail               VARCHAR2(32767);
1334      l_contact_index              BINARY_INTEGER;
1335 
1336      l_autolaunch_workflow_flag   VARCHAR2(1);
1337      l_abort_workflow_close_flag  VARCHAR2(1);
1338      l_workflow_process_name      VARCHAR2(30);
1339      l_workflow_process_id        NUMBER;
1340 
1341      l_org_id    NUMBER;
1342 
1343      l_interaction_id             NUMBER;
1344 
1345      l_bind_data_id               NUMBER;
1346 
1347      l_primary_contact_found      VARCHAR2(1) := 'N' ;
1348      l_contacts_passed            VARCHAR2(1) :=  'N';
1349 
1350      -- For Workflow Hook
1351      l_workflow_item_key         NUMBER;
1352 
1353      l_test  NUMBER;
1354 
1355     -- for UWQ message
1356      l_msg_id   NUMBER;
1357      l_msg_count    NUMBER;
1358      l_msg_data   VARCHAR2(2000);
1359 
1360      --Fixed bug#2802393, changed length from 255 to 2500
1361      l_uwq_body  VARCHAR2(2500);
1362      l_imp_level  NUMBER;
1363      --Fixed bug#2802393, changed length from 30 to 80
1364      l_title VARCHAR2(80);
1365      l_send_uwq_notification BOOLEAN := FALSE;
1366      --Fixed bug#2802393, changed length from 40 to 2000
1367      l_uwq_body1 VARCHAR2(2000);
1368      p_uwq_msg_notification  VARCHAR2(30) :='CS_SR_UWQ_NOTIFICATION';
1369 
1370 --     l_coverage_type_rec    coverage_type_rec; ---- PKESANI
1371      Auto_Assign_Excep            EXCEPTION;
1372 	 invalid_install_site		  EXCEPTION;
1373    -- Added for enh. 2655115
1374      l_status_flag                VARCHAR2(1);
1375 
1376    -- Added for enh. 2690787
1377    l_primary_contact            NUMBER;
1378 
1379    -- Added to be used as OUT parameters in the call to the Business Events wrapper
1380    -- API.
1381    lx_return_status              VARCHAR2(3);
1382    lx_msg_count                  NUMBER(15);
1383    lx_msg_data                   VARCHAR2(2000);
1384 
1385    -- for cmro-eam; Local variable to store the eam/cmro type flags that
1386    -- will be used to populate the sr record type variable that is passed to the
1387    -- user hooks
1388    l_maintenance_flag           VARCHAR2(3):= l_service_request_rec.new_type_maintenance_flag;
1389    l_cmro_flag 			VARCHAR2(3):= l_service_request_rec.new_type_CMRO_flag;
1390     -- Changes for usability changes enh, 11.5.10 project
1391    l_responded_flag             VARCHAR2(1);
1392    l_resolved_flag              VARCHAR2(1);
1393 
1394    -- Added to be used as OUT parameter for calling CS_AutoGen_Task_PVT.Auto_Generate_Tasks API
1395    l_auto_task_gen_rec		CS_AutoGen_Task_PVT.auto_task_gen_rec_type;
1396    l_task_template_group_rec	JTF_TASK_INST_TEMPLATES_PUB.task_template_group_info;
1397    l_task_template_table	JTF_TASK_INST_TEMPLATES_PUB.task_template_info_tbl;
1398     -- Added for Misc ER :Owner auto assignment changes
1399        l_work_item_id             NUMBER;
1400 
1401    --Added for calling Auditing project of 11.5.10
1402    lx_audit_id			NUMBER;
1403 
1404    -- Added for 11.5.10 Misc ER : Default SLA (iSupport changes)
1405    px_inp_rec             OKS_ENTITLEMENTS_PUB.get_contin_rec;
1406    l_inp_rec              OKS_COV_ENT_PUB.gdrt_inp_rec_type;
1407    l_react_rec            OKS_COV_ENT_PUB.rcn_rsn_rec_type;
1408    l_resolve_rec          OKS_COV_ENT_PUB.rcn_rsn_rec_type;
1409    l_ent_contracts        OKS_ENTITLEMENTS_PUB.get_contop_tbl;
1410    Li_TableIdx BINARY_INTEGER;
1411 
1412    -- Added for API changes for unassigned_indicator
1413    l_unassigned_indicator NUMBER := 0 ;
1414 
1415    -- Local variable to store business usage for security validation
1416    l_business_usage       VARCHAR2(30);
1417 
1418    -- Local variable to store attribute if security is enabled for self service resps.
1419    l_ss_sr_type_restrict   VARCHAR2(10);
1420 
1421    -- local variable to get org_id of the SR
1422    l_inc_org_id            NUMBER ;
1423 
1424    -- local variable for  validate owner
1425    lx_owner_name           VARCHAR2(240);
1426    lx_owner_id             NUMBER;
1427    x_msg_index_out               NUMBER;
1428    l_auto_assign_level fnd_profile_option_values.profile_option_value % type;
1429 
1430   --  Local variable to store the request_id, to be passed to IEU procedure.
1431    q_request_id           NUMBER;
1432    l_note_status          VARCHAR2(3);
1433    l_old_contacts         contacts_table;
1434    l_processed_contacts   contacts_table;
1435    l_sr_related_data      RELATED_DATA_TYPE;
1436 
1437    lx_timezone_id             NUMBER;
1438    lx_timezone_name           VARCHAR2(80);
1439    l_primary_contact_party_id NUMBER := NULL;
1440    l_primary_contact_point_id NUMBER := NULL;
1441    l_hook_request_number		varchar2(64):=NULL; -- To be use to store the request number from pre hook
1442 
1443    --added by siahmed for onetime address creation
1444    l_incident_location_id    NUMBER;
1445    l_onetime_add_cnt         NUMBER;
1446    --end of addition by siahmed for onetime address creation
1447    --added for 12.2+ status
1448   l_project_info_status    VARCHAR2(2);
1449   --15995804. Adding price_list_header_id to user_hook Create_ServiceRequest_Pre
1450    l_price_list_header_id       NUMBER := NULL ;
1451 
1452 BEGIN
1453 
1454   -- Standard start of API savepoint
1455   SAVEPOINT Create_ServiceRequest_PVT;
1456 
1457   -- Standard call to check for call compatibility
1458   IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
1459                                      G_PKG_NAME) THEN
1460     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1461   END IF;
1462 
1463 -- Initialize message list if p_init_msg_list is set to TRUE
1464   IF FND_API.To_Boolean(p_init_msg_list) THEN
1465     FND_MSG_PUB.Initialize;
1466   END IF;
1467 
1468   IF ( l_service_request_rec.initialize_flag IS NULL OR
1469        l_service_request_rec.initialize_flag <> G_INITIALIZED) THEN
1470     RAISE FND_API.G_EXC_ERROR;
1471   END IF;
1472 
1473 ----------------------- FND Logging -----------------------------------
1474   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
1475   THEN
1476     FND_LOG.String
1477     ( FND_LOG.level_procedure , L_LOG_MODULE || 'start'
1478     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
1479     );
1480     FND_LOG.String
1481     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1482     , 'p_api_version:' || p_api_version
1483     );
1484     FND_LOG.String
1485     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1486     , 'p_init_msg_list:' || p_init_msg_list
1487     );
1488     FND_LOG.String
1489     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1490     , 'p_commit:' || p_commit
1491     );
1492     FND_LOG.String
1493     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1494     , 'p_resp_appl_id:' || p_resp_appl_id
1495     );
1496     FND_LOG.String
1497     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1498     , 'p_resp_id:' || p_resp_id
1499     );
1500     FND_LOG.String
1501     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1502     , 'p_user_id:' || p_user_id
1503     );
1504     FND_LOG.String
1505     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1506     , 'p_login_id:' || p_login_id
1507     );
1508     FND_LOG.String
1509     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1510     , 'p_org_id:' || p_org_id
1511     );
1512     FND_LOG.String
1513     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1514     , 'p_request_id:' || p_request_id
1515     );
1516     FND_LOG.String
1517     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1518     , 'p_request_number:' || p_request_number
1519     );
1520     FND_LOG.String
1521     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1522     , 'p_validation_level:' || p_validation_level
1523     );
1524     FND_LOG.String
1525     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1526     , 'p_invocation_mode:' || p_invocation_mode
1527     );
1528     FND_LOG.String
1529     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1530     , 'p_auto_assign:' || p_auto_assign
1531     );
1532     FND_LOG.String
1533     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1534     , 'p_auto_generate_tasks:' || p_auto_generate_tasks
1535     );
1536     FND_LOG.String
1537     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1538     , 'p_default_contract_sla_ind:' || p_default_contract_sla_ind
1539     );
1540     FND_LOG.String
1541     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1542     , 'p_default_coverage_template_id:' || p_default_coverage_template_id
1543     );
1544 
1545  -- --------------------------------------------------------------------------
1546  -- This procedure Logs the record paramters of SR and NOTES, CONTACTS tables.
1547  -- --------------------------------------------------------------------------
1548     Log_SR_PVT_Parameters
1549     ( p_service_request_rec   	=> p_service_request_rec
1550     , p_notes                 	=> p_notes
1551     , p_contacts              	=> p_contacts
1552     );
1553 
1554   END IF;
1555 
1556 
1557   IF l_service_request_rec.item_serial_number <> FND_API.G_MISS_CHAR
1558   THEN
1559     FND_MESSAGE.set_name ('CS', 'CS_SR_ITEM_SERIAL_OBSOLETE');
1560     FND_MESSAGE.set_token
1561     ( 'API_NAME'
1562     , 'CS_SERVICEREQUEST_PVT.create_servicerequest'
1563     );
1564     FND_MSG_PUB.ADD_DETAIL
1565     ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.ITEM_SERIAL_NUMBER'
1566     );
1567     RAISE FND_API.G_EXC_ERROR;
1568   END IF;
1569 
1570   -- Initialize API return status to success
1571   x_return_status := FND_API.G_RET_STS_SUCCESS;
1572 
1573 
1574    if ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) then
1575       -- First step is to validate if the current responsibility has access to the
1576       -- SR type being created. Invoke the VALIDATE_TYPE procedure that has the
1577       -- logic to check for security access
1578 
1579       -- Get the business usage of the responsibility that is attempting to create
1580       -- the SR.
1581       get_business_usage (
1582          p_responsibility_id      => p_resp_id,
1583          p_application_id         => fnd_global.resp_appl_id,
1584          x_business_usage         => l_business_usage );
1585 
1586       -- Get indicator of self service security enabled or not
1587       if ( l_business_usage = 'SELF_SERVICE' ) then
1588          get_ss_sec_enabled (
1589 	    x_ss_sr_type_restrict => l_ss_sr_type_restrict );
1590       end if;
1591 
1592       -- For bug 3370562 - pass resp_id an appl_id
1593       -- validate security in create
1594       cs_servicerequest_util.validate_type (
1595          p_parameter_name       => NULL,
1596          p_type_id   	        => p_service_request_rec.type_id,
1597          p_subtype  	        => G_SR_SUBTYPE,
1598          p_status_id            => p_service_request_rec.status_id,
1599          p_resp_id              => p_resp_id,
1600          p_resp_appl_id         => NVL(p_resp_appl_id,fnd_global.resp_appl_id),
1601          p_business_usage       => l_business_usage,
1602          p_ss_srtype_restrict   => l_ss_sr_type_restrict,
1603          p_operation            => 'CREATE',
1604          x_return_status        => lx_return_status,
1605          x_cmro_flag            => l_cmro_flag,
1606          x_maintenance_flag     => l_maintenance_flag );
1607 
1608       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
1609          -- security violation; responsibility does not have access to SR Type
1610          -- being created. Stop and raise error.
1611          RAISE FND_API.G_EXC_ERROR;
1612       end if;
1613 
1614    IF NVL(l_maintenance_flag,'N') <> 'Y'
1615    THEN
1616      IF p_service_request_rec.maint_organization_id <> FND_API.G_MISS_NUM
1617      THEN
1618        FND_MESSAGE.set_name ('CS', 'CS_SR_MAINT_ORG_NOT_ALLOWED');
1619        FND_MESSAGE.set_token
1620        ( 'API_NAME'
1621        , 'CS_SERVICEREQUEST_PVT.create_servicerequest'
1622        );
1623        FND_MSG_PUB.ADD_DETAIL
1624        ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.MAINT_ORGANIZATION_ID'
1625        );
1626        RAISE FND_API.G_EXC_ERROR;
1627      END IF;
1628    ELSE -- maintenance flag is 'Y'
1629      IF (p_service_request_rec.customer_product_id IS NOT NULL AND
1630          p_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM)
1631      THEN
1632        IF p_service_request_rec.maint_organization_id = FND_API.G_MISS_NUM
1633        THEN
1634          CS_ServiceRequest_UTIL.Add_Missing_Param_Msg(l_api_name_full, 'Maint_organization_id');
1635          RAISE FND_API.G_EXC_ERROR;
1636        ELSIF (p_service_request_rec.maint_organization_id IS NULL) THEN
1637          CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'Maint_organization_id');
1638          RAISE FND_API.G_EXC_ERROR;
1639        END IF;
1640      END IF;
1641    END IF;
1642    end if;   -- if ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) then
1643 
1644   -- Initialize the value of the parameter from profile cs_sr_restrict_ib
1645   -- by shijain 4th dec 2002
1646 
1647    g_restrict_ib:= fnd_profile.value('CS_SR_RESTRICT_IB');
1648 
1649   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
1650   THEN
1651     FND_LOG.String
1652     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1653     , 'The Value of profile CS_SR_RESTRICT_IB :' || g_restrict_ib
1654     );
1655   END IF;
1656   -- At present the call below in needed only for defaulting contract
1657   -- if type attributes are needed for some other purpose then the if condition
1658   -- can be modified accordingly
1659   IF p_default_contract_sla_ind = 'Y'
1660   THEN
1661     CS_SERVICEREQUEST_PVT.get_incident_type_details
1662     ( p_incident_type_id          => p_service_request_rec.type_id
1663     , x_business_process_id       => l_sr_related_data.business_process_id
1664     , x_autolaunch_workflow_flag  => l_sr_related_data.autolaunch_workflow_flag
1665     , x_abort_workflow_close_flag => l_sr_related_data.abort_workflow_close_flag
1666     , x_workflow                  => l_sr_related_data.workflow
1667     , x_return_status             => l_return_status
1668     );
1669     IF l_return_status = FND_API.G_RET_STS_ERROR
1670     THEN
1671       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
1672       ( p_token_an     => l_api_name_full
1673       , p_token_v      => TO_CHAR(p_service_request_rec.type_id)
1674       , p_token_p      => 'p_type_id'
1675       , p_table_name   => G_TABLE_NAME
1676       , p_column_name  => 'INCIDENT_TYPE_ID'
1677       );
1678       RAISE FND_API.G_EXC_ERROR;
1679     END IF;
1680 
1681     IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
1682     THEN
1683       FND_LOG.String
1684       ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1685       , 'The defaulted value of parameter business_process_id :'
1686       || l_sr_related_data.business_process_id
1687       );
1688     END IF;
1689   END IF;
1690 
1691   --
1692   -- Make the preprocessing call to the user hooks
1693   --
1694   -- Pre call to the Customer Type User Hook
1695   --
1696    IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
1697                                       'Create_ServiceRequest',
1698                                       'B', 'C')  THEN
1699 
1700 -- hardcoded the version 2.0 shijain nov 27 2002
1701 
1702     	l_hook_request_number:=null;
1703     cs_servicerequest_cuhk.Create_ServiceRequest_Pre(
1704     p_api_version            =>   2.0,
1705     p_init_msg_list          =>   fnd_api.g_false ,
1706     p_commit                 =>   p_commit,
1707     p_validation_level       =>   p_validation_level,
1708     x_return_status          =>   l_return_status,
1709     x_msg_count              =>   x_msg_count ,
1710     x_msg_data               =>   x_msg_data,
1711     p_resp_appl_id           =>   p_resp_appl_id,
1712     p_resp_id                =>   p_resp_id,
1713     p_user_id                =>   p_user_id,
1714     p_login_id               =>   p_login_id,
1715     p_org_id                 =>   p_org_id,
1716     p_request_id             =>   l_request_id,
1717     p_request_number         =>   l_request_number,
1718     p_invocation_mode        =>   p_invocation_mode,
1719     p_service_request_rec    =>   l_service_request_rec,
1720     p_notes                  =>   p_notes,
1721     p_contacts               =>   p_contacts,
1722     -- Changed out parameter references to out rec references
1723     x_request_id             =>   x_sr_create_out_rec.request_id,
1724     x_request_number         =>   x_sr_create_out_rec.request_number,
1725     x_interaction_id         =>   x_sr_create_out_rec.interaction_id,
1726     x_workflow_process_id    =>   x_sr_create_out_rec.workflow_process_id,
1727     --15995804. Get the value of price_list_header_id from user hooks
1728     x_price_list_header_id   =>   l_price_list_header_id);
1729 
1730     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1731       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1732     END IF;
1733     -- Incorporate the following changes
1734     -- if user hook return a number use that to stamp as service request number
1735     if x_sr_create_out_rec.request_number  is not null then
1736     	l_hook_request_number:=x_sr_create_out_rec.request_number ;
1737     end if;
1738 
1739     --15995804. Get the value of price_list_header_id from user hooks
1740    IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
1741     THEN
1742       FND_LOG.String
1743       ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1744       , 'The  value of l_price_list_header_id from user hook :'
1745       || l_price_list_header_id
1746       );
1747     END IF;
1748 
1749    END IF;
1750 
1751   -- Pre call to the Vertical Type User Hook
1752   --
1753   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
1754                                       'Create_ServiceRequest',
1755                                       'B', 'V')  THEN
1756 
1757 -- hardcoded the version 2.0 shijain nov 27 2002
1758 
1759     cs_servicerequest_vuhk.Create_ServiceRequest_Pre(
1760     p_api_version            =>   2.0,
1761     p_init_msg_list          =>   fnd_api.g_false ,
1762     p_commit                 =>   p_commit,
1763     p_validation_level       =>   p_validation_level,
1764     x_return_status          =>   l_return_status,
1765     x_msg_count              =>   x_msg_count ,
1766     x_msg_data               =>   x_msg_data,
1767     p_resp_appl_id           =>   p_resp_appl_id,
1768     p_resp_id                =>   p_resp_id,
1769     p_user_id                =>   p_user_id,
1770     p_login_id               =>   p_login_id,
1771     p_org_id                 =>   p_org_id,
1772     p_request_id             =>   l_request_id,
1773     p_request_number         =>   l_request_number,
1774     p_service_request_rec    =>   l_service_request_rec,
1775     p_notes                  =>   p_notes,
1776     p_contacts               =>   p_contacts,
1777     -- Changed out parameter references to out rec references
1778     x_request_id             =>   x_sr_create_out_rec.request_id,
1779     x_request_number         =>   x_sr_create_out_rec.request_number,
1780     x_interaction_id         =>   x_sr_create_out_rec.interaction_id,
1781     x_workflow_process_id    =>   x_sr_create_out_rec.workflow_process_id);
1782 
1783     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1784       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1785     END IF;
1786   END IF;
1787 
1788   -- Pre call to the Internal Type User Hook
1789   --
1790   -- Code to populate the global record type with the passed record type
1791   --
1792   -- internal_user_hooks_rec.customer_id  :=  l_old_ServiceRequest_rec.customer_id ;
1793   -- internal_user_hooks_rec.request_id   :=  p_request_id ;
1794 
1795   -- Mobile FS team usually has packages registered for execution
1796   -- So, if the API returns an unexpected error, please check
1797   -- JTF_HOOKS_DATA for the Mobile FS packges and check if they are invalid
1798 
1799     cs_servicerequest_iuhk.Create_ServiceRequest_Pre( x_return_status=>l_return_status);
1800 
1801     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1802       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1803     END IF;
1804 
1805 --Fix for bug 16736357 ,FP of 16572427 .If p_org_id is passed as null then need to default the value,lkullamb
1806 IF p_org_id = FND_API.G_MISS_NUM OR p_org_id IS NULL
1807   THEN
1808     -- Charges Logistics 12.2
1809 	/*
1810 	*i.The default value for this field will be obtained from profile MO: Default Operating Unit.  This is the official default MOAC operating unit.
1811 	*ii.If there is no value set for this profile, then the default value will be obtained from the profile Service: Default Operating Unit.
1812 	*iii.If the profile Service: Default Operating Unit is set to an operating unit not available in the operating unit LOV at the service request header, leave the field blank so that user can select one from the LOV.
1813 	*If the profile Service: Restrict Operating Unit by MOAC is set to No, then check the value in profile Service: Default Operating Unit.
1814 	*/
1815 
1816     --l_org_id := to_number(FND_PROFILE.value('CS_SR_ORG_ID'));
1817 
1818     If fnd_profile.value('CS_SR_RESTRICT_OPERATING_UNIT')='Y' then
1819       if fnd_profile.value('DEFAULT_ORG_ID') is not null then
1820          l_org_id := to_number(fnd_profile.value('DEFAULT_ORG_ID'));
1821       else
1822 	l_org_id := to_number(fnd_profile.value('CS_SR_ORG_ID'));
1823       end if;
1824       -- Fix for bug 10375745
1825       -- Moving this logic below since mo_global.check_access has to be done in any case if the profile CS_SR_RESTRICT_OPERATING_UNIT is set to yes
1826       if l_org_id is not null then
1827                if (mo_global.check_access(l_org_id) <> 'Y') then
1828 			l_org_id := null;
1829                end if ;
1830       end if;
1831 
1832     Else -- CS_SR_RESTRICT_OPERATING_UNIT set to NO
1833        l_org_id := to_number(fnd_profile.value('CS_SR_ORG_ID'));
1834     End if;
1835 
1836     --  End of changes Charges Logistics 12.2
1837 
1838     IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
1839     THEN
1840       FND_LOG.String
1841       ( FND_LOG.level_procedure , L_LOG_MODULE || ''
1842       , 'The Value of profile CS_SR_ORG_ID :' || l_org_id
1843       );
1844     END IF;
1845 
1846   ELSIF p_org_id is NOT NULL THEN -- p_org_id is NOT NULL
1847 
1848       If fnd_profile.value('CS_SR_RESTRICT_OPERATING_UNIT')='Y' then
1849       --changed l_org_id to p_org_id for the bug 10317826
1850 		if mo_global.check_access(p_org_id) ='Y' then
1851 			l_org_id := p_org_id;
1852 		else
1853 			l_org_id := null;
1854 			FND_MESSAGE.set_name  ('CS','CS_SR_OPERATING_UNIT_INVALID');
1855 			FND_MESSAGE.set_token ('OPERATING_UNIT',p_org_id);
1856 			FND_MESSAGE.set_token ('USER_NAME',p_user_id);
1857                end if ;
1858       else --new profile set to NO. follow old logic
1859 	    l_org_id := p_org_id;
1860       end if;
1861   END IF;
1862   --End of changes for Charges Logistics
1863 
1864   -- use hook return value if it is not null otherwise use p_request_number
1865   if l_hook_request_number is null then
1866     l_hook_request_number:=p_request_number;
1867   end if;
1868   CS_ServiceRequest_PVT.Create_SR_Validation
1869    (   p_api_name            => l_api_name_full,
1870        p_service_request_rec => p_service_request_rec,
1871        p_contacts            => p_contacts,
1872        p_resp_id             => p_resp_id,
1873        p_resp_appl_id        => p_resp_appl_id,
1874        p_user_id             => p_user_id,
1875        p_login_id            => p_login_id,
1876        p_org_id              => l_org_id,
1877        p_request_id          => p_request_id,
1878        p_request_number      => l_hook_request_number,
1879        p_validation_level    => p_validation_level,
1880        p_commit              => p_commit,
1881        x_msg_count           => x_msg_count,
1882        x_msg_data            => x_msg_data,
1883        x_return_status       => l_return_status,
1884        x_contra_id           => l_contra_id,
1885        x_contract_number     => l_contract_number,
1886        x_owner_assigned_flag => l_owner_assigned_flag,
1887        x_req_id              => l_req_id,
1888        x_request_id          => l_request_id,
1889        x_req_num             => l_req_num,
1890        x_request_number      => l_request_number,
1891        x_autolaunch_wkf_flag => l_autolaunch_workflow_flag,
1892        x_abort_wkf_close_flag=> l_abort_workflow_close_flag,
1893        x_wkf_process_name    => l_workflow_process_name,
1894 	   x_audit_vals_rec	     => l_audit_vals_rec,
1895        x_service_request_rec => l_service_request_rec,
1896        -- for cmro
1897        p_cmro_flag           => l_cmro_flag,
1898        p_maintenance_flag    => l_maintenance_flag,
1899        p_auto_assign         => p_auto_assign,
1900 	  p_price_list_header_id => l_price_list_header_id
1901    );
1902 
1903    IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1904       RAISE FND_API.G_EXC_ERROR;
1905    END IF;
1906 
1907 -- for cmro_eam
1908 
1909 	l_service_request_rec.New_type_CMRO_flag := l_cmro_flag;
1910 	l_service_request_rec.New_type_Maintenance_flag := l_maintenance_flag;
1911 
1912 -- end for cmro
1913 
1914 
1915 
1916   /***************************************************************
1917     This is a tempopary solution for Depot Repair team to get the site_use_id
1918     if the site_id is passed from the SR form and the validation level is none
1919     **********************************************/
1920 
1921 IF ( p_validation_level = FND_API.G_VALID_LEVEL_NONE ) THEN
1922   IF ( p_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM  AND
1923        p_service_request_rec.bill_to_site_id IS NOT NULL ) THEN
1924 
1925     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
1926       ( p_api_name            => 'Get bill to site use id',
1927         p_parameter_name      => 'Bill_To Site ',
1928         p_bill_to_site_id     => p_service_request_rec.bill_to_site_id,
1929         p_bill_to_party_id    => p_service_request_rec.bill_to_party_id,
1930         p_site_use_type       => 'BILL_TO',
1931         x_site_use_id         => l_service_request_rec.bill_to_site_use_id,
1932         x_return_status       => l_return_status
1933       );
1934     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1935       RAISE FND_API.G_EXC_ERROR;
1936     END IF;
1937   END IF;
1938 
1939   IF ( p_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM  AND
1940        p_service_request_rec.ship_to_site_id IS NOT NULL ) THEN
1941 
1942     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
1943       ( p_api_name            => 'Get ship to site use id',
1944         p_parameter_name      => 'Ship_To Site ',
1945         p_bill_to_site_id     => p_service_request_rec.ship_to_site_id,
1946         p_bill_to_party_id    => p_service_request_rec.ship_to_party_id,
1947         p_site_use_type       => 'SHIP_TO',
1948         x_site_use_id         => l_service_request_rec.ship_to_site_use_id,
1949         x_return_status       => l_return_status
1950       );
1951     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1952       RAISE FND_API.G_EXC_ERROR;
1953     END IF;
1954   END IF;
1955 
1956   IF ( p_service_request_rec.install_site_id <> FND_API.G_MISS_NUM) THEN
1957       l_service_request_rec.install_site_use_id:=
1958                                           p_service_request_rec.install_site_id;
1959   END IF;
1960 END IF;
1961  -- For BUG # 2933250 check to see if install_site_id and install_site_use_id are same . -- pkesani
1962 
1963 	IF (p_service_request_rec.install_site_id <> FND_API.G_MISS_NUM) AND
1964 	   (p_service_request_rec.install_site_use_id <> FND_API.G_MISS_NUM) THEN
1965 	   IF	( p_service_request_rec.install_site_id <> p_service_request_rec.install_site_use_id) THEN
1966 	   RAISE invalid_install_site;
1967 	   END IF;
1968 	END IF;
1969 
1970 
1971 /********************************************************************
1972 Changes for depot repair finished, need to remove all this for 115.10
1973 ***********************************************************************/
1974 
1975  ----- Validate owner id .
1976  --- If the passed owner_id is not valid , NULL will be assigned to
1977  --- incident_owner_id column in the DB.
1978 
1979 
1980    -- UWQ pop up in service request
1981    -- while creating an SR from Teleservice
1982    l_imp_level := Get_Importance_Level(p_service_request_rec.severity_id);
1983    --select the l_title from jtf_objects_vl
1984    l_title := Get_Title('SR');
1985    -- Assign the value of request_id to the local variable that will be passed to the
1986    -- IEU procedure .
1987     IF l_request_id IS NULL THEN
1988          q_request_id := l_req_id ;
1989          ELSE
1990          q_request_id := l_request_id;
1991     END IF;
1992 
1993    l_uwq_body1 := Get_Message(p_uwq_msg_notification);
1994 
1995    l_uwq_body := l_title ||' '|| l_req_num ||' '|| l_uwq_body1 ||' '||TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS'); --with time;
1996 
1997    IF (l_service_request_rec.last_update_channel in ('PHONE', 'AGENT')  AND
1998         l_imp_level =1 AND
1999         l_service_request_rec.owner_id IS NOT NULL AND
2000         l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) OR
2001         (l_service_request_rec.last_update_channel = 'WEB' AND
2002         (l_imp_level =1 OR l_imp_level =2)  AND
2003          l_service_request_rec.owner_id IS NOT NULL AND
2004          l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) THEN
2005          l_send_uwq_notification := TRUE;
2006    END IF;
2007 
2008    IF l_send_uwq_notification THEN
2009           IEU_MSG_PRODUCER_PUB.Send_Plain_text_Msg (
2010             p_api_version      => 1.0,
2011             p_init_msg_list    => fnd_api.g_false,
2012             p_commit           => fnd_api.g_false,
2013             p_application_id   => 170,
2014             p_resource_id      => l_service_request_rec.owner_id,
2015             p_resource_type    => l_service_request_rec.resource_type,
2016             p_title            => l_title,
2017             p_body             => l_uwq_body,
2018             p_workitem_obj_code=> 'SR',
2019             p_workitem_pk_id   => q_request_id,
2020             x_message_id       => l_msg_id,
2021             x_return_status    => l_return_status,
2022             x_msg_count        => l_msg_count,
2023             x_msg_data         => l_msg_data );
2024    END IF;
2025 
2026 /* Added call to get_status_flag for enh 2655115, to get the status flag
2027    based on the closed flag by shijain date 27th nov 2002*/
2028 
2029 -- for bug 3050727 - commented out as the flag is updated in the create_Sr_validation
2030 --   l_status_flag:= get_status_flag ( l_service_request_rec.status_id);
2031 
2032  /* this code is moved in create_sr_validate. it's presence after create_sr_validation
2033     stops stamping of incident_resolved_date and inc_responded_by_date to audit rec
2034     smisra 12/31/2003
2035     SELECT  responded_flag,resolved_flag
2036     INTO l_responded_flag,l_resolved_flag
2037     FROM  cs_incident_statuses_vl
2038     WHERE incident_status_id=l_service_request_rec.status_id ;
2039 
2040    IF ((l_responded_flag='Y') OR (l_resolved_flag ='Y')) THEN
2041      IF((l_responded_flag='Y' ) AND (l_service_request_rec.inc_responded_by_date is NULL OR
2042        l_service_request_rec.inc_responded_by_date= FND_API.G_MISS_DATE ))
2043      THEN
2044        l_service_request_rec.inc_responded_by_date := SYSDATE;
2045 
2046 	  IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
2047 	  THEN
2048 	    FND_LOG.String
2049 	    ( FND_LOG.level_procedure , L_LOG_MODULE || ''
2050 	    , 'The defaulted value of parameter inc_responded_by_date :'
2051 	    || l_service_request_rec.inc_responded_by_date
2052 	    );
2053 	  END IF;
2054      END IF;
2055 
2056     IF((l_resolved_flag ='Y' ) AND (l_service_request_rec.incident_resolved_date is NULL
2057        OR l_service_request_rec.incident_resolved_date = FND_API.G_MISS_DATE ))
2058     THEN
2059        l_service_request_rec.incident_resolved_date := SYSDATE;
2060 
2061 	  IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
2062 	  THEN
2063 	    FND_LOG.String
2064 	    ( FND_LOG.level_procedure , L_LOG_MODULE || ''
2065 	    , 'The defaulted value of parameter incident_resolved_date :'
2066 	    || l_service_request_rec.incident_resolved_date
2067 	    );
2068 	  END IF;
2069     END IF;
2070   END IF;
2071   */
2072   /* end of usability changes*/
2073 -- Validate service request contacts
2074  CS_SRCONTACT_PKG.process
2075  ( p_mode            => 'CREATE'
2076  , p_incident_id     => NULL
2077  , p_caller_type     => l_service_request_rec.caller_type
2078  , p_customer_id     => l_service_request_rec.customer_id
2079  , p_validation_mode => p_validation_level
2080  , p_contact_tbl     => p_contacts
2081  , x_contact_tbl     => l_processed_contacts
2082  , x_old_contact_tbl => l_old_contacts
2083  , x_primary_party_id         => l_sr_related_data.primary_party_id
2084  , x_primary_contact_point_id => l_sr_related_data.primary_contact_point_id
2085  , x_return_status   => l_return_status
2086  );
2087  IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
2088  THEN
2089    RAISE FND_API.G_EXC_ERROR;
2090  END IF;
2091 -- End of SR contact validation
2092    vldt_sr_rec
2093    ( p_sr_rec           => l_service_request_rec
2094    , p_sr_rec_inp       => p_service_request_rec
2095    , p_sr_related_data  => l_sr_related_data
2096    , p_mode             => 'CREATE'
2097    , p_request_id               => NULL
2098    , p_object_version_number    => NULL
2099    , p_last_updated_by          => p_user_id
2100    , p_validation_level         => p_validation_level
2101    , p_default_contract_sla_ind => p_default_contract_sla_ind
2102    , p_default_coverage_template_id => p_default_coverage_template_id
2103    , p_auto_assign                  => p_auto_assign
2104    , x_contract_number  => l_contract_number
2105    , x_return_status    => l_return_status
2106    );
2107    IF l_return_status <> FND_API.G_RET_STS_SUCCESS
2108    THEN
2109       RAISE FND_API.G_EXC_ERROR;
2110    END IF;
2111    l_contra_id := l_service_request_rec.contract_id;
2112 
2113 
2114     -- Code Changes for setting unassigned_indicator
2115     -- 12/3/03 smisra. as l_service_request_rec will have owner, group info
2116     -- returned by Assignment manager API, so using l_ser.. instead of p_service..
2117 	IF (l_service_request_rec.owner_id  <> FND_API.G_MISS_NUM  AND
2118 	    l_service_request_rec.owner_id IS NOT NULL ) AND
2119 	   (l_service_request_rec.owner_group_id  <> FND_API.G_MISS_NUM  AND
2120 	    l_service_request_rec.owner_group_id IS NOT NULL ) THEN
2121 	    l_unassigned_indicator := 3 ;
2122 	ELSIF (l_service_request_rec.owner_id  <> FND_API.G_MISS_NUM  AND
2123 	    l_service_request_rec.owner_id IS  NOT NULL ) AND
2124 	   (l_service_request_rec.owner_group_id  = FND_API.G_MISS_NUM  OR
2125 	    l_service_request_rec.owner_group_id IS NULL ) THEN
2126 	    l_unassigned_indicator := 1 ;
2127 	ELSIF (l_service_request_rec.owner_id  = FND_API.G_MISS_NUM  OR
2128 	    l_service_request_rec.owner_id IS  NULL ) AND
2129 	   (l_service_request_rec.owner_group_id  <> FND_API.G_MISS_NUM  AND
2130 	    l_service_request_rec.owner_group_id IS NOT NULL ) THEN
2131 	    l_unassigned_indicator := 2 ;
2132 	ELSE
2133 	    l_unassigned_indicator := 0 ;
2134 	END IF;
2135 -- Start of change , Sanjana Rao, bug 6955756
2136 	 IF (l_service_request_rec.owner_id  <> FND_API.G_MISS_NUM  AND
2137 	    l_service_request_rec.owner_id IS NOT NULL )
2138   THEN
2139        l_service_request_rec.owner_assigned_time   := SYSDATE;
2140   END IF;
2141 --- End of change , Sanjana Rao , bug 6955756
2142 
2143  x_sr_create_out_rec.individual_owner := l_service_request_rec.owner_id;
2144  x_sr_create_out_rec.individual_type  := l_service_request_rec.resource_type;
2145  x_sr_create_out_rec.group_owner      := l_service_request_rec.owner_group_id;
2146   -- March 23 2000, customer_number is not to be stored in cs_incidents_all_b
2147   -- If passed to teh api, it is used to retrieve the id from customer table
2148   -- l_service_request_rec.customer_number,       /*CUSTOMER_NUMBER*/
2149 
2150 
2151   -------------------------------------------------------
2152   --siahmed start of code for creating onetime address
2153   IF (l_service_request_rec.incident_location_id IS null) THEN
2154       --(l_service_request_rec.incident_location_id = FND_API.G_MISS_NUM)) THEN
2155      IF ((l_service_request_rec.incident_address  IS NOT null) OR
2156          (l_service_request_rec.incident_address2 IS NOT null) OR
2157          (l_service_request_rec.incident_address3 IS NOT null) OR
2158          (l_service_request_rec.incident_address4 IS NOT null) OR
2159          (l_service_request_rec.incident_city     IS NOT null) OR
2160          (l_service_request_rec.incident_state    IS NOT null) OR
2161          (l_service_request_rec.incident_postal_code IS NOT null) OR
2162          (l_service_request_rec.incident_county   IS NOT null) OR
2163          (l_service_request_rec.incident_province IS NOT null) OR
2164          (l_service_request_rec.incident_country  IS NOT null) OR
2165          (l_service_request_rec.site_name   IS NOT NULL) OR
2166          (l_service_request_rec.site_number IS NOT NULL) OR
2167          (l_service_request_rec.addressee   IS NOT NULL)) THEN
2168 
2169          --call create onetime address creation procedure
2170          CREATE_ONETIME_ADDRESS (
2171            p_service_req_rec   =>  l_service_request_rec,
2172            x_msg_count         =>  l_msg_count,
2173            x_msg_data          =>  l_msg_data,
2174            x_return_status     =>  l_return_status,
2175            x_location_id       =>  l_incident_location_id
2176          );
2177 
2178          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2179             FND_MESSAGE.Set_Name('CS', 'CS_SR_ONETIME_CREATE_ERROR');
2180             FND_MESSAGE.Set_Token('API_NAME', l_api_name||'CREATE_ONETIME_ADDRESS');
2181             FND_MSG_PUB.ADD;
2182          ELSIF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2183             --so that the new party_site_id gets stamped in the cs_incidents_all_b table
2184             l_service_request_rec.incident_location_id := l_incident_location_id;
2185             l_service_request_rec.incident_location_type := 'HZ_PARTY_SITE';
2186 
2187 
2188             --stamp the out rec type with the incident location_id
2189             x_sr_create_out_rec.incident_location_id := l_incident_location_id;
2190 
2191          END IF;
2192             --set the variables to null so that they dont get stored in the incidents table
2193             l_service_request_rec.incident_address  := null;
2194             l_service_request_rec.incident_address2 := null;
2195             l_service_request_rec.incident_address3 := null;
2196             l_service_request_rec.incident_address4 := null;
2197             l_service_request_rec.incident_city     := null;
2198             l_service_request_rec.incident_state    := null;
2199             l_service_request_rec.incident_postal_code := null;
2200             l_service_request_rec.incident_county   := null;
2201             l_service_request_rec.incident_province := null;
2202             l_service_request_rec.incident_country  := null;
2203             l_service_request_rec.site_name   := null;
2204             l_service_request_rec.site_number := null;
2205             l_service_request_rec.addressee   := null;
2206             --fix for bug 8563365
2207             l_service_request_rec.incident_addr_lines_phonetic := null;
2208             l_service_request_rec.incident_postal_plus4_code := null;
2209 
2210             --end of fix for bug 8563365
2211       END IF;
2212    --if they pass an incidnt_id then it should not be of type
2213    --SR_ONETIME because SR_ONTIME can only be associated for the
2214    --life of one SR so it should be an existing address but not
2215    -- SR_ONEIME
2216    ELSIF (l_service_request_rec.incident_location_id IS NOT NULL) THEN
2217         --check if created by module = 'SR_ONETIME'
2218 	   -- fix for bug 8594093 to check for location as well Ranjan
2219 	   if l_service_request_rec.incident_location_type='HZ_PARTY_SITE' then
2220         	SELECT count(party_site_id) into l_onetime_add_cnt
2221         	FROM hz_party_sites
2222         	WHERE party_site_id = l_service_request_rec.incident_location_id
2223         	AND created_by_module = 'SR_ONETIME';
2224 	   elsif l_service_request_rec.incident_location_type='HZ_LOCATION' then
2225         	SELECT count(location_id) into l_onetime_add_cnt
2226         	FROM hz_locations
2227         	WHERE location_id = l_service_request_rec.incident_location_id
2228         	AND created_by_module = 'SR_ONETIME';
2229 	   end if;
2230 
2231 	--Fix for bug 13467585
2232 	l_service_request_rec.incident_country  := null;
2233 	--End of fix for bug 13467585
2234 
2235         -- if the incident_location_id is of type SR_ONETIME NULL the
2236         -- incident location_id
2237         IF (l_onetime_add_cnt >= 1) THEN
2238              l_service_request_rec.incident_location_id := null;
2239 	     --Fix for bug 8594093
2240               l_service_request_rec.incident_location_type := null;
2241 	      l_service_request_rec.incident_address  := null;
2242               l_service_request_rec.incident_address2 := null;
2243               l_service_request_rec.incident_address3 := null;
2244               l_service_request_rec.incident_address4 := null;
2245               l_service_request_rec.incident_city     := null;
2246               l_service_request_rec.incident_state    := null;
2247               l_service_request_rec.incident_postal_code := null;
2248               l_service_request_rec.incident_county   := null;
2249               l_service_request_rec.incident_province := null;
2250               --l_service_request_rec.incident_country  := null;
2251               l_service_request_rec.site_name   := null;
2252               l_service_request_rec.site_number := null;
2253               l_service_request_rec.addressee   := null;
2254               l_service_request_rec.incident_addr_lines_phonetic := null;
2255               l_service_request_rec.incident_postal_plus4_code := null;
2256 	     --End of changes for bug 8594093
2257 	     FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_INCIDENT_ADDRESS');
2258              FND_MESSAGE.Set_Token('API_NAME', l_api_name||'CREATE_INCIDENT_ADDRESS');
2259              FND_MSG_PUB.ADD;
2260         END IF;
2261 
2262    END IF;
2263 
2264   --end of code siahmed
2265   -------------------------------------------------------
2266 
2267   --siahmed 12.2+ project where we are trying to link project_id and task_id from
2268   --oracle projects to SR
2269   --code added
2270   --if there are no project_id being supplied or project_task_id being supplied we will not run validation.
2271   --also added the p_validation_level whcih was missing
2272   --dbms_output.put_line ('it comes here');
2273       --moved this from the bottom to the top because customer could be passinng only project-id  and in that case
2274       --project task_id would be coming in with te value of G_MISS_NUM
2275       --fix for bug 13841612
2276   IF l_service_request_rec.project_id = FND_API.G_MISS_NUM THEN
2277        l_service_request_rec.project_id      :=  NULL;
2278   END IF;
2279   IF l_service_request_rec.project_task_id = FND_API.G_MISS_NUM THEN
2280        l_service_request_rec.project_task_id :=  NULL;
2281   END IF;
2282   IF l_service_request_rec.expenditure_org_id = FND_API.G_MISS_NUM THEN
2283        l_service_request_rec.expenditure_org_id :=  NULL;
2284   END IF;
2285 
2286  IF ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) then
2287     --removed the or and put AND here as they should always be passing both the values for bug 13626087
2288     IF ((l_service_request_rec.project_id IS NOT NULL AND l_service_request_rec.project_id <> FND_API.G_MISS_NUM ) OR
2289         (l_service_request_rec.project_task_id IS NOT NULL AND l_service_request_rec.project_task_id <> FND_API.G_MISS_NUM) OR
2290         (l_service_request_rec.expenditure_org_id IS NOT NULL AND l_service_request_rec.expenditure_org_id <> FND_API.G_MISS_NUM)
2291 	   ) THEN
2292 
2293       CS_ServiceRequest_UTIL.VALIDATE_PROJECT_INFO
2294        (p_api_name            => 'Validate_project_Task_id',
2295        p_project_id          => l_service_request_rec.project_id,
2296        p_project_task_id     => l_service_request_rec.project_task_id,
2297        p_exp_org_id          => l_service_request_rec.expenditure_org_id,
2298        x_return_status       => l_project_info_status,
2299        x_error_msg           => l_msg_data );
2300        IF (l_project_info_status <> FND_API.G_RET_STS_SUCCESS) THEN
2301           l_service_request_rec.project_id      :=  null; --FND_API.G_MISS_NUM;
2302           l_service_request_rec.project_task_id :=  null; --FND_API.G_MISS_NUM;
2303           l_service_request_rec.expenditure_org_id      :=  null;
2304 
2305 	   /*
2306          FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_PROJECT_DETAILS');
2307          FND_MESSAGE.Set_Token('API_NAME', l_api_name||'VALIDATE_PROJECT_INFO');
2308          FND_MSG_PUB.ADD;
2309 	   */
2310        END IF;
2311     END IF;
2312 
2313   END IF; --end of p_validation_level
2314 
2315   --end of addition siahmed
2316   ----------------------------------------------------
2317 
2318   --
2319   -- Insert into _B table
2320   --
2321   INSERT INTO cs_incidents_all_b
2322     ( incident_id,
2323       last_update_date,
2324       last_updated_by,
2325       creation_date,
2326       created_by,
2327       last_update_login,
2328       incident_number,
2329       incident_status_id,
2330       incident_type_id,
2331       incident_urgency_id,
2332       incident_severity_id,
2333       incident_owner_id,
2334       resource_type,
2335 --       resource_subtype_id, -- For BUG 2748584
2336       inventory_item_id,
2337       caller_type,
2338       customer_id,
2339       account_id,
2340       employee_id,
2341       current_serial_number,
2342       expected_resolution_date,
2343       actual_resolution_date,
2344       customer_product_id,
2345       bill_to_site_use_id,
2346       bill_to_contact_id,
2347       ship_to_site_use_id,
2348       ship_to_contact_id,
2349       install_site_use_id,
2350       incident_attribute_1,
2351       incident_attribute_2,
2352       incident_attribute_3,
2353       incident_attribute_4,
2354       incident_attribute_5,
2355       incident_attribute_6,
2356       incident_attribute_7,
2357       incident_attribute_8,
2358       incident_attribute_9,
2359       incident_attribute_10,
2360       incident_attribute_11,
2361       incident_attribute_12,
2362       incident_attribute_13,
2363       incident_attribute_14,
2364       incident_attribute_15,
2365       incident_context,
2366       external_attribute_1,
2367       external_attribute_2,
2368       external_attribute_3,
2369       external_attribute_4,
2370       external_attribute_5,
2371       external_attribute_6,
2372       external_attribute_7,
2373       external_attribute_8,
2374       external_attribute_9,
2375       external_attribute_10,
2376       external_attribute_11,
2377       external_attribute_12,
2378       external_attribute_13,
2379       external_attribute_14,
2380       external_attribute_15,
2381       external_context,
2382       resolution_code,
2383       incident_date,
2384       problem_code,
2385       original_order_number,
2386       purchase_order_num,
2387       close_date,
2388       publish_flag,
2389       obligation_date,
2390       qa_collection_id,
2391       contract_service_id,
2392       contract_id,
2393       contract_number,
2394       project_number,
2395       customer_po_number,
2396       customer_ticket_number,
2397       time_zone_id,
2398       time_difference,
2399       platform_id,
2400       platform_version,
2401       platform_version_id,
2402       db_version,
2403       cp_component_id,
2404       cp_component_version_id,
2405       cp_subcomponent_id,
2406       cp_subcomponent_version_id,
2407       cp_revision_id,
2408       inv_item_revision,
2409       inv_component_id,
2410       inv_component_version,
2411       inv_subcomponent_id,
2412       inv_subcomponent_version,
2413       site_id,
2414       customer_site_id,
2415       territory_id,
2416       inv_organization_id,
2417       object_version_number,
2418       -----Added for enhancement 11.5.6
2419       cust_pref_lang_id,
2420       tier,
2421       tier_version,
2422       operating_system,
2423       operating_system_version,
2424       DATABASE,
2425       category_id,
2426       group_type,
2427       owner_group_id,
2428       group_territory_id,
2429       owner_assigned_time,
2430       owner_assigned_flag,
2431       --- Added for the unassigned_ind enh.
2432       unassigned_indicator,
2433       inv_platform_org_id,
2434       product_revision,
2435       component_version,
2436       subcomponent_version,
2437       comm_pref_code,
2438       cust_pref_lang_code,
2439       last_update_channel,
2440       category_set_id,
2441       external_reference,
2442       system_id,
2443       error_code,
2444       incident_occurred_date,
2445       incident_resolved_date,
2446       inc_responded_by_date,
2447       incident_location_id ,
2448       incident_address ,
2449       incident_city,
2450       incident_state,
2451       incident_country,
2452       incident_province ,
2453       incident_postal_code ,
2454       incident_county,
2455       sr_creation_channel ,
2456       -- Added for ER# 2320056
2457       coverage_type ,
2458       -- Added For ER# 2433831
2459       bill_to_account_id ,
2460       ship_to_account_id ,
2461       --  Added for ER# 2463321
2462       customer_phone_id,
2463       customer_email_id,
2464       -- Added for source changes for 1159 by shijain oct 11 2002
2465       creation_program_code,
2466       last_update_program_code,
2467       bill_to_party_id,
2468       ship_to_party_id,
2469       bill_to_site_id,
2470       ship_to_site_id,
2471       program_id                 ,
2472       program_application_id     ,
2473       request_id            ,
2474       program_login_id ,
2475       -- Added for enh 2655115
2476       status_flag,
2477       -- Added address field by shijain dec5th 2002
2478       incident_point_of_interest  ,
2479       incident_cross_street ,
2480       incident_direction_qualifier ,
2481       incident_distance_qualifier  ,
2482       incident_distance_qual_uom  ,
2483       incident_address2   ,
2484       incident_address3 ,
2485       incident_address4  ,
2486       incident_address_style ,
2487       incident_addr_lines_phonetic  ,
2488       incident_po_box_number  ,
2489       incident_house_number ,
2490       incident_street_suffix ,
2491       incident_street ,
2492       incident_street_number ,
2493       incident_floor,
2494       incident_suite  ,
2495       incident_postal_plus4_code ,
2496       incident_position  ,
2497       incident_location_directions,
2498       incident_location_description  ,
2499       install_site_id,
2500       -- for cmro_eam
2501       owning_department_id,
2502       -- Added for MIsc ERs project of 11.5.10 --anmukher --08/26/03
2503       incident_location_type,
2504       -- Added for Auditing project of 11.5.10 --anmukher --09/03/03
2505       incident_last_modified_date	           ,
2506       maint_organization_id,
2507       org_id,
2508 	 -- Credit Card 9358401
2509 	    instrument_payment_use_id,
2510       --siahmed 12.2+ project where we are integrating oracle projects with SR
2511       project_id,
2512       project_task_id,
2513 	 expenditure_org_id,
2514       -- 14004721 . Additional SLA dates . shramana
2515       sla_date_1,
2516       sla_date_2,
2517       sla_date_3,
2518       sla_date_4,
2519       sla_date_5,
2520       sla_date_6,
2521       sla_duration_1,
2522       sla_duration_2,
2523 	  --15995804. Add price_list_header_id
2524       price_list_header_id
2525     )
2526   VALUES
2527     ( DECODE(l_request_id,NULL,l_req_id,l_request_id), /* INCIDENT_ID */
2528       l_service_request_rec.last_update_date,          /* LAST_UPDATE_DATE */
2529       l_service_request_rec.last_updated_by,           /* LAST_UPDATED_BY */
2530       l_service_request_rec.creation_date,             /* CREATION_DATE */
2531       l_service_request_rec.created_by,                /* CREATED_BY */
2532       l_service_request_rec.last_update_login,         /* LAST_UPDATE_LOGIN */
2533       DECODE(l_request_number,NULL,l_req_num,l_request_number), /* INCIDENT_NUMBER */
2534       l_service_request_rec.status_id,                 /* INCIDENT_STATUS_ID */
2535       l_service_request_rec.type_id,                   /* INCIDENT_TYPE_ID */
2536       l_service_request_rec.urgency_id,                /* INCIDENT_URGENCY_ID */
2537       l_service_request_rec.severity_id,               /* INCIDENT_SEVERITY_ID */
2538       l_service_request_rec.owner_id,                  /* INCIDENT_OWNER_ID */
2539       l_service_request_rec.resource_type,             /* RESOURCE_TYPE */
2540 --      l_service_request_rec.resource_subtype_id,       /* RESOURCE_SUBTYPE_ID */ For BUG 2748584
2541       l_service_request_rec.inventory_item_id,         /* INVENTORY_ITEM_ID */
2542       l_service_request_rec.caller_type,               /* CALLER_TYPE */
2543       -- removed decode for 11.5.6 enhancement
2544       l_service_request_rec.customer_id,               /* CUSTOMER_ID */
2545       l_service_request_rec.account_id,                /* ACCOUNT_ID */
2546       l_service_request_rec.employee_id,               /* EMPLOYEE_ID */
2547       l_service_request_rec.current_serial_number,     /* CURRENT_SERIAL_NUMBER */
2548       l_service_request_rec.exp_resolution_date,       /* EXPECTED_RESOLUTION_DATE */
2549       l_service_request_rec.act_resolution_date,       /* ACTUAL_RESOLUTION_DATE */
2550       l_service_request_rec.customer_product_id,       /* CUSTOMER_PRODUCT_ID */
2551       l_service_request_rec.bill_to_site_use_id,       /* BILL_TO_SITE_USE_ID */
2552       l_service_request_rec.bill_to_contact_id,        /* BILL_TO_CONTACT_ID */
2553       l_service_request_rec.ship_to_site_use_id,       /* SHIP_TO_SITE_USE_ID */
2554       l_service_request_rec.ship_to_contact_id,        /* SHIP_TO_CONTACT_ID */
2555       l_service_request_rec.install_site_use_id,       /* INSTALL_SITE_USE_ID */
2556       l_service_request_rec.request_attribute_1,       /* INCIDENT_ATTRIBUTE_1 */
2557       l_service_request_rec.request_attribute_2,       /* INCIDENT_ATTRIBUTE_2 */
2558       l_service_request_rec.request_attribute_3,       /* INCIDENT_ATTRIBUTE_3 */
2559       l_service_request_rec.request_attribute_4,       /* INCIDENT_ATTRIBUTE_4 */
2560       l_service_request_rec.request_attribute_5,       /* INCIDENT_ATTRIBUTE_5 */
2561       l_service_request_rec.request_attribute_6,       /* INCIDENT_ATTRIBUTE_6 */
2562       l_service_request_rec.request_attribute_7,       /* INCIDENT_ATTRIBUTE_7 */
2563       l_service_request_rec.request_attribute_8,       /* INCIDENT_ATTRIBUTE_8 */
2564       l_service_request_rec.request_attribute_9,       /* INCIDENT_ATTRIBUTE_9 */
2565       l_service_request_rec.request_attribute_10,      /* INCIDENT_ATTRIBUTE_10 */
2566       l_service_request_rec.request_attribute_11,      /* INCIDENT_ATTRIBUTE_11 */
2567       l_service_request_rec.request_attribute_12,      /* INCIDENT_ATTRIBUTE_12 */
2568       l_service_request_rec.request_attribute_13,      /* INCIDENT_ATTRIBUTE_13 */
2569       l_service_request_rec.request_attribute_14,      /* INCIDENT_ATTRIBUTE_14 */
2570       l_service_request_rec.request_attribute_15,      /* INCIDENT_ATTRIBUTE_15 */
2571       l_service_request_rec.request_context,           /* INCIDENT_CONTEXT */
2572       l_service_request_rec.external_attribute_1,      /* EXTERNAL_ATTRIBUTE_1 */
2573       l_service_request_rec.external_attribute_2,      /* EXTERNAL_ATTRIBUTE_2 */
2574       l_service_request_rec.external_attribute_3,      /* EXTERNAL_ATTRIBUTE_3 */
2575       l_service_request_rec.external_attribute_4,      /* EXTERNAL_ATTRIBUTE_4 */
2576       l_service_request_rec.external_attribute_5,      /* EXTERNAL_ATTRIBUTE_5 */
2577       l_service_request_rec.external_attribute_6,      /* EXTERNAL_ATTRIBUTE_6 */
2578       l_service_request_rec.external_attribute_7,      /* EXTERNAL_ATTRIBUTE_7 */
2579       l_service_request_rec.external_attribute_8,      /* EXTERNAL_ATTRIBUTE_8 */
2580       l_service_request_rec.external_attribute_9,      /* EXTERNAL_ATTRIBUTE_9 */
2581       l_service_request_rec.external_attribute_10,     /* EXTERNAL_ATTRIBUTE_10 */
2582       l_service_request_rec.external_attribute_11,     /* EXTERNAL_ATTRIBUTE_11 */
2583       l_service_request_rec.external_attribute_12,     /* EXTERNAL_ATTRIBUTE_12 */
2584       l_service_request_rec.external_attribute_13,     /* EXTERNAL_ATTRIBUTE_13 */
2585       l_service_request_rec.external_attribute_14,     /* EXTERNAL_ATTRIBUTE_14 */
2586       l_service_request_rec.external_attribute_15,     /* EXTERNAL_ATTRIBUTE_15 */
2587       l_service_request_rec.external_context,          /* EXTERNAL_CONTEXT */
2588       UPPER(l_service_request_rec.resolution_code),    /* RESOLUTION_CODE */
2589       l_service_request_rec.request_date,              /* INCIDENT_DATE */
2590       UPPER(l_service_request_rec.problem_code),       /* PROBLEM_CODE */
2591       l_service_request_rec.original_order_number,     /* ORIGINAL_ORDER_NUMBER */
2592       l_service_request_rec.purchase_order_num,        /* PURCHASE_ORDER_NUM */
2593       l_service_request_rec.closed_date,               /* CLOSE_DATE */
2594       l_service_request_rec.publish_flag,              /* PUBLISH_FLAG */
2595       l_service_request_rec.obligation_date,
2596       l_service_request_rec.qa_collection_plan_id,
2597       l_service_request_rec.contract_service_id,
2598       l_contra_id,
2599       l_contract_number,
2600       l_service_request_rec.project_number,
2601       l_service_request_rec.cust_po_number,
2602       l_service_request_rec.cust_ticket_number,
2603       l_service_request_rec.time_zone_id,
2604       l_service_request_rec.time_difference,
2605       l_service_request_rec.platform_id,
2606       l_service_request_rec.platform_version,
2607       l_service_request_rec.platform_version_id,
2608       l_service_request_rec.db_version,
2609       l_service_request_rec.cp_component_id,
2610       l_service_request_rec.cp_component_version_id,
2611       l_service_request_rec.cp_subcomponent_id,
2612       l_service_request_rec.cp_subcomponent_version_id,
2613       l_service_request_rec.cp_revision_id,
2614       l_service_request_rec.inv_item_revision,
2615       l_service_request_rec.inv_component_id,
2616       l_service_request_rec.inv_component_version,
2617       l_service_request_rec.inv_subcomponent_id,
2618       l_service_request_rec.inv_subcomponent_version,
2619       l_service_request_rec.site_id,
2620       l_service_request_rec.customer_site_id,
2621       l_service_request_rec.territory_id,
2622       l_service_request_rec.inventory_org_id,
2623 	 1,
2624       --- Added for enhancement 11.5.6
2625       l_service_request_rec.cust_pref_lang_id,
2626       l_service_request_rec.tier,
2627       l_service_request_rec.tier_version,
2628       l_service_request_rec.operating_system,
2629       l_service_request_rec.operating_system_version,
2630       l_service_request_rec.DATABASE,
2631       l_service_request_rec.category_id,
2632       l_service_request_rec.group_type,
2633       l_service_request_rec.owner_group_id,
2634       l_service_request_rec.group_territory_id,
2635       l_service_request_rec.owner_assigned_time,
2636       l_service_request_rec.owner_assigned_flag,
2637       l_unassigned_indicator,
2638       l_service_request_rec.inv_platform_org_id,
2639       l_service_request_rec.product_revision,
2640       l_service_request_rec.component_version,
2641       l_service_request_rec.subcomponent_version,
2642       l_service_request_rec.comm_pref_code,
2643       l_service_request_rec.cust_pref_lang_code,
2644       l_service_request_rec.last_update_channel,
2645       l_service_request_rec.category_set_id,
2646       l_service_request_rec.external_reference,
2647       l_service_request_rec.system_id,
2648       l_service_request_rec.error_code,
2649       l_service_request_rec.incident_occurred_date,
2650       l_service_request_rec.incident_resolved_date,
2651       l_service_request_rec.inc_responded_by_date,
2652       l_service_request_rec.incident_location_id ,
2653       l_service_request_rec.incident_address ,
2654       l_service_request_rec.incident_city,
2655       l_service_request_rec.incident_state,
2656       l_service_request_rec.incident_country,
2657       l_service_request_rec.incident_province ,
2658       l_service_request_rec.incident_postal_code ,
2659       l_service_request_rec.incident_county,
2660       l_service_request_rec.sr_creation_channel ,
2661       -- Added for ER# 2320056
2662       l_service_request_rec.coverage_type,
2663       -- Added For ER# 2433831
2664       l_service_request_rec.bill_to_account_id ,
2665       l_service_request_rec.ship_to_account_id ,
2666       --  Added for ER# 2463321
2667       l_service_request_rec.customer_phone_id,
2668       l_service_request_rec.customer_email_id,
2669       -- Added for source changes for 1159 by shijain oct 11 2002
2670       l_service_request_rec.creation_program_code,
2671       l_service_request_rec.creation_program_code,
2672       l_service_request_rec.bill_to_party_id,
2673       l_service_request_rec.ship_to_party_id,
2674       l_service_request_rec.bill_to_site_id,
2675       l_service_request_rec.ship_to_site_id,
2676       l_service_request_rec.program_id                 ,
2677       l_service_request_rec.program_application_id     ,
2678       l_service_request_rec.conc_request_id            ,
2679       l_service_request_rec.program_login_id  ,
2680       -- Added for enh. 2655115
2681       --l_status_flag ,
2682       --for bug 3050727
2683       l_service_request_rec.status_flag,
2684       l_service_request_rec.incident_point_of_interest,
2685       l_service_request_rec.incident_cross_street,
2686       l_service_request_rec.incident_direction_qualifier,
2687       l_service_request_rec.incident_distance_qualifier,
2688       l_service_request_rec.incident_distance_qual_uom,
2689       l_service_request_rec.incident_address2,
2690       l_service_request_rec.incident_address3,
2691       l_service_request_rec.incident_address4,
2692       l_service_request_rec.incident_address_style,
2693       l_service_request_rec.incident_addr_lines_phonetic,
2694       l_service_request_rec.incident_po_box_number,
2695       l_service_request_rec.incident_house_number,
2696       l_service_request_rec.incident_street_suffix,
2697       l_service_request_rec.incident_street,
2698       l_service_request_rec.incident_street_number,
2699       l_service_request_rec.incident_floor,
2700       l_service_request_rec.incident_suite,
2701       l_service_request_rec.incident_postal_plus4_code,
2702       l_service_request_rec.incident_position,
2703       l_service_request_rec.incident_location_directions,
2704       l_service_request_rec.incident_location_description,
2705       l_service_request_rec.install_site_id,
2706        --for cmro_eam
2707       l_service_request_rec.owning_dept_id,
2708       -- Added for Misc ERs project of 11.5.10 --anmukher --08/26/03
2709       l_service_request_rec.incident_location_type,
2710       -- Added for Auditing project of 11.5.10 --anmukher --09/03/03
2711       l_service_request_rec.last_update_date ,   /* INCIDENT_LAST_MODIFIED_DATE */
2712       l_service_request_rec.maint_organization_id,
2713       l_org_id,
2714 	 --Credit Card 9358401
2715       l_service_request_rec.instrument_payment_use_id,
2716        --siahmed adding  12.2+ project_id and task_id to integrate with oracle projects
2717       l_service_request_rec.project_id,
2718       l_service_request_rec.project_task_id,
2719       l_service_request_rec.expenditure_org_id,
2720       --14004721 . Additional SLA dates
2721       l_service_request_rec.sla_date_1,
2722       l_service_request_rec.sla_date_2,
2723       l_service_request_rec.sla_date_3,
2724       l_service_request_rec.sla_date_4,
2725       l_service_request_rec.sla_date_5,
2726       l_service_request_rec.sla_date_6,
2727       l_service_request_rec.sla_duration_1,
2728       l_service_request_rec.sla_duration_2,
2729 	 --15995804
2730       l_service_request_rec.price_list_header_id
2731   ) RETURNING INCIDENT_ID, INCIDENT_NUMBER, ORG_ID  INTO l_request_id, l_request_number, l_inc_org_id;
2732 
2733   --
2734   -- Insert into _TL table
2735   --
2736   INSERT INTO cs_incidents_all_tl (
2737     incident_id,
2738     creation_date,
2739     created_by,
2740     last_update_date,
2741     last_updated_by,
2742     last_update_login,
2743     summary,
2744     resolution_summary ,
2745     LANGUAGE,
2746     source_lang,
2747     text_index
2748   ) SELECT
2749       l_request_id,
2750       l_service_request_rec.creation_date,
2751       l_service_request_rec.created_by,
2752       l_service_request_rec.last_update_date,
2753       l_service_request_rec.last_updated_by,
2754       l_service_request_rec.last_update_login,
2755       l_service_request_rec.summary,
2756       l_service_request_rec.resolution_summary ,
2757       L.LANGUAGE_CODE,
2758       USERENV('LANG'),
2759       'A'
2760     FROM FND_LANGUAGES L
2761     WHERE l.installed_flag IN ('I', 'B')
2762     AND NOT EXISTS
2763     (SELECT NULL
2764      FROM cs_incidents_all_tl t
2765      WHERE t.incident_id = l_request_id
2766      AND t.LANGUAGE = l.language_code
2767     );
2768 
2769   -- ----------------------------------------------------------------------
2770   -- Reindex if ConText Option is enabled and summary, problem description
2771   -- or resolution description is inserted.
2772   -- Reindex even if the service request is not published (bug 841260).
2773   -- ----------------------------------------------------------------------
2774 
2775   -- Added for Auditing project of 11.5.10 --anmukher --09/15/03
2776   -- Assignments are made here (and not immediately before calling Create_Audit_record)
2777   -- in order to ensure that the audit rec is fully populated
2778   -- before CS_SR_AUDIT_CHILD API is called after contact point creation.
2779 
2780   l_audit_vals_rec.incident_number		:= l_request_number;
2781 
2782   IF (l_contra_id <> FND_API.G_MISS_NUM) AND
2783     (l_contra_id IS NOT NULL) THEN
2784     l_audit_vals_rec.CONTRACT_ID		:= l_contra_id;
2785   END IF;
2786 
2787   IF (l_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM) AND
2788     (l_service_request_rec.contract_service_id IS NOT NULL) THEN
2789     l_audit_vals_rec.CONTRACT_SERVICE_ID	:= l_service_request_rec.contract_service_id ;
2790   END IF;
2791 
2792   IF (l_contract_number <> FND_API.G_MISS_CHAR) AND
2793     (l_contract_number IS NOT NULL) THEN
2794     l_audit_vals_rec.CONTRACT_NUMBER		:= l_contract_number;
2795   END IF;
2796 
2797   IF (l_unassigned_indicator <> FND_API.G_MISS_NUM) AND
2798     (l_unassigned_indicator IS NOT NULL) THEN
2799     l_audit_vals_rec.UNASSIGNED_INDICATOR	:= l_unassigned_indicator;
2800   END IF;
2801   -- At this point l_servicerequest_rec has been processed for g_miss values
2802   -- so no need to check for g_miss. directly assign the value to audit rec.
2803   l_audit_vals_rec.coverage_type	:= l_service_request_rec.coverage_type;
2804 
2805 
2806   -- This record creation should  not take place if caller_type is CALLER_EMP
2807   -- For Caller type Employee, should not create any contacts
2808   /*  updating value of the primary_contact_id in the cs_incidents_all_b table
2809       after we insert record in cs_hz_sr_contact_points, so that
2810       sr_contact_point_id can be inserted as primary_contact_id by shijain
2811       for enh. 2690787
2812 
2813     l_primary_contact:= get_primary_contact(l_request_id);
2814 
2815     IF l_primary_contact is not null THEN
2816 
2817         UPDATE cs_incidents_all_b
2818         SET    primary_contact_id = l_primary_contact
2819         WHERE  incident_id = l_request_id;
2820 
2821     END IF;
2822   */
2823 
2824 -- END IF;  --  caller type check
2825 /****************Delete Above code***************************************/
2826 
2827   -- ------------------------------------------------------
2828   -- Insert a record into the audit table
2829   -- ------------------------------------------------------
2830 
2831   --Added for Auditing project of 11.5.10 --anmukher --09/03/03
2832   l_audit_vals_rec.updated_entity_code		:= 'SR_HEADER';
2833   l_audit_vals_rec.updated_entity_id		:= l_request_id;
2834   l_audit_vals_rec.entity_activity_code         := 'C';
2835   l_audit_vals_rec.incident_last_modified_date  := l_service_request_rec.last_update_date ;
2836   -- R12 changes
2837   l_audit_vals_rec.org_id                       := l_org_id;
2838   l_audit_vals_rec.old_org_id                   := null ;
2839   l_audit_vals_rec.maint_organization_id        := l_service_request_rec.maint_organization_id ;
2840   l_audit_vals_rec.old_maint_organization_id    := null ;
2841   l_audit_vals_rec.last_update_program_code     := l_service_request_rec.creation_program_code ;
2842   --
2843   IF l_service_request_rec.exp_resolution_date IS NULL
2844   THEN
2845     l_audit_vals_rec.CHANGE_RESOLUTION_FLAG := 'N';
2846   ELSE
2847     l_audit_vals_rec.CHANGE_RESOLUTION_FLAG := 'Y';
2848     l_audit_vals_rec.EXPECTED_RESOLUTION_DATE        := l_service_request_rec.exp_resolution_date;
2849   END IF;
2850 
2851   IF l_service_request_rec.obligation_date IS NULL
2852   THEN
2853     l_audit_vals_rec.CHANGE_OBLIGATION_FLAG := 'N';
2854   ELSE
2855     l_audit_vals_rec.CHANGE_OBLIGATION_FLAG := 'Y';
2856     l_audit_vals_rec.obligation_date        := l_service_request_rec.obligation_date;
2857   END IF;
2858   l_audit_vals_rec.incident_country        := l_service_request_rec.incident_country;
2859   l_audit_vals_rec.incident_location_id    := l_service_request_rec.incident_location_id;
2860   l_audit_vals_rec.incident_location_type  := l_service_request_rec.incident_location_type;
2861   -- Owner and Group Related Columns
2862   IF l_service_request_rec.owner_id IS NULL
2863   THEN
2864     l_audit_vals_rec.change_incident_owner_flag := 'N';
2865   ELSE
2866     l_audit_vals_rec.change_incident_owner_FLAG := 'Y';
2867     l_audit_vals_rec.incident_owner_id          := l_service_request_rec.owner_id;
2868 
2869    --commented by Sanjana Rao, bug 6955756
2870    -- l_service_request_rec.owner_assigned_time   := SYSDATE;
2871   END IF;
2872 
2873   IF l_service_request_rec.OWNER_ASSIGNED_TIME IS NULL
2874   THEN
2875     l_audit_vals_rec.CHANGE_ASSIGNED_TIME_FLAG  := 'N';
2876   ELSE
2877     l_audit_vals_rec.CHANGE_ASSIGNED_TIME_FLAG  := 'Y';
2878     l_audit_vals_rec.OWNER_ASSIGNED_TIME        := l_service_request_rec.OWNER_ASSIGNED_TIME;
2879   END IF;
2880 
2881   IF l_service_request_rec.OWNER_GROUP_ID IS NULL
2882   THEN
2883     l_audit_vals_rec.CHANGE_GROUP_FLAG := 'N';
2884   ELSE
2885     l_audit_vals_rec.CHANGE_GROUP_FLAG := 'Y';
2886     l_audit_vals_rec.GROUP_ID          := l_service_request_rec.OWNER_GROUP_ID;
2887   END IF;
2888 
2889   IF l_service_request_rec.group_type IS NULL
2890   THEN
2891     l_audit_vals_rec.CHANGE_GROUP_TYPE_FLAG := 'N';
2892   ELSE
2893     l_audit_vals_rec.CHANGE_GROUP_TYPE_FLAG := 'Y';
2894     l_audit_vals_rec.group_type             := l_service_request_rec.group_type;
2895   END IF;
2896 
2897   IF l_service_request_rec.RESOURCE_TYPE IS NULL
2898   THEN
2899     l_audit_vals_rec.CHANGE_RESOURCE_TYPE_FLAG  := 'N';
2900   ELSE
2901     l_audit_vals_rec.CHANGE_RESOURCE_TYPE_FLAG  := 'Y';
2902     l_audit_vals_rec.RESOURCE_TYPE              := l_service_request_rec.RESOURCE_TYPE;
2903   END IF;
2904 
2905   IF l_service_request_rec.territory_id IS NULL
2906   THEN
2907     l_audit_vals_rec.CHANGE_TERRITORY_ID_FLAG := 'N';
2908   ELSE
2909     l_audit_vals_rec.CHANGE_TERRITORY_ID_FLAG := 'Y';
2910     l_audit_vals_rec.territory_id             := l_service_request_rec.territory_id;
2911   END IF;
2912 
2913   IF l_service_request_rec.site_id IS NULL
2914   THEN
2915     l_audit_vals_rec.CHANGE_SITE_FLAG := 'N';
2916   ELSE
2917     l_audit_vals_rec.CHANGE_SITE_FLAG := 'Y';
2918     l_audit_vals_rec.site_id          := l_service_request_rec.site_id;
2919   END IF;
2920 
2921    --siahemd 12.2+ project adding project related attributes to be audited in create_servicerequest
2922 
2923     l_audit_vals_rec.project_id          := l_service_request_rec.project_id;
2924     l_audit_vals_rec.project_task_id     := l_service_request_rec.project_task_id;
2925     l_audit_vals_rec.expenditure_org_id          := l_service_request_rec.expenditure_org_id;
2926   --siahmed 12.2+ end of project related attributes
2927 
2928   --siahmed added for disabling aduit when invocation_mode is set to REPLAY
2929   IF (p_invocation_mode <> 'REPLAY' ) THEN
2930   CS_ServiceRequest_PVT.Create_Audit_Record (
2931        p_api_version         => 2.0,
2932        x_return_status       => l_return_status,
2933        x_msg_count           => x_msg_count,
2934        x_msg_data            => x_msg_data,
2935        p_request_id          => l_request_id,
2936        p_audit_id            => l_audit_id,
2937        p_audit_vals_rec      => l_audit_vals_rec,
2938        p_user_id             => l_service_request_rec.last_updated_by,
2939        p_login_id            => l_service_request_rec.last_update_login,
2940        p_last_update_date    => l_service_request_rec.last_update_date,
2941        p_creation_date       => l_service_request_rec.last_update_date,
2942        x_audit_id            => l_audit_id
2943      );
2944    END IF; --end of invocationn_mode check for audit
2945 
2946     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2947       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2948     END IF;
2949     CS_SRCONTACT_PKG.create_update
2950     ( p_incident_id     => l_request_id
2951     , p_invocation_mode => p_invocation_mode
2952     , p_sr_update_date  => l_service_request_rec.last_update_date
2953     , p_sr_updated_by   => l_service_request_rec.last_updated_by
2954     , p_sr_update_login => l_service_request_rec.last_update_login
2955     , p_contact_tbl     => l_processed_contacts
2956     , p_old_contact_tbl => l_old_contacts
2957     , x_return_status   => l_return_status
2958     );
2959     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
2960     THEN
2961       RAISE FND_API.G_EXC_ERROR;
2962     END IF;
2963 
2964     ----- AUDIT
2965 
2966     -- Call to Enqueuer API if it is in Maintenance Mode
2967     -- added b'coz l_req_num will always be null,when request_number is passed
2968        l_enqueue_number := NVL(l_request_number,l_req_num);
2969 
2970     FND_PROFILE.get('APPS_MAINTENANCE_MODE', l_maintenance_mode);
2971 
2972       IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
2973       THEN
2974         FND_LOG.String
2975 	( FND_LOG.level_procedure , L_LOG_MODULE || ''
2976 	, 'The Value of profile APPS_MAINTENANCE_MODE :' || l_maintenance_mode
2977 	);
2978       END IF;
2979 
2980 
2981     IF (l_maintenance_mode = 'MAINT' AND
2982         p_invocation_mode <> 'REPLAY' ) THEN
2983 
2984 -- hardcoded the version 2.0 shijain nov 27 2002
2985 
2986      CS_ServiceRequest_ENQUEUE_PKG.EnqueueSR(
2987        p_init_msg_list         => fnd_api.g_false ,
2988        p_api_version           => 2.0,
2989        p_commit                => p_commit,
2990        p_validation_level      => p_validation_level,
2991        x_return_status         => l_return_status,
2992        x_msg_count             => x_msg_count,
2993        x_msg_data              => x_msg_data,
2994        p_request_id            => l_req_id,
2995        p_request_number        => l_enqueue_number,
2996        p_audit_id              => l_audit_id,
2997        p_resp_appl_id          => p_resp_appl_id,
2998        p_resp_id               => p_resp_id,
2999        p_user_id               => p_user_id,
3000        p_login_id              => p_login_id,
3001        p_org_id                => p_org_id,
3002        p_update_desc_flex      => p_update_desc_flex,
3003        p_object_version_number => p_object_version_number,
3004        p_transaction_type      => l_transaction_type,
3005        p_message_rev           => l_message_revision,
3006        p_servicerequest        => l_service_request_rec,
3007        p_contacts              => l_contacts
3008      );
3009 
3010      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3011         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3012      END IF;
3013     END IF;
3014 
3015   --
3016   -- Create entries in JTF_NOTES from p_notes
3017   --
3018   l_note_index := p_notes.FIRST;
3019   WHILE l_note_index IS NOT NULL LOOP
3020     /* Create JTF_NOTES */
3021     --l_notes_detail := DBMS_LOB.SUBSTR(p_notes(l_note_index).note_detail);
3022 
3023    IF ((p_notes(l_note_index).note IS NOT NULL) AND
3024         (p_notes(l_note_index).note <> FND_API.G_MISS_CHAR)) THEN
3025 
3026     l_note_status := null ;
3027 
3028     IF ((p_notes(l_note_index).note_status IS NULL) OR
3029         (p_notes(l_note_index).note_status = FND_API.G_MISS_CHAR)) THEN
3030         l_note_status := 'E';
3031     ELSE
3032         l_note_status := p_notes(l_note_index).note_status ;
3033     END IF ;
3034 
3035      jtf_notes_pub.create_note(
3036       p_api_version    => 1.0,
3037       p_init_msg_list  => FND_API.G_FALSE,
3038       p_commit         => FND_API.G_FALSE,
3039       x_return_status  => x_return_status,
3040       x_msg_count      => x_msg_count,
3041       x_msg_data       => x_msg_data,
3042       p_source_object_id => l_request_id,
3043       p_source_object_code => 'SR',
3044       p_notes              => p_notes(l_note_index).note,
3045       p_notes_detail       => p_notes(l_note_index).note_detail,
3046       p_note_type          => p_notes(l_note_index).note_type,
3047       p_note_status        => l_note_status,
3048       p_entered_by         => p_user_id,
3049       p_entered_date       => SYSDATE,
3050       p_created_by         => p_user_id,
3051       p_creation_date      => SYSDATE,
3052       p_last_updated_by    => p_user_id,
3053       p_last_update_date   => SYSDATE,
3054       x_jtf_note_id        => l_note_id
3055     );
3056 
3057      IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3058         RAISE FND_API.G_EXC_ERROR;
3059         END IF;
3060 
3061    END IF;
3062 
3063 
3064    IF ((p_notes(l_note_index).note_context_type_01 IS NOT NULL) AND
3065         (p_notes(l_note_index).note_context_type_01 <> FND_API.G_MISS_CHAR) AND
3066         (p_notes(l_note_index).note_context_type_id_01 IS NOT NULL) AND
3067         (p_notes(l_note_index).note_context_type_id_01 <> FND_API.G_MISS_NUM)) THEN
3068 
3069       jtf_notes_pub.create_note_context(
3070         x_return_status        => x_return_status,
3071         p_creation_date        => SYSDATE,
3072         p_last_updated_by      => p_user_id,
3073         p_last_update_date     => SYSDATE,
3074         p_jtf_note_id          => l_note_id,
3075         p_note_context_type    => p_notes(l_note_index).note_context_type_01,
3076         p_note_context_type_id => p_notes(l_note_index).note_context_type_id_01,
3077         x_note_context_id      => l_note_context_id
3078       );
3079 
3080         IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3081                 RAISE FND_API.G_EXC_ERROR;
3082      END IF;
3083     END IF;
3084 
3085 
3086     IF ((p_notes(l_note_index).note_context_type_02 IS NOT NULL) AND
3087         (p_notes(l_note_index).note_context_type_02 <> FND_API.G_MISS_CHAR) AND
3088         (p_notes(l_note_index).note_context_type_id_02 IS NOT NULL) AND
3089         (p_notes(l_note_index).note_context_type_id_02 <> FND_API.G_MISS_NUM))THEN
3090 
3091 
3092        jtf_notes_pub.create_note_context(
3093         x_return_status        => x_return_status,
3094         p_creation_date        => SYSDATE,
3095         p_last_updated_by      => p_user_id,
3096         p_last_update_date     => SYSDATE,
3097         p_jtf_note_id          => l_note_id,
3098         p_note_context_type    => p_notes(l_note_index).note_context_type_02,
3099         p_note_context_type_id => p_notes(l_note_index).note_context_type_id_02,
3100         x_note_context_id      => l_note_context_id
3101 
3102       );
3103      IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3104                 RAISE FND_API.G_EXC_ERROR;
3105         END IF;
3106     END IF;
3107 
3108 
3109     IF ((p_notes(l_note_index).note_context_type_03 IS NOT NULL) AND
3110         (p_notes(l_note_index).note_context_type_03 <> FND_API.G_MISS_CHAR) AND
3111         (p_notes(l_note_index).note_context_type_id_03 IS NOT NULL) AND
3112         (p_notes(l_note_index).note_context_type_id_03 <> FND_API.G_MISS_NUM)) THEN
3113 
3114 
3115       jtf_notes_pub.create_note_context(
3116         x_return_status        => x_return_status,
3117         p_creation_date        => SYSDATE,
3118         p_last_updated_by      => p_user_id,
3119         p_last_update_date     => SYSDATE,
3120         p_jtf_note_id          => l_note_id,
3121         p_note_context_type    => p_notes(l_note_index).note_context_type_03,
3122         p_note_context_type_id => p_notes(l_note_index).note_context_type_id_03,
3123         x_note_context_id      => l_note_context_id
3124       );
3125 
3126                  IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3127                          RAISE FND_API.G_EXC_ERROR;
3128                  END IF;
3129    END IF;
3130 
3131    l_note_index := p_notes.NEXT(l_note_index);
3132   END LOOP;
3133 
3134 
3135   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #8');
3136   -- Launching the workflow (HOOK)
3137   IF (JTF_USR_HKS.Ok_To_Execute('CS_ServiceRequest_PVT', 'Create_ServiceRequest',
3138                                 'W', 'W')) THEN
3139 
3140      IF (cs_servicerequest_cuhk.Ok_To_Launch_Workflow(p_request_id => l_request_id,
3141                                                       p_service_request_rec=>l_service_request_rec)) THEN
3142 
3143        l_bind_data_id := JTF_USR_HKS.Get_bind_data_id ;
3144        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'USER_ID', p_user_id, 'W', 'T');
3145        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'RESP_ID', p_resp_id, 'W', 'T');
3146        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'RESP_APPL_ID', p_resp_appl_id, 'W', 'T');
3147        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_ID', l_request_id, 'W', 'T');
3148        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_DATE', l_service_request_rec.request_date, 'W', 'T');
3149        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_TYPE', l_service_request_rec.type_id, 'W', 'T');
3150        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_STATUS', l_service_request_rec.status_id, 'W', 'T');
3151        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_SEVERITY', l_service_request_rec.severity_id, 'W', 'T');
3152        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_URGENCY', l_service_request_rec.urgency_id, 'W', 'T');
3153        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'OWNER_ID', l_service_request_rec.owner_id, 'W', 'T');
3154        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_SUMMARY', l_service_request_rec.summary, 'W', 'T');
3155        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_CUSTOMER', l_service_request_rec.customer_id, 'W', 'T');
3156        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'INVENTORY_ITEM_ID', l_service_request_rec.inventory_item_id, 'W', 'T');
3157        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'CUSTOMER_PRODUCT_ID', l_service_request_rec.customer_product_id, 'W', 'T');
3158        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'PROBLEM_CODE', l_service_request_rec.problem_code, 'W', 'T');
3159        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'EXPECTED_RESOLUTION_DATE', l_service_request_rec.exp_resolution_date, 'W', 'T');
3160 
3161        -- Before the call to WorkFlow Hook, generate a unique item key using the workflow sequence
3162        SELECT cs_wf_process_id_s.NEXTVAL INTO l_workflow_item_key FROM dual;
3163 
3164        JTF_USR_HKS.WrkflowLaunch(p_wf_item_name => 'SERVEREQ',
3165                                  p_wf_item_process_name => 'CALL_SUPPORT',
3166                                  p_wf_item_key => 'SR' || TO_CHAR(l_workflow_item_key),
3167                                  p_bind_data_id => l_bind_data_id,
3168                                  x_return_code => l_return_status);
3169 
3170        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3171          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3172        END IF;
3173 
3174    END IF ;
3175   END IF ;
3176 
3177   --
3178   -- Make the post processing call to the user hooks
3179   --
3180   -- Post call to the Customer Type User Hook
3181   --
3182   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
3183                                       'Create_ServiceRequest',
3184                                       'A', 'C')  THEN
3185 
3186 -- hardcoded the version 2.0 shijain nov 27 2002
3187 
3188     cs_servicerequest_cuhk.Create_ServiceRequest_Post(
3189     p_api_version            =>   2.0,
3190     p_init_msg_list          =>   fnd_api.g_false ,
3191     p_commit                 =>   p_commit,
3192     p_validation_level       =>   p_validation_level,
3193     x_return_status          =>   l_return_status,
3194     x_msg_count              =>   x_msg_count ,
3195     x_msg_data               =>   x_msg_data,
3196     p_resp_appl_id           =>   p_resp_appl_id,
3197     p_resp_id                =>   p_resp_id,
3198     p_user_id                =>   p_user_id,
3199     p_login_id               =>   p_login_id,
3200     p_org_id                 =>   p_org_id,
3201     p_request_id             =>   l_request_id,
3202     p_request_number         =>   l_request_number,
3203     p_invocation_mode        =>   p_invocation_mode,
3204     p_service_request_rec    =>   l_service_request_rec,
3205     p_notes                  =>   p_notes,
3206     p_contacts               =>   p_contacts,
3207     -- Changed out parameter references to out rec references
3208     x_request_id             =>   x_sr_create_out_rec.request_id,
3209     x_request_number         =>   x_sr_create_out_rec.request_number,
3210     x_interaction_id         =>   x_sr_create_out_rec.interaction_id,
3211     x_workflow_process_id    =>   x_sr_create_out_rec.workflow_process_id);
3212 
3213 
3214     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3215       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3216     END IF;
3217   END IF;
3218 
3219 
3220   -- Post call to the Vertical Type User Hook
3221   --
3222   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
3223                                       'Create_ServiceRequest',
3224                                       'A', 'V')  THEN
3225 
3226 -- hardcoded the version 2.0 shijain nov 27 2002
3227 
3228     cs_servicerequest_vuhk.Create_ServiceRequest_Post(
3229     p_api_version            =>   2.0,
3230     p_init_msg_list          =>   fnd_api.g_false ,
3231     p_commit                 =>   p_commit,
3232     p_validation_level       =>   p_validation_level,
3233     x_return_status          =>   l_return_status,
3234     x_msg_count              =>   x_msg_count ,
3235     x_msg_data               =>   x_msg_data,
3236     p_resp_appl_id           =>   p_resp_appl_id,
3237     p_resp_id                =>   p_resp_id,
3238     p_user_id                =>   p_user_id,
3239     p_login_id               =>   p_login_id,
3240     p_org_id                 =>   p_org_id,
3241     p_request_id             =>   l_request_id,
3242     p_request_number         =>   l_request_number,
3243     p_service_request_rec    =>   l_service_request_rec,
3244     p_notes                  =>   p_notes,
3245     p_contacts               =>   p_contacts,
3246     -- Changed out parameter references to out rec references
3247     x_request_id             =>   x_sr_create_out_rec.request_id,
3248     x_request_number         =>   x_sr_create_out_rec.request_number,
3249     x_interaction_id         =>   x_sr_create_out_rec.interaction_id,
3250     x_workflow_process_id    =>   x_sr_create_out_rec.workflow_process_id);
3251 
3252 
3253     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3254       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3255     END IF;
3256   END IF;
3257 
3258 
3259 
3260   -- Post call to the internal Type User Hook
3261   --
3262   -- Fix to bug # 2986971
3263   -- Code to populate the global record type. These globals can be used by the internal
3264   -- user hooks procedures registered to be executed by the Create SR Private proc.
3265 
3266     user_hooks_rec.customer_id := l_service_request_rec.customer_id ;
3267     user_hooks_rec.request_id  := l_request_id ;
3268 
3269   -- for cmro_eam
3270   -- set additional paramters for cmro_eam
3271   -- status_flag,pls_type_cmro_flag,new_type_cmro_flag,customer_product_id,
3272   -- status_id,exp_resolution_date
3273 
3274     user_hooks_rec.status_flag 		:= l_service_request_rec.status_flag;
3275     user_hooks_rec.old_type_cmro_flag 	:= NULL;
3276     user_hooks_rec.new_type_cmro_flag 	:= l_service_request_rec.New_type_CMRO_flag;
3277     user_hooks_rec.customer_product_id 	:= l_service_request_rec.customer_product_id;
3278     user_hooks_rec.status_id 		:= l_service_request_rec.status_id;
3279     user_hooks_rec.exp_resolution_date 	:= l_service_request_rec.exp_resolution_date;
3280 
3281     -- end for cmro_eam
3282 
3283     cs_servicerequest_iuhk.Create_ServiceRequest_Post( x_return_status=>l_return_status);
3284 
3285     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3286       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3287     END IF;
3288 
3289   -- ----------------------------------------------------------------------
3290   -- Insert interaction record
3291   -- ----------------------------------------------------------------------
3292   IF (l_service_request_rec.parent_interaction_id IS NULL) THEN
3293     /* CREATE INTERACTION */ /* l_interaction_id := */
3294     NULL;
3295   END IF;
3296 
3297   -- Changed out parameter references to out rec references
3298   x_sr_create_out_rec.interaction_id := l_interaction_id;
3299 
3300   --
3301   -- Create INTERACTION_ACTIVITY
3302   --
3303 
3304   --
3305   -- Set OUT values
3306   --
3307   -- Changed out parameter references to out rec references
3308   x_sr_create_out_rec.request_id := l_request_id;
3309   x_sr_create_out_rec.request_number := l_request_number;
3310 
3311   -- Standard call for message generation
3312   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
3313                                       'Create_ServiceRequest',
3314                                       'M', 'M')  THEN
3315 
3316     IF (cs_servicerequest_cuhk.Ok_To_Generate_Msg(p_request_id  => l_request_id,
3317                                                 p_service_request_rec=>l_service_request_rec)) THEN
3318 
3319       l_bind_data_id := JTF_USR_HKS.Get_bind_data_id;
3320 
3321       JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'incident_id', l_request_id, 'S', 'N');
3322 
3323       JTF_USR_HKS.generate_message(p_prod_code => 'CS',
3324                                  p_bus_obj_code => 'SR',
3325                                  p_action_code => 'I',
3326                                  p_bind_data_id => l_bind_data_id,
3327                                  x_return_code => l_return_status);
3328 
3329 
3330        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3331           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3332       END IF;
3333     END IF;
3334   END IF;
3335 
3336 --- Added for HA Enhancement
3337 
3338     IF (p_invocation_mode <> 'REPLAY' ) THEN
3339       -- Raise BES Event that the SR is created. Before business events, a WF process
3340       -- was kicked off if the following conditions were met:
3341       -- if l_autolaunch_wf_flag = 'Y' AND resource_type = 'RS_EMPLOYEE' AND
3342       -- owner_id IS NOT NULL. After the introduction of business event, the SR API
3343       -- calls the CS BES wrapper API and this wrapper API raises the needed business
3344       -- events, in this case - SR Created,  after checking the required conditions.
3345 
3346       CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT(
3347          -- These 4 parameters added for bug #2798269
3348          p_api_version           => p_api_version,
3349          p_init_msg_list         => fnd_api.g_false ,
3350          p_commit                => p_commit,
3351          p_validation_level      => p_validation_level,
3352          p_event_code            => 'CREATE_SERVICE_REQUEST',
3353          p_incident_number       => l_request_number,
3354          p_user_id               => p_user_id,
3355          p_resp_id               => p_resp_id,
3356          p_resp_appl_id          => p_resp_appl_id,
3357 	 p_old_sr_rec            => NULL,
3358 	 p_new_sr_rec            => l_service_request_rec, -- using l_ser...coz this is the
3359 							   -- rec. type used in the insert.
3360 	 p_contacts_table        => p_contacts,
3361          p_link_rec              => NULL,  -- using default value
3362          p_wf_process_id         => NULL,  -- using default value
3363          p_owner_id		 => NULL,  -- using default value
3364          p_wf_manual_launch	 => 'N' ,  -- using default value
3365          x_wf_process_id         => l_workflow_process_id,
3366          x_return_status         => lx_return_status,
3367          x_msg_count             => lx_msg_count,
3368          x_msg_data              => lx_msg_data );
3369 
3370       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
3371 	 -- do nothing in this API. The BES wrapper API will have to trap this
3372 	 -- situation and send a notification to the SR owner that the BES has
3373 	 -- not been raised. If the BES API return back a failure status, it
3374 	 -- means only that the BES raise event has failed, and has nothing to
3375 	 -- do with the creation of the SR.
3376 	 null;
3377       end if;
3378     END IF;   -- IF (p_invocation_mode <> 'REPLAY' )
3379     -- Changed out parameter reference to out rec reference
3380     x_sr_create_out_rec.workflow_process_id  := l_workflow_process_id ;
3381 
3382 /*resetting the parameter value shijain 4th dec 2002*/
3383   g_restrict_ib:=NULL;
3384 
3385   -- Standard call to get message count and if count is 1, get message info
3386   FND_MSG_PUB.Count_And_Get
3387     ( p_count => x_msg_count,
3388       p_data  => x_msg_data
3389     );
3390 
3391 
3392 -- Moved before calling the assignment manager
3393 -- *****************************************************************/
3394 
3395 /******************** Commit moved for bug 2857350*****************************/
3396 
3397   -- Assign the incident id and the incident number for the new service request to the Out Rec attributes --anmukher -- 08/25/03
3398   x_sr_create_out_rec.request_id 	:= l_request_id;
3399   x_sr_create_out_rec.request_number	:= l_request_number;
3400 
3401   -- Added for Auto Task Generation Project of 11.5.10 -- anmukher --08/25/03
3402   -- Check if Auto Generate Tasks parameters is set ON
3403 
3404   -- For bug 3535918 - remove case sensitivity and add ignore message
3405 
3406   If (p_auto_generate_tasks = 'Y' OR p_auto_generate_tasks = 'y') Then
3407 
3408     -- Check if the Service Request has been closed at the time of creation
3409     If l_service_request_rec.status_flag = 'C' Then
3410       x_sr_create_out_rec.auto_task_gen_attempted 	:= FALSE;
3411     Else
3412       -- Service Request is Open and Auto Generate Task parameter is On, So call the Auto Generate Tasks API
3413       CS_AutoGen_Task_PVT.Auto_Generate_Tasks
3414       ( p_api_version			=> 1.0,
3415         p_init_msg_list			=> fnd_api.g_false ,
3416         p_commit			=> p_commit,
3417         p_validation_level		=> p_validation_level,
3418         p_incident_id                   => l_request_id ,
3419         p_service_request_rec		=> l_service_request_rec,
3420         p_task_template_group_owner	=> null,-- l_service_request_rec.owner_group_id,
3421         p_task_tmpl_group_owner_type    => null,-- l_service_request_rec.owner_type,
3422         p_task_template_group_rec	=> l_task_template_group_rec,
3423         p_task_template_table		=> l_task_template_table,
3424         x_auto_task_gen_rec		=> l_auto_task_gen_rec,
3425         x_return_status			=> l_return_status,
3426         x_msg_count			=> x_msg_count,
3427         x_msg_data			=> x_msg_data
3428       );
3429     End If; -- If l_service_request_rec.status_flag = 'C'
3430 
3431     If l_return_status = FND_API.G_RET_STS_SUCCESS Then
3432       x_sr_create_out_rec.auto_task_gen_status		:= FND_API.G_RET_STS_SUCCESS;
3433       x_sr_create_out_rec.auto_task_gen_attempted	:= l_auto_task_gen_rec.auto_task_gen_attempted;
3434       x_sr_create_out_rec.field_service_task_created	:= l_auto_task_gen_rec.field_service_task_created;
3435     Else
3436       x_sr_create_out_rec.auto_task_gen_status		:= FND_API.G_RET_STS_ERROR ;
3437       x_sr_create_out_rec.auto_task_gen_attempted	:= TRUE;
3438 
3439 /* Commented out since the service request should be created even if creation of task fails. -- spusegao
3440    Rolling back the partial task creation, if any , is handled in Auto_Task_Generate API.
3441 
3442       IF (l_return_status = FND_API.G_RET_STS_ERROR) THEN
3443         RAISE FND_API.G_EXC_ERROR;
3444       ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3445         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3446       END IF;
3447 */
3448     End If; -- If l_return_status = FND_API.G_RET_STS_SUCCESS
3449 
3450   Else
3451     x_sr_create_out_rec.auto_task_gen_attempted 	:= FALSE;
3452 
3453      IF (p_auto_generate_tasks <> 'N' AND p_auto_generate_tasks <> 'n') THEN
3454               FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_AUTOTASK_PARAM');
3455               FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
3456               FND_MSG_PUB.ADD;
3457      END IF;
3458 
3459   End If; -- If p_auto_generate_tasks = 'Y'
3460 
3461 
3462   -- Added this call for Misc ER: Owner auto assignment changes
3463 
3464 
3465         CS_SR_WORKITEM_PVT.Create_Workitem(
3466                    p_api_version        => 1.0,
3467                    p_init_msg_list      => fnd_api.g_false ,
3468                    p_commit             => p_commit,
3469                    p_incident_id        => l_request_id,
3470                    p_incident_number    => l_request_number ,
3471                    p_sr_rec             => l_service_request_rec,
3472                    p_user_id            => l_service_request_rec.last_updated_by,
3473                    p_resp_appl_id       => p_resp_appl_id ,
3474                    p_login_id           => l_service_request_rec.last_update_login,
3475                    x_work_item_id       => l_work_item_id,
3476                    x_return_status      => l_return_status,
3477                    x_msg_count          => x_msg_count,
3478                    x_msg_data           => x_msg_data) ;
3479 
3480         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
3481            FND_MSG_PUB.Count_And_Get
3482         ( p_count => x_msg_count,
3483           p_data  => x_msg_data
3484          );
3485        END IF;
3486 
3487  -- Standard check of p_commit
3488   IF FND_API.To_Boolean(p_commit) THEN
3489     COMMIT WORK;
3490   END IF;
3491 
3492 EXCEPTION
3493   WHEN FND_API.G_EXC_ERROR THEN
3494     ROLLBACK TO Create_ServiceRequest_PVT;
3495     x_return_status := FND_API.G_RET_STS_ERROR;
3496     FND_MSG_PUB.Count_And_Get
3497       ( p_count => x_msg_count,
3498         p_data  => x_msg_data
3499       );
3500   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3501     ROLLBACK TO Create_ServiceRequest_PVT;
3502     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3503     FND_MSG_PUB.Count_And_Get
3504       ( p_count => x_msg_count,
3505         p_data  => x_msg_data
3506       );
3507   WHEN Auto_Assign_Excep THEN
3508     x_return_status := FND_API.G_RET_STS_SUCCESS;
3509      FND_MSG_PUB.Count_And_Get
3510       ( p_count => x_msg_count,
3511         p_data  => x_msg_data
3512       );
3513 --- For BUG # 2933250
3514   WHEN invalid_install_site THEN
3515   	ROLLBACK TO Create_ServiceRequest_PVT;
3516   	x_return_status := FND_API.G_RET_STS_ERROR;
3517     FND_MESSAGE.SET_NAME('CS','CS_SR_INVALID_INSTALL_SITE');
3518     FND_MSG_PUB.ADD;
3519     FND_MSG_PUB.Count_And_Get
3520       ( p_count => x_msg_count,
3521         p_data  => x_msg_data
3522       );
3523   WHEN OTHERS THEN
3524     ROLLBACK TO Create_ServiceRequest_PVT;
3525     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3526     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
3527       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
3528     END IF;
3529     FND_MSG_PUB.Count_And_Get
3530       ( p_count => x_msg_count,
3531         p_data  => x_msg_data
3532       );
3533 
3534 END Create_ServiceRequest;
3535 
3536 
3537 ----------------anmukher---------------08/11/2003
3538 -- Added overloaded SR Update API for backward compatibility with 11.5.9
3539 -- This will call the 11.5.10 version of the API
3540 PROCEDURE Update_ServiceRequest
3541   ( p_api_version			IN	NUMBER,
3542     p_init_msg_list			IN	VARCHAR2 DEFAULT fnd_api.g_false,
3543     p_commit				IN	VARCHAR2 DEFAULT fnd_api.g_false,
3544     p_validation_level			IN	NUMBER   DEFAULT fnd_api.g_valid_level_full,
3545     x_return_status			OUT	NOCOPY VARCHAR2,
3546     x_msg_count				OUT	NOCOPY NUMBER,
3547     x_msg_data				OUT	NOCOPY VARCHAR2,
3548     p_request_id			IN	NUMBER,
3549     p_audit_id				IN      NUMBER ,
3550     p_object_version_number		IN      NUMBER,
3551     p_resp_appl_id			IN	NUMBER   DEFAULT NULL,
3552     p_resp_id				IN	NUMBER   DEFAULT NULL,
3553     p_last_updated_by			IN	NUMBER,
3554     p_last_update_login	     		IN	NUMBER   DEFAULT NULL,
3555     p_last_update_date	     		IN	DATE,
3556     p_service_request_rec    		IN    service_request_rec_type,
3557     p_invocation_mode        		IN    VARCHAR2 := 'NORMAL',
3558     p_update_desc_flex       		IN    VARCHAR2 DEFAULT fnd_api.g_false,
3559     p_notes                  		IN    notes_table,
3560     p_contacts               		IN    contacts_table,
3561     p_audit_comments         		IN    VARCHAR2 DEFAULT NULL,
3562     p_called_by_workflow     		IN    VARCHAR2 DEFAULT fnd_api.g_false,
3563     p_workflow_process_id    		IN    NUMBER   DEFAULT NULL,
3564     p_default_contract_sla_ind          IN    VARCHAR2 Default 'N',
3565     x_workflow_process_id    		OUT   NOCOPY NUMBER,
3566     x_interaction_id	    		OUT   NOCOPY NUMBER
3567     )
3568 IS
3569 
3570   l_api_version	       CONSTANT	NUMBER		:= 3.0;
3571   l_api_version_back   CONSTANT	NUMBER		:= 2.0;
3572   l_api_name	       CONSTANT	VARCHAR2(30)	:= 'Update_ServiceRequest';
3573   l_api_name_full      CONSTANT	VARCHAR2(61)	:= G_PKG_NAME||'.'||l_api_name;
3574   l_return_status		VARCHAR2(1);
3575   l_msg_count			NUMBER;
3576   l_msg_data			VARCHAR2(2000);
3577 
3578   l_sr_update_out_rec		sr_update_out_rec_type;
3579 
3580 BEGIN
3581   -- Standard start of API savepoint
3582   SAVEPOINT Update_ServiceRequest_PVT;
3583 
3584   -- Standard call to check for call compatibility
3585   -- Added the and condition for backward compatibility project, now
3586   -- both the version 2.0 and 3.0 are valid as this procedure can be called
3587   -- from both 1158 or 1159 env.
3588   IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
3589                                      G_PKG_NAME)
3590   AND NOT FND_API.Compatible_API_Call(l_api_version_back, p_api_version, l_api_name,
3591                                      G_PKG_NAME) THEN
3592     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3593   END IF;
3594 
3595   -- This check is not needed here. It is included in version 4.0 of the API, which this API calls by anmukher 08/12/03
3596   -- IF (l_service_request_rec.initialize_flag IS NULL OR l_service_request_rec.initialize_flag <> G_INITIALIZED) THEN
3597   --  RAISE FND_API.G_EXC_ERROR;
3598   -- END IF;
3599 
3600   -- Initialize message list if p_init_msg_list is set to TRUE
3601   IF FND_API.To_Boolean(p_init_msg_list) THEN
3602     FND_MSG_PUB.Initialize;
3603   END IF;
3604 
3605   -- Initialize API return status to success
3606   x_return_status := FND_API.G_RET_STS_SUCCESS;
3607 
3608 -- Call 11.5.10 version of the Update SR API
3609   CS_ServiceRequest_PVT.Update_ServiceRequest
3610     ( p_api_version           => 4.0,
3611       p_init_msg_list	      => FND_API.G_FALSE,
3612       p_commit		      => p_commit,
3613       p_validation_level      => p_validation_level,
3614       x_return_status	      => x_return_status,
3615       x_msg_count	      => x_msg_count,
3616       x_msg_data	      => x_msg_data,
3617       p_request_id	      => p_request_id,
3618       p_audit_id	      => p_audit_id,
3619       p_object_version_number => p_object_version_number,
3620       p_resp_appl_id          => p_resp_appl_id,
3621       p_resp_id               => p_resp_id,
3622       p_last_updated_by	      => p_last_updated_by,
3623       p_last_update_login     => p_last_update_login,
3624       p_last_update_date      => p_last_update_date,
3625       p_service_request_rec   => p_service_request_rec,
3626       p_invocation_mode	      => p_invocation_mode,
3627       p_update_desc_flex      => p_update_desc_flex,
3628       p_notes                 => p_notes,
3629       p_contacts              => p_contacts,
3630       p_audit_comments	      => p_audit_comments,
3631       p_called_by_workflow    => p_called_by_workflow,
3632       p_workflow_process_id   => p_workflow_process_id,
3633       p_auto_assign	      => 'N',
3634       p_validate_sr_closure   => 'N',
3635       p_auto_close_child_entities => 'N',
3636       p_default_contract_sla_ind  => p_default_contract_sla_ind,
3637       x_sr_update_out_rec     => l_sr_update_out_rec
3638     );
3639 
3640   -- Assign values returned by the called API to the OUT parameters
3641   x_workflow_process_id		:= l_sr_update_out_rec.workflow_process_id;
3642   x_interaction_id		:= l_sr_update_out_rec.interaction_id;
3643 
3644   IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
3645     raise FND_API.G_EXC_ERROR;
3646   ELSIF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
3647     raise FND_API.G_EXC_UNEXPECTED_ERROR;
3648   END IF;
3649 
3650 EXCEPTION
3651   WHEN FND_API.G_EXC_ERROR THEN
3652     ROLLBACK TO Update_ServiceRequest_PVT;
3653     --IF (l_ServiceRequest_csr%ISOPEN) THEN
3654     --  CLOSE l_ServiceRequest_csr;
3655     -- END IF;
3656     x_return_status := FND_API.G_RET_STS_ERROR;
3657     FND_MSG_PUB.Count_And_Get
3658       ( p_count => x_msg_count,
3659         p_data  => x_msg_data
3660       );
3661 
3662   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3663     ROLLBACK TO Update_ServiceRequest_PVT;
3664    -- IF (l_ServiceRequest_csr%ISOPEN) THEN
3665     --  CLOSE l_ServiceRequest_csr;
3666   --  END IF;
3667     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3668     FND_MSG_PUB.Count_And_Get
3669       ( p_count => x_msg_count,
3670         p_data  => x_msg_data
3671       );
3672 
3673   WHEN OTHERS THEN
3674     ROLLBACK TO Update_ServiceRequest_PVT;
3675    -- IF (l_ServiceRequest_csr%ISOPEN) THEN
3676     --  CLOSE l_ServiceRequest_csr;
3677   --  END IF;
3678     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3679     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
3680       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
3681     END IF;
3682     FND_MSG_PUB.Count_And_Get
3683       ( p_count => x_msg_count,
3684         p_data  => x_msg_data
3685       );
3686 
3687 END Update_ServiceRequest;
3688 
3689 
3690 --------------------------------------------------------------------------
3691 -- Update_ServiceRequest
3692 --------------------------------------------------------------------------
3693 --    p_org_id			    IN	NUMBER   DEFAULT NULL,
3694 
3695 -- Modification History
3696 -- Date     Name     Desc
3697 -- -------- -------- -----------------------------------------------------------
3698 -- 03/04/05 smisra   Reopened Bug 3958329.
3699 --                   Modified IF condition for calling get_default_contract
3700 --                   procedure and added one more condition to call
3701 --                   get_default_contract. Now contract defaulting will happen
3702 --                   when contract related attributes change and existing
3703 --                   contract service id is NULL.
3704 -- 04/29/05 smisra   removed contact point logic and replacd it with procedures
3705 --                   cs_srcontact_pkg.process to validate contact points and
3706 --                   cs_srcontact_pkg.create_update to insert or update
3707 --                   service request contact points
3708 -- 05/09/05 smisra   updated maint_organization_id col from SR Rec record.
3709 --                   set maint_organization_id and inventory_item_id cols of
3710 --                   audit record.
3711 -- 05/27/05 smisra   Bug 4227769
3712 --                   Removed owner and group_owner columns from update to
3713 --                   cs_incidents_all_tl table.
3714 -- 06/07/05 smisra   Release 12 changes
3715 --                   Raised error msg when maint_organization_id is passed for
3716 --                   Non EAM service requests
3717 --                   Raised error msg when maint_organization_id is NOT passed
3718 --                   for EAM SRs with customer product
3719 -- 07/11/05 smisra   Release 12 ERES changes
3720 --                   called CS_SERVICEREQUEST_UTIL.get_status_details to
3721 --                   details of old status and new status.
3722 --                   if request updated is not allowed and new status has
3723 --                   intermediate status id then do the following
3724 --                   1. Warn user that only status will be updated
3725 --                   2. intialize SR record
3726 --                   3. set status_id and last_updated_by from input SR record
3727 --                      p_servicerequest_rec
3728 --                   If new status has intermediate status then set variable
3729 --                   l_start_eres_flag ot Y
3730 --                   if new status has pending approval flag as 'Y' then raise
3731 --                   error because SR cannot be updated to an status needing
3732 --                   approval
3733 --                   Added new parameters to procedure
3734 --                   CS_SERVICEREQUEST_PVT.get_default_contract call
3735 --                   Moved SR Audit creation after ERES processing
3736 --                   If SR status needs approval then Call ERES apporval
3737 --                   CS_ERES_INT_PKG.start_approval_process procedure.
3738 --                   if this procedure return NO_ACTION then do the following
3739 --                   1. validate target status
3740 --                   2. get response, resolution and close dates
3741 --                   3. get status_flag
3742 --                   4. update SR with target status, response, resolution,
3743 --                      close date, status flag
3744 --                   5. if target status is a closed status the
3745 --                      a. call CS_SR_STATUS_PROPAGATION_PKG.CLOSE_SR_CHILDREN
3746 --                         to close SR child entities
3747 --                      b. abort any open workflow if new type allows
3748 --                   Moved raise business event after ERES approval processing
3749 -- 08/01/05 smisra   passed intermediate status id instead of target status
3750 --                   to ERES call
3751 -- 08/03/05 smisra   Raised error if item_serial_number is passed to this proc
3752 --                   passed incident_occurred_date to get_default_contract
3753 -- 08/29/05 smisra   Called task_restrict_close_cross_val procedure for
3754 --                   Service request needing ERES procesing.
3755 -- 10/05/05 smisra   Added a call to update_task_address.
3756 --                   This procedure is called when validation level is FULL and
3757 --                   incident location id or type is changed
3758 -- 10/11/05 smisra   Bug 4666784
3759 --                   called validate_sr_closure and close_sr_children only
3760 --                   if old close flag is 'N' and new close flag is 'Y'
3761 -- 10/14/05 smisra   fixed Bug 4674131
3762 --                   moved update_task_address under condition
3763 --                   l_only_status_updated <> 'Y' so that task address update
3764 --                   does not happen when only status is changed
3765 -- 12/14/05 smisra   Bug 4386870. Called vldt_sr_rec after update_sr_validation
3766 --                   set incident_country, incident_location_id and
3767 --                   incident_locatiomn_type attribute of audit record just-
3768 --                   before call to create audit
3769 -- 12/23/05 smisra   Bug 4894942
3770 --                   1. Passed additional parameters to vldt_sr_rec call
3771 --                   2. Removed the code to default contract service id, Now
3772 --                      this code is part of vldt_sr_rec.
3773 --                   3. Removed the code to get coverage type. This code is
3774 --                      moved to vldt_sr_rec
3775 --                   4. Added auditing of following attributes just before call
3776 --                      to create audit
3777 --                      a. resource_type
3778 --                      b. group_type
3779 --                      c. incident_owner_id
3780 --                      d. group_owner_id
3781 --                      e. owner_assigned_time
3782 --                      f. territory_id
3783 -- 12/30/05 smisra   Bug 4869065
3784 --                   Set site_id cols of audit record just before call to
3785 --                   create audit
3786 -- 03/01/05 spusegao Modified to allow service request status update using SR Update api for ERES call back procedure.
3787 --------------------------------------------------------------------------------
3788 PROCEDURE Update_ServiceRequest
3789   ( p_api_version			IN	NUMBER,
3790     p_init_msg_list			IN	VARCHAR2 DEFAULT fnd_api.g_false,
3791     p_commit				IN	VARCHAR2 DEFAULT fnd_api.g_false,
3792     p_validation_level			IN	NUMBER   DEFAULT fnd_api.g_valid_level_full,
3793     x_return_status			OUT	NOCOPY VARCHAR2,
3794     x_msg_count				OUT	NOCOPY NUMBER,
3795     x_msg_data				OUT	NOCOPY VARCHAR2,
3796     p_request_id			IN	NUMBER,
3797     p_audit_id				IN      NUMBER ,
3798     p_object_version_number		IN      NUMBER,
3799     p_resp_appl_id			IN	NUMBER   DEFAULT NULL,
3800     p_resp_id				IN	NUMBER   DEFAULT NULL,
3801     p_last_updated_by			IN	NUMBER,
3802     p_last_update_login	     		IN	NUMBER   DEFAULT NULL,
3803     p_last_update_date	     		IN	DATE,
3804     p_service_request_rec    		IN    service_request_rec_type,
3805     p_invocation_mode        		IN    VARCHAR2 := 'NORMAL',
3806     p_update_desc_flex       		IN    VARCHAR2 DEFAULT fnd_api.g_false,
3807     p_notes                  		IN    notes_table,
3808     p_contacts               		IN    contacts_table,
3809     p_audit_comments         		IN    VARCHAR2 DEFAULT NULL,
3810     p_called_by_workflow     		IN    VARCHAR2 DEFAULT fnd_api.g_false,
3811     p_workflow_process_id    		IN    NUMBER   DEFAULT NULL,
3812     -- Commented out since these are now part of the out rec type --anmukher--08/08/03
3813     -- x_workflow_process_id    	OUT   NOCOPY NUMBER,
3814     -- x_interaction_id	    		OUT   NOCOPY NUMBER
3815     ----------------anmukher--------------------08/05/03
3816     -- Added for 11.5.10 projects
3817     p_auto_assign		    	IN	VARCHAR2 Default 'N',
3818     p_validate_sr_closure	    	IN	VARCHAR2 Default 'N',
3819     p_auto_close_child_entities	    	IN	VARCHAR2 Default 'N',
3820     p_default_contract_sla_ind          IN      VARCHAR2 Default 'N',
3821     --Add p_auto_generate_tasks for 12.2-Auto Task creation
3822     p_auto_generate_tasks		IN	VARCHAR2 Default 'N',
3823     x_sr_update_out_rec		    	OUT NOCOPY sr_update_out_rec_type
3824     )
3825   IS
3826      l_api_name                   CONSTANT VARCHAR2(30)    := 'Update_ServiceRequest';
3827 
3828 -- changed the version from 3.0 to 4.0 anmukher aug 11 2003
3829 
3830      l_api_version                CONSTANT NUMBER          := 4.0;
3831      l_api_version_back           CONSTANT NUMBER          := 3.0;
3832      l_api_name_full              CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
3833      l_log_module                 CONSTANT VARCHAR2(255)   := 'cs.plsql.' || l_api_name_full || '.';
3834      l_return_status              VARCHAR2(1);
3835      l_return_status_onetime	  VARCHAR2(1);
3836      l_cp_inventory_item_id       NUMBER;
3837      l_close_flag                 VARCHAR2(1);
3838      l_service_request_rec        service_request_rec_type DEFAULT p_service_request_rec;
3839      l_sr_rec_temp                service_request_rec_type DEFAULT p_service_request_rec;
3840      l_transaction_type           CONSTANT VARCHAR2(61)    := G_PKG_NAME||'_'||l_api_name;
3841      l_message_revision           NUMBER;
3842      l_maintenance_mode           VARCHAR2(30);
3843      p_request_number             VARCHAR2(30) DEFAULT NULL;
3844      p_user_id                    NUMBER DEFAULT  NULL;
3845      p_login_id                   NUMBER DEFAULT  NULL;
3846      p_org_id                     NUMBER DEFAULT  NULL;
3847      l_contacts                   contacts_table ;
3848      l_update_flag                VARCHAR2(1);
3849      l_dummy                      NUMBER;
3850      l_audit_id                   NUMBER;
3851 
3852      l_jtf_note_id                NUMBER ;
3853      l_owner_assigned_flag        VARCHAR2(1);
3854 
3855      l_bind_data_id               NUMBER;
3856      l_contra_id                  NUMBER;
3857      l_contract_number            VARCHAR2(120) ;
3858 
3859      l_msg_id   NUMBER;
3860      l_msg_count    NUMBER;
3861      l_msg_data   VARCHAR2(2000);
3862 
3863      -- Added for enh. 2655115
3864      l_status_flag  VARCHAR2(1);
3865     -- changes for  11.5.10 usability enhancement
3866     l_old_responded_flag   VARCHAR2(1);
3867     l_old_resolved_flag    VARCHAR2(1);
3868     l_new_responded_flag   VARCHAR2(1);
3869     l_new_resolved_flag    VARCHAR2(1);
3870     l_res_close_flag       VARCHAR2(1);
3871     --Fixed bug#2802393, changed length from 255 to 2500
3872     l_uwq_body  VARCHAR2(2500);
3873     l_imp_level  NUMBER;
3874     l_imp_level_old NUMBER;
3875     --Fixed bug#2802393, changed length from 30 to 80
3876     l_title VARCHAR2(80);
3877     l_send_uwq_notification  BOOLEAN := FALSE;
3878     l_uwq_body2 VARCHAR2(2000);
3879     p_uwq_msg_notification  VARCHAR2(30) := 'CS_SR_UWQ_NOTIFICATION';
3880     p_uwq_upd_notification  VARCHAR2(30) := 'CS_SR_UWQ_UPDATION';
3881     l_old_owner_id     NUMBER;
3882     --	l_coverage_type_rec  coverage_type_rec; ----pkesani
3883     lv_primary_flag VARCHAR2(3) ;
3884 
3885     -- added below 2 variables for bug 11699979
3886     l_validate_sr_closure VARCHAR2(3);
3887     l_auto_close_child_entities VARCHAR2(3);
3888 
3889     --12.2+ siahmed
3890     l_project_info_status   VARCHAR2(3);
3891     --end of 12.2+
3892 
3893     SR_Lock_Row                  EXCEPTION;
3894     invalid_install_site           EXCEPTION;
3895 
3896      PRAGMA EXCEPTION_INIT( SR_Lock_Row, -54 );
3897 
3898 /* **************** This cursor is no longer needed as the
3899    l_old_ServiceRequest_rec is now changed to type sr_oldvalues_rec_type .
3900 
3901    Replacing the select list of columns with a select * so that the
3902    subtype defined in the spec can be used to pass the old SR values as
3903    a parameter to other procedures
3904 
3905 * *****************/
3906  -- This rec type was changed to sr_oldvalues_rec_type as the
3907  -- workitem API (Misc ER owner Auto Assginment )needed a record type
3908  -- with old values , also the API validations needed the oldvalues_rec .
3909 
3910      CURSOR L_SERVICEREQUEST_CSR IS
3911      SELECT *
3912      from   cs_incidents_all_vl
3913      where  incident_id = p_request_id
3914      for    update nowait;
3915 
3916      L_OLD_SERVICEREQUEST_REC     SR_OLDVALUES_REC_TYPE;
3917 
3918      -- out rec for servicerequest_cross_val
3919 
3920 	 l_sr_cross_val_out_rec       CS_ServiceRequest_UTIL.sr_cross_val_out_rec_type;
3921 
3922      -- Validation record
3923      l_sr_validation_rec          request_validation_rec_type;
3924 
3925      l_audit_vals_rec		      sr_audit_rec_type;
3926 
3927      -- Some temp variables
3928      l_update_desc_flex           VARCHAR2(1) := p_update_desc_flex;
3929      l_type_id_temp               NUMBER;
3930      l_only_status_update_flag    VARCHAR2(1) := 'N';
3931      l_inventory_org_id           NUMBER;
3932      l_closed_flag_temp           VARCHAR2(1);
3933      l_status_validated           BOOLEAN:= FALSE;
3934      l_contact_phone_num          VARCHAR2(36);
3935      l_contact_fax_num            VARCHAR2(36);
3936      l_employee_name              VARCHAR2(240);
3937 
3938      l_note_index                 BINARY_INTEGER;
3939      l_contact_index              BINARY_INTEGER;
3940      l_note_id                    NUMBER;
3941      l_note_context_id            NUMBER;
3942      l_notes_detail               VARCHAR2(32767);
3943      l_interaction_id             NUMBER;
3944 
3945      l_bill_to_customer_id        NUMBER;
3946      l_bill_to_location_id        NUMBER;
3947      l_ship_to_customer_id        NUMBER;
3948      l_ship_to_location_id        NUMBER;
3949      l_install_customer_id        NUMBER;
3950      l_install_location_id        NUMBER;
3951 
3952      l_org_id                     NUMBER;
3953 
3954      l_contract_id                NUMBER;
3955      l_project_number             VARCHAR2(120);
3956 
3957      l_primary_contact_found      VARCHAR2(1) := 'N';
3958      l_contacts_passed            VARCHAR2(1) := 'N' ;
3959 
3960      l_old_close_flag             VARCHAR2(1) ;
3961      l_new_close_flag             VARCHAR2(1) ;
3962 
3963      -- For Workflow Hook
3964      l_workflow_item_key          NUMBER;
3965 
3966      l_autolaunch_workflow_flag   VARCHAR2(1);
3967      l_abort_workflow_close_flag  VARCHAR2(1);
3968 
3969      l_disallow_request_update   VARCHAR2(1);
3970      l_disallow_owner_update     VARCHAR2(1);
3971      l_disallow_product_update   VARCHAR2(1);
3972 
3973      l_sr_contact_point_id NUMBER;
3974      p_sr_contact_point_id NUMBER;
3975 
3976      l_party_id_update             VARCHAR2(1);
3977      l_contact_point_id_update     VARCHAR2(1);
3978      l_contact_point_type_update   VARCHAR2(1);
3979      l_contact_type_update         VARCHAR2(1);
3980      l_primary_flag_update         VARCHAR2(1) ;
3981 
3982      l_old_party_id           NUMBER;
3983      l_old_contact_point_id   NUMBER;
3984      l_old_contact_point_type VARCHAR2(30);
3985      l_old_contact_type       VARCHAR2(30);
3986      l_old_primary_flag       VARCHAR2(1) ;
3987 
3988      l_primary_contact_point_id    NUMBER;
3989      l_saved_primary_contact_id    NUMBER;
3990      l_saved_contact_point_id      NUMBER ;
3991 
3992      l_primary_contact_change      VARCHAR2(1) := 'N';
3993 
3994      l_count                  NUMBER;
3995 
3996      ---Added so that workflow can call Update SR API  instead of Calling Create Audit API
3997      ----bug 1485825
3998      l_wf_process_itemkey    VARCHAR2(30);
3999      l_workflow_process_name  VARCHAR2(30);
4000      l_workflow_process_id    NUMBER;
4001      DestUpdated          EXCEPTION;
4002 	 NoUpdate			  EXCEPTION;
4003 	 TargUpdated		  EXCEPTION;
4004 
4005    -- Added for enh. 2690787
4006    l_primary_contact       NUMBER;
4007 
4008    -- Added to be used as OUT parameters in the call to the Business Events wrapper
4009    -- API.
4010    lx_return_status              VARCHAR2(3);
4011    lx_msg_count                  NUMBER(15);
4012    lx_msg_data                   VARCHAR2(2000);
4013 
4014    -- The BES wraper requires the old and new values of the updated SR to be passed
4015    -- as service_request_rec_type data types. The new values are accepted as an IN
4016    -- parameter, but there is'nt an equivalent rec type for the old values.
4017    -- This rec type will be populated only with attributes that can potentially be
4018    -- used to raise Business events. eg. Staus, Urgency, Owner, etc.
4019    l_old_sr_rec                  service_request_rec_type;
4020 
4021    -- for cmro-eam; Local variable to store the old and new eam/cmro type flags that
4022    -- will be used to populate the sr record type variable that is passed to the
4023    -- user hooks
4024 
4025    l_old_maintenance_flag        VARCHAR2(3) := l_service_request_rec.old_type_maintenance_flag;
4026    l_new_maintenance_flag        VARCHAR2(3) := l_service_request_rec.new_type_maintenance_flag;
4027 
4028    l_old_cmro_flag               VARCHAR2(3) := l_service_request_rec.old_type_CMRO_flag;
4029    l_new_cmro_flag               VARCHAR2(3) := l_service_request_rec.new_type_CMRO_flag;
4030 
4031    --Added for 11.5.10 Auditing project
4032    lx_audit_id			NUMBER;
4033 
4034    -- Added for API changes for unassigned_indicator
4035    l_unassigned_indicator NUMBER := 0 ;
4036 
4037    -- Local variable to store business usage for security validation
4038    l_business_usage       VARCHAR2(30);
4039 
4040    -- Local variable to store attribute if security is enabled for self service resps.
4041    l_ss_sr_type_restrict   VARCHAR2(10);
4042 
4043    -- bug 3077818
4044 
4045    l_primary_flag         VARCHAR2(3) := 'N';
4046    l_note_status          VARCHAR2(3) ;
4047    l_timezone_id              NUMBER        ;
4048 
4049    l_primary_flag_temp        VARCHAR2(1)   ;
4050    l_contact_point_id_temp    NUMBER        ;
4051    l_contact_party_id_temp    NUMBER        ;
4052    l_contact_point_type_temp  VARCHAR2(30)  ;
4053    l_contact_type_temp        VARCHAR2(30)  ;
4054 l_business_process_id       NUMBER;
4055 l_contract_service_id_valid VARCHAR2(1);
4056 l_old_contacts         contacts_table;
4057 l_processed_contacts   contacts_table;
4058 
4059 l_start_eres_flag              VARCHAR2(1);
4060 l_approval_status              VARCHAR2(80);
4061 l_sr_related_data              RELATED_DATA_TYPE;
4062 l_primary_contact_party_id     cs_hz_sr_contact_points.party_id % TYPE;
4063 l_last_updated_by_temp         NUMBER;
4064 
4065    --siahmed added for update onetime address
4066    l_incident_location_id     NUMBER;
4067    l_onetime_add_cnt          NUMBER;
4068    --end of addition by siahmed
4069 
4070   --Added for Auto-Task Creation
4071   l_task_template_id             NUMBER;
4072   l_task_template_group_owner    NUMBER;
4073   l_task_tmpl_group_owner_type   VARCHAR2(240);
4074   l_task_owner_name              VARCHAR2(120);
4075   l_auto_task_gen_rec	         CS_AutoGen_Task_PVT.auto_task_gen_rec_type;
4076   l_task_template_group_rec	 JTF_TASK_INST_TEMPLATES_PUB.task_template_group_info;
4077   l_task_template_table	         JTF_TASK_INST_TEMPLATES_PUB.task_template_info_tbl;
4078 
4079 BEGIN
4080 
4081   -- Standard start of API savepoint
4082   SAVEPOINT Update_ServiceRequest_PVT;
4083 
4084   -- Standard call to check for call compatibility
4085   -- Added the and condition for backward compatibility project, now
4086   -- both the version 2.0 and 3.0 are valid as this procedure can be called
4087   -- from both 1158 or 1159 env.
4088   -- The previous version, 3.0, is supported by the overloaded procedure. This API can be
4089   -- called only with ver 4.0
4090   IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
4091                                      G_PKG_NAME) THEN
4092   -- AND NOT FND_API.Compatible_API_Call(l_api_version_back, p_api_version, l_api_name,
4093   --                                   G_PKG_NAME)
4094     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4095   END IF;
4096 
4097   IF ( l_service_request_rec.initialize_flag IS NULL OR
4098        l_service_request_rec.initialize_flag <> G_INITIALIZED ) THEN
4099     RAISE FND_API.G_EXC_ERROR;
4100   END IF;
4101 
4102   -- Initialize message list if p_init_msg_list is set to TRUE
4103   IF FND_API.To_Boolean(p_init_msg_list) THEN
4104     FND_MSG_PUB.Initialize;
4105   END IF;
4106 
4107   -- Initialize API return status to success
4108   x_return_status := FND_API.G_RET_STS_SUCCESS;
4109 
4110 ----------------------- FND Logging -----------------------------------
4111   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4112   THEN
4113     FND_LOG.String
4114     ( FND_LOG.level_procedure , L_LOG_MODULE || 'start'
4115     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
4116     );
4117     FND_LOG.String
4118     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4119     , 'p_api_version:' || p_api_version
4120     );
4121     FND_LOG.String
4122     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4123     , 'p_init_msg_list:' || p_init_msg_list
4124     );
4125     FND_LOG.String
4126     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4127     , 'p_commit:' || p_commit
4128     );
4129     FND_LOG.String
4130     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4131     , 'p_validation_level:' || p_validation_level
4132     );
4133     FND_LOG.String
4134     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4135     , 'p_resp_appl_id:' || p_resp_appl_id
4136     );
4137     FND_LOG.String
4138     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4139     , 'p_resp_id:' || p_resp_id
4140     );
4141     FND_LOG.String
4142     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4143     , 'P_audit_comments:' || P_audit_comments
4144     );
4145     FND_LOG.String
4146     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4147     , 'P_object_version_number:' || P_object_version_number
4148     );
4149     FND_LOG.String
4150     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4151     , 'P_Last_updated_by:' || P_Last_updated_by
4152     );
4153     FND_LOG.String
4154     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4155     , 'P_Last_update_login:' || P_Last_update_login
4156     );
4157     FND_LOG.String
4158     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4159     , 'P_Last_update_date:' || P_Last_update_date
4160     );
4161     FND_LOG.String
4162     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4163     , 'p_request_id:' || p_request_id
4164     );
4165     FND_LOG.String
4166     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4167     , 'p_request_number:' || p_request_number
4168     );
4169     FND_LOG.String
4170     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4171     , 'p_auto_assign:' || p_auto_assign
4172     );
4173     FND_LOG.String
4174     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4175     , 'P_Called_by_workflow:' || P_Called_by_workflow
4176     );
4177     FND_LOG.String
4178     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4179     , 'P_Workflow_process_id:' || P_Workflow_process_id
4180     );
4181     FND_LOG.String
4182     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4183     , 'P_Validate_SR_Closure:' || P_Validate_SR_Closure
4184     );
4185     FND_LOG.String
4186     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4187     , 'P_Auto_Close_Child_Entities:' || P_Auto_Close_Child_Entities
4188     );
4189     FND_LOG.String
4190     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4191     , 'P_auto_generate_tasks:' || P_auto_generate_tasks
4192     );
4193 
4194  -- --------------------------------------------------------------------------
4195  -- This procedure Logs the record paramters of SR and NOTES, CONTACTS tables.
4196  -- --------------------------------------------------------------------------
4197     Log_SR_PVT_Parameters
4198     ( p_service_request_rec   	=> p_service_request_rec
4199     , p_notes                 	=> p_notes
4200     , p_contacts              	=> p_contacts
4201     );
4202 
4203   END IF;
4204 
4205   -- Initialize the value of the parameter from profile cs_sr_restrict_ib
4206   -- by shijain 4th dec 2002
4207 
4208      g_restrict_ib:= fnd_profile.value('CS_SR_RESTRICT_IB');
4209 
4210      IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4211      THEN
4212        FND_LOG.String
4213        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4214 	, 'The Value of profile CS_SR_RESTRICT_IB :' || g_restrict_ib
4215        );
4216      END IF;
4217 
4218     BEGIN
4219 
4220     SELECT object_version_number INTO l_dummy
4221     FROM cs_incidents_all_b
4222     WHERE incident_id = p_request_id;
4223 
4224     EXCEPTION
4225 	WHEN NO_DATA_FOUND THEN
4226 	       l_return_status := FND_API.G_RET_STS_ERROR;
4227 		  CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
4228               (p_token_an     => l_api_name_full,
4229 			   p_token_v      => TO_CHAR(p_request_id),
4230 			   p_token_p      => 'Request ID' ,
4231                p_table_name   => G_TABLE_NAME,
4232                p_column_name  => 'INCIDENT_ID');
4233 	    RAISE FND_API.G_EXC_ERROR;
4234     END ;
4235 
4236 
4237 
4238     IF (l_dummy > p_object_version_number ) THEN
4239       RAISE DestUpdated;
4240     ELSIF (l_dummy < p_object_version_number ) THEN
4241 	     IF  (p_invocation_mode = 'NORMAL')THEN
4242 	        RAISE NoUpdate;
4243 		 ELSIF (p_invocation_mode = 'REPLAY')THEN
4244 		    NULL;
4245 		 END IF;
4246     ELSE
4247   	  	 IF (p_invocation_mode = 'REPLAY') THEN
4248 		    RAISE TargUpdated;
4249 		 ELSIF (p_invocation_mode = 'NORMAL')THEN
4250 		    NULL;
4251 		 END IF;
4252 
4253   END IF;
4254 
4255   -- Check if mandatory parameter is passed
4256   IF (p_request_id IS NULL ) THEN
4257       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4258                              (p_token_an    => l_api_name_full,
4259                               p_token_np     => 'SR Incident Id',
4260                               p_table_name  => G_TABLE_NAME,
4261                               p_column_name => 'INCIDENT_ID' );
4262 
4263       RAISE FND_API.G_EXC_ERROR;
4264   END IF;
4265 
4266   IF (p_object_version_number IS NULL ) THEN
4267       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4268                            (p_token_an   => l_api_name_full,
4269                             p_token_np    => 'SR Object Version Number',
4270                             p_table_name => G_TABLE_NAME,
4271                             p_column_name => 'OBJECT_VERSION_NUMBER');
4272 
4273       RAISE FND_API.G_EXC_ERROR;
4274   END IF;
4275 
4276   -- Check if user has passed null to mandatory parameters.
4277 
4278   IF  (l_service_request_rec.type_id  IS NULL) THEN
4279       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4280                               (p_token_an    => l_api_name_full,
4281                                p_token_np     => 'SR Type',
4282                                p_table_name  => G_TABLE_NAME,
4283                                p_column_name => 'INCIDENT_TYPE_ID');
4284       RAISE FND_API.G_EXC_ERROR;
4285   END IF;
4286 
4287   IF  (l_service_request_rec.status_id  IS NULL) THEN
4288       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4289                                  (p_token_an    => l_api_name_full,
4290                                   p_token_np     =>  'SR Status',
4291                                   p_table_name  => G_TABLE_NAME,
4292                                   p_column_name => 'INCIDENT_STATUS_ID');
4293       RAISE FND_API.G_EXC_ERROR;
4294   END IF;
4295 
4296   IF  (l_service_request_rec.severity_id  IS NULL) THEN
4297       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4298                              (p_token_an    => l_api_name_full,
4299                               p_token_np     => 'SR Severity',
4300                               p_table_name  => G_TABLE_NAME,
4301                               p_column_name => 'SEVERITY_ID');
4302 
4303       RAISE FND_API.G_EXC_ERROR;
4304   END IF;
4305 
4306   -- Request Date is a reqd field, so check if passed, else return error
4307   IF  (l_service_request_rec.request_date IS NULL) THEN
4308     CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
4309                              (p_token_an    => l_api_name_full,
4310                               p_token_np     => 'SR Request Date',
4311                               p_table_name  => G_TABLE_NAME,
4312                               p_column_name => 'REQUEST_DATE');
4313     RAISE FND_API.G_EXC_ERROR;
4314   END IF;
4315 
4316 
4317   IF (l_service_request_rec.summary IS NULL) THEN
4318     CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg (
4319        p_token_an    => l_api_name_full,
4320        p_token_np     => 'SR Summary',
4321        p_table_name  => G_TABLE_NAME,
4322        p_column_name => 'SUMMARY');
4323     RAISE FND_API.G_EXC_ERROR;
4324   END IF;
4325 
4326 
4327   -- Fetch and lock the original values
4328   OPEN  l_ServiceRequest_csr;
4329   FETCH l_ServiceRequest_csr INTO l_old_ServiceRequest_rec;
4330 
4331   IF ( l_ServiceRequest_csr%NOTFOUND ) THEN
4332 
4333      CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
4334                                ( p_token_an    =>  l_api_name_full,
4335                                  p_token_v     =>  TO_CHAR(p_request_id),
4336                                  p_token_p     =>  'p_request_id',
4337                                  p_table_name  => G_TABLE_NAME,
4338                                  p_column_name => 'REQUEST_ID' );
4339 
4340     RAISE FND_API.G_EXC_ERROR;
4341   END IF;
4342   -- check for item serial number. it must be null or G_miss_char
4343   IF l_service_request_rec.item_serial_number <> FND_API.G_MISS_CHAR
4344   THEN
4345     FND_MESSAGE.set_name ('CS', 'CS_SR_ITEM_SERIAL_OBSOLETE');
4346     FND_MESSAGE.set_token
4347     ( 'API_NAME'
4348     , 'CS_SERVICEREQUEST_PVT.update_servicerequest'
4349     );
4350     FND_MSG_PUB.ADD_DETAIL
4351     ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.ITEM_SERIAL_NUMBER'
4352     );
4353     RAISE FND_API.G_EXC_ERROR;
4354   END IF;
4355   --
4356   IF l_service_request_rec.type_id = FND_API.G_MISS_NUM
4357   THEN
4358     l_service_request_rec.type_id := l_old_servicerequest_rec.incident_type_id;
4359   END IF;
4360   IF l_service_request_rec.status_id = FND_API.G_MISS_NUM
4361   THEN
4362     l_service_request_rec.status_id := l_old_servicerequest_rec.incident_status_id;
4363   END IF;
4364 
4365   CS_SERVICEREQUEST_PVT.get_incident_type_details
4366   ( p_incident_type_id          => l_service_request_rec.type_id
4367   , x_business_process_id       => l_sr_related_data.business_process_id
4368   , x_autolaunch_workflow_flag  => l_sr_related_data.autolaunch_workflow_flag
4369   , x_abort_workflow_close_flag => l_sr_related_data.abort_workflow_close_flag
4370   , x_workflow                  => l_sr_related_data.workflow
4371   , x_return_status             => l_return_status
4372   );
4373   IF l_return_status = FND_API.G_RET_STS_ERROR
4374   THEN
4375     CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
4376     ( p_token_an     => l_api_name_full
4377     , p_token_v      => TO_CHAR(l_service_request_rec.type_id)
4378     , p_token_p      => 'p_type_id'
4379     , p_table_name   => G_TABLE_NAME
4380     , p_column_name  => 'INCIDENT_TYPE_ID'
4381     );
4382     RAISE FND_API.G_EXC_ERROR;
4383   END IF;
4384 
4385   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4386   THEN
4387     FND_LOG.String
4388     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4389     , 'The defaulted value of parameter business_process_id :'
4390     || l_sr_related_data.business_process_id
4391     );
4392   END IF;
4393 
4394    -- 1. Perform the security check if validation level is > none
4395    -- 2. Perform the SR Type change check for EAM to non-EAM and vice versa
4396    -- 3. Check if the install site and site use are the same
4397 
4398    IF ( p_validation_level > fnd_api.g_valid_level_none ) then
4399       -- dj api cleanup
4400       -- Validate if the current responsibility has access to the SR type being update.
4401       -- If the SR Type is itself being updated, then first validate if the responsibility
4402       -- has access to the old SR Type and then vaidate if the responsibility has accesss
4403       -- to the new SR Type as well.
4404       -- Invoke the VALIDATE_TYPE procedure that has the logic to check for security
4405       -- access
4406 
4407       -- Get the business usage of the responsibility that is attempting to create
4408       -- the SR.
4409       get_business_usage (
4410          p_responsibility_id      => p_resp_id,
4411          p_application_id         => fnd_global.resp_appl_id,
4412          x_business_usage         => l_business_usage );
4413 
4414       IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4415       THEN
4416 	FND_LOG.String
4417 	( FND_LOG.level_procedure , L_LOG_MODULE || ''
4418 	, 'The defaulted value of parameter business_usage :' || l_business_usage
4419 	);
4420       END IF;
4421 
4422       -- Get indicator of self service security enabled or not
4423       if ( l_business_usage = 'SELF_SERVICE' ) then
4424          get_ss_sec_enabled (
4425 	    x_ss_sr_type_restrict => l_ss_sr_type_restrict );
4426       end if;
4427 
4428 
4429       -- For bug 3370562 - pass resp_id an appl_id
4430       -- validate security in update; first against old sr type
4431 
4432       -- For bug 3474365 - pass different operation code for old sr type
4433       cs_servicerequest_util.validate_type (
4434          p_parameter_name       => NULL,
4435          p_type_id   	        => l_old_servicerequest_rec.incident_type_id,
4436          p_subtype  	        => G_SR_SUBTYPE,
4437          p_status_id            => p_service_request_rec.status_id, -- not used
4438          p_resp_id              => p_resp_id,
4439          p_resp_appl_id         => NVL(p_resp_appl_id, fnd_global.resp_appl_id),
4440          p_business_usage       => l_business_usage,
4441          p_ss_srtype_restrict   => l_ss_sr_type_restrict,
4442          p_operation            => 'UPDATE_OLD',
4443          x_return_status        => lx_return_status,
4444          x_cmro_flag            => l_old_cmro_flag,
4445          x_maintenance_flag     => l_old_maintenance_flag );
4446 
4447       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
4448          -- security violation; responsibility does not have access to SR Type
4449          -- being created. Stop and raise error.
4450          RAISE FND_API.G_EXC_ERROR;
4451       end if;
4452 
4453       -- For bug 3370562 - pass resp_id an appl_id
4454       -- if type has changed and is not the same as the existing type, then validate
4455       -- if the responsibility has access to the new SR Type
4456       IF ( p_service_request_rec.type_id <> FND_API.G_MISS_NUM   AND
4457 	   p_service_request_rec.type_id <> l_old_ServiceRequest_rec.incident_type_id ) then
4458          cs_servicerequest_util.validate_type (
4459             p_parameter_name       => NULL,
4460             p_type_id   	   => p_service_request_rec.type_id,
4461             p_subtype  	           => G_SR_SUBTYPE,
4462             p_status_id            => p_service_request_rec.status_id, -- not used
4463             p_resp_id              => p_resp_id,
4464             p_resp_appl_id         => NVL(p_resp_appl_id, fnd_global.resp_appl_id),
4465             p_business_usage       => l_business_usage,
4466             p_ss_srtype_restrict   => l_ss_sr_type_restrict,
4467             p_operation            => 'UPDATE',
4468             x_return_status        => lx_return_status,
4469             x_cmro_flag            => l_new_cmro_flag,
4470             x_maintenance_flag     => l_new_maintenance_flag );
4471 
4472          if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
4473             -- security violation; responsibility does not have access to SR Type
4474             -- being created. Stop and raise error.
4475             RAISE FND_API.G_EXC_ERROR;
4476          end if;
4477 
4478 	 -- if the type has changed, check if the change is EAM <-> non-EAM.
4479          cs_servicerequest_util.validate_type_change (
4480            p_old_eam_type_flag        => l_old_maintenance_flag,
4481            p_new_eam_type_flag        => l_new_maintenance_flag,
4482            x_return_status            => lx_return_status );
4483 
4484          if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
4485             -- Type change is not allowed. Msg put on stack by val. proc
4486             RAISE FND_API.G_EXC_ERROR;
4487          end if;
4488 
4489       ELSE  -- the type has not changed; assign old flag values to the new flags
4490          l_new_cmro_flag          := l_old_cmro_flag;
4491          l_new_maintenance_flag   := l_old_maintenance_flag;
4492       END IF;
4493       IF NVL(l_new_maintenance_flag,'N') <> 'Y'
4494       THEN
4495         IF p_service_request_rec.maint_organization_id <> FND_API.G_MISS_NUM
4496         THEN
4497           FND_MESSAGE.set_name ('CS', 'CS_SR_MAINT_ORG_NOT_ALLOWED');
4498           FND_MESSAGE.set_token
4499           ( 'API_NAME'
4500           , 'CS_SERVICEREQUEST_PVT.update_servicerequest'
4501           );
4502           FND_MSG_PUB.ADD_DETAIL
4503           ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.MAINT_ORGANIZATION_ID'
4504           );
4505           RAISE FND_API.G_EXC_ERROR;
4506         END IF;
4507       ELSE -- maintenance flag is 'Y'
4508         IF (p_service_request_rec.customer_product_id IS NOT NULL AND
4509             p_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM)
4510         THEN
4511           IF (p_service_request_rec.maint_organization_id = FND_API.G_MISS_NUM AND
4512               l_old_servicerequest_rec.maint_organization_id IS NULL)
4513           THEN
4514             CS_ServiceRequest_UTIL.Add_Missing_Param_Msg(l_api_name_full, 'Maint_organization_id');
4515             RAISE FND_API.G_EXC_ERROR;
4516           ELSIF (p_service_request_rec.maint_organization_id IS NULL) THEN
4517             CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'Maint_organization_id');
4518             RAISE FND_API.G_EXC_ERROR;
4519           END IF;
4520         END IF;
4521       END IF;
4522 
4523       --- For BUG # 2933250, check to see if install_site_id and install_site_use_id are same . -- pkesani
4524 
4525       IF (l_service_request_rec.install_site_id = FND_API.G_MISS_NUM)  THEN
4526          IF ( l_service_request_rec.install_site_use_id <>  FND_API.G_MISS_NUM) THEN
4527             l_service_request_rec.install_site_id := l_service_request_rec.install_site_use_id;
4528          END IF;
4529       ELSIF (l_service_request_rec.install_site_id IS NOT NULL) THEN
4530          IF (l_service_request_rec.install_site_use_id = FND_API.G_MISS_NUM) THEN
4531             l_service_request_rec.install_site_use_id := l_service_request_rec.install_site_id;
4532          ELSIF (l_service_request_rec.install_site_use_id <> l_service_request_rec.install_site_id) THEN
4533             RAISE invalid_install_site;
4534          ELSIF (l_service_request_rec.install_site_use_id IS NULL) THEN
4535             RAISE invalid_install_site;
4536          END IF;
4537       ELSIF (l_service_request_rec.install_site_id IS NULL) THEN
4538          IF (l_service_request_rec.install_site_use_id = FND_API.G_MISS_NUM) THEN
4539             l_service_request_rec.install_site_use_id := l_service_request_rec.install_site_id;
4540          ELSIF (l_service_request_rec.install_site_use_id IS NOT NULL) THEN
4541             RAISE invalid_install_site;
4542          END IF;
4543       END IF;
4544 
4545       IF (l_new_maintenance_flag = 'y' OR l_new_maintenance_flag = 'Y') THEN
4546          IF (l_service_request_rec.inventory_org_id IS NULL) THEN
4547             CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(
4548                                l_api_name_full, 'Inventory Org ID');
4549             RAISE FND_API.G_EXC_ERROR;
4550          END IF;
4551       END IF;
4552 
4553       -- popluate the record for the user hooks
4554       l_service_request_rec.Old_type_CMRO_Flag        := l_old_cmro_flag;
4555       l_service_request_rec.Old_type_Maintenance_Flag := l_old_maintenance_flag;
4556       l_service_request_rec.New_type_CMRO_flag        := l_new_cmro_flag;
4557       l_service_request_rec.New_type_Maintenance_flag := l_new_maintenance_flag;
4558 
4559    END IF;   -- IF ( p_validation_level > fnd_api.g_valid_level_none )
4560 
4561    l_sr_related_data.target_status_id := l_service_request_rec.status_id;
4562    CS_SERVICEREQUEST_UTIL.get_status_details
4563    ( p_status_id                  => l_old_servicerequest_rec.incident_status_id
4564    , x_close_flag                 => l_sr_related_data.old_close_flag
4565    , x_disallow_request_update    => l_sr_related_data.old_disallow_request_update
4566    , x_disallow_agent_dispatch    => l_sr_related_data.old_disallow_owner_update
4567    , x_disallow_product_update    => l_sr_related_data.old_disallow_product_update
4568    , x_pending_approval_flag      => l_sr_related_data.old_pending_approval_flag
4569    , x_intermediate_status_id     => l_sr_related_data.old_intermediate_status_id
4570    , x_approval_action_status_id  => l_sr_related_data.old_approval_action_status_id
4571    , x_rejection_action_status_id => l_sr_related_data.old_rejection_action_status_id
4572    , x_return_status              => l_return_status
4573    );
4574    l_start_eres_flag := 'N';
4575    IF (l_service_request_rec.status_id <> FND_API.G_MISS_NUM AND
4576        l_service_request_rec.status_id <> l_old_servicerequest_rec.incident_status_id)
4577    THEN
4578      CS_SERVICEREQUEST_UTIL.get_status_details
4579      ( p_status_id                  => l_sr_related_data.target_status_id
4580      , x_close_flag                 => l_sr_related_data.close_flag
4581      , x_disallow_request_update    => l_sr_related_data.disallow_request_update
4582      , x_disallow_agent_dispatch    => l_sr_related_data.disallow_owner_update
4583      , x_disallow_product_update    => l_sr_related_data.disallow_product_update
4584      , x_pending_approval_flag      => l_sr_related_data.pending_approval_flag
4585      , x_intermediate_status_id     => l_sr_related_data.intermediate_status_id
4586      , x_approval_action_status_id  => l_sr_related_data.approval_action_status_id
4587      , x_rejection_action_status_id => l_sr_related_data.rejection_action_status_id
4588      , x_return_status              => l_return_status
4589      );
4590 
4591      IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4592      THEN
4593        FND_LOG.String
4594        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4595        , 'The defaulted value of parameter disallow_request_update :'
4596        || l_sr_related_data.disallow_request_update
4597        );
4598        FND_LOG.String
4599        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4600        , 'The defaulted value of parameter disallow_owner_update :'
4601        || l_sr_related_data.disallow_owner_update
4602        );
4603        FND_LOG.String
4604        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4605        , 'The defaulted value of parameter disallow_product_update :'
4606        || l_sr_related_data.disallow_product_update
4607        );
4608        FND_LOG.String
4609        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4610        , 'The defaulted value of parameter pending_approval_flag :'
4611        || l_sr_related_data.pending_approval_flag
4612        );
4613        FND_LOG.String
4614        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4615        , 'The defaulted value of parameter intermediate_status_id :'
4616        || l_sr_related_data.intermediate_status_id
4617        );
4618        FND_LOG.String
4619        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4620        , 'The defaulted value of parameter approval_action_status_id :'
4621        || l_sr_related_data.approval_action_status_id
4622        );
4623        FND_LOG.String
4624        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4625        , 'The defaulted value of parameter rejection_action_status_id :'
4626        || l_sr_related_data.rejection_action_status_id
4627        );
4628      END IF;
4629 
4630      IF (l_sr_related_data.intermediate_status_id IS NOT NULL AND
4631          l_sr_related_data.intermediate_status_id <> l_old_servicerequest_rec.incident_status_id AND
4632          NVL(p_service_request_rec.last_update_program_code,'UNKOWN') <> 'ERES')
4633      THEN
4634        l_start_eres_flag := 'Y';
4635        l_service_request_rec.status_id := l_sr_related_data.intermediate_status_id;
4636      END IF;
4637 
4638      IF (l_sr_related_data.pending_approval_flag = 'Y' AND
4639          NVL(p_service_request_rec.last_update_program_code,'UNKOWN') <> 'ERES')
4640      THEN
4641        FND_MESSAGE.set_name ('CS', 'CS_SR_INTERMEDIATE_STATUS');
4642        FND_MESSAGE.set_token
4643        ( 'API_NAME'
4644        , 'CS_SERVICEREQUEST_PVT.update_servicerequest'
4645        );
4646        FND_MESSAGE.set_token('STATUS_ID',l_sr_related_data.target_status_id);
4647        FND_MSG_PUB.ADD_DETAIL
4648        ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.incident_status_id'
4649        );
4650        RAISE FND_API.G_EXC_ERROR;
4651      END IF; -- l_pending approval flag is Y
4652    ELSE -- status_id <> G_MISS and not equal to old value
4653      l_sr_related_data.close_flag             := l_sr_related_data.old_close_flag;
4654      l_sr_related_data.target_status_id       := l_old_servicerequest_rec.incident_status_id;
4655      l_sr_related_data.intermediate_status_id := l_sr_related_data.old_intermediate_status_id;
4656 
4657      IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
4658      THEN
4659        FND_LOG.String
4660        ( FND_LOG.level_procedure , L_LOG_MODULE || ''
4661        , 'The defaulted value of parameter intermediate_status_id :'
4662        || l_sr_related_data.intermediate_status_id
4663        );
4664      END IF;
4665    END IF;
4666    IF l_sr_related_data.old_disallow_request_update = 'Y' AND
4667       l_sr_related_data.intermediate_status_id IS NOT NULL AND
4668       NVL(p_service_request_rec.last_update_program_code,'UNKOWN') <> 'ERES'
4669    THEN
4670      FND_MESSAGE.Set_Name('CS', 'CS_API_SR_ONLY_STATUS_UPDATED');
4671      FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
4672      FND_MSG_PUB.Add_Detail
4673      ( p_message_type => fnd_msg_pub.G_WARNING_MSG
4674      , p_same_associated_columns => 'CS_INCIDENTS_ALL_B.INCIDENT_STATUS_ID'
4675      );
4676      IF l_old_servicerequest_rec.incident_status_id = l_service_request_rec.status_id
4677      THEN
4678        CS_ServiceRequest_UTIL.Add_Same_Val_Update_Msg
4679        ( p_token_an     => 'CS_SERVICEREQUEST_PUB.update_servicerequest'
4680        , p_token_p      => 'p_status_id'
4681        , p_table_name   => G_TABLE_NAME
4682        , p_column_name  => 'INCIDENT_STATUS_ID'
4683        );
4684        RETURN;
4685      ELSE
4686        l_last_updated_by_temp := l_service_request_rec.last_updated_by;
4687        CS_SERVICEREQUEST_PVT.initialize_rec(l_service_request_rec);
4688        -- we need to copy back intermediate status because this case will happen only if
4689        -- input status has intermediate status
4690        l_service_request_rec.status_id        := l_sr_related_data.intermediate_status_id;
4691        l_service_request_rec.last_updated_by  := p_service_request_rec.last_updated_by;
4692      END IF;
4693    END IF;
4694 
4695    -- end of cmro_eam
4696 
4697   -- Made changes for bug #2835847, if either last_update_date is passed
4698   -- in the parameter (p_last_updated_by or in the service request rec.
4699   -- last_updated_by, both will be considered.
4700 
4701      IF (l_service_request_rec.last_updated_by IS NULL OR
4702          l_service_request_rec.last_updated_by = FND_API.G_MISS_NUM) THEN
4703          IF (p_last_updated_by IS NOT NULL AND
4704              p_last_updated_by <>FND_API.G_MISS_NUM) THEN
4705               l_service_request_rec.last_updated_by := p_last_updated_by;
4706          END IF;
4707      END IF;
4708 
4709   -- Make the preprocessing call to the user hooks
4710   --
4711   -- Pre call to the Customer Type User Hook
4712 
4713   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
4714                                       'Update_ServiceRequest',
4715                                       'B', 'C')  THEN
4716 
4717 -- hardcoded the version 2.0 shijain nov 27 2002
4718 
4719     cs_servicerequest_cuhk.Update_ServiceRequest_Pre
4720     ( p_api_version         => 2.0,
4721     p_init_msg_list         => fnd_api.g_false ,
4722     p_commit                => p_commit,
4723     p_validation_level      => p_validation_level,
4724     x_return_status         => l_return_status,
4725     x_msg_count             => x_msg_count,
4726     x_msg_data              => x_msg_data,
4727     p_request_id            => p_request_id ,
4728     p_object_version_number => p_object_version_number,
4729     p_resp_appl_id          => p_resp_appl_id,
4730     p_resp_id               => p_resp_id,
4731     p_last_updated_by       => p_last_updated_by,
4732     p_last_update_login     => p_last_update_login,
4733     p_last_update_date      => p_last_update_date,
4734     p_invocation_mode       => p_invocation_mode,
4735     p_service_request_rec   => l_service_request_rec,
4736     p_update_desc_flex      => p_update_desc_flex,
4737     p_notes                 => p_notes,
4738     p_contacts              => p_contacts,
4739     p_audit_comments        => p_audit_comments,
4740     p_called_by_workflow    => p_called_by_workflow,
4741     p_workflow_process_id   => p_workflow_process_id,
4742     x_workflow_process_id   => x_sr_update_out_rec.workflow_process_id,
4743     x_interaction_id        => x_sr_update_out_rec.interaction_id);
4744 
4745     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4746       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4747     END IF;
4748   END IF;
4749 
4750   -- Pre call to the Vertical Type User Hook
4751   --
4752   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
4753                                       'Update_ServiceRequest',
4754                                       'B', 'V')  THEN
4755 
4756 -- hardcoded the version 2.0 shijain nov 27 2002
4757 
4758     cs_servicerequest_vuhk.Update_ServiceRequest_Pre
4759     ( p_api_version           => 2.0,
4760       p_init_msg_list         => fnd_api.g_false ,
4761       p_commit                => p_commit,
4762       p_validation_level      => p_validation_level,
4763       x_return_status         => l_return_status,
4764       x_msg_count             => x_msg_count,
4765       x_msg_data              => x_msg_data,
4766       p_request_id            => p_request_id ,
4767       p_object_version_number => p_object_version_number,
4768       p_resp_appl_id          => p_resp_appl_id,
4769       p_resp_id               => p_resp_id,
4770       p_last_updated_by       => p_last_updated_by,
4771       p_last_update_login     => p_last_update_login,
4772       p_last_update_date      => p_last_update_date,
4773       p_service_request_rec   => l_service_request_rec,
4774       p_update_desc_flex      => p_update_desc_flex,
4775       p_notes                 => p_notes,
4776       p_contacts              => p_contacts,
4777       p_audit_comments        => p_audit_comments,
4778       p_called_by_workflow    => p_called_by_workflow,
4779       p_workflow_process_id   => p_workflow_process_id,
4780       x_workflow_process_id   => x_sr_update_out_rec.workflow_process_id,
4781       x_interaction_id        => x_sr_update_out_rec.interaction_id);
4782 
4783     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4784       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4785     END IF;
4786   END IF;
4787 
4788   -- Pre call to the Internal Type User Hook
4789   --
4790 
4791   --Code to populate the global record type with the passed record type
4792   --
4793   user_hooks_rec.customer_id  :=  l_old_ServiceRequest_rec.customer_id ;
4794   user_hooks_rec.request_id   :=  p_request_id ;
4795 
4796 -- for cmro_eam
4797   -- set additional paramters for cmro_eam
4798   -- status_flag,old_type_cmro_flag,new_type_cmro_flag,customer_product_id,
4799   -- status_id,exp_resolution_date
4800 
4801     if (l_service_request_rec.status_id = FND_API.G_MISS_NUM) then
4802         l_service_request_rec.status_id := l_old_ServiceRequest_rec.incident_status_id;
4803     end if;
4804 
4805     if (l_service_request_rec.customer_product_id = FND_API.G_MISS_NUM) then
4806         l_service_request_rec.customer_product_id := l_old_ServiceRequest_rec.customer_product_id;
4807     end if;
4808 
4809     if (l_service_request_rec.exp_resolution_date = FND_API.G_MISS_DATE) then
4810         l_service_request_rec.exp_resolution_date := l_old_ServiceRequest_rec.expected_resolution_date;
4811     end if;
4812 
4813     user_hooks_rec.status_flag 		:= get_status_flag(l_service_request_rec.status_id);
4814     user_hooks_rec.old_type_cmro_flag 	:= l_service_request_rec.Old_type_CMRO_Flag;
4815     user_hooks_rec.new_type_cmro_flag 	:= l_service_request_rec.New_type_CMRO_flag;
4816     user_hooks_rec.customer_product_id 	:= l_service_request_rec.customer_product_id;
4817     user_hooks_rec.status_id 		:= l_service_request_rec.status_id;
4818     user_hooks_rec.exp_resolution_date 	:= l_service_request_rec.exp_resolution_date;
4819 
4820 -- end for cmro_eam
4821 
4822    cs_servicerequest_iuhk.Update_ServiceRequest_Pre(x_return_status=>l_return_status);
4823 
4824     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4825       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4826     END IF;
4827 
4828 
4829    -- siahmed 12.1.2 project this to make sure that the address field that will be updated
4830    -- is a one_time_address. This is doen to make so that we can use this
4831    -- global variabel in the update_sr_validation the country gets assigned
4832    -- with the old country valu which is preventing the onetime address
4833    -- to change a country once it has been assined. Using the global
4834    -- variable we will assign the value accordingly.
4835    --check if created by module = 'SR_ONETIME'
4836 	   -- fix for bug 8594093 to check for location as well Ranjan
4837 	   if l_service_request_rec.incident_location_type='HZ_PARTY_SITE' then
4838         	SELECT count(party_site_id) into G_ONETIME_ADD_CNT
4839         	FROM hz_party_sites
4840         	WHERE party_site_id = l_service_request_rec.incident_location_id
4841         	AND created_by_module = 'SR_ONETIME';
4842 	   elsif l_service_request_rec.incident_location_type='HZ_LOCATION' then
4843         	SELECT count(location_id) into G_ONETIME_ADD_CNT
4844         	FROM hz_locations
4845         	WHERE location_id = l_service_request_rec.incident_location_id
4846         	AND created_by_module = 'SR_ONETIME';
4847 	   end if;
4848 	   /*
4849      SELECT count(party_site_id) into G_ONETIME_ADD_CNT
4850      FROM hz_party_sites
4851      WHERE party_site_id = l_service_request_rec.incident_location_id
4852      AND created_by_module = 'SR_ONETIME';
4853 	*/
4854 
4855    --end of addition by siahmed
4856 
4857 
4858 -- hardcoded the version 2.0 shijain nov 27 2002
4859 
4860    l_sr_rec_temp := l_service_request_rec;
4861 
4862      Update_SR_Validation
4863       (   p_api_version           => 2.0,
4864           p_init_msg_list         => fnd_api.g_false ,
4865           --p_service_request_rec   => p_service_request_rec,
4866           p_service_request_rec   => l_sr_rec_temp,
4867           p_contacts              => p_contacts,
4868           p_notes                 => p_notes,
4869           p_audit_comments        => p_audit_comments,
4870           p_invocation_mode       => p_invocation_mode,
4871           p_resp_id               => p_resp_id,
4872           p_resp_appl_id          => p_resp_appl_id,
4873           p_request_id            => p_request_id,
4874           p_validation_level      => p_validation_level,
4875           p_commit                => p_commit,
4876           p_last_updated_by       => p_last_updated_by,
4877           p_last_update_login     => p_last_update_login,
4878           p_last_update_date      => p_last_update_date,
4879           p_object_version_number => p_object_version_number,
4880           x_return_status         => l_return_status,
4881           x_contra_id             => l_contra_id,
4882           x_contract_number       => l_contract_number,
4883           x_owner_assigned_flag   => l_owner_assigned_flag,
4884           x_msg_count             => x_msg_count,
4885           x_msg_data              => x_msg_data,
4886 	      x_audit_vals_rec	      => l_audit_vals_rec,
4887           x_service_request_rec   => l_service_request_rec,
4888           x_autolaunch_wkf_flag   => l_autolaunch_workflow_flag,
4889           x_abort_wkf_close_flag  => l_abort_workflow_close_flag,
4890           x_wkf_process_name      => l_workflow_process_name,
4891           x_workflow_process_id   => l_workflow_process_id,
4892           x_interaction_id        => l_interaction_id,
4893           p_update_desc_flex      => p_update_desc_flex,
4894           p_called_by_workflow    => p_called_by_workflow,
4895           p_workflow_process_id   => p_workflow_process_id,
4896           -- for cmro
4897          p_cmro_flag              => l_new_cmro_flag,
4898          p_maintenance_flag       => l_new_maintenance_flag,
4899          p_auto_assign            => p_auto_assign
4900       );
4901 
4902 
4903 -- for cmro_eam
4904          l_service_request_rec.Old_type_CMRO_Flag 	 := l_old_cmro_flag;
4905          l_service_request_rec.Old_type_Maintenance_Flag := l_old_maintenance_flag;
4906          l_service_request_rec.New_type_CMRO_flag 	 := l_new_cmro_flag;
4907          l_service_request_rec.New_type_Maintenance_flag := l_new_maintenance_flag;
4908 
4909      -- end of cmro_eam
4910 
4911     IF (l_return_status = 'R' ) THEN
4912        l_only_status_update_flag := 'Y';
4913 
4914 -- hardcoded the version 2.0 shijain nov 27 2002
4915 -- for bug # 3640344 - pkesani added the parameter p_closed_date.
4916       -- Give a message to user
4917    -- Fix for bug 14161917  - lkullamb.If the SR is updated from closed to open status,
4918    -- then based l_only_status_update_flag, we should only update the status and no other attributes of SR.
4919    -- Since from Contact center, we can only update status field, check whether last_update_prgoram_code
4920    -- is contact center, if, so do not throw the warning.
4921    IF(l_service_request_rec.last_update_program_code <> 'CSXSRTAB') THEN
4922       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4923       THEN
4924         FND_MESSAGE.Set_Name('CS', 'CS_API_SR_ONLY_STATUS_UPDATED');
4925         FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
4926         FND_MSG_PUB.Add_Detail
4927         ( p_message_type            => fnd_msg_pub.G_WARNING_MSG
4928         , p_same_associated_columns => 'T'
4929         );
4930       END IF;
4931    END IF;
4932 
4933      --Fix for bug 11699979  , lkullamb, if the update_sr_validation returns 'R' as
4934      -- return status, then check if the status of SR is closed and prev status
4935      -- is not closed , and pass the correct closure flags to update_status API
4936      IF l_sr_related_data.old_close_flag = 'N' AND
4937         l_sr_related_data.close_flag     = 'Y' THEN
4938 	   l_validate_sr_closure := 'Y';
4939 	   l_auto_close_child_entities := 'Y';
4940      ELSE
4941            l_validate_sr_closure :='N';
4942            l_auto_close_child_entities := 'N';
4943      END if;
4944     --End of changes for bug 11699979
4945 
4946 
4947        CS_Servicerequest_PVT.Update_Status
4948        ( p_api_version       => 2.0,
4949         p_init_msg_list      => fnd_api.g_false ,
4950         p_resp_id            => p_resp_id,
4951         p_validation_level   => fnd_api.g_valid_level_full,
4952         x_return_status      => l_return_status,
4953         x_msg_count          => x_msg_count,
4954         x_msg_data           => x_msg_data,
4955         p_request_id         => p_request_id,
4956         p_object_version_number => p_object_version_number,
4957         p_status_id          => l_service_request_rec.status_id,
4958         p_closed_date        => l_service_request_rec.closed_date,
4959 	p_validate_sr_closure => l_validate_sr_closure, -- added for bug 11699979
4960 	p_auto_close_child_entities => l_auto_close_child_entities, -- added for bug 11699979
4961         p_last_updated_by    => l_service_request_rec.last_updated_by ,
4962         p_last_update_login  => l_service_request_rec.last_update_login ,
4963         p_last_update_date   => l_service_request_rec.last_update_date ,
4964         x_interaction_id     => l_interaction_id
4965        );
4966 
4967 
4968        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4969          RAISE FND_API.G_EXC_ERROR;
4970        END IF;
4971 
4972     ELSIF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4973       RAISE FND_API.G_EXC_ERROR;
4974     END IF;
4975 
4976    IF (l_only_status_update_flag <> 'Y') THEN
4977 
4978      vldt_sr_rec
4979      ( p_sr_rec                       => l_service_request_rec
4980      , p_sr_rec_inp                   => p_service_request_rec
4981      , p_sr_related_data              => l_sr_related_data
4982      , p_mode                         => 'UPDATE'
4983      , p_validation_level             => p_validation_level
4984      , p_request_id                   => p_request_id
4985      , p_object_version_number        => p_object_version_number
4986      , p_last_updated_by              => p_last_updated_by
4987      , p_default_contract_sla_ind     => p_default_contract_sla_ind
4988      , p_auto_assign                  => p_auto_assign
4989      , p_old_incident_location_id     => l_old_servicerequest_rec.incident_location_id
4990      , p_old_incident_location_type   => l_old_servicerequest_rec.incident_location_type
4991      , p_old_incident_country         => l_old_servicerequest_rec.incident_country
4992      , p_old_incident_owner_id        => l_old_servicerequest_rec.incident_owner_id
4993      , p_old_owner_group_id           => l_old_servicerequest_rec.owner_group_id
4994      , p_old_resource_type            => l_old_servicerequest_rec.resource_type
4995      , p_old_site_id                  => l_old_servicerequest_rec.site_id
4996      , p_old_obligation_date          => l_old_servicerequest_rec.obligation_date
4997      , p_old_expected_resolution_date => l_old_servicerequest_rec.expected_resolution_date
4998      , p_old_contract_id              => l_old_servicerequest_rec.contract_id
4999      , p_old_contract_service_id      => l_old_servicerequest_rec.contract_service_id
5000      , p_old_install_site_id          => l_old_servicerequest_rec.install_site_id
5001      , p_old_system_id                => l_old_servicerequest_rec.system_id
5002      , p_old_account_id               => l_old_servicerequest_rec.account_id
5003      , p_old_inventory_item_id        => l_old_servicerequest_rec.inventory_item_id
5004      , p_old_customer_product_id      => l_old_servicerequest_rec.customer_product_id
5005      , p_old_incident_type_id         => l_old_servicerequest_rec.incident_type_id
5006      , p_old_time_zone_id             => l_old_servicerequest_rec.time_zone_id
5007      , p_old_incident_severity_id     => l_old_servicerequest_rec.incident_severity_id
5008      , x_contract_number              => l_contract_number
5009      , x_return_status                => l_return_status
5010      );
5011      IF l_return_status <> FND_API.G_RET_STS_SUCCESS
5012      THEN
5013        RAISE FND_API.G_EXC_ERROR;
5014      END IF;
5015      l_contra_id := l_service_request_rec.contract_id;
5016       -- API cleanup for 11.5.10
5017       -- Call the cross validation procedure if the validation level is
5018       -- more than none.
5019       -- The cross validation procedure executes all the data relationships
5020       -- that exist between the SR attributes. This was introduced in
5021       -- Release 11.5.10 as part of the API Cleanup projecT
5022       --
5023       l_contract_service_id_valid := 'Y';
5024       IF ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) THEN
5025         CS_ServiceRequest_UTIL.SERVICEREQUEST_CROSS_VAL (
5026            p_new_sr_rec            =>  l_service_request_rec,
5027            p_old_sr_rec            =>  l_old_ServiceRequest_rec,
5028            x_cross_val_out_rec     =>  l_sr_cross_val_out_rec,
5029            x_return_status         =>  l_return_status );
5030 
5031         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5032           RAISE FND_API.G_EXC_ERROR;
5033         END IF;
5034 
5035     -- Assigning the values from the out parameters to respective fields .
5036 
5037    -- For bug 3340433 - populate directly as the out rec will have the current value
5038    /* IF (l_service_request_rec.customer_product_id IS NOT NULL) AND
5039        (l_sr_cross_val_out_rec.inventory_item_id <> l_old_ServiceRequest_rec.inventory_item_id) THEN
5040       l_service_request_rec.inventory_item_id := l_sr_cross_val_out_rec.inventory_item_id;
5041     END IF; */
5042 
5043     l_service_request_rec.inventory_item_id := l_sr_cross_val_out_rec.inventory_item_id;
5044 
5045     IF (l_sr_cross_val_out_rec.bill_to_site_id IS NOT NULL) then
5046         l_service_request_rec.bill_to_site_id := l_sr_cross_val_out_rec.bill_to_site_id;
5047     END IF;
5048     IF (l_sr_cross_val_out_rec.bill_to_site_use_id IS NOT NULL) then
5049         l_service_request_rec.bill_to_site_use_id := l_sr_cross_val_out_rec.bill_to_site_use_id;
5050     END IF;
5051     IF (l_sr_cross_val_out_rec.ship_to_site_id IS NOT NULL) then
5052         l_service_request_rec.ship_to_site_id := l_sr_cross_val_out_rec.ship_to_site_id;
5053     END IF;
5054     IF (l_sr_cross_val_out_rec.ship_to_site_use_id IS NOT NULL) then
5055         l_service_request_rec.ship_to_site_use_id := l_sr_cross_val_out_rec.ship_to_site_use_id;
5056     END IF;
5057     IF (l_sr_cross_val_out_rec.contract_id IS NOT NULL) then
5058         l_contra_id := l_sr_cross_val_out_rec.contract_id;
5059     END IF;
5060     IF (l_sr_cross_val_out_rec.contract_number IS NOT NULL) then
5061         l_contract_number := l_sr_cross_val_out_rec.contract_number;
5062     END IF;
5063     -- Product Revision
5064     l_service_request_rec.product_revision := l_sr_cross_val_out_rec.product_revision;
5065     IF (l_service_request_rec.product_revision = FND_API.G_MISS_CHAR) then
5066         l_service_request_rec.product_revision := null;
5067     END IF;
5068     IF  (nvl(l_service_request_rec.product_revision,'-999') = nvl(l_old_ServiceRequest_rec.product_revision,'-999')) THEN
5069       l_audit_vals_rec.CHANGE_PRODUCT_REVISION_FLAG  := 'N';
5070       l_audit_vals_rec.old_product_revision := l_old_ServiceRequest_rec.product_revision;
5071       l_auDit_vals_rec.product_revision     := l_service_request_rec.product_revision;
5072     ELSE
5073       l_audit_vals_rec.CHANGE_PRODUCT_REVISION_FLAG := 'Y';
5074       l_audit_vals_rec.OLD_product_revision := l_old_ServiceRequest_rec.product_revision;
5075       l_audit_vals_rec.product_revision := l_service_request_rec.product_revision;
5076     END IF;
5077     -- Component Version
5078     l_service_request_rec.component_version := l_sr_cross_val_out_rec.component_version;
5079     IF (l_service_request_rec.component_version = FND_API.G_MISS_CHAR) then
5080         l_service_request_rec.component_version := null;
5081     END IF;
5082     IF  (nvl(l_service_request_rec.component_version,'-999') = nvl(l_old_ServiceRequest_rec.component_version,'-999')) THEN
5083       l_audit_vals_rec.change_comp_ver_flag  := 'N';
5084       l_audit_vals_rec.old_component_version := l_old_ServiceRequest_rec.component_version;
5085       l_auDit_vals_rec.component_version     := l_service_request_rec.component_version;
5086     ELSE
5087       l_audit_vals_rec.CHANGE_COMP_VER_FLAG := 'Y';
5088       l_audit_vals_rec.OLD_component_version := l_old_ServiceRequest_rec.component_version;
5089       l_audit_vals_rec.component_version := l_service_request_rec.component_version;
5090     END IF;
5091     -- Subcomponent Version
5092     l_service_request_rec.subcomponent_version := l_sr_cross_val_out_rec.subcomponent_version;
5093     IF (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR) then
5094         l_service_request_rec.subcomponent_version := null;
5095     END IF;
5096     IF (nvl(l_service_request_rec.subcomponent_version,'-999') = nvl(l_old_ServiceRequest_rec.subcomponent_version,'-999')) THEN
5097       l_audit_vals_rec.change_subcomp_ver_flag  := 'N';
5098       l_audit_vals_rec.old_subcomponent_version := l_old_ServiceRequest_rec.subcomponent_version;
5099       l_audit_vals_rec.subcomponent_version     := l_service_request_rec.subcomponent_version;
5100     ELSE
5101       l_audit_vals_rec.CHANGE_SUBCOMP_VER_FLAG := 'Y';
5102       l_audit_vals_rec.OLD_subcomponent_version := l_old_ServiceRequest_rec.subcomponent_version;
5103       l_audit_vals_rec.subcomponent_version := l_service_request_rec.subcomponent_version;
5104     END IF;
5105       l_contract_service_id_valid := l_sr_cross_val_out_rec.contract_service_id_valid;
5106 
5107       END IF;  -- IF ( p_validation_level > FND_API.G_VALID_LEVEL_NONE )
5108    -- Validate service request contacts
5109    -- This procedure should always be called before get_default_contract
5110    -- because it needs primary contact info
5111    IF l_sr_related_data.old_disallow_request_update <> 'Y'
5112    THEN
5113      CS_SRCONTACT_PKG.process
5114      ( p_mode            => 'UPDATE'
5115      , p_incident_id     => p_request_id
5116      , p_caller_type     => l_service_request_rec.caller_type
5117      , p_customer_id     => l_service_request_rec.customer_id
5118      , p_validation_mode => p_validation_level
5119      , p_contact_tbl     => p_contacts
5120      , x_contact_tbl     => l_processed_contacts
5121      , x_old_contact_tbl => l_old_contacts
5122      , x_primary_party_id         => l_sr_related_data.primary_party_id
5123      , x_primary_contact_point_id => l_sr_related_data.primary_contact_point_id
5124      , x_return_status   => l_return_status
5125      );
5126      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
5127      THEN
5128        RAISE FND_API.G_EXC_ERROR;
5129      END IF;
5130    END IF; -- request update is allowed
5131    -- End of SR contact validation
5132     -- Logic to populate default contract based on default contract SLA indicator
5133     IF (l_contract_service_id_valid <> 'Y')
5134     THEN
5135       IF (p_default_contract_sla_ind <> 'Y' OR
5136           (p_service_request_rec.contract_service_id IS NOT NULL AND
5137            p_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM)
5138          )
5139       THEN
5140         FND_MESSAGE.set_name ('CS', 'CS_SR_CONTRACT_INVALID');
5141         FND_MESSAGE.set_token('API_NAME', 'CS_SERVICEREQUEST_UTIL.contracts_cross_val' );
5142         FND_MSG_PUB.add;
5143         RAISE FND_API.G_EXC_ERROR;
5144       END IF;
5145     END IF;
5146 
5147   /***************************************************************
5148     This is a tempopary solution for Depot Repair team to get the site_use_id
5149     if the site_id is passed from the SR form and the validation level is none
5150     **********************************************/
5151 IF ( p_validation_level = FND_API.G_VALID_LEVEL_NONE ) THEN
5152   IF ( nvl(p_service_request_rec.bill_to_site_id,-99) <> nvl(l_old_ServiceRequest_rec.bill_to_site_id,-99))
5153   AND p_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM THEN
5154 
5155     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
5156       ( p_api_name            => 'Get bill to site use id',
5157         p_parameter_name      => 'Bill_To Site ',
5158         p_bill_to_site_id     => p_service_request_rec.bill_to_site_id,
5159         p_bill_to_party_id    => p_service_request_rec.bill_to_party_id,
5160         p_site_use_type       => 'BILL_TO',
5161         x_site_use_id         => l_service_request_rec.bill_to_site_use_id,
5162         x_return_status       => l_return_status
5163       );
5164     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5165       RAISE FND_API.G_EXC_ERROR;
5166     END IF;
5167 
5168     IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
5169     THEN
5170       FND_LOG.String
5171       ( FND_LOG.level_procedure , L_LOG_MODULE || ''
5172       , 'The defaulted value of parameter bill_to_site_use_id :'
5173       || l_service_request_rec.bill_to_site_use_id
5174       );
5175     END IF;
5176   ELSIF  (p_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM) OR
5177      (NVL(p_service_request_rec.bill_to_site_id, -99) = NVL(l_old_ServiceRequest_rec.bill_to_site_id, -99))  THEN
5178       l_service_request_rec.bill_to_site_use_id := l_old_ServiceRequest_rec.bill_to_site_use_id;
5179       l_service_request_rec.bill_to_site_id := l_old_ServiceRequest_rec.bill_to_site_id;
5180   ELSIF  (p_service_request_rec.bill_to_site_id IS NULL ) THEN
5181           l_service_request_rec.bill_to_site_use_id :=NULL;
5182   END IF;
5183 
5184   IF ( nvl(p_service_request_rec.ship_to_site_id,-99) <> nvl(l_old_ServiceRequest_rec.ship_to_site_id,-99))
5185   AND p_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM THEN
5186 
5187     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
5188       ( p_api_name            => 'Get ship to site use id',
5189         p_parameter_name      => 'Ship_To Site ',
5190         p_bill_to_site_id     => p_service_request_rec.ship_to_site_id,
5191         p_bill_to_party_id    => p_service_request_rec.ship_to_party_id,
5192         p_site_use_type       => 'SHIP_TO',
5193         x_site_use_id         => l_service_request_rec.ship_to_site_use_id,
5194         x_return_status       => l_return_status
5195       );
5196     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5197       RAISE FND_API.G_EXC_ERROR;
5198     END IF;
5199 
5200     IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
5201     THEN
5202       FND_LOG.String
5203       ( FND_LOG.level_procedure , L_LOG_MODULE || ''
5204       , 'The defaulted value of parameter ship_to_site_use_id :'
5205       || l_service_request_rec.ship_to_site_use_id
5206       );
5207     END IF;
5208   ELSIF  (p_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM) OR
5209      (NVL(p_service_request_rec.ship_to_site_id, -99) = NVL(l_old_ServiceRequest_rec.ship_to_site_id, -99))  THEN
5210       l_service_request_rec.ship_to_site_use_id := l_old_ServiceRequest_rec.ship_to_site_use_id;
5211       l_service_request_rec.ship_to_site_id := l_old_ServiceRequest_rec.ship_to_site_id;
5212   ELSIF  (p_service_request_rec.ship_to_site_id IS NULL ) THEN
5213           l_service_request_rec.ship_to_site_use_id :=NULL;
5214   END IF;
5215 
5216   IF (nvl(p_service_request_rec.install_site_id,-99)<> nvl(l_old_ServiceRequest_rec.install_site_id,-99))
5217   AND p_service_request_rec.install_site_id <> FND_API.G_MISS_NUM THEN
5218       l_service_request_rec.install_site_use_id:=
5219                                           p_service_request_rec.install_site_id;
5220   ELSIF  (p_service_request_rec.install_site_id = FND_API.G_MISS_NUM) OR
5221      (NVL(p_service_request_rec.install_site_id, -99) = NVL(l_old_ServiceRequest_rec.install_site_id, -99))  THEN
5222       l_service_request_rec.install_site_use_id := l_old_ServiceRequest_rec.install_site_use_id;
5223       l_service_request_rec.install_site_id := l_old_ServiceRequest_rec.install_site_id;
5224   ELSIF  (p_service_request_rec.install_site_id IS NULL ) THEN
5225           l_service_request_rec.install_site_use_id :=NULL;
5226   END IF;
5227 END IF;
5228 
5229 /********************************************************************
5230 Changes for depot reapi finished, need to remove all this for 115.10
5231 ***********************************************************************/
5232 
5233 
5234    --------UWQ for 11.5.6 Enhancement --------
5235    -- at this point during update p_Service_request_rec may have g_miss_num for
5236    -- severity_id but l_service_request_rec will have valid value for severity_id
5237    -- as this would have been populated by update_sr_validation procedure
5238    -- so i am using l_service_request_rec instead of p_service_request_rec
5239    l_imp_level := Get_Importance_Level(l_service_request_rec.severity_id);
5240    l_imp_level_old := Get_Old_Importance_level(p_request_id);
5241    l_old_owner_id := Get_Owner_id(p_request_id);
5242 
5243      --select the l_title from jtf_objects_vl
5244      l_title := Get_Title('SR');
5245 
5246     IF (l_service_request_rec.last_update_channel in ('PHONE', 'AGENT')  AND
5247         (l_imp_level_old <> 1 OR l_imp_level_old = 1) AND
5248         l_imp_level=1 AND
5249         l_service_request_rec.owner_id IS NOT NULL AND
5250         l_service_request_rec.owner_id <> l_old_owner_id AND
5251         l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) THEN
5252         l_uwq_body2 := Get_Message(p_uwq_msg_notification);
5253         l_send_uwq_notification := TRUE;
5254      ELSIF (l_service_request_rec.last_update_channel in ('PHONE', 'AGENT')  AND
5255             l_imp_level_old <>1 AND
5256             l_imp_level=1 AND
5257             l_service_request_rec.owner_id IS NOT NULL AND
5258             l_service_request_rec.owner_id = l_old_owner_id AND
5259             l_service_request_rec.owner_id <> FND_API.G_MISS_NUM)
5260         OR  (l_service_request_rec.last_update_channel = 'WEB' AND
5261              (l_imp_level =1 OR l_imp_level =2) AND
5262              l_service_request_rec.owner_id IS NOT NULL AND
5263              l_service_request_rec.owner_id <> FND_API.G_MISS_NUM)
5264      THEN
5265             l_uwq_body2 := Get_Message(p_uwq_upd_notification);
5266             l_send_uwq_notification := TRUE;
5267      END IF;
5268 
5269       l_uwq_body := l_title ||' '|| l_old_ServiceRequest_rec.incident_number ||'
5270  '|| l_uwq_body2 ||' '||to_char(SYSDATE,'MM/DD/YYYY HH24:MI:SS'); --with time;
5271 
5272     IF l_send_uwq_notification THEN
5273          IEU_MSG_PRODUCER_PUB.Send_Plain_text_Msg (
5274           p_api_version      => 1.0,
5275           p_init_msg_list    => fnd_api.g_false,
5276           p_commit           => fnd_api.g_false,
5277           p_application_id   => 170,
5278           p_resource_id      => l_service_request_rec.owner_id,
5279           p_resource_type    => l_service_request_rec.resource_type,
5280           p_title            => l_title,
5281           p_body             => l_uwq_body,
5282           p_workitem_obj_code=> 'SR',
5283           p_workitem_pk_id   => p_request_id,
5284           x_message_id       => l_msg_id,
5285           x_return_status    => l_return_status,
5286           x_msg_count        => l_msg_count,
5287           x_msg_data         => l_msg_data );
5288     END IF;
5289 
5290    /* Added call to get_status_flag for enh 2655115, to get the status flag
5291       based on the closed flag by shijain date 27th nov 2002 */
5292 
5293 -- for the bug 3050727
5294    --   l_status_flag:= get_status_flag ( l_service_request_rec.status_id);
5295 
5296 
5297   --*************************************************
5298   --Adding this code,(12th July 2000) so that workflow can call Update Service Request
5299   --instead of calling this Create Audit api.
5300 
5301   --Get the workflow process name associted to the service request type
5302   --IF called by workflow then do this :
5303 
5304 /****************************************
5305    commenting out code; this is no longer needed as the WF will directly do
5306    an update on the SR's workflow_process_id and not call the SR Update API.
5307 
5308   IF (FND_API.To_Boolean(p_called_by_workflow) = TRUE) THEN
5309     SELECT workflow INTO l_workflow_process_name
5310     FROM  cs_incident_types_b
5311     WHERE incident_type_id = l_service_request_rec.type_id
5312     AND   incident_subtype = G_SR_SUBTYPE
5313     AND    TRUNC(SYSDATE) BETWEEN TRUNC(NVL(start_date_active, SYSDATE))
5314     AND     TRUNC(NVL(end_date_active, SYSDATE));
5315     ---Build the workflow process item key.
5316     l_wf_process_itemkey  := l_old_ServiceRequest_rec.incident_number  || '-' || TO_CHAR(p_workflow_process_id) ;
5317 
5318     --  Changed for audit l_change_flags_rec.new_workflow   := FND_API.G_TRUE; --- check for audit
5319     l_audit_vals_rec.new_workflow_flag   := 'Y'; --- check for audit
5320 
5321     --Call Upadte SR without incrementing the object version number(only for lauch workflow)
5322     --Put this code because from the form side, if record was queried
5323     --with object version as 2 and then Launch workflow was called with
5324     --Update  Sr then, if object version is incremented to 3 , then
5325     --cannot update any other attributes displayed on the Sr form, since
5326     --SR form had already locked the record with object version as 2.
5327 
5328     UPDATE cs_incidents_all_b
5329     SET workflow_process_id  = p_workflow_process_id
5330     WHERE ROWID = l_old_ServiceRequest_rec.ROW_ID   ;
5331 
5332   ELSE
5333 commenting out code; this is no longer needed as the WF will directly do
5334 an update on the SR's workflow_process_id and not call the SR Update API.
5335 ***********************************************/
5336 
5337        -- Code Changes for 11.5.10 Auto Close SR project
5338        -- For bug 3332985
5339  IF l_sr_related_data.old_close_flag = 'N' AND
5340     l_sr_related_data.close_flag     = 'Y'
5341  THEN
5342    -- it means an open service request is being close, so check if SR can be closed
5343    -- and then close all SR child entities
5344    --
5345    -- This validation happens irrespective of ERES flag
5346    IF ( p_validate_sr_closure = 'Y' OR p_validate_sr_closure = 'y') THEN
5347       CS_SR_STATUS_PROPAGATION_PKG.VALIDATE_SR_CLOSURE(
5348               p_api_version        => p_api_version,
5349               p_init_msg_list      => fnd_api.g_false ,
5350               p_commit             => FND_API.G_FALSE,
5351               p_service_request_id => p_request_id,
5352               p_user_id            => l_service_request_rec.last_updated_by,
5353               p_resp_appl_id       => p_resp_appl_id,
5354               p_login_id           => l_service_request_rec.last_update_login,
5355               x_return_status      => l_return_status,
5356               x_msg_count          => l_msg_count ,
5357               x_msg_data           => l_msg_data);
5358 
5359      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5360          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5361      END IF;
5362    END IF;
5363    IF l_start_eres_flag = 'N'
5364    THEN
5365      -- Child entities will be close only for Non ERES flow.
5366      -- For ERES flow child entities may get closed if ERES returns NO_ACTION
5367      -- or in separate transaction when ERES approval comes in.
5368      IF (p_auto_close_child_entities='Y' OR p_auto_close_child_entities='y') THEN
5369        CS_SR_STATUS_PROPAGATION_PKG.CLOSE_SR_CHILDREN
5370        ( p_api_version         => p_api_version
5371        , p_init_msg_list       => fnd_api.g_false
5372        , p_commit              => FND_API.G_FALSE
5373        , p_validation_required => 'N'
5374        , p_action_required     => 'Y'
5375        , p_service_request_id  => p_request_id
5376        , p_user_id             => l_service_request_rec.last_updated_by
5377        , p_resp_appl_id        => p_resp_appl_id
5378        , p_login_id            => l_service_request_rec.last_update_login
5379        , x_return_status       => l_return_status
5380        , x_msg_count           => l_msg_count
5381        , x_msg_data            => l_msg_data
5382        );
5383        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5384          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5385        END IF;
5386      END IF;
5387    END IF;  -- l_start_eres_flag = 'N' condition
5388  END IF;  -- if old_close_flag ='N' and close_flag = 'Y' condition
5389    -- This is to be executed only for ERES update. For non eres updates
5390    -- this procedure is called from servicerequest_cross_val procedure.
5391    IF l_start_eres_flag = 'Y'
5392    THEN
5393      CS_SERVICEREQUEST_UTIL.task_restrict_close_cross_val
5394      ( p_incident_id   => p_request_id
5395      , p_status_id     => l_sr_related_data.target_status_id
5396      , x_return_status => l_return_status
5397      );
5398      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
5399      THEN
5400        RAISE FND_API.G_EXC_ERROR;
5401      END IF;
5402    END IF;
5403    -- End of  Code Changes for 11.5.10 Auto Close SR project
5404 
5405    -- Replace old code with get_reacted_resolved_dates
5406    -- if eres is being processed i.e. l_start_eres_flag = 'Y' then that intermediate status
5407    -- cannot have resolved, responded flags as 'Y'. so no need to attempt to default
5408    -- resolved and responded by dates.
5409    IF l_start_eres_flag = 'N'
5410    THEN
5411      CS_SERVICEREQUEST_UTIL.get_reacted_resolved_dates
5412      ( p_incident_status_id         => l_service_request_rec.status_id
5413      , p_old_incident_status_id     => l_old_servicerequest_rec.incident_status_id
5414      , p_old_incident_resolved_date => l_old_servicerequest_rec.incident_resolved_date
5415      , p_old_inc_responded_by_date  => l_old_servicerequest_rec.inc_responded_by_date
5416      , x_inc_responded_by_date      => l_service_request_rec.inc_responded_by_date
5417      , x_incident_resolved_date     => l_service_request_rec.incident_resolved_date
5418      , x_return_status              => l_return_status
5419      );
5420      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
5421      THEN
5422        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5423      END IF;
5424    END IF; -- l_start_eres_flag = 'N'
5425 
5426    IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
5427    THEN
5428      FND_LOG.String
5429      ( FND_LOG.level_procedure , L_LOG_MODULE || ''
5430      , 'The defaulted value of parameter inc_responded_by_date :'
5431      || l_service_request_rec.inc_responded_by_date
5432      );
5433      FND_LOG.String
5434      ( FND_LOG.level_procedure , L_LOG_MODULE || ''
5435      , 'The defaulted value of parameter incident_resolved_date :'
5436      || l_service_request_rec.incident_resolved_date
5437      );
5438    END IF;
5439 
5440   -- End of usability changes .
5441 
5442 
5443   -- Code Changes for setting unassigned_indicator
5444   /* l_service_request should be used not the p_service_request. if values are not changed
5445      then p_service rec will have g_miss_num only and it will cause wrong value for unassigned ind
5446      l_service rec will have the values going to database. so it is the correct rec to be used
5447   smisra 11/30/2004
5448   ********************************************************************************************/
5449         IF (l_service_request_rec.owner_id  <> FND_API.G_MISS_NUM  AND
5450             l_service_request_rec.owner_id IS NOT NULL ) AND
5451            (l_service_request_rec.owner_group_id  <> FND_API.G_MISS_NUM  AND
5452             l_service_request_rec.owner_group_id IS NOT NULL ) THEN
5453             l_unassigned_indicator := 3 ;
5454         ELSIF (l_service_request_rec.owner_id  <> FND_API.G_MISS_NUM  AND
5455             l_service_request_rec.owner_id IS  NOT NULL ) AND
5456            (l_service_request_rec.owner_group_id  = FND_API.G_MISS_NUM  OR
5457             l_service_request_rec.owner_group_id IS NULL ) THEN
5458             l_unassigned_indicator := 1 ;
5459         ELSIF (l_service_request_rec.owner_id  = FND_API.G_MISS_NUM  OR
5460             l_service_request_rec.owner_id IS  NULL ) AND
5461            (l_service_request_rec.owner_group_id  <> FND_API.G_MISS_NUM  AND
5462             l_service_request_rec.owner_group_id IS NOT NULL ) THEN
5463             l_unassigned_indicator := 2 ;
5464         ELSE
5465             l_unassigned_indicator := 0 ;
5466         END IF;
5467 
5468       -- Fix to bug # 2520816.
5469       -- Setting the value for l_contra_id and l_contract_number to the existing values
5470       -- in the db, if they have not been passed to the update API, or have not been
5471       -- assigned values thru the 'validate_contract_id' and 'validate_contract_service_id'
5472       -- procedures.
5473 -- Start of changes by aneemuch, 16-Oct-2003
5474 -- To fix bug 3137011, Update_servicerequest api causes contracts column to null values
5475 
5476       --if ( l_contra_id = FND_API.G_MISS_NUM ) THEN
5477       --   l_contra_id := l_old_servicerequest_rec.contract_id;
5478       --end if;
5479       --if ( l_contract_number = FND_API.G_MISS_CHAR ) THEN
5480       --   l_contract_number := l_old_servicerequest_rec.contract_number;
5481       --end if;
5482 
5483       -- contracts : 3224828 - remove the call to validate_contract_Service_id
5484       -- These five lines are change due to default contract SLA in update
5485       --IF  (( l_contra_id = FND_API.G_MISS_NUM ) OR (l_contra_id IS NULL)) THEN
5486       --  IF p_service_request_rec.contract_service_id = FND_API.G_MISS_NUM THEN
5487       --     l_contra_id := l_old_servicerequest_rec.contract_id;
5488       --     l_contract_number := l_old_servicerequest_rec.contract_number;
5489       --  ELSIF p_service_request_rec.contract_service_id is null THEN
5490 
5491       IF  (( l_contra_id = FND_API.G_MISS_NUM ) OR (l_contra_id IS NULL)) THEN
5492         IF l_service_request_rec.contract_service_id = l_old_servicerequest_rec.contract_service_id THEN
5493            l_contra_id := l_old_servicerequest_rec.contract_id;
5494            l_contract_number := l_old_servicerequest_rec.contract_number;
5495         ELSIF l_service_request_rec.contract_service_id is null THEN
5496            l_contra_id := null;
5497            l_contract_number := NULL;
5498        /* ELSE
5499            CS_ServiceRequest_UTIL.Validate_Contract_Service_Id(
5500                   p_api_name         => l_api_name,
5501                   p_parameter_name   => 'contract_service_id',
5502                   p_contract_service_id => p_service_request_rec.contract_service_id,
5503                   x_contract_id      =>l_contra_id,
5504                   x_contract_number  =>l_contract_number,
5505                   x_return_status    => l_return_status);
5506 
5507            IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5508               x_return_status := FND_API.G_RET_STS_ERROR;
5509               RETURN;
5510           END IF;  */
5511         END IF ;
5512       END IF;
5513      -- update contract attributes in audit
5514      l_audit_vals_rec.old_contract_number     := l_old_ServiceRequest_rec.contract_number;
5515      l_audit_vals_rec.old_contract_id         := l_old_ServiceRequest_rec.contract_id;
5516      l_audit_vals_rec.old_contract_service_id := l_old_ServiceRequest_rec.contract_service_id;
5517      l_audit_vals_rec.old_coverage_type       := l_old_ServiceRequest_rec.coverage_type;
5518      -- New contract Values
5519      l_audit_vals_rec.contract_number     := l_contract_number;
5520      l_audit_vals_rec.contract_id         := l_contra_id;
5521      l_audit_vals_rec.contract_service_id := l_service_request_rec.contract_service_id;
5522      l_audit_vals_rec.coverage_type       := l_service_request_rec.coverage_type;
5523      l_audit_vals_rec.maint_organization_id     := l_service_request_rec.maint_organization_id;
5524      l_audit_vals_rec.old_maint_organization_id := l_old_servicerequest_rec.maint_organization_id;
5525      l_audit_vals_rec.inventory_item_id         := l_service_request_rec.inventory_item_id;
5526      l_audit_vals_rec.old_inventory_item_id     := l_old_servicerequest_rec.inventory_item_id;
5527 
5528 
5529       -- Assign owner, group to output record
5530      x_sr_update_out_rec.individual_owner := l_service_request_rec.owner_id;
5531      x_sr_update_out_rec.group_owner      := l_service_request_rec.owner_group_id;
5532      x_sr_update_out_rec.individual_type  := l_service_request_rec.resource_type;
5533 
5534 -- end of changes by aneemuch, 16-Oct-2003
5535 -- Assign owner, group to output record
5536      x_sr_update_out_rec.individual_owner := l_service_request_rec.owner_id;
5537      x_sr_update_out_rec.group_owner      := l_service_request_rec.owner_group_id;
5538      x_sr_update_out_rec.individual_type  := l_service_request_rec.resource_type;
5539 
5540    -- Start of change , Sanjana Rao , bug 6955756
5541      IF (l_service_request_rec.owner_id = FND_API.G_MISS_NUM) OR
5542      NVL(l_service_request_rec.owner_id,-99) = NVL(l_old_ServiceRequest_rec.incident_owner_id,-99)
5543     THEN
5544       IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE) OR
5545          (l_service_request_rec.owner_assigned_time IS NULL AND
5546          l_old_ServiceRequest_rec.owner_assigned_time IS NULL) OR
5547         (l_service_request_rec.owner_assigned_time = l_old_ServiceRequest_rec.owner_assigned_time)
5548      THEN
5549        l_service_request_rec.owner_assigned_time   := l_old_ServiceRequest_rec.owner_assigned_time;
5550 
5551      END IF;
5552    ELSE
5553      IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE) OR
5554       (l_service_request_rec.owner_assigned_time IS NULL AND
5555       l_old_ServiceRequest_rec.owner_assigned_time IS NULL) OR
5556      (l_service_request_rec.owner_assigned_time = l_old_ServiceRequest_rec.owner_assigned_time)
5557      THEN
5558 
5559       l_service_request_rec.owner_assigned_time   := SYSDATE;
5560       END IF;
5561     END IF;
5562 
5563 --End of change , Sanjana Rao, bug 6955756
5564 
5565     ---------------------------------------------------------------------
5566     -- start of code for onetime address creation
5567     --siahmed check to see if we need to update onetime address creation
5568     --there is only 2 scenarios when we need to call the update service onetime address
5569 
5570       -------------------------------------------------------
5571   --siahmed start of code for creating onetime address
5572      --check if created by module = 'SR_ONETIME'
5573    /*
5574      SELECT count(party_site_id) into l_onetime_add_cnt
5575      FROM hz_party_sites
5576      WHERE party_site_id = l_service_request_rec.incident_location_id
5577      AND created_by_module = 'SR_ONETIME';
5578    */
5579     IF ((l_service_request_rec.incident_location_id IS NULL ) AND
5580            ((l_service_request_rec.incident_address  IS NOT null) OR
5581            (l_service_request_rec.incident_address2 IS NOT null) OR
5582            (l_service_request_rec.incident_address3 IS NOT null) OR
5583            (l_service_request_rec.incident_address4 IS NOT null) OR
5584            (l_service_request_rec.incident_city     IS NOT null) OR
5585            (l_service_request_rec.incident_state    IS NOT null) OR
5586            (l_service_request_rec.incident_postal_code IS NOT null) OR
5587            (l_service_request_rec.incident_county   IS NOT null) OR
5588            (l_service_request_rec.incident_province IS NOT null) OR
5589            (l_service_request_rec.incident_country  IS NOT null) OR
5590            (l_service_request_rec.site_name   IS NOT NULL) OR
5591            (l_service_request_rec.site_number IS NOT NULL) OR
5592            (l_service_request_rec.addressee   IS NOT NULL))) THEN
5593            --call create onetime address creation procedure
5594            CREATE_ONETIME_ADDRESS   (
5595              p_service_req_rec   =>  l_service_request_rec,
5596              x_msg_count         =>  l_msg_count,
5597              x_msg_data          =>  l_msg_data,
5598              x_return_status     =>  l_return_status_onetime,
5599              x_location_id       =>  l_incident_location_id
5600            );
5601 
5602            IF (l_return_status_onetime <> FND_API.G_RET_STS_SUCCESS) THEN
5603 	   --start changes for bug 8545879
5604 	      l_service_request_rec.incident_location_id := l_old_servicerequest_rec.incident_location_id;
5605 	      l_service_request_rec.incident_location_type := l_old_servicerequest_rec.incident_location_type;
5606 	      x_sr_update_out_rec.incident_location_id := l_old_servicerequest_rec.incident_location_id;
5607 	   --end changes for bug 8545879
5608               FND_MESSAGE.Set_Name('CS', 'CS_SR_ONETIME_CREATE_ERROR');
5609               FND_MESSAGE.Set_Token('API_NAME', l_api_name||'CREATE_ONETIME_ADDRESS');
5610               FND_MSG_PUB.ADD;
5611 
5612            ELSIF (l_return_status_onetime = FND_API.G_RET_STS_SUCCESS) THEN
5613               --so that the new party_site_id gets stamped in the cs_incidents_all_b table
5614               l_service_request_rec.incident_location_id := l_incident_location_id;
5615               l_service_request_rec.incident_location_type := 'HZ_PARTY_SITE';
5616               --stamp the out rec type with the incident location_id
5617               x_sr_update_out_rec.incident_location_id := l_incident_location_id;
5618 
5619            END IF;
5620               --set the variables to null so that they dont get stored in the incidents table
5621               l_service_request_rec.incident_address  := null;
5622               l_service_request_rec.incident_address2 := null;
5623               l_service_request_rec.incident_address3 := null;
5624               l_service_request_rec.incident_address4 := null;
5625               l_service_request_rec.incident_city     := null;
5626               l_service_request_rec.incident_state    := null;
5627               l_service_request_rec.incident_postal_code := null;
5628               l_service_request_rec.incident_county   := null;
5629               l_service_request_rec.incident_province := null;
5630               l_service_request_rec.incident_country  := null;
5631 	      --added for the bug fix 8563365
5632               l_service_request_rec.incident_addr_lines_phonetic := null;
5633               l_service_request_rec.incident_postal_plus4_code := null;
5634               --end of addition for the bug fix 8563365
5635           --END IF;
5636 
5637     ELSIF (l_service_request_rec.incident_location_id = l_old_servicerequest_rec.incident_location_id) THEN
5638 	IF (G_ONETIME_ADD_CNT >= 1) THEN
5639 
5640           --call update address procedure
5641            UPDATE_ONETIME_ADDRESS (
5642              p_service_req_rec     =>  l_service_request_rec,
5643              x_msg_count           =>  l_msg_count,
5644              x_msg_data            =>  l_msg_data,
5645              x_return_status       =>  l_return_status_onetime
5646            );
5647 
5648            IF (l_return_status_onetime <> FND_API.G_RET_STS_SUCCESS) THEN
5649               FND_MESSAGE.Set_Name('CS', 'CS_SR_ONETIME_UPDATE_ERROR');
5650               FND_MESSAGE.Set_Token('API_NAME', l_api_name||'UPDATE_ONETIME_ADDRESS');
5651               FND_MSG_PUB.ADD;
5652 
5653            ELSIF (l_return_status_onetime = FND_API.G_RET_STS_SUCCESS) THEN
5654               l_service_request_rec.incident_location_type := 'HZ_PARTY_SITE';
5655            END IF;
5656         END IF;
5657               --set the variables to null so that they dont get stored in the incidents table
5658               l_service_request_rec.incident_address  := null;
5659               l_service_request_rec.incident_address2 := null;
5660               l_service_request_rec.incident_address3 := null;
5661               l_service_request_rec.incident_address4 := null;
5662               l_service_request_rec.incident_city     := null;
5663               l_service_request_rec.incident_state    := null;
5664               l_service_request_rec.incident_postal_code := null;
5665               l_service_request_rec.incident_county   := null;
5666               l_service_request_rec.incident_province := null;
5667               l_service_request_rec.incident_country  := null;
5668               --added for the bug fix 8563365
5669               l_service_request_rec.incident_addr_lines_phonetic := null;
5670               l_service_request_rec.incident_postal_plus4_code := null;
5671               --end of addition for the bug fix 8563365
5672 
5673 
5674 
5675       -- if old incident_location_id is not equal to new incident location id
5676       -- and the new incident location id of not created by SR_ONETIME then
5677       -- we should not update the incident location id with the new incident location id
5678       -- rathre we should null the incident location id in that case
5679       ELSIF (l_service_request_rec.incident_location_id <> l_old_servicerequest_rec.incident_location_id) THEN
5680 
5681 	    IF (G_ONETIME_ADD_CNT >= 1) THEN
5682 		--The current incident address shall not be made null
5683                 --l_service_request_rec.incident_location_id := null;
5684 		l_service_request_rec.incident_location_id := l_old_servicerequest_rec.incident_location_id;
5685 		--Fix for bug 8594093
5686 		l_service_request_rec.incident_location_type := l_old_servicerequest_rec.incident_location_type;
5687                 l_service_request_rec.incident_address  := l_old_servicerequest_rec.incident_address;
5688                 l_service_request_rec.incident_address2 := l_old_servicerequest_rec.incident_address2;
5689                 l_service_request_rec.incident_address3 := l_old_servicerequest_rec.incident_address3;
5690                 l_service_request_rec.incident_address4 := l_old_servicerequest_rec.incident_address4;
5691                 l_service_request_rec.incident_city     := l_old_servicerequest_rec.incident_city;
5692                 l_service_request_rec.incident_state    := l_old_servicerequest_rec.incident_state;
5693                 l_service_request_rec.incident_postal_code := l_old_servicerequest_rec.incident_postal_code;
5694                 l_service_request_rec.incident_county   := l_old_servicerequest_rec.incident_county;
5695                 l_service_request_rec.incident_province := l_old_servicerequest_rec.incident_province;
5696                 l_service_request_rec.incident_country  := l_old_servicerequest_rec.incident_country;
5697                 l_service_request_rec.incident_addr_lines_phonetic := l_old_servicerequest_rec.incident_addr_lines_phonetic;
5698                 l_service_request_rec.incident_postal_plus4_code := l_old_servicerequest_rec.incident_postal_plus4_code;
5699 		--End of changes for bug 8594093
5700 		FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_INCIDENT_ADDRESS');
5701                 FND_MESSAGE.Set_Token('API_NAME', l_api_name||'CREATE_INCIDENT_ADDRESS');
5702                 FND_MSG_PUB.ADD;
5703 
5704             END IF;
5705       END IF;
5706 
5707 
5708     --end of addition by siahmed for update onetime address
5709     ---------------------------------------------------------------------
5710 
5711      --siahmed 12.2+ project where we are trying to link project_id and task_id from
5712   --oracle projects to SR
5713   --code added
5714   --if project_id has been nulled and there was value value before we should null it
5715   --and we are not to accept project_task_id without project_id
5716    --IF ((l_service_request_rec.project_id IS null) OR (l_service_request_Rec.project_id = FND_API.G_MISS_NUM))  THEN
5717    ---the following three scenarios takes care of the null conditions
5718 
5719       --set the statu to success initially
5720       l_project_info_status := FND_API.G_RET_STS_SUCCESS;
5721 
5722 --project_id and task_id must be passed together other wise throw error and stop update
5723       --fix for bug 13626184 throw error message and no project_task_id
5724       IF ((l_service_request_Rec.project_id = FND_API.G_MISS_NUM AND l_service_request_rec.project_task_id <> FND_API.G_MISS_NUM AND
5725 								     l_service_request_rec.project_task_id IS NOT NULL ) OR
5726           (l_service_request_Rec.project_task_id = FND_API.G_MISS_NUM AND l_service_request_rec.project_id <>  FND_API.G_MISS_NUM AND
5727 									  l_service_request_rec.project_id IS NOT NULL )) THEN
5728 		       --set the status to error
5729                  l_project_info_status := FND_API.G_RET_STS_ERROR;
5730                    --rollback here
5731 
5732       --set values to null if they are removing the project id/task_id and org_info manually
5733       ELSIF (l_service_request_Rec.project_id IS NULL AND l_service_request_rec.project_task_id IS NULL AND
5734 	        l_service_request_rec.expenditure_org_id IS null)  THEN
5735 
5736             l_service_request_rec.project_id      := null;
5737             l_service_request_rec.project_task_id := null ;
5738             l_service_request_rec.expenditure_org_id := null ;
5739 		  --set the status to success as this scenario should go through update
5740             l_project_info_status := FND_API.G_RET_STS_SUCCESS;
5741 
5742       --validate the newly passed exp_org_id with existing project/task id if only exp_org_id is passed
5743 	 --note that null is considered a passed value therefore it will get validated
5744 	 --so anytime they pass org_info it goes through validation even if there is no value for project/task_id
5745       ELSIF (l_service_request_Rec.project_id = FND_API.G_MISS_NUM AND l_service_request_rec.project_task_id = FND_API.G_MISS_NUM AND
5746 	        l_service_request_rec.expenditure_org_id <> FND_API.G_MISS_NUM) THEN
5747             l_service_request_rec.project_id      := l_old_serviceRequest_rec.project_id;
5748             l_service_request_rec.project_task_id := l_old_serviceRequest_rec.project_task_id;
5749 		    IF ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) THEN
5750                 CS_ServiceRequest_UTIL.VALIDATE_PROJECT_INFO
5751                   (p_api_name            => 'Validate_project_Task_id',
5752                    p_project_id          => l_service_request_rec.project_id,
5753                    p_project_task_id     => l_service_request_rec.project_task_id,
5754                    p_exp_org_id          => l_service_request_rec.expenditure_org_id     ,
5755                    x_return_status       => l_project_info_status,
5756                    x_error_msg           => l_msg_data );
5757 			END IF;
5758                IF (l_project_info_status <> FND_API.G_RET_STS_SUCCESS) THEN
5759                     FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_PROJECT_DETAILS');
5760                     FND_MESSAGE.Set_Token('API_NAME', l_api_name||'VALIDATE_PROJECT_INFO');
5761                     FND_MSG_PUB.ADD;
5762 		     END IF;
5763 
5764 	 --validate all newly passed values
5765       ELSIF (l_service_request_Rec.project_id <> FND_API.G_MISS_NUM AND l_service_request_rec.project_task_id <> FND_API.G_MISS_NUM AND l_service_request_rec.expenditure_org_id <> FND_API.G_MISS_NUM) THEN
5766               IF ( p_validation_level > FND_API.G_VALID_LEVEL_NONE ) THEN
5767                 CS_ServiceRequest_UTIL.VALIDATE_PROJECT_INFO
5768                   (p_api_name            => 'Validate_project_Task_id',
5769                    p_project_id          => l_service_request_rec.project_id,
5770                    p_project_task_id     => l_service_request_rec.project_task_id,
5771                    p_exp_org_id          => l_service_request_rec.expenditure_org_id     ,
5772                    x_return_status       => l_project_info_status,
5773                    x_error_msg           => l_msg_data );
5774 			END IF;
5775 
5776                IF (l_project_info_status <> FND_API.G_RET_STS_SUCCESS) THEN
5777                     FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_PROJECT_DETAILS');
5778                     FND_MESSAGE.Set_Token('API_NAME', l_api_name||'VALIDATE_PROJECT_INFO');
5779                     FND_MSG_PUB.ADD;
5780 		     END IF;
5781 
5782 
5783       --if all scenarios handled dont fall under the checked condition default all values to old valus and do the update
5784       ELSE
5785             l_service_request_rec.project_id      := l_old_serviceRequest_rec.project_id;
5786             l_service_request_rec.project_task_id := l_old_serviceRequest_rec.project_task_id;
5787             l_service_request_rec.expenditure_org_id      := l_old_serviceRequest_rec.expenditure_org_id;
5788             l_project_info_status := FND_API.G_RET_STS_SUCCESS;
5789 
5790        END IF;
5791 
5792 
5793       --if validation fails then dont update the SR raise error
5794       IF (l_project_info_status <> FND_API.G_RET_STS_SUCCESS) THEN
5795 	   /*
5796           FND_MESSAGE.Set_Name('CS', 'CS_SR_INVALID_PROJECT_DETAILS');
5797           FND_MESSAGE.Set_Token('API_NAME', l_api_name||'UPDATE SERVICE_REQUEST');
5798           FND_MSG_PUB.ADD;
5799          */
5800           RAISE FND_API.G_EXC_ERROR ;
5801 		--ROLLBACK TO Update_ServiceRequest_PVT;
5802       END IF;
5803 
5804   --end of addition siahmed
5805   ----------------------------------------------------
5806 
5807 
5808      ---Update for all cases.
5809      UPDATE cs_incidents_all_b
5810      SET incident_status_id             = l_service_request_rec.status_id,
5811 	 incident_type_id               = l_service_request_rec.type_id,
5812          incident_urgency_id            = l_service_request_rec.urgency_id,
5813          incident_severity_id           = l_service_request_rec.severity_id,
5814          incident_owner_id              = l_service_request_rec.owner_id,
5815 	 resource_type                  = l_service_request_rec.resource_type,
5816 --	 resource_subtype_id            = l_service_request_rec.resource_subtype_id, For BUG 2748584
5817          inventory_item_id              = l_service_request_rec.inventory_item_id,
5818          -- removed decode for 11.5.6 enhancement
5819          customer_id                    = l_service_request_rec.customer_id,
5820 	 account_id                     = l_service_request_rec.account_id,
5821          current_serial_number          = l_service_request_rec.current_serial_number,
5822          expected_resolution_date       = l_service_request_rec.exp_resolution_date,
5823          actual_resolution_date         = l_service_request_rec.act_resolution_date,
5824          customer_product_id            = l_service_request_rec.customer_product_id,
5825          bill_to_site_use_id            = l_service_request_rec.bill_to_site_use_id,
5826          bill_to_contact_id             = l_service_request_rec.bill_to_contact_id,
5827          ship_to_site_use_id            = l_service_request_rec.ship_to_site_use_id,
5828          ship_to_contact_id             = l_service_request_rec.ship_to_contact_id,
5829          install_site_use_id            = l_service_request_rec.install_site_use_id,
5830          incident_attribute_1           = l_service_request_rec.request_attribute_1,
5831          incident_attribute_2           = l_service_request_rec.request_attribute_2,
5832          incident_attribute_3           = l_service_request_rec.request_attribute_3,
5833          incident_attribute_4           = l_service_request_rec.request_attribute_4,
5834          incident_attribute_5           = l_service_request_rec.request_attribute_5,
5835          incident_attribute_6           = l_service_request_rec.request_attribute_6,
5836          incident_attribute_7           = l_service_request_rec.request_attribute_7,
5837          incident_attribute_8           = l_service_request_rec.request_attribute_8,
5838          incident_attribute_9           = l_service_request_rec.request_attribute_9,
5839          incident_attribute_10          = l_service_request_rec.request_attribute_10,
5840          incident_attribute_11          = l_service_request_rec.request_attribute_11,
5841          incident_attribute_12          = l_service_request_rec.request_attribute_12,
5842          incident_attribute_13          = l_service_request_rec.request_attribute_13,
5843          incident_attribute_14          = l_service_request_rec.request_attribute_14,
5844          incident_attribute_15          = l_service_request_rec.request_attribute_15,
5845          incident_context               = l_service_request_rec.request_context,
5846          external_attribute_1           = l_service_request_rec.external_attribute_1,
5847          external_attribute_2           = l_service_request_rec.external_attribute_2,
5848          external_attribute_3           = l_service_request_rec.external_attribute_3,
5849          external_attribute_4           = l_service_request_rec.external_attribute_4,
5850          external_attribute_5           = l_service_request_rec.external_attribute_5,
5851          external_attribute_6           = l_service_request_rec.external_attribute_6,
5852          external_attribute_7           = l_service_request_rec.external_attribute_7,
5853          external_attribute_8           = l_service_request_rec.external_attribute_8,
5854          external_attribute_9           = l_service_request_rec.external_attribute_9,
5855          external_attribute_10          = l_service_request_rec.external_attribute_10,
5856          external_attribute_11          = l_service_request_rec.external_attribute_11,
5857          external_attribute_12          = l_service_request_rec.external_attribute_12,
5858          external_attribute_13          = l_service_request_rec.external_attribute_13,
5859          external_attribute_14          = l_service_request_rec.external_attribute_14,
5860          external_attribute_15          = l_service_request_rec.external_attribute_15,
5861          external_context               = l_service_request_rec.external_context,
5862          resolution_code                = l_service_request_rec.resolution_code,
5863          problem_code                   = l_service_request_rec.problem_code,
5864          original_order_number          = l_service_request_rec.original_order_number,
5865          purchase_order_num             = l_service_request_rec.purchase_order_num,
5866          close_date                     = l_service_request_rec.closed_date,
5867          publish_flag                   = l_service_request_rec.publish_flag,
5868          obligation_date                = l_service_request_rec.obligation_date,
5869          qa_collection_id               = l_service_request_rec.qa_collection_plan_id,
5870          contract_service_id            = l_service_request_rec.contract_service_id,
5871          contract_id                    = l_contra_id,
5872          contract_number                = l_contract_number,
5873          project_number                 = l_service_request_rec.project_number,
5874          customer_po_number             = l_service_request_rec.cust_po_number,
5875          customer_ticket_number         = l_service_request_rec.cust_ticket_number,
5876          time_zone_id                   = l_service_request_rec.time_zone_id,
5877          time_difference                = l_service_request_rec.time_difference,
5878          platform_id                    = l_service_request_rec.platform_id ,
5879 	 platform_version		= l_service_request_rec.platform_version,
5880 	 platform_version_id		= l_service_request_rec.platform_version_id,
5881 	 db_version			= l_service_request_rec.db_version,
5882          cp_component_id                = l_service_request_rec.cp_component_id,
5883          cp_component_version_id        = l_service_request_rec.cp_component_version_id,
5884          cp_subcomponent_id             = l_service_request_rec.cp_subcomponent_id,
5885          cp_subcomponent_version_id     = l_service_request_rec.cp_subcomponent_version_id ,
5886          cp_revision_id                 = l_service_request_rec.cp_revision_id ,
5887          inv_item_revision              = l_service_request_rec.inv_item_revision ,
5888          inv_component_id               = l_service_request_rec.inv_component_id ,
5889          inv_component_version          = l_service_request_rec.inv_component_version,
5890          inv_subcomponent_id            = l_service_request_rec.inv_subcomponent_id ,
5891          inv_subcomponent_version       = l_service_request_rec.inv_subcomponent_version,
5892          site_id                        = l_service_request_rec.site_id,
5893 	 customer_site_id               = l_service_request_rec.customer_site_id,
5894          territory_id                   = l_service_request_rec.territory_id,
5895          -- Added for enhancements---11.5.6------jngeorge-----
5896          cust_pref_lang_id              = l_service_request_rec.cust_pref_lang_id,
5897          comm_pref_code                 = l_service_request_rec.comm_pref_code,
5898          cust_pref_lang_code            = l_service_request_rec.cust_pref_lang_code,
5899          last_update_channel            = l_service_request_rec.last_update_channel,
5900          tier                           = l_service_request_rec.tier,
5901          tier_version                   = l_service_request_rec.tier_version,
5902          operating_system               = l_service_request_rec.operating_system,
5903          operating_system_version       = l_service_request_rec.operating_system_version,
5904          DATABASE                       = l_service_request_rec.DATABASE,
5905          category_id                    = l_service_request_rec.category_id,
5906          group_type                     = l_service_request_rec.group_type,
5907          owner_group_id                 = l_service_request_rec.owner_group_id,
5908          group_territory_id             = l_service_request_rec.group_territory_id,
5909          owner_assigned_time            = l_service_request_rec.owner_assigned_time,
5910          owner_assigned_flag            = l_service_request_rec.owner_assigned_flag,
5911          unassigned_indicator           = l_unassigned_indicator,
5912          inv_platform_org_id            = l_service_request_rec.inv_platform_org_id,
5913          product_revision               = l_service_request_rec.product_revision,
5914          component_version              = l_service_request_rec.component_version,
5915          subcomponent_version           = l_service_request_rec.subcomponent_version,
5916          category_set_id                = l_service_request_rec.category_set_id,
5917          external_reference             = l_service_request_rec.external_reference,
5918          system_id                      = l_service_request_rec.system_id,
5919          error_code                     = l_service_request_rec.error_code,
5920          incident_occurred_date         = l_service_request_rec.incident_occurred_date,
5921          incident_resolved_date         = l_service_request_rec.incident_resolved_date,
5922          inc_responded_by_date          = l_service_request_rec.inc_responded_by_date,
5923          incident_location_id           = l_service_request_rec.incident_location_id ,
5924          incident_address               = l_service_request_rec.incident_address ,
5925          incident_city                  = l_service_request_rec.incident_city,
5926          incident_state                 = l_service_request_rec.incident_state,
5927          incident_country               = l_service_request_rec.incident_country,
5928          incident_province              = l_service_request_rec.incident_province ,
5929          incident_postal_code           = l_service_request_rec.incident_postal_code ,
5930          incident_county                = l_service_request_rec.incident_county,
5931          sr_creation_channel            = l_service_request_rec.sr_creation_channel,
5932          -- Added for ER# 2320056
5933          coverage_type                  = l_service_request_rec.coverage_type,
5934          -- Added for ER#2433831
5935          bill_to_account_id             = l_service_request_rec.bill_to_account_id,
5936          ship_to_account_id             = l_service_request_rec.ship_to_account_id,
5937          -- Added for ER#2463321
5938          customer_phone_id              = l_service_request_rec.customer_phone_id,
5939          customer_email_id              = l_service_request_rec.customer_email_id,
5940          -- Added for source cahnges for 1159 shijain oct 11 2002
5941          last_update_program_code       = l_service_request_rec.last_update_program_code,
5942          last_updated_by                = l_service_request_rec.last_updated_by,
5943          last_update_login              = l_service_request_rec.last_update_login,
5944          last_update_date               = l_service_request_rec.last_update_date,
5945          bill_to_party_id               = l_service_request_rec.bill_to_party_id,
5946          ship_to_party_id               = l_service_request_rec.ship_to_party_id,
5947          -- Conc request related fields
5948          program_id                     = l_service_request_rec.program_id,
5949          program_application_id         = l_service_request_rec.program_application_id,
5950          request_id                = l_service_request_rec.conc_request_id,
5951          program_login_id               = l_service_request_rec.program_login_id,
5952          -- Bill_to_site, ship_to_site
5953          bill_to_site_id                = l_service_request_rec.bill_to_site_id,
5954          ship_to_site_id                = l_service_request_rec.ship_to_site_id,
5955          -- Added for enh. 2655115
5956          -- for bug 3050727
5957          status_flag                    = l_service_request_rec.status_flag,
5958 	 object_version_number          = p_object_version_number+1,
5959          -- Added these address columns by shijain 2002 5th dec
5960          incident_point_of_interest=l_service_request_rec.incident_point_of_interest,
5961          incident_cross_street=l_service_request_rec.incident_cross_street,
5962          incident_direction_qualifier=l_service_request_rec.incident_direction_qualifier,
5963          incident_distance_qualifier=l_service_request_rec.incident_distance_qualifier,
5964          incident_distance_qual_uom  =l_service_request_rec.incident_distance_qual_uom,
5965          incident_address2  =l_service_request_rec.incident_address2 ,
5966          incident_address3=l_service_request_rec.incident_address3 ,
5967          incident_address4=l_service_request_rec.incident_address4  ,
5968          incident_address_style=l_service_request_rec.incident_address_style ,
5969          incident_addr_lines_phonetic =l_service_request_rec.incident_addr_lines_phonetic ,
5970          incident_po_box_number =l_service_request_rec.incident_po_box_number ,
5971          incident_house_number =l_service_request_rec.incident_house_number,
5972          incident_street_suffix =l_service_request_rec.incident_street_suffix,
5973          incident_street =l_service_request_rec.incident_street,
5974          incident_street_number =l_service_request_rec.incident_street_number,
5975          incident_floor=l_service_request_rec.incident_floor,
5976          incident_suite =l_service_request_rec.incident_suite ,
5977          incident_postal_plus4_code =l_service_request_rec.incident_postal_plus4_code,
5978          incident_position =l_service_request_rec.incident_position ,
5979          incident_location_directions=l_service_request_rec.incident_location_directions,
5980          incident_location_description =l_service_request_rec.incident_location_description ,
5981          install_site_id =l_service_request_rec.install_site_id ,
5982          inv_organization_id= l_service_request_rec.inventory_org_id,
5983          -- for cmro_eam
5984          owning_department_id = l_service_request_rec.owning_dept_id,
5985          --end for cmro_eam
5986          -- Added for Misc ERs project of 11.5.10 --anmukher --08/26/03
5987          incident_location_type = l_service_request_rec.incident_location_type,
5988          --Added for Auditing project of 11.5.10 --anmukher --09/05/03
5989          incident_last_modified_date = sysdate,
5990          maint_organization_id = l_service_request_rec.maint_organization_id,
5991 /* Credit Card 9358401 */
5992          instrument_payment_use_id  = l_service_request_rec.instrument_payment_use_id,
5993    --siahmed 12.2+ project where we are integrating Oracle Projects with SR
5994          project_id = l_service_request_rec.project_id,
5995          project_task_id = l_service_request_rec.project_task_id,
5996          expenditure_org_id = l_service_request_rec.expenditure_org_id,
5997     --end of addition siahmed
5998     --14004721 . Additional SLA dates. shramana
5999 	 sla_date_1 = l_service_request_rec.sla_date_1,
6000 	 sla_date_2 = l_service_request_rec.sla_date_2,
6001 	 sla_date_3 = l_service_request_rec.sla_date_3,
6002 	 sla_date_4 = l_service_request_rec.sla_date_4,
6003 	 sla_date_5 = l_service_request_rec.sla_date_5,
6004 	 sla_date_6 = l_service_request_rec.sla_date_6,
6005 	 sla_duration_1 = l_service_request_rec.sla_duration_1,
6006 	 sla_duration_2 = l_service_request_rec.sla_duration_2,
6007 	  --15995804. Add price_list_header_id
6008 	 price_list_header_id = l_service_request_rec.price_list_header_id
6009    WHERE ROWID = l_old_ServiceRequest_rec.ROW_ID   ;
6010 	    --for performance reason
6011 
6012 --  END IF;
6013 
6014 -- Start of changes by aneemuch 28-Oct-2004
6015 -- Changes for interMedia index, need to update text_index column only when incident_type_id,
6016 -- inventory_item_id, or summary column has changed. This is required in order to rebuild index for that
6017 -- particular record when interMedia sync conc program is run.
6018 
6019    IF  l_service_request_rec.type_id <> l_old_servicerequest_rec.incident_type_id
6020      OR NVL(l_service_request_rec.inventory_item_id,-99) <> NVL(l_old_servicerequest_rec.inventory_item_id,-99)
6021      OR l_service_request_rec.summary <> l_old_servicerequest_rec.summary THEN
6022 
6023      UPDATE cs_incidents_all_tl
6024      SET    summary                     = l_service_request_rec.summary,
6025             resolution_summary          = l_service_request_rec.resolution_summary,
6026             last_update_date            = l_service_request_rec.last_update_date,
6027             last_updated_by             = l_service_request_rec.last_updated_by,
6028             last_update_login           = l_service_request_rec.last_update_login,
6029             source_lang                 = userenv('LANG'), --l_service_request_rec.LANGUAGE,
6030             text_index                  = 'A'
6031      WHERE incident_id                  = p_request_id
6032      AND   userenv('LANG') IN (LANGUAGE, source_lang);
6033 
6034    ELSE
6035 
6036      UPDATE cs_incidents_all_tl
6037      SET    summary                     = l_service_request_rec.summary,
6038             resolution_summary          = l_service_request_rec.resolution_summary,
6039             last_update_date            = l_service_request_rec.last_update_date,
6040             last_updated_by             = l_service_request_rec.last_updated_by,
6041             last_update_login           = l_service_request_rec.last_update_login,
6042             source_lang                 = userenv('LANG') --l_service_request_rec.LANGUAGE
6043      WHERE incident_id                  = p_request_id
6044      AND   userenv('LANG') IN (LANGUAGE, source_lang);
6045    END IF;
6046 
6047 -- For bug 3512696 - modified to point the source lang to be updated with userenv('LANG');
6048 
6049 --  UPDATE cs_incidents_all_tl
6050 --  SET    summary                     = l_service_request_rec.summary,
6051 --         resolution_summary          = l_service_request_rec.resolution_summary,
6052 --         owner                       = l_service_request_rec.owner,
6053 --         group_owner                 = l_service_request_rec.group_owner,
6054 --         last_update_date            = l_service_request_rec.last_update_date,
6055 --         last_updated_by             = l_service_request_rec.last_updated_by,
6056 --         last_update_login           = l_service_request_rec.last_update_login,
6057 --         source_lang                 = userenv('LANG') --l_service_request_rec.LANGUAGE
6058 --  WHERE incident_id                  = p_request_id
6059 --  AND   userenv('LANG') IN (LANGUAGE, source_lang);
6060 
6061 -- End of changes by aneemuch 28-Oct-2004
6062 -- Changes for interMedia index
6063 
6064   IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6065     RAISE FND_API.G_EXC_ERROR;
6066   END IF;
6067 
6068   -- Added for 11.5.10 Auditing project --anmukher --09/15/03
6069   -- Added these assignments here as these values are not available in Update_SR_Validation
6070 
6071   /* These are not correct. if old value is null then else condition will get executed and
6072      wrong value will go to new value col in audit rec
6073      These are already set before update to cs_incidents_all_b table
6074      smisra: 29th nov 2004
6075   l_audit_vals_rec.OLD_CONTRACT_ID		:= l_old_ServiceRequest_rec.CONTRACT_ID;
6076   IF (l_contra_id <> FND_API.G_MISS_NUM) AND
6077     (l_contra_id <> l_old_ServiceRequest_rec.CONTRACT_ID) THEN
6078     l_audit_vals_rec.CONTRACT_ID		:= l_contra_id;
6079   ELSE
6080     l_audit_vals_rec.CONTRACT_ID		:= l_old_ServiceRequest_rec.CONTRACT_ID;
6081   END IF;
6082 
6083   l_audit_vals_rec.OLD_CONTRACT_NUMBER		:= l_old_ServiceRequest_rec.CONTRACT_NUMBER;
6084   IF (l_contract_number <> FND_API.G_MISS_CHAR) AND
6085     (l_contract_number <> l_old_ServiceRequest_rec.CONTRACT_NUMBER) THEN
6086     l_audit_vals_rec.CONTRACT_NUMBER		:= l_contract_number;
6087   ELSE
6088     l_audit_vals_rec.CONTRACT_NUMBER		:= l_old_ServiceRequest_rec.CONTRACT_NUMBER;
6089   END IF;
6090   *******************************************/
6091 
6092   l_audit_vals_rec.OLD_UNASSIGNED_INDICATOR	:= l_old_ServiceRequest_rec.UNASSIGNED_INDICATOR;
6093   IF (l_unassigned_indicator <> FND_API.G_MISS_NUM) AND
6094     (l_unassigned_indicator <> l_old_ServiceRequest_rec.unassigned_indicator) THEN
6095     l_audit_vals_rec.UNASSIGNED_INDICATOR		:= l_unassigned_indicator;
6096   ELSE
6097     l_audit_vals_rec.UNASSIGNED_INDICATOR		:= l_old_ServiceRequest_rec.UNASSIGNED_INDICATOR;
6098   END IF;
6099 
6100 
6101 
6102 -- for the bug 3027154 - moved the create_audit_record inside the if condition
6103 -- END IF; /* only_status_update_flag check*/
6104 
6105 
6106 END IF; /* only_status_update_flag check */
6107 
6108 
6109  ---- Call to Enqueue API if it is in maintenance Mode
6110 
6111      FND_PROFILE.get('APPS_MAINTENANCE_MODE', l_maintenance_mode);
6112 
6113   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
6114   THEN
6115     FND_LOG.String
6116     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6117     , 'The Value of profile APPS_MAINTENANCE_MODE :' || l_maintenance_mode
6118     );
6119   END IF;
6120 
6121      IF (l_maintenance_mode = 'MAINT' AND
6122          p_invocation_mode <> 'REPLAY') THEN
6123 
6124 -- hardcoded the version 2.0 shijain nov 27 2002
6125 
6126       CS_ServiceRequest_ENQUEUE_PKG.EnqueueSR(
6127         p_init_msg_list         => fnd_api.g_false ,
6128         p_api_version           => 2.0,
6129         p_commit                => p_commit,
6130         p_validation_level      => p_validation_level,
6131         x_return_status         => l_return_status,
6132         x_msg_count             => x_msg_count,
6133         x_msg_data              => x_msg_data,
6134         p_request_id            => p_request_id,
6135         p_request_number        => l_old_ServiceRequest_rec.incident_number,
6136         p_audit_id              => l_audit_id,
6137         p_resp_appl_id          => p_resp_appl_id,
6138         p_resp_id               => p_resp_id,
6139         p_user_id               => p_user_id,
6140         p_login_id              => p_login_id,
6141         p_org_id                => p_org_id,
6142         p_update_desc_flex      => p_update_desc_flex,
6143         p_object_version_number => p_object_version_number,
6144         p_transaction_type      => l_transaction_type,
6145         p_message_rev           => l_message_revision,
6146         p_servicerequest        => l_service_request_rec,
6147         p_contacts              => l_contacts
6148       );
6149 
6150       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6151          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6152       END IF;
6153      END IF;
6154 
6155   IF (l_only_status_update_flag <> 'Y') THEN
6156   --
6157   -- Create entries in JTF_NOTES from p_notes
6158   --
6159   l_note_index := p_notes.FIRST;
6160   WHILE l_note_index IS NOT NULL LOOP
6161     /* Create JTF_NOTES */
6162     --l_notes_detail := DBMS_LOB.SUBSTR(p_notes(l_note_index).note_detail);
6163 
6164 
6165    IF ((p_notes(l_note_index).note IS NOT NULL) AND
6166         (p_notes(l_note_index).note <> FND_API.G_MISS_CHAR)) THEN
6167 
6168     l_note_status := null ;
6169 
6170     IF ((p_notes(l_note_index).note_status IS NULL) OR
6171         (p_notes(l_note_index).note_status = FND_API.G_MISS_CHAR)) THEN
6172         l_note_status := 'E';
6173     ELSE
6174         l_note_status := p_notes(l_note_index).note_status ;
6175     END IF ;
6176 
6177     jtf_notes_pub.create_note(
6178       p_api_version    => 1.0,
6179       p_init_msg_list  => FND_API.G_FALSE,
6180       p_commit         => FND_API.G_FALSE,
6181       x_return_status  => x_return_status,
6182       x_msg_count      => x_msg_count,
6183       x_msg_data       => x_msg_data,
6184       p_source_object_id => p_request_id,
6185       p_source_object_code => 'SR',
6186       p_notes              => p_notes(l_note_index).note,
6187       p_notes_detail       => p_notes(l_note_index).note_detail,
6188       p_note_type          => p_notes(l_note_index).note_type,
6189       p_note_status        => l_note_status,
6190       p_entered_by         => p_last_updated_by,
6191       p_entered_date       => p_last_update_date,
6192       p_created_by         => p_last_updated_by,
6193       p_creation_date      => p_last_update_date,
6194       p_last_updated_by    => p_last_updated_by,
6195       p_last_update_date  =>  p_last_update_date,
6196       x_jtf_note_id        => l_note_id
6197     );
6198 
6199     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6200             RAISE FND_API.G_EXC_ERROR;
6201     END IF;
6202 
6203   END IF;
6204 
6205     IF ((p_notes(l_note_index).note_context_type_01 IS NOT NULL) AND
6206         (p_notes(l_note_index).note_context_type_01 <> FND_API.G_MISS_CHAR) AND
6207         (p_notes(l_note_index).note_context_type_id_01 IS NOT NULL) AND
6208         (p_notes(l_note_index).note_context_type_id_01 <> FND_API.G_MISS_NUM)) THEN
6209 
6210 
6211          jtf_notes_pub.create_note_context(
6212            x_return_status        => x_return_status,
6213            p_creation_date        => p_last_update_date,         ----SYSDATE,
6214            p_last_updated_by      => p_last_updated_by,
6215            p_last_update_date     => p_last_update_date,         ------SYSDATE,
6216            p_jtf_note_id          => l_note_id,
6217            p_note_context_type    => p_notes(l_note_index).note_context_type_01,
6218            p_note_context_type_id => p_notes(l_note_index).note_context_type_id_01,
6219            x_note_context_id      => l_note_context_id
6220          );
6221 
6222 	  IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
6223 	  THEN
6224 	    FND_LOG.String
6225 	    ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6226 	    , 'The defaulted value of parameter note_context_id :' || l_note_context_id
6227 	    );
6228 	  END IF;
6229          IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6230                  RAISE FND_API.G_EXC_ERROR;
6231          END IF;
6232     END IF;
6233 
6234     IF ((p_notes(l_note_index).note_context_type_02 IS NOT NULL) AND
6235         (p_notes(l_note_index).note_context_type_02 <> FND_API.G_MISS_CHAR) AND
6236         (p_notes(l_note_index).note_context_type_id_02 IS NOT NULL) AND
6237         (p_notes(l_note_index).note_context_type_id_02 <> FND_API.G_MISS_NUM)) THEN
6238 
6239 
6240          jtf_notes_pub.create_note_context(
6241            x_return_status        => x_return_status,
6242            p_creation_date        => p_last_update_date,
6243            p_last_updated_by      => p_last_updated_by,
6244            p_last_update_date     => p_last_update_date,
6245            p_jtf_note_id          => l_note_id,
6246            p_note_context_type    => p_notes(l_note_index).note_context_type_02,
6247            p_note_context_type_id => p_notes(l_note_index).note_context_type_id_02,
6248            x_note_context_id      => l_note_context_id
6249          );
6250 
6251 	  IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
6252 	  THEN
6253 	    FND_LOG.String
6254 	    ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6255 	    , 'The defaulted value of parameter note_context_id :' || l_note_context_id
6256 	    );
6257 	  END IF;
6258          IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6259                  RAISE FND_API.G_EXC_ERROR;
6260          END IF;
6261     END IF;
6262 
6263     IF ((p_notes(l_note_index).note_context_type_03 IS NOT NULL) AND
6264         (p_notes(l_note_index).note_context_type_03 <> FND_API.G_MISS_CHAR) AND
6265         (p_notes(l_note_index).note_context_type_id_03 IS NOT NULL) AND
6266         (p_notes(l_note_index).note_context_type_id_03 <> FND_API.G_MISS_NUM)) THEN
6267 
6268          jtf_notes_pub.create_note_context(
6269            x_return_status        => x_return_status,
6270            p_creation_date        => p_last_update_date,
6271            p_last_updated_by      => p_last_updated_by,
6272            p_last_update_date     => p_last_update_date,
6273            p_jtf_note_id          => l_note_id,
6274            p_note_context_type    => p_notes(l_note_index).note_context_type_03,
6275            p_note_context_type_id => p_notes(l_note_index).note_context_type_id_03,
6276            x_note_context_id      => l_note_context_id
6277          );
6278 
6279 	  IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
6280 	  THEN
6281 	    FND_LOG.String
6282 	    ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6283 	    , 'The defaulted value of parameter note_context_id :' || l_note_context_id
6284 	    );
6285 	  END IF;
6286 	 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6287                  RAISE FND_API.G_EXC_ERROR;
6288          END IF;
6289     END IF;
6290     l_note_index := p_notes.NEXT(l_note_index);
6291   END LOOP;
6292 
6293   -- Launching the workflow (HOOK)
6294   IF (JTF_USR_HKS.Ok_To_Execute('CS_ServiceRequest_PVT', 'Update_ServiceRequest',
6295                                 'W', 'W')) THEN
6296 
6297      IF (cs_servicerequest_cuhk.Ok_To_Launch_Workflow
6298                                   (p_request_id => p_request_id,
6299                                    p_service_request_rec=>l_service_request_rec)) THEN
6300 
6301        l_bind_data_id := JTF_USR_HKS.Get_bind_data_id ;
6302        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'USER_ID', p_last_updated_by, 'W', 'T');
6303        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'RESP_ID', p_resp_id, 'W', 'T');
6304        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'RESP_APPL_ID', p_resp_appl_id, 'W', 'T');
6305        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_ID', p_request_id, 'W', 'T');
6306        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_DATE', l_old_servicerequest_rec.incident_date, 'W', 'T');
6307        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_TYPE', l_service_request_rec.type_id, 'W', 'T');
6308        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_STATUS', l_service_request_rec.status_id, 'W', 'T');
6309        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_SEVERITY', l_service_request_rec.severity_id, 'W', 'T');
6310        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_URGENCY', l_service_request_rec.urgency_id, 'W', 'T');
6311        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'OWNER_ID', l_service_request_rec.owner_id, 'W', 'T');
6312        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_SUMMARY', l_service_request_rec.summary, 'W', 'T');
6313        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'REQUEST_CUSTOMER', l_service_request_rec.customer_id, 'W', 'T');
6314        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'INVENTORY_ITEM_ID', l_service_request_rec.inventory_item_id, 'W', 'T');
6315        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'CUSTOMER_PRODUCT_ID', l_service_request_rec.customer_product_id, 'W', 'T');
6316        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'PROBLEM_CODE', l_service_request_rec.problem_code, 'W', 'T');
6317        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'EXPECTED_RESOLUTION_DATE', l_service_request_rec.exp_resolution_date, 'W', 'T');
6318 
6319 
6320        -- Before the call to WorkFlow Hook, generate a unique item key using the workflow sequence
6321        SELECT cs_wf_process_id_s.NEXTVAL INTO l_workflow_item_key FROM dual;
6322 
6323        JTF_USR_HKS.WrkflowLaunch(p_wf_item_name => 'SERVEREQ',
6324                                  p_wf_item_process_name => 'CALL_SUPPORT',
6325                                  p_wf_item_key => 'SR' || TO_CHAR(l_workflow_item_key),
6326                                  p_bind_data_id => l_bind_data_id,
6327                                  x_return_code => l_return_status);
6328 
6329        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6330          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6331        END IF;
6332 
6333    END IF ;
6334   END IF ;
6335  END IF; /* only status update flag check */
6336 
6337 
6338   --
6339   -- Make the post processing call to the user hooks
6340   --
6341   -- Post call to the Customer Type User Hook
6342   -- hardcoded the version 2.0 shijain nov 27 2002
6343 
6344   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
6345                                'Update_ServiceRequest',
6346                                'A', 'C')  THEN
6347     cs_servicerequest_cuhk.Update_ServiceRequest_Post
6348     ( p_api_version         => 2.0,
6349       p_init_msg_list       => fnd_api.g_false ,
6350       p_commit              => p_commit,
6351     p_validation_level      =>  p_validation_level,
6352     x_return_status         =>  l_return_status,
6353     x_msg_count             =>  x_msg_count,
6354     x_msg_data              =>  x_msg_data,
6355     p_request_id            =>   p_request_id ,
6356     p_object_version_number  =>  p_object_version_number,
6357     p_resp_appl_id           =>  p_resp_appl_id,
6358     p_resp_id                =>  p_resp_id,
6359     p_last_updated_by        =>  p_last_updated_by,
6360     p_last_update_login      =>  p_last_update_login,
6361     p_last_update_date       =>  p_last_update_date,
6362     p_invocation_mode        =>   p_invocation_mode,
6363     p_service_request_rec    =>  l_service_request_rec,
6364     p_update_desc_flex       =>  p_update_desc_flex,
6365     p_notes                  =>  p_notes,
6366     p_contacts               =>  p_contacts,
6367     p_audit_comments         =>  p_audit_comments,
6368     p_called_by_workflow     =>  p_called_by_workflow,
6369     p_workflow_process_id    =>  p_workflow_process_id,
6370     x_workflow_process_id    =>  x_sr_update_out_rec.workflow_process_id,
6371     x_interaction_id         =>  x_sr_update_out_rec.interaction_id);
6372 
6373     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6374       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6375     END IF;
6376   END IF;
6377 
6378 
6379   -- Post call to the Vertical Type User Hook
6380   --
6381   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
6382                                       'Update_ServiceRequest',
6383                                       'A', 'V')  THEN
6384 
6385 -- hardcoded the version 2.0 shijain nov 27 2002
6386 
6387     cs_servicerequest_vuhk.Update_ServiceRequest_Post
6388     ( p_api_version         => 2.0,
6389       p_init_msg_list       => fnd_api.g_false ,
6390       p_commit              => p_commit,
6391     p_validation_level      =>  p_validation_level,
6392     x_return_status         =>  l_return_status,
6393     x_msg_count             =>  x_msg_count,
6394     x_msg_data              =>  x_msg_data,
6395     p_request_id            =>   p_request_id ,
6396     p_object_version_number  =>  p_object_version_number,
6397     p_resp_appl_id           =>  p_resp_appl_id,
6398     p_resp_id                =>  p_resp_id,
6399     p_last_updated_by        =>  p_last_updated_by,
6400     p_last_update_login      =>  p_last_update_login,
6401     p_last_update_date       =>  p_last_update_date,
6402     p_service_request_rec    =>  l_service_request_rec,
6403     p_update_desc_flex       =>  p_update_desc_flex,
6404     p_notes                  =>  p_notes,
6405     p_contacts               =>  p_contacts,
6406     p_audit_comments         =>  p_audit_comments,
6407     p_called_by_workflow     =>  p_called_by_workflow,
6408     p_workflow_process_id    =>  p_workflow_process_id,
6409     x_workflow_process_id    =>  x_sr_update_out_rec.workflow_process_id,
6410     x_interaction_id         =>  x_sr_update_out_rec.interaction_id);
6411 
6412     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6413       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6414     END IF;
6415   END IF;
6416 
6417   -- Post call to the Internal Type User Hook
6418   -- commented out by siahmed to fix bug 9494021 and moved after the contact creation
6419  /*   cs_servicerequest_iuhk.Update_ServiceRequest_Post( x_return_status=>l_return_status);
6420 
6421     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6422       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6423     END IF;
6424  */
6425 
6426   IF (l_only_status_update_flag <> 'Y') THEN
6427   -- ------------------------------------------------------
6428   -- Insert a record into the calls table if the caller is
6429   -- not a workflow process
6430   -- ------------------------------------------------------
6431   IF NOT FND_API.To_Boolean(p_called_by_workflow) THEN
6432     IF (l_service_request_rec.parent_interaction_id IS NULL) THEN
6433       /* CREATE INTERACTION */ /* l_interaction_id := */
6434       NULL;
6435     END IF;
6436     x_sr_update_out_rec.interaction_id := l_interaction_id;
6437 
6438     --
6439     -- Create INTERACTION_ACTIVITY
6440     --
6441 
6442     IF (l_return_status = fnd_api.g_ret_sts_error) THEN
6443        RAISE fnd_api.g_exc_error;
6444     ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
6445        RAISE fnd_api.g_exc_unexpected_error;
6446     END IF;
6447   END IF;    /* called by workflow */
6448   END IF; /* only status update flag check */
6449 
6450 
6451   -- Standard call for message generation
6452   IF jtf_usr_hks.Ok_To_Execute('CS_ServiceRequest_PVT',
6453                                       'Create_ServiceRequest',
6454                                       'M', 'M')  THEN
6455 
6456      IF (cs_servicerequest_cuhk.Ok_To_Generate_Msg(p_request_id => p_request_id,
6457                                                    p_service_request_rec=>l_service_request_rec)) THEN
6458 
6459        l_bind_data_id := JTF_USR_HKS.Get_bind_data_id;
6460 
6461        JTF_USR_HKS.Load_bind_data(l_bind_data_id, 'incident_id', p_request_id, 'S', 'N');
6462 
6463        JTF_USR_HKS.generate_message(p_prod_code => 'CS',
6464                                  p_bus_obj_code => 'SR',
6465                                  p_action_code => 'U',
6466                                  p_bind_data_id => l_bind_data_id,
6467                                  x_return_code => l_return_status);
6468 
6469 
6470        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6471          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6472        END IF;
6473     END IF;
6474   END IF;
6475 
6476 /***************************************************
6477  commented for bug 2857350, moved after calling the business events
6478 
6479    -- Standard check of p_commit
6480    IF FND_API.To_Boolean(p_commit) THEN
6481       COMMIT WORK;
6482    END IF;
6483 comments ended for bug 2857350
6484 ***********************************************************/
6485 
6486 
6487 --   END IF; -- IF (l_dummy > p_object_version_number )
6488 
6489 
6490     -- Added this call for Misc ER: Owner auto assignment changes
6491 
6492   IF (l_only_status_update_flag <> 'Y')
6493   THEN
6494 
6495     -- ------------------------------------------------------------------
6496     -- Changes starts for 12.2 Auto Task Creation, in case the 'To Status'
6497     -- doesn't have 'Disallow Request Update Checked'. - lkullamb
6498     -- ------------------------------------------------------------------
6499     IF NVL(l_sr_related_data.disallow_request_update,'N') <> 'Y' THEN
6500        IF p_auto_generate_tasks = 'Y' OR  p_auto_generate_tasks = 'y' THEN
6501 
6502 	--Fix for bug 12668350
6503 	--Check if status_group_id is defined in 'CS_SR_TYPE_MAPPING'
6504         --table first If it is not defined,then look in cs_incident_types
6505         BEGIN
6506 	   SELECT task_template_id into l_task_template_id
6507 	   FROM  cs_sr_status_transitions cst,cs_sr_type_mapping srtype
6508 	   WHERE srtype.incident_type_id = l_service_request_rec.type_id
6509            AND srtype.responsibility_id = p_resp_id
6510            AND trunc(sysdate) BETWEEN
6511             trunc(nvl(srtype.start_date, sysdate)) AND
6512             trunc(nvl(srtype.end_date, sysdate))
6513 	   AND   cst.status_group_id=srtype.status_group_id
6514 	   AND   cst.from_incident_status_id = l_old_servicerequest_rec.incident_status_id --refers to old status_id
6515 	   AND   cst.to_incident_status_id = l_service_request_rec.status_id; -- refers to new status_id
6516 	 EXCEPTION
6517          WHEN NO_DATA_FOUND THEN
6518             NULL;
6519         END;
6520 
6521        IF l_task_template_id IS NULL THEN
6522 	   BEGIN
6523        		--Get task template id
6524 		select task_template_id into l_task_template_id
6525 		FROM  cs_sr_status_transitions cst,cs_incident_types_b cit
6526 		WHERE cit.incident_type_id = l_service_request_rec.type_id
6527 		AND   cst.status_group_id=cit.status_group_id
6528 		AND   from_incident_status_id = l_old_servicerequest_rec.incident_status_id --refers to old status_id
6529 		AND   to_incident_status_id = l_service_request_rec.status_id; -- refers to new status_id
6530           EXCEPTION
6531           WHEN NO_DATA_FOUND THEN
6532             NULL;
6533           END;
6534        END IF;
6535 
6536 	IF l_task_template_id IS NOT NULL AND l_task_template_id <> -1 THEN
6537            --l_task_template_id = -2 means 'Use Task template Mapping'
6538            IF l_task_template_id <> -2 THEN
6539                l_task_template_group_rec.task_template_group_id := l_task_template_id;
6540            END IF;
6541 
6542            l_task_template_group_owner :=  FND_PROFILE.value('INC_DEFAULT_INCIDENT_TASK_OWNER');
6543 	   l_task_tmpl_group_owner_type := FND_PROFILE.value('INC_DEFAULT_INCIDENT_TASK_OWNER_TYPE');
6544 
6545 	   l_task_owner_name := JTF_TASK_UTL.get_owner(l_task_tmpl_group_owner_type,l_task_template_group_owner);
6546 
6547            IF l_task_owner_name IS NULL THEN
6548               l_task_template_group_owner :=  NULL;
6549 	      l_task_tmpl_group_owner_type := NULL;
6550             END IF;
6551 
6552 	   --Invoke auto generate task api
6553 	   CS_AutoGen_Task_PVT.Auto_Generate_Tasks
6554 	   ( p_api_version		   => 1.0,
6555 	     p_init_msg_list		   => fnd_api.g_false ,
6556 	     p_commit			   => p_commit,
6557              p_validation_level		   => p_validation_level,
6558              p_incident_id                 => p_request_id ,
6559              p_service_request_rec	   => l_service_request_rec,
6560              p_task_template_group_owner   => l_task_template_group_owner,
6561              p_task_tmpl_group_owner_type  => l_task_tmpl_group_owner_type,
6562              p_task_template_group_rec	   => l_task_template_group_rec,
6563              p_task_template_table	   => l_task_template_table,
6564              x_auto_task_gen_rec	   => l_auto_task_gen_rec,
6565              x_return_status		   => l_return_status,
6566              x_msg_count		   => x_msg_count,
6567              x_msg_data			   => x_msg_data
6568            );
6569 
6570 	   IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6571                FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
6572 			            p_data  => x_msg_data );
6573            END IF;
6574         END IF; -- End of l_task_template_id is null and l_task_template_id <> -1 , if task_template_id null or -1, dont generate task
6575      END IF; -- end of p_auto_generate_tasks = 'Y'
6576     END IF; -- end of l_new_disallow_request_update <> 'Y'
6577 
6578     -- End of changes for 12.2 Auto Task Creation
6579 
6580     IF l_start_eres_flag = 'Y'
6581     THEN
6582       CS_ERES_INT_PKG.start_approval_process
6583       ( p_incident_id => p_request_id
6584       , p_incident_type_id => l_service_request_rec.type_id
6585       , p_incident_status_id => l_sr_related_data.intermediate_status_id
6586       , p_qa_collection_id => l_service_request_rec.qa_collection_plan_id
6587       , x_approval_status  => l_approval_status
6588       , x_return_status    => x_return_status
6589       , x_msg_count        => x_msg_count
6590       , x_msg_data         => x_msg_data
6591       );
6592       IF x_return_status <> FND_API.G_RET_STS_SUCCESS
6593       THEN
6594         RAISE FND_API.G_EXC_ERROR;
6595       END IF;
6596       IF l_approval_status = 'NO_ACTION'
6597       THEN
6598         -- validated orginal target status
6599         CS_ServiceRequest_UTIL.Validate_Updated_Status
6600         ( p_api_name                 => 'CS_SERVICEREQUEST_PVT.update_servicerequest'
6601         , p_parameter_name           => 'p_status_id'
6602         , p_resp_id                  =>  p_resp_id
6603         , p_new_status_id            => l_sr_related_data.target_status_id
6604         , p_old_status_id            => l_old_servicerequest_rec.incident_status_id
6605         , p_subtype                  => G_SR_SUBTYPE
6606         , p_type_id                  => l_service_request_rec.type_id
6607 	   , p_old_type_id              => l_old_servicerequest_rec.incident_type_id
6608         , p_close_flag               => l_sr_related_data.close_flag
6609         , p_disallow_request_update  => l_sr_related_data.disallow_request_update
6610         , p_disallow_owner_update    => l_sr_related_data.disallow_owner_update
6611         , p_disallow_product_update  => l_sr_related_data.disallow_product_update
6612         , x_return_status  => l_return_status
6613         );
6614         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6615           x_return_status := FND_API.G_RET_STS_ERROR;
6616           RAISE FND_API.G_EXC_ERROR;
6617         END IF;
6618         -- target status is valid at this point.
6619         --
6620         -- Now get responded and resolved dates
6621         CS_SERVICEREQUEST_UTIL.get_reacted_resolved_dates
6622         ( p_incident_status_id         => l_sr_related_data.target_status_id
6623         , p_old_incident_status_id     => l_old_servicerequest_rec.incident_status_id
6624         , p_old_incident_resolved_date => l_old_servicerequest_rec.incident_resolved_date
6625         , p_old_inc_responded_by_date  => l_old_servicerequest_rec.inc_responded_by_date
6626         , x_inc_responded_by_date      => l_service_request_rec.inc_responded_by_date
6627         , x_incident_resolved_date     => l_service_request_rec.incident_resolved_date
6628         , x_return_status              => l_return_status
6629         );
6630         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6631           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6632         END IF;
6633 	   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
6634 	   THEN
6635 	     FND_LOG.String
6636 	     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6637 	     , 'The defaulted value of parameter inc_responded_by_date :'
6638 	     || l_service_request_rec.inc_responded_by_date
6639 	     );
6640 	     FND_LOG.String
6641 	     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
6642 	     , 'The defaulted value of parameter incident_resolved_date :'
6643 	     || l_service_request_rec.incident_resolved_date
6644 	     );
6645 	   END IF;
6646 	IF NVL(l_sr_related_data.close_flag,'N') = 'Y'
6647         THEN
6648            l_service_request_rec.status_flag := 'C';
6649            IF l_service_request_rec.closed_date IS NULL
6650            THEN
6651              l_service_request_rec.closed_date := NVL(l_old_servicerequest_rec.close_date,SYSDATE);
6652            END IF;
6653         ELSE
6654            l_service_request_rec.status_flag := 'O' ;
6655            l_service_request_rec.closed_date := NULL;
6656         END IF;
6657         -- Now update service request record with new value for
6658         --   1. new status
6659         --   2. incident responded date
6660         --   3. incident resolved date
6661         --   4. Close date
6662         l_service_request_rec.status_id := l_sr_related_data.target_status_id;
6663         UPDATE cs_incidents_all_b
6664         SET    incident_status_id     = l_service_request_rec.status_id
6665         ,      inc_responded_by_date  = l_service_request_rec.inc_responded_by_date
6666         ,      incident_resolved_date = l_service_request_rec.incident_resolved_date
6667         ,      status_flag            = l_service_request_rec.status_flag
6668         ,      close_date             = l_service_request_rec.closed_date
6669         WHERE  incident_id = p_request_id;
6670         -- if close flag for target status is Y then close SR child entities and workflow
6671       END IF; -- l_approval_status = NO_ACTION
6672     END IF; -- l_start_eres_flag = 'Y'
6673     x_sr_update_out_rec.status_id         := l_service_request_rec.status_id;
6674     x_sr_update_out_rec.close_date        := l_service_request_rec.closed_date;
6675     x_sr_update_out_rec.resolved_on_date  := l_service_request_rec.incident_resolved_date;
6676     x_sr_update_out_rec.responded_on_date := l_service_request_rec.inc_responded_by_date;
6677     -- Create audit record
6678     l_audit_vals_rec.entity_activity_code 	  := 'U';
6679     l_audit_vals_rec.updated_entity_code	  := 'SR_HEADER';
6680     l_audit_vals_rec.updated_entity_id	          := p_request_id;
6681     l_audit_vals_rec.incident_last_modified_date  := l_service_request_rec.last_update_date ;
6682     l_audit_vals_rec.incident_status_id           := l_service_request_rec.status_id     ;
6683     --
6684     l_audit_vals_rec.incident_resolved_date       := l_service_request_rec.incident_resolved_date;
6685     l_audit_vals_rec.old_incident_resolved_date   := l_old_ServiceRequest_rec.incident_resolved_date;
6686     --
6687     l_audit_vals_rec.inc_responded_by_date        := l_service_request_rec.inc_responded_by_date;
6688     l_audit_vals_rec.old_inc_responded_by_date    := l_old_ServiceRequest_rec.inc_responded_by_date;
6689     --
6690     l_audit_vals_rec.close_date                   := l_service_request_rec.closed_date          ;
6691     l_audit_vals_rec.old_close_date               := l_old_ServiceRequest_rec.close_date        ;
6692     --
6693     l_audit_vals_rec.status_flag                  := l_service_request_rec.status_flag          ;
6694     l_audit_vals_rec.old_status_flag              := l_old_ServiceRequest_rec.status_flag       ;
6695     IF l_service_request_rec.status_flag = l_old_servicerequest_rec.status_flag
6696     THEN
6697       l_audit_vals_rec.change_status_flag := 'N';
6698     ELSE
6699       l_audit_vals_rec.change_status_flag := 'Y';
6700     END IF;
6701     l_audit_vals_rec.incident_country           := l_service_request_rec.incident_country         ;
6702     l_audit_vals_rec.old_incident_country       := l_old_servicerequest_rec.incident_country      ;
6703     --
6704     l_audit_vals_rec.incident_location_id       := l_service_request_rec.incident_location_id     ;
6705     l_audit_vals_rec.old_incident_location_id   := l_old_servicerequest_rec.incident_location_id  ;
6706     --
6707     l_audit_vals_rec.incident_location_type     := l_service_request_rec.incident_location_type   ;
6708     l_audit_vals_rec.old_incident_location_type := l_old_servicerequest_rec.incident_location_type;
6709     --
6710     IF NVL(l_service_request_rec.owner_id,-99) = NVL(l_old_ServiceRequest_rec.incident_owner_id,-99)
6711     THEN
6712       IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE) OR
6713          (l_service_request_rec.owner_assigned_time IS NULL AND
6714           l_old_ServiceRequest_rec.owner_assigned_time IS NULL) OR
6715          (l_service_request_rec.owner_assigned_time = l_old_ServiceRequest_rec.owner_assigned_time)
6716       THEN
6717       --commented by Sanjana Rao, bug 6955756
6718       -- l_service_request_rec.owner_assigned_time   := l_old_ServiceRequest_rec.owner_assigned_time;
6719         -- For audit record
6720         l_audit_vals_rec.change_assigned_time_flag  := 'N';
6721         l_audit_vals_rec.old_owner_assigned_time    := l_old_ServiceRequest_rec.owner_assigned_time;
6722         --2993526
6723         l_audit_vals_rec.owner_assigned_time        := l_old_ServiceRequest_rec.owner_assigned_time;
6724       ELSE
6725         -- For audit record
6726         l_audit_vals_rec.change_ASSIGNED_TIME_FLAG  := 'Y';
6727         l_audit_vals_rec.OLD_OWNER_ASSIGNED_TIME    := l_old_ServiceRequest_rec.owner_assigned_time;
6728         --2993526 ... passed value should be stamped
6729         l_audit_vals_rec.OWNER_ASSIGNED_TIME        := l_service_request_rec.owner_assigned_time;
6730       END IF;
6731       -- for audit record added by shijain
6732       l_audit_vals_rec.change_incident_owner_flag := 'N';
6733     ELSE
6734       IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE) OR
6735        (l_service_request_rec.owner_assigned_time IS NULL AND
6736         l_old_ServiceRequest_rec.owner_assigned_time IS NULL) OR
6737        (l_service_request_rec.owner_assigned_time = l_old_ServiceRequest_rec.owner_assigned_time)
6738       THEN
6739         --2993526
6740 
6741       --commented by Sanjana Rao, bug 6955756
6742       --  l_service_request_rec.owner_assigned_time   := SYSDATE;
6743 
6744         -- For audit record
6745 
6746         l_audit_vals_rec.change_assigned_time_flag  := 'Y' ;
6747         l_audit_vals_rec.old_owner_assigned_time    := l_old_ServiceRequest_rec.owner_assigned_time;
6748         l_audit_vals_rec.owner_assigned_time        := SYSDATE;
6749       ELSE
6750         --2993526
6751         -- For audit record
6752         l_audit_vals_rec.change_ASSIGNED_TIME_FLAG  := 'Y';
6753         l_audit_vals_rec.OLD_OWNER_ASSIGNED_TIME    := l_old_ServiceRequest_rec.owner_assigned_time;
6754         --2993526
6755         l_audit_vals_rec.OWNER_ASSIGNED_TIME        := l_service_request_rec.owner_assigned_time;
6756       END IF;
6757       -- For audit record
6758       l_audit_vals_rec.CHANGE_INCIDENT_OWNER_FLAG := 'Y';
6759     END IF;
6760     l_audit_vals_rec.OLD_INCIDENT_OWNER_ID      := l_old_ServiceRequest_rec.incident_owner_id;
6761     l_audit_vals_rec.INCIDENT_OWNER_ID          := l_service_request_rec.owner_id;
6762 
6763     -- end for 2993526
6764     --- Added code for bug# 1966184
6765     IF NVL(l_service_request_rec.group_type,-99) = NVL(l_old_ServiceRequest_rec.group_type,-99)
6766     THEN
6767       l_audit_vals_rec.change_group_type_flag := 'N';
6768     ELSE
6769       l_audit_vals_rec.change_group_type_FLAG := 'Y';
6770     END IF;
6771     l_audit_vals_rec.OLD_group_type := l_old_ServiceRequest_rec.group_type;
6772     l_audit_vals_rec.group_type     := l_service_request_rec.group_type;
6773     -- Audit Resource Type
6774     IF NVL(l_service_request_rec.resource_type,-99) = NVL(l_old_ServiceRequest_rec.resource_type,-99)
6775     THEN
6776       l_audit_vals_rec.change_resource_type_flag := 'N';
6777     ELSE
6778       l_audit_vals_rec.change_resource_type_FLAG := 'Y';
6779     END IF;
6780     l_audit_vals_rec.old_resource_type         := l_old_ServiceRequest_rec.resource_type;
6781     l_audit_vals_rec.resource_type             := l_service_request_rec.resource_type;
6782 
6783     -----Added for enhancements 11.5.6-------jngeorge-----08/03/01
6784     ----Added code for bug# 1966169
6785     IF NVL(l_service_request_rec.owner_group_id,-99) = NVL(l_old_ServiceRequest_rec.owner_group_id,-99)
6786     THEN
6787       l_audit_vals_rec.change_group_flag := 'N';
6788     ELSE
6789       ---- Added for Enh# 2216664
6790       -- For audit record
6791       l_audit_vals_rec.change_group_FLAG := 'Y';
6792     END IF;
6793     l_audit_vals_rec.old_group_id      := l_old_ServiceRequest_rec.owner_group_id;
6794     l_audit_vals_rec.group_id          := l_service_request_rec.owner_group_id;
6795     --
6796     -- Territory Audit
6797     --
6798     IF NVL(l_service_request_rec.territory_id,-99) = NVL(l_old_ServiceRequest_rec.territory_id,-99)
6799     THEN
6800       l_audit_vals_rec.change_territory_id_flag := 'N';
6801     ELSE
6802       ---- Added for Enh# 2216664
6803       -- For audit record
6804       l_audit_vals_rec.change_territory_id_FLAG := 'Y';
6805     END IF;
6806     l_audit_vals_rec.old_territory_id      := l_old_ServiceRequest_rec.territory_id;
6807     l_audit_vals_rec.territory_id          := l_service_request_rec.territory_id;
6808     --End of audit changes for Group, owner and Group Type
6809     -- Added for Auditing project of 11.5.10 --anmukher --09/05/03 l_old_ServiceRequest_rec
6810     --
6811     IF NVL(l_service_request_rec.site_id,-99) = NVL(l_old_ServiceRequest_rec.site_id,-99)
6812     THEN
6813       l_audit_vals_rec.change_site_flag := 'N';
6814     ELSE
6815       l_audit_vals_rec.change_site_FLAG := 'Y';
6816     END IF;
6817     l_audit_vals_rec.old_site_id        := l_old_ServiceRequest_rec.site_id;
6818     l_audit_vals_rec.site_id            := l_service_request_rec.site_id;
6819 
6820     --siahmed 12.2+ project additing project attributes to audit
6821     l_audit_vals_rec.old_project_id        := l_old_ServiceRequest_rec.project_id;
6822     l_audit_vals_rec.project_id            := l_service_request_rec.project_id;
6823 
6824     l_audit_vals_rec.old_project_task_id   := l_old_ServiceRequest_rec.project_task_id;
6825     l_audit_vals_rec.project_task_id       := l_service_request_rec.project_task_id;
6826 
6827     l_audit_vals_rec.old_expenditure_org_id   := l_old_ServiceRequest_rec.expenditure_org_id;
6828     l_audit_vals_rec.expenditure_org_id       := l_service_request_rec.expenditure_org_id;
6829    --end of addition 12.2+ project  attributes
6830 
6831 
6832    --siahmed added for disabling audit when invocation_mode is of replay
6833    IF (p_invocation_mode <> 'REPLAY' ) THEN
6834     CS_ServiceRequest_PVT.Create_Audit_Record
6835     ( p_api_version         => 2.0
6836     , x_return_status       => l_return_status
6837     , x_msg_count           => x_msg_count
6838     , x_msg_data            => x_msg_data
6839     , p_request_id          => p_request_id
6840     , p_audit_id            => p_audit_id
6841     , p_audit_vals_rec      => l_audit_vals_rec
6842     , p_user_id             => l_service_request_rec.last_updated_by
6843     , p_wf_process_name     => l_workflow_process_name
6844     , p_wf_process_itemkey  => l_wf_process_itemkey
6845     , p_login_id            => l_service_request_rec.last_update_login
6846     , p_last_update_date    => l_service_request_rec.last_update_date
6847     , p_creation_date       => l_service_request_rec.last_update_date
6848     , p_comments            => p_audit_comments
6849     , x_audit_id            => l_audit_id
6850     );
6851    END IF; -- end of addition by siahmed for invocation_mode high avaialibility project
6852     --
6853     -- Create entries in CS_HZ_SR_CONTACT_POINTS from p_contacts
6854     CS_SRCONTACT_PKG.create_update
6855     ( p_incident_id     => p_request_id
6856     , p_invocation_mode => p_invocation_mode
6857     , p_sr_update_date  => l_service_request_rec.last_update_date
6858     , p_sr_updated_by   => l_service_request_rec.last_updated_by
6859     , p_sr_update_login => l_service_request_rec.last_update_login
6860     , p_contact_tbl     => l_processed_contacts
6861     , p_old_contact_tbl => l_old_contacts
6862     , x_return_status   => l_return_status
6863     );
6864 
6865     --siahmed added for the post hook fix after the contact creation
6866     --bug fix 9494021
6867    cs_servicerequest_iuhk.Update_ServiceRequest_Post( x_return_status=>l_return_status);
6868    --end of addition siahmed
6869 
6870     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
6871     THEN
6872       RAISE FND_API.G_EXC_ERROR;
6873     END IF;
6874 
6875     IF l_start_eres_flag = 'Y' AND
6876        l_approval_status = 'NO_ACTION'
6877     THEN
6878         IF NVL(l_sr_related_data.close_flag,'N') = 'Y'
6879         THEN
6880           -- Close workflow processing
6881           -- check if old status was closed on Not
6882           CS_SERVICEREQUEST_UTIL.get_status_details
6883           ( p_status_id                  => l_old_servicerequest_rec.incident_status_id
6884           , x_close_flag                 => l_sr_related_data.old_close_flag
6885           , x_disallow_request_update    => l_sr_related_data.old_disallow_request_update
6886           , x_disallow_agent_dispatch    => l_sr_related_data.old_disallow_owner_update
6887           , x_disallow_product_update    => l_sr_related_data.old_disallow_product_update
6888           , x_pending_approval_flag      => l_sr_related_data.old_pending_approval_flag
6889           , x_intermediate_status_id     => l_sr_related_data.old_intermediate_status_id
6890           , x_approval_action_status_id  => l_sr_related_data.old_approval_action_status_id
6891           , x_rejection_action_status_id => l_sr_related_data.old_rejection_action_status_id
6892           , x_return_status              => l_return_status
6893           );
6894           --
6895           IF l_sr_related_data.old_close_flag           <> 'Y' AND
6896              l_sr_related_data.abort_workflow_close_flag = 'Y' AND
6897              CS_Workflow_PKG.Is_Servereq_Item_Active
6898              ( p_request_number  => l_old_ServiceRequest_rec.incident_number
6899              , p_wf_process_id   => l_old_ServiceRequest_rec.workflow_process_id
6900              )  = 'Y'
6901           THEN
6902                CS_Workflow_PKG.Abort_Servereq_Workflow
6903                   (p_request_number  => l_old_ServiceRequest_rec.incident_number,
6904                    p_wf_process_id   => l_old_ServiceRequest_rec.workflow_process_id,
6905                    p_user_id         => p_last_updated_by);
6906           END IF;
6907           IF ( p_validate_sr_closure = 'Y' OR p_validate_sr_closure = 'y') THEN
6908             CS_SR_STATUS_PROPAGATION_PKG.VALIDATE_SR_CLOSURE
6909             ( p_api_version        => p_api_version
6910             , p_init_msg_list      => fnd_api.g_false
6911             , p_commit             => p_commit
6912             , p_service_request_id => p_request_id
6913             , p_user_id            => l_service_request_rec.last_updated_by
6914             , p_resp_appl_id       =>  p_resp_appl_id
6915             , p_login_id           => l_service_request_rec.last_update_login
6916             , x_return_status      => l_return_status
6917             , x_msg_count          => l_msg_count
6918             , x_msg_data           => l_msg_data
6919             );
6920             IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
6921             THEN
6922               RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6923             ELSIF (p_auto_close_child_entities='Y' OR p_auto_close_child_entities='y')
6924             THEN
6925               CS_SR_STATUS_PROPAGATION_PKG.CLOSE_SR_CHILDREN
6926               ( p_api_version         => p_api_version
6927               , p_init_msg_list       => fnd_api.g_false
6928               , p_commit              => p_commit
6929               , p_validation_required =>'N'
6930               , p_action_required     => 'Y'
6931               , p_service_request_id  => p_request_id
6932               , p_user_id             => l_service_request_rec.last_updated_by
6933               , p_resp_appl_id        =>  p_resp_appl_id
6934               , p_login_id            => l_service_request_rec.last_update_login
6935               , x_return_status       => l_return_status
6936               , x_msg_count           => l_msg_count
6937               , x_msg_data            => l_msg_data
6938               );
6939               IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
6940               THEN
6941                 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6942               END IF;
6943             END IF; -- for auto_close-child = 'Y'
6944           END IF; ------ p_validate_sr_closeure = 'Y'
6945         END IF; -------- l_sr_related_data.close_flag = 'Y'
6946     END IF; -- l_start_eres_flag = 'Y'
6947     --
6948     -- Change task address is incident address is changed.
6949 
6950     IF p_validation_level >  FND_API.G_VALID_LEVEL_NONE
6951     THEN
6952 
6953       IF NVL(l_service_request_rec.incident_location_id,-1)  <>
6954          NVL(l_old_servicerequest_rec.incident_location_id,-1) OR
6955          NVL(l_service_request_rec.incident_location_type,'-') <>
6956          NVL(l_old_servicerequest_rec.incident_location_type,'-')
6957       THEN
6958 
6959         CS_ServiceRequest_UTIL.Verify_LocUpdate_For_FSTasks
6960          (p_incident_id   => p_request_id,
6961           x_return_status => x_return_status );
6962 
6963 
6964         IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6965           RAISE FND_API.G_EXC_ERROR;
6966         ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6967           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6968         END IF ;
6969 
6970         CS_servicerequest_util.update_task_address
6971         ( p_incident_id   => p_request_id
6972         , p_location_type => l_service_request_rec.incident_location_type
6973         , p_location_id   => l_service_request_rec.incident_location_id
6974         , p_old_location_id   => l_old_servicerequest_rec.incident_location_id  -- bug 8947959
6975         , x_return_status => x_return_status
6976         );
6977         IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6978           RAISE FND_API.G_EXC_ERROR;
6979         ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6980           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6981         END IF;
6982       END IF;
6983     END IF;
6984   END IF; -- l_only_status_update_flag <> 'Y'
6985    --- Added for HA Enhancement
6986 
6987    IF (p_invocation_mode <> 'REPLAY') THEN
6988    --AND (FND_API.To_Boolean(p_called_by_workflow) = FALSE) THEN
6989       -- Raise BES Event that the SR is updated. Before business events, a WF process
6990       -- was kicked off if the following conditions were met: if l_autolaunch_wf_flag
6991       -- is 'Y' AND resource_type = 'RS_EMPLOYEE' AND owner_id IS NOT NULL and the
6992       -- status of the SR is not 'CLOSE' and there is'nt an active WF tied to this SR.
6993       -- After the introduction of business event, the SR API calls the CS BES wrapper
6994       -- API and this wrapper API raises the needed business events, in this case -
6995       -- SR Updated, after checking the required conditions.
6996       -- The wrapper API will also check if a Contact was added or the SR was re-assigned
6997       -- and raise those evens as well if true.
6998 
6999       -- Initialize and populate the old rec type with the SR Old values.
7000 
7001 
7002     --siahmed added by siahmed for post hook
7003       initialize_rec ( p_sr_record          => l_old_sr_rec );
7004 
7005       l_old_sr_rec.type_id                  := l_old_servicerequest_rec.incident_type_id;
7006       l_old_sr_rec.status_id                := l_old_servicerequest_rec.incident_status_id;
7007       l_old_sr_rec.severity_id              := l_old_servicerequest_rec.incident_severity_id;
7008       l_old_sr_rec.urgency_id               := l_old_servicerequest_rec.incident_urgency_id;
7009       l_old_sr_rec.owner_id                 := l_old_servicerequest_rec.incident_owner_id;
7010       l_old_sr_rec.owner_group_id           := l_old_servicerequest_rec.owner_group_id;
7011       l_old_sr_rec.customer_id              := l_old_servicerequest_rec.customer_id;
7012       l_old_sr_rec.customer_product_id      := l_old_servicerequest_rec.customer_product_id;
7013       l_old_sr_rec.inventory_item_id        := l_old_servicerequest_rec.inventory_item_id;
7014       l_old_sr_rec.problem_code             := l_old_servicerequest_rec.problem_code;
7015       --Added summary as a fix for bug#2809232
7016       l_old_sr_rec.summary                  := l_old_servicerequest_rec.summary;
7017       l_old_sr_rec.exp_resolution_date      := l_old_servicerequest_rec.expected_resolution_date;
7018       l_old_sr_rec.install_site_id          := l_old_servicerequest_rec.install_site_id;
7019       l_old_sr_rec.bill_to_site_id          := l_old_servicerequest_rec.bill_to_site_id;
7020       l_old_sr_rec.bill_to_contact_id       := l_old_servicerequest_rec.bill_to_contact_id;
7021       l_old_sr_rec.ship_to_site_id          := l_old_servicerequest_rec.ship_to_site_id;
7022       l_old_sr_rec.ship_to_contact_id       := l_old_servicerequest_rec.ship_to_contact_id;
7023       l_old_sr_rec.resolution_code          := l_old_servicerequest_rec.resolution_code;
7024       l_old_sr_rec.contract_service_id      := l_old_servicerequest_rec.contract_service_id;
7025       l_old_sr_rec.sr_creation_channel      := l_old_servicerequest_rec.sr_creation_channel;
7026       l_old_sr_rec.last_update_channel      := l_old_servicerequest_rec.last_update_channel;
7027       l_old_sr_rec.last_update_program_code := l_old_servicerequest_rec.last_update_program_code;
7028 
7029        -- added wf process id to be passed to the BES event, so that it does'nt raise another
7030       -- event if there is a wf process id already that is active.
7031 
7032 
7033       CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT(
7034          -- These 4 parameters added for bug #2798269
7035          p_api_version           => p_api_version,
7036          p_init_msg_list         => fnd_api.g_false ,
7037          p_commit                => p_commit,
7038          p_validation_level      => p_validation_level,
7039          p_event_code            => 'UPDATE_SERVICE_REQUEST',
7040          p_incident_number       => l_old_ServiceRequest_rec.incident_number,
7041          p_user_id               => l_service_request_rec.last_updated_by,
7042          p_resp_id               => p_resp_id,
7043          p_resp_appl_id          => p_resp_appl_id,
7044 	 p_old_sr_rec            => l_old_sr_rec,
7045 	 p_new_sr_rec            => l_service_request_rec, -- using l_ser...coz this is the
7046 							   -- rec. type used in the insert.
7047 	 p_contacts_table        => p_contacts,
7048          p_link_rec              => NULL,  -- using default value
7049          p_wf_process_id         => p_workflow_process_id,  -- value of the WF
7050                           -- process id if the update API is invoked from a WF.
7051          p_owner_id		 => NULL,  -- using default value
7052          p_wf_manual_launch	 => 'N' ,  -- using default value
7053          x_wf_process_id         => l_workflow_process_id,
7054          x_return_status         => lx_return_status,
7055          x_msg_count             => lx_msg_count,
7056          x_msg_data              => lx_msg_data );
7057 
7058       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
7059          -- do nothing in this API. The BES wrapper API will have to trap this
7060          -- situation and send a notification to the SR owner that the BES has
7061          -- not been raised. If the BES API return back a failure status, it
7062          -- means only that the BES raise event has failed, and has nothing to
7063          -- do with the update of the SR.
7064          --null;
7065 	 -- Added for bug 8849523.
7066 	 --If the subscription action type ON ERROR is set to STOP and ROLLBACK, then if
7067 	 --an error is raised that should be propagated to the calling application.
7068 	 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7069       end if;
7070       x_sr_update_out_rec.workflow_process_id  := l_workflow_process_id ;
7071    END IF;   -- IF (p_invocation_mode <> 'REPLAY')
7072    --
7073    -- end of Raise service request events.
7074    --
7075         CS_SR_WORKITEM_PVT.Update_Workitem(
7076                 p_api_version           => 1.0,
7077                 p_init_msg_list         => fnd_api.g_false  ,
7078                 p_commit                => p_commit       ,
7079                 p_incident_id           => p_request_id,
7080                 p_old_sr_rec            => l_old_ServiceRequest_rec,
7081                 p_new_sr_rec            => l_service_request_rec,
7082                 p_user_id               => l_service_request_rec.last_updated_by,
7083                 p_resp_appl_id          => p_resp_appl_id ,
7084                 x_return_status         => l_return_status,
7085                 x_msg_count             => x_msg_count,
7086                 x_msg_data              => x_msg_data);
7087 
7088        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7089            FND_MSG_PUB.Count_And_Get
7090         ( p_count => x_msg_count,
7091           p_data  => x_msg_data
7092          );
7093       END IF;
7094 
7095   CLOSE l_ServiceRequest_csr;
7096 /**************Commit moved for bug 2857350**************************/
7097  -- Standard check of p_commit
7098    IF FND_API.To_Boolean(p_commit) THEN
7099       COMMIT WORK;
7100    END IF;
7101 
7102    /*resetting the parameter value shijain 4th dec 2002*/
7103    g_restrict_ib:=NULL;
7104 
7105    -- Standard call to get message count and if count is 1, get message info
7106    FND_MSG_PUB.Count_And_Get (
7107       p_count => x_msg_count,
7108       p_data  => x_msg_data );
7109 
7110 EXCEPTION
7111   WHEN FND_API.G_EXC_ERROR THEN
7112     ROLLBACK TO Update_ServiceRequest_PVT;
7113     IF (l_ServiceRequest_csr%ISOPEN) THEN
7114       CLOSE l_ServiceRequest_csr;
7115     END IF;
7116     x_return_status := FND_API.G_RET_STS_ERROR;
7117     FND_MSG_PUB.Count_And_Get
7118       ( p_count => x_msg_count,
7119         p_data  => x_msg_data
7120       );
7121 
7122   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
7123     ROLLBACK TO Update_ServiceRequest_PVT;
7124     IF (l_ServiceRequest_csr%ISOPEN) THEN
7125       CLOSE l_ServiceRequest_csr;
7126     END IF;
7127     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7128     FND_MSG_PUB.Count_And_Get
7129       ( p_count => x_msg_count,
7130         p_data  => x_msg_data
7131       );
7132 
7133   WHEN DestUpdated THEN
7134     IF (l_ServiceRequest_csr%ISOPEN) THEN
7135       CLOSE l_ServiceRequest_csr;
7136     END IF;
7137     IF (p_invocation_mode = 'REPLAY' ) THEN
7138       x_return_status := FND_API.G_RET_STS_SUCCESS;
7139     ELSE
7140       x_return_status := FND_API.G_RET_STS_ERROR;
7141     END IF;
7142     FND_MESSAGE.SET_NAME('CS','CS_SR_DESTINATION_UPDATED');
7143     FND_MSG_PUB.ADD;
7144     FND_MSG_PUB.Count_And_Get
7145       ( p_count => x_msg_count,
7146         p_data  => x_msg_data
7147       );
7148 
7149   WHEN NoUpdate THEN
7150     IF (l_ServiceRequest_csr%ISOPEN) THEN
7151       CLOSE l_ServiceRequest_csr;
7152     END IF;
7153     x_return_status := FND_API.G_RET_STS_ERROR;
7154     FND_MESSAGE.SET_NAME('CS','CS_SR_LESSER_OBJ_VERSION');
7155     FND_MSG_PUB.ADD;
7156     FND_MSG_PUB.Count_And_Get
7157       ( p_count => x_msg_count,
7158         p_data  => x_msg_data
7159       );
7160 
7161   WHEN TargUpdated THEN
7162     IF (l_ServiceRequest_csr%ISOPEN) THEN
7163       CLOSE l_ServiceRequest_csr;
7164     END IF;
7165       x_return_status := FND_API.G_RET_STS_SUCCESS;
7166     FND_MESSAGE.SET_NAME('CS','CS_SR_HA_NO_REPLAY');
7167     FND_MSG_PUB.ADD;
7168     FND_MSG_PUB.Count_And_Get
7169       ( p_count => x_msg_count,
7170         p_data  => x_msg_data
7171       );
7172 
7173   WHEN SR_Lock_Row THEN
7174     IF (l_ServiceRequest_csr%ISOPEN) THEN
7175       CLOSE l_ServiceRequest_csr;
7176     END IF;
7177     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7178     FND_MESSAGE.SET_NAME('FND','FORM_RECORD_CHANGED');
7179     FND_MSG_PUB.ADD;
7180     FND_MSG_PUB.Count_And_Get
7181       ( p_count => x_msg_count,
7182         p_data  => x_msg_data
7183       );
7184 
7185 --- For BUG # 2933250
7186   WHEN invalid_install_site THEN
7187   	ROLLBACK TO Update_ServiceRequest_PVT;
7188   	x_return_status := FND_API.G_RET_STS_ERROR;
7189     FND_MESSAGE.SET_NAME('CS','CS_SR_INVALID_INSTALL_SITE');
7190     FND_MSG_PUB.ADD;
7191     FND_MSG_PUB.Count_And_Get
7192       ( p_count => x_msg_count,
7193         p_data  => x_msg_data
7194       );
7195 
7196   WHEN OTHERS THEN
7197     ROLLBACK TO Update_ServiceRequest_PVT;
7198     IF (l_ServiceRequest_csr%ISOPEN) THEN
7199       CLOSE l_ServiceRequest_csr;
7200     END IF;
7201     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7202     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7203       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
7204     END IF;
7205     FND_MSG_PUB.Count_And_Get
7206       ( p_count => x_msg_count,
7207         p_data  => x_msg_data
7208       );
7209 
7210 
7211 END Update_ServiceRequest;
7212 
7213 
7214 -- -------------------------------------------------------------------
7215 -- Update_Status
7216 -- -------------------------------------------------------------------
7217 
7218 --p_org_id             IN   NUMBER   DEFAULT NULL,
7219 
7220 -- -------- -------- -----------------------------------------------------------
7221 -- Modification History
7222 -- Date     Name     Desc
7223 -- -------- -------- -----------------------------------------------------------
7224 -- 07/11/05 smisra   Rel 12.0 ERES changes
7225 --                   call get_status_details procedure for parameter p_status_id
7226 --                   if this status has intermediated status id as NOT NULL then
7227 --                   called update_servicerequest procedure. This is needed
7228 --                   for ERES processing and avoiding duplicate coding in this
7229 --                   procedure.
7230 -- 07/15/05 smisra   Bug 4489746 modified sql statement for cs_incident_types_b
7231 --                   and removed condition on start and end active dates so that
7232 --                   API does not give error for those types that become end
7233 --                   dated
7234 --                   Passed UPDATE_OLD to validate_type call because we need to
7235 --                   just check user's access to SR
7236 -- 07/21/05 smisra   Bug 3215462
7237 --                   Add a call to CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT
7238 -- 10/11/05 smisra   Bug 4666784
7239 --                   called validate_sr_closure and close_sr_children only
7240 --                   if close flag associated with status is 'Y'
7241 -- 10/14/05 smisra   fixed Bug 4674131
7242 --                   based on status id flags set response and resolved dates
7243 -- 04/25/06 spusegao Modofied to check if the existing SR status is an intermediate status with
7244 --                   disallow_request_update flag = 'Y'. If yes then disallow any update to
7245 --                   the service request.
7246 -- -------- -------- -----------------------------------------------------------
7247 PROCEDURE Update_Status
7248   ( p_api_version                   IN   NUMBER,
7249     p_init_msg_list                 IN   VARCHAR2 DEFAULT fnd_api.g_false,
7250     p_commit                        IN   VARCHAR2 DEFAULT fnd_api.g_false,
7251     p_resp_id                       IN   NUMBER,
7252     p_validation_level              IN   NUMBER   DEFAULT fnd_api.g_valid_level_full,
7253     x_return_status                OUT   NOCOPY VARCHAR2,
7254     x_msg_count                    OUT   NOCOPY NUMBER,
7255     x_msg_data                     OUT   NOCOPY VARCHAR2,
7256     p_request_id                    IN   NUMBER,
7257     p_object_version_number         IN   NUMBER,
7258     p_status_id                     IN   NUMBER,
7259     p_closed_date                   IN   DATE     DEFAULT fnd_api.g_miss_date,
7260     p_last_updated_by               IN   NUMBER,
7261     p_last_update_login             IN   NUMBER   DEFAULT NULL,
7262     p_last_update_date              IN   DATE,
7263     p_audit_comments                IN   VARCHAR2 DEFAULT NULL,
7264     p_called_by_workflow            IN   VARCHAR2 DEFAULT fnd_api.g_false,
7265     p_workflow_process_id           IN   NUMBER   DEFAULT NULL,
7266     p_comments                      IN   VARCHAR2 DEFAULT NULL,
7267     p_public_comment_flag           IN   VARCHAR2 DEFAULT fnd_api.g_false,
7268     p_parent_interaction_id         IN   NUMBER   DEFAULT NULL,
7269     p_validate_sr_closure           IN   VARCHAR2 Default 'N',
7270     p_auto_close_child_entities     IN   VARCHAR2 Default 'N',
7271      --Add p_auto_generate_tasks for 12.2-Auto Task creation
7272     p_auto_generate_tasks	    IN	 VARCHAR2 Default 'N',
7273     x_interaction_id               OUT   NOCOPY NUMBER
7274   )
7275   IS
7276      l_api_name          CONSTANT VARCHAR2(30) := 'Update_Status';
7277      l_api_version  CONSTANT NUMBER       := 2.0;
7278      l_api_name_full     CONSTANT VARCHAR2(62) := G_PKG_NAME||'.'||l_api_name;
7279      l_log_module         CONSTANT VARCHAR2(255)   := 'cs.plsql.' || l_api_name_full || '.';
7280      l_return_status     VARCHAR2(1);
7281      l_orig_status_id    NUMBER;
7282      l_closed_flag  VARCHAR2(1);
7283      l_orig_closed_date  DATE ;
7284      l_disallow_request_update  VARCHAR2(1);
7285      l_disallow_owner_update  VARCHAR2(1);
7286      l_disallow_product_update   VARCHAR2(1);
7287      l_audit_id                NUMBER;
7288      l_creation_date           DATE;
7289 
7290      l_closed_date  DATE;
7291      l_audit_vals_rec		   sr_audit_rec_type;
7292 
7293      l_autolaunch_workflow_flag   VARCHAR2(1);
7294      l_abort_workflow_close_flag  VARCHAR2(1);
7295      l_workflow_process_name      VARCHAR2(30);
7296      l_workflow_process_id        NUMBER;
7297 
7298      -- Added for enh. 2655115
7299      l_status_flag                VARCHAR2(1);
7300 
7301      --Added for Auto-Task Creation for Update_status
7302      l_new_disallow_request_update  VARCHAR2(1);
7303      l_task_template_id             NUMBER;
7304      l_task_template_group_owner    NUMBER;
7305      l_task_tmpl_group_owner_type   VARCHAR2(240);
7306      l_task_owner_name              VARCHAR2(120);
7307      l_auto_task_gen_rec	    CS_AutoGen_Task_PVT.auto_task_gen_rec_type;
7308      l_task_template_group_rec	    JTF_TASK_INST_TEMPLATES_PUB.task_template_group_info;
7309      l_task_template_table	    JTF_TASK_INST_TEMPLATES_PUB.task_template_info_tbl;
7310 
7311      --Fixed bug#2775580, getting all the columns in the cursor.
7312 
7313 /* ****************
7314    l_old_ServiceRequest_rec is now changed to type sr_oldvalues_rec_type .
7315 
7316    Replacing the select list of columns with a select * so that the
7317    subtype defined in the spec can be used to pass the old SR values as
7318    a parameter to other procedures
7319 
7320 * *****************/
7321 
7322      CURSOR L_SERVICEREQUEST_CSR IS
7323      SELECT *
7324      from   cs_incidents_all_vl
7325      where  incident_id = p_request_id
7326      and    object_version_number = p_object_version_number
7327      for    update nowait;
7328 
7329  -- The rec type was changed to sr_oldvalues_rec_type as the
7330  -- workitem API (Misc ER owner Auto Assginment )needed a record type
7331  -- with old values , also the API validations needed the oldvalues_rec .
7332 
7333      l_ServiceRequest_rec   sr_oldvalues_rec_type;
7334      l_new_sr_rec           service_request_rec_type;
7335      l_old_sr_rec           service_request_rec_type;
7336       --Adding a service_request_rec_type for passing it to Auto Task Creation API
7337      l_sr_rec_for_task      service_request_rec_type;
7338 
7339 
7340    -- Local variable to store business usage for security validation
7341    l_business_usage       VARCHAR2(30);
7342 
7343    -- Local variable to store attribute if security is enabled for self service resps.
7344    l_ss_sr_type_restrict   VARCHAR2(10);
7345 
7346    -- Local variable to get the return status of validate type for security check
7347    lx_return_status              VARCHAR2(3);
7348 
7349    l_old_cmro_flag               VARCHAR2(3);
7350    l_old_maintenance_flag        VARCHAR2(3);
7351 
7352    -- Added for Auditing --anmukher --10/15/03
7353    lx_audit_id			 NUMBER;
7354 
7355 l_sr_related_data       RELATED_DATA_TYPE;
7356 l_sr_update_out_rec	sr_update_out_rec_type;
7357 l_notes                 notes_table;
7358 l_contacts              contacts_table;
7359 l_inc_responded_by_date  DATE;
7360 l_incident_resolved_date  DATE;
7361 BEGIN
7362 
7363     -- ---------------------------------------
7364     -- Standard API stuff
7365     -- ---------------------------------------
7366 
7367     -- Establish save point
7368     SAVEPOINT Update_Status_PVT;
7369 
7370     -- Check version number
7371     IF NOT FND_API.Compatible_API_Call( l_api_version,
7372                             p_api_version,
7373                             l_api_name,
7374                             G_PKG_NAME ) THEN
7375       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7376     END IF;
7377 
7378     -- Initialize message list if requested
7379     IF FND_API.to_Boolean( p_init_msg_list ) THEN
7380       FND_MSG_PUB.initialize;
7381     END IF;
7382 
7383 ----------------------- FND Logging -----------------------------------
7384   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
7385   THEN
7386     FND_LOG.String
7387     ( FND_LOG.level_procedure , L_LOG_MODULE || 'start'
7388     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
7389     );
7390     FND_LOG.String
7391     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7392     , 'p_api_version:' || p_api_version
7393     );
7394     FND_LOG.String
7395     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7396     , 'p_init_msg_list:' || p_init_msg_list
7397     );
7398     FND_LOG.String
7399     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7400     , 'p_commit:' || p_commit
7401     );
7402     FND_LOG.String
7403     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7404     , 'p_validation_level:' || p_validation_level
7405     );
7406     FND_LOG.String
7407     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7408     , 'p_last_updated_by:' || p_last_updated_by
7409     );
7410     FND_LOG.String
7411     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7412     , 'p_resp_id:' || p_resp_id
7413     );
7414     FND_LOG.String
7415     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7416     , 'P_audit_comments:' || P_audit_comments
7417     );
7418     FND_LOG.String
7419     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7420     , 'P_object_version_number:' || P_object_version_number
7421     );
7422     FND_LOG.String
7423     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7424     , 'p_last_update_login:' || p_last_update_login
7425     );
7426     FND_LOG.String
7427     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7428     , 'p_last_update_date:' || p_last_update_date
7429     );
7430     FND_LOG.String
7431     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7432     , 'P_status_id:' || P_status_id
7433     );
7434     FND_LOG.String
7435     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7436     , 'p_parent_interaction_id:' || p_parent_interaction_id
7437     );
7438     FND_LOG.String
7439     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7440     , 'P_Closed_date:' || P_Closed_date
7441     );
7442     FND_LOG.String
7443     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7444     , 'p_request_id:' || p_request_id
7445     );
7446     FND_LOG.String
7447     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7448     , 'p_comments:' || p_comments
7449     );
7450     FND_LOG.String
7451     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7452     , 'P_Public_Comment_Flag:' || P_Public_Comment_Flag
7453     );
7454     FND_LOG.String
7455     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7456     , 'P_Called_by_workflow:' || P_Called_by_workflow
7457     );
7458     FND_LOG.String
7459     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7460     , 'P_Workflow_process_id:' || P_Workflow_process_id
7461     );
7462     FND_LOG.String
7463     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7464     , 'P_Validate_SR_Closure:' || P_Validate_SR_Closure
7465     );
7466     FND_LOG.String
7467     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7468     , 'P_Auto_Close_Child_Entities:' || P_Auto_Close_Child_Entities
7469     );
7470     FND_LOG.String
7471     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
7472     , 'P_auto_generate_tasks:' || P_auto_generate_tasks
7473     );
7474 
7475   END IF;
7476 
7477     -- Initialize the New Audit Record ******
7478     Initialize_audit_rec(
7479     p_sr_audit_record         => l_audit_vals_rec) ;
7480 
7481     -- Initialize return status to SUCCESS
7482     x_return_status := FND_API.G_RET_STS_SUCCESS;
7483 
7484     -- Initialize the new record and assign the required values for
7485     -- workitem call
7486 
7487     initialize_rec ( p_sr_record    => l_new_sr_rec );
7488     initialize_rec ( p_sr_record    => l_old_sr_rec );
7489     initialize_rec ( p_sr_record    => l_sr_rec_for_task);
7490 
7491     l_new_sr_rec.status_id := p_status_id ;
7492     l_new_sr_rec.closed_date:= p_closed_date;
7493     l_new_sr_rec.public_comment_flag := p_public_comment_flag;
7494     l_new_sr_rec.parent_interaction_id:= p_parent_interaction_id;
7495 
7496     -- ----------------------------------------
7497     -- Open cursor for update
7498     -- ----------------------------------------
7499     OPEN  l_ServiceRequest_csr;
7500     FETCH l_ServiceRequest_csr INTO l_ServiceRequest_rec;
7501     IF (l_ServiceRequest_csr%NOTFOUND) THEN
7502 
7503       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
7504                      ( p_token_an     =>  l_api_name_full,
7505                        p_token_v      =>  TO_CHAR(p_request_id),
7506                        p_token_p      =>  'p_request_id',
7507                        p_table_name   => G_TABLE_NAME,
7508                        p_column_name  => 'REQUEST_ID');
7509 
7510       RAISE FND_API.G_EXC_ERROR;
7511 
7512     END IF;
7513     -- --------------------------------------------------------
7514     -- If the new status is the same as old, there's no need
7515     -- to continue
7516     -- --------------------------------------------------------
7517 	-- for bug 3640344 - pkesani
7518     IF (p_status_id = l_ServiceRequest_rec.incident_status_id
7519 	    OR p_status_id = FND_API.G_MISS_NUM) THEN
7520 
7521     -- abhgauta - Fix for Bug 6042520
7522     -- Display the Warning that SR Status has not changed, only if SR Status's Disallow Update is unchecked
7523 
7524     IF (l_sr_related_data.disallow_request_update <> 'Y') THEN
7525 
7526       CS_ServiceRequest_UTIL.Add_Same_Val_Update_Msg
7527                     ( p_token_an     =>  l_api_name_full,
7528                       p_token_p      =>  'p_status_id' ,
7529                       p_table_name   => G_TABLE_NAME,
7530                       p_column_name  => 'INCIDENT_STATUS_ID');
7531 
7532       CLOSE l_ServiceRequest_csr;
7533       RETURN;
7534     END IF;
7535     END IF;
7536 
7537     -- -------------------------------------
7538     -- Perform validation when necessary
7539     -- -------------------------------------
7540     IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
7541 
7542       CS_ServiceRequest_UTIL.Validate_Who_Info(
7543                 p_api_name              => l_api_name_full,
7544           	p_parameter_name_usr    => 'p_last_updated_by',
7545           	p_parameter_name_login  => 'p_last_update_login',
7546                 p_user_id               => p_last_updated_by,
7547                 p_login_id              => p_last_update_login,
7548                 x_return_status         => l_return_status);
7549 
7550       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7551         RAISE FND_API.G_EXC_ERROR;
7552       END IF;
7553 
7554       -- Service security validation
7555       -- Validate if the current responsibility has access to the SR type being update.
7556       -- Invoke the VALIDATE_TYPE procedure that has the logic to check for security
7557       -- access
7558 
7559       -- Get the business usage of the responsibility that is attempting to create
7560       -- the SR.
7561       get_business_usage (
7562          p_responsibility_id      => p_resp_id,
7563          p_application_id         => fnd_global.resp_appl_id,
7564          x_business_usage         => l_business_usage );
7565 
7566       -- Get indicator of self service security enabled or not
7567       if ( l_business_usage = 'SELF_SERVICE' ) then
7568          get_ss_sec_enabled (
7569 	    x_ss_sr_type_restrict => l_ss_sr_type_restrict );
7570       end if;
7571 
7572       -- For bug 3370562 - pass resp_id an appl_id
7573       -- validate security in update; first against old sr type
7574       cs_servicerequest_util.validate_type (
7575          p_parameter_name       => NULL,
7576          p_type_id   	        => l_servicerequest_rec.incident_type_id,
7577          p_subtype  	        => G_SR_SUBTYPE,
7578          p_status_id            => l_servicerequest_rec.incident_status_id, -- not used
7579          p_resp_id              => p_resp_id,
7580          p_resp_appl_id         => fnd_global.resp_appl_id,
7581          p_business_usage       => l_business_usage,
7582          p_ss_srtype_restrict   => l_ss_sr_type_restrict,
7583          p_operation            => 'UPDATE_OLD',
7584          x_return_status        => lx_return_status,
7585          x_cmro_flag            => l_old_cmro_flag,
7586          x_maintenance_flag     => l_old_maintenance_flag );
7587 
7588       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
7589          -- security violation; responsibility does not have access to SR Type
7590          -- being created. Stop and raise error.
7591          RAISE FND_API.G_EXC_ERROR;
7592       end if;
7593     END IF;   -- IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
7594 
7595     -- Get the details of the existing status of SR
7596 
7597     CS_SERVICEREQUEST_UTIL.get_status_details
7598        ( p_status_id                  => l_servicerequest_rec.incident_status_id
7599        , x_close_flag                 => l_sr_related_data.old_close_flag
7600        , x_disallow_request_update    => l_sr_related_data.old_disallow_request_update
7601        , x_disallow_agent_dispatch    => l_sr_related_data.old_disallow_owner_update
7602        , x_disallow_product_update    => l_sr_related_data.old_disallow_product_update
7603        , x_pending_approval_flag      => l_sr_related_data.old_pending_approval_flag
7604        , x_intermediate_status_id     => l_sr_related_data.old_intermediate_status_id
7605        , x_approval_action_status_id  => l_sr_related_data.old_approval_action_status_id
7606        , x_rejection_action_status_id => l_sr_related_data.old_rejection_action_status_id
7607        , x_return_status              => l_return_status);
7608 
7609       IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
7610 
7611          IF (l_sr_related_data.old_pending_approval_flag = 'Y') AND
7612             (l_sr_related_data.old_disallow_request_update = 'Y') THEN
7613             FND_MESSAGE.set_name('CS','CS_ERES_SR_FROZEN_STATUS');
7614             FND_MSG_PUB.ADD;
7615             --FND_MESSAGE.set_name('CS','CS_SR_INTERMEDIATE_STATUS');
7616             --FND_MESSAGE.set_token('API_NAME','CS_SERVICEREQUEST_PVT.update_status');
7617             --FND_MESSAGE.set_token('STATUS_ID',l_servicerequest_rec.incident_status_id);
7618             --FND_MSG_PUB.ADD_DETAIL(p_associated_column1=>'CS_INCIDENTS_ALL_B.incident_status_id');
7619             RAISE FND_API.G_EXC_ERROR;
7620          END IF; -- l_pending approval flag is Y
7621       END IF; -- if after get_status_details call
7622 
7623     -- Get the details of the new status
7624     CS_SERVICEREQUEST_UTIL.get_status_details
7625     ( p_status_id                  => p_status_id
7626     , x_close_flag                 => l_sr_related_data.close_flag
7627     , x_disallow_request_update    => l_sr_related_data.disallow_request_update
7628     , x_disallow_agent_dispatch    => l_sr_related_data.disallow_owner_update
7629     , x_disallow_product_update    => l_sr_related_data.disallow_product_update
7630     , x_pending_approval_flag      => l_sr_related_data.pending_approval_flag
7631     , x_intermediate_status_id     => l_sr_related_data.intermediate_status_id
7632     , x_approval_action_status_id  => l_sr_related_data.approval_action_status_id
7633     , x_rejection_action_status_id => l_sr_related_data.rejection_action_status_id
7634     , x_return_status              => l_return_status
7635     );
7636     IF l_return_status = FND_API.G_RET_STS_SUCCESS
7637     THEN
7638 /*
7639       IF l_sr_related_data.pending_approval_flag = 'Y' THEN
7640         FND_MESSAGE.set_name ('CS', 'CS_SR_INTERMEDIATE_STATUS');
7641         FND_MESSAGE.set_token
7642         ( 'API_NAME'
7643         , 'CS_SERVICEREQUEST_PVT.update_status'
7644         );
7645         FND_MESSAGE.set_token('STATUS_ID',p_status_id);
7646         FND_MSG_PUB.ADD_DETAIL
7647         ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.incident_status_id'
7648         );
7649         RAISE FND_API.G_EXC_ERROR;
7650       END IF; -- l_pending approval flag is Y
7651 */
7652       IF l_sr_related_data.intermediate_status_id IS NOT NULL
7653       THEN
7654 
7655         CS_ServiceRequest_PVT.Update_ServiceRequest
7656         ( p_api_version               => 4.0
7657         , p_init_msg_list	      => p_init_msg_list
7658         , p_commit		      => p_commit
7659         , p_validation_level          => p_validation_level
7660         , x_return_status	      => x_return_status
7661         , x_msg_count	              => x_msg_count
7662         , x_msg_data	              => x_msg_data
7663         , p_request_id	              => p_request_id
7664         , p_audit_id	              => NULL
7665         , p_object_version_number     => p_object_version_number
7666         , p_resp_id                   => p_resp_id
7667         , p_last_updated_by	      => p_last_updated_by
7668         , p_last_update_login         => p_last_update_login
7669         , p_last_update_date          => p_last_update_date
7670         , p_service_request_rec       => l_new_sr_rec
7671         , p_notes                     => l_notes
7672         , p_contacts                  => l_contacts
7673         , p_called_by_workflow        => p_called_by_workflow
7674         , p_workflow_process_id       => p_workflow_process_id
7675         , p_validate_sr_closure       => p_validate_sr_closure
7676         , p_auto_close_child_entities => p_auto_close_child_entities
7677         , x_sr_update_out_rec         => l_sr_update_out_rec
7678         );
7679 
7680         RETURN;
7681       END IF; -- intermediated status id is not null
7682     END IF; -- if after get_status_details call
7683     -- ------------------------------------------------------------------
7684     -- We ALWAYS have to validate the status because we don't know if the
7685     -- status is a "closed" status, and we need this information in order
7686     -- to set the closed_date variable accordingly
7687     -- ------------------------------------------------------------------
7688     CS_ServiceRequest_UTIL.Validate_Updated_Status(
7689           p_api_name         => l_api_name_full,
7690           p_parameter_name   => 'p_status_id',
7691           p_resp_id          => p_resp_id  ,
7692           p_new_status_id    => p_status_id,
7693           p_old_status_id    => l_ServiceRequest_rec.incident_status_id,
7694           p_subtype          => G_SR_SUBTYPE,
7695           p_type_id          => l_ServiceRequest_rec.incident_type_id,
7696           p_old_type_id      => l_ServiceRequest_rec.incident_type_id,
7697           p_close_flag       => l_closed_flag,
7698           p_disallow_request_update  => l_disallow_request_update,
7699           p_disallow_owner_update    => l_disallow_owner_update,
7700           p_disallow_product_update  => l_disallow_product_update,
7701           x_return_status    => l_return_status );
7702 
7703     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7704       RAISE FND_API.G_EXC_ERROR;
7705     END IF;
7706 
7707     -- ------------------------------------------------------------------
7708     -- Changes starts for 12.2 Auto Task Creation, in case the 'To Status'
7709     -- doesn't have 'Disallow Request Update Checked'. - lkullamb
7710     -- ------------------------------------------------------------------
7711     SELECT disallow_request_update
7712     INTO  l_new_disallow_request_update
7713     FROM  cs_incident_statuses_b
7714     WHERE incident_status_id = p_status_id
7715     AND   incident_subtype = G_SR_SUBTYPE;
7716 
7717 
7718     IF NVL(l_new_disallow_request_update,'N') <> 'Y' THEN
7719        IF p_auto_generate_tasks = 'Y' OR  p_auto_generate_tasks = 'y' THEN
7720 
7721         --Fix for bug 12668350
7722 	--Check if status_group_id is defined in 'CS_SR_TYPE_MAPPING'
7723         --table first If it is not defined,then look in cs_incident_types
7724         BEGIN
7725 	   SELECT task_template_id into l_task_template_id
7726 	   FROM  cs_sr_status_transitions cst,cs_sr_type_mapping srtype
7727 	   WHERE srtype.incident_type_id = l_servicerequest_rec.incident_type_id
7728            AND srtype.responsibility_id = p_resp_id
7729            AND trunc(sysdate) BETWEEN
7730             trunc(nvl(srtype.start_date, sysdate)) AND
7731             trunc(nvl(srtype.end_date, sysdate))
7732 	   AND   cst.status_group_id=srtype.status_group_id
7733 	   AND   cst.from_incident_status_id = l_servicerequest_rec.incident_status_id--refers to old status_id
7734 	   AND   cst.to_incident_status_id = p_status_id; -- refers to new status_id
7735 	 EXCEPTION
7736          WHEN NO_DATA_FOUND THEN
7737             NULL;
7738         END;
7739 
7740        IF l_task_template_id IS NULL THEN
7741 	   BEGIN
7742        		--Get task template id
7743 		select task_template_id into l_task_template_id
7744 		FROM  cs_sr_status_transitions cst,cs_incident_types_b cit
7745 		WHERE cit.incident_type_id = l_servicerequest_rec.incident_type_id
7746 		AND   cst.status_group_id=cit.status_group_id
7747 		AND   from_incident_status_id = l_servicerequest_rec.incident_status_id --refers to old status_id
7748 		AND   to_incident_status_id = p_status_id; -- refers to new status_id
7749           EXCEPTION
7750           WHEN NO_DATA_FOUND THEN
7751             NULL;
7752           END;
7753        END IF;
7754 
7755 	--call the task api
7756         IF l_task_template_id IS NOT NULL AND l_task_template_id <> -1 THEN
7757            --l_task_template_id = -2 means 'Use Task template Mapping'
7758            IF l_task_template_id <> -2 THEN
7759                l_task_template_group_rec.task_template_group_id := l_task_template_id;
7760            END IF;
7761 
7762 
7763            l_sr_rec_for_task.account_id             := l_servicerequest_rec.account_id;
7764    	   l_sr_rec_for_task.customer_id            := l_servicerequest_rec.customer_id;
7765 	   l_sr_rec_for_task.type_id                := l_ServiceRequest_rec.incident_type_id;
7766 	   l_sr_rec_for_task.inventory_org_id       := l_servicerequest_rec.inv_organization_id;
7767 	   l_sr_rec_for_task.inventory_item_id	    := l_servicerequest_rec.inventory_item_id;
7768 	   l_sr_rec_for_task.category_id            := l_servicerequest_rec.category_id;
7769 	   l_sr_rec_for_task.problem_code           := l_servicerequest_rec.problem_code;
7770 	   l_sr_rec_for_task.incident_location_type := l_servicerequest_rec.incident_location_type;
7771 	   l_sr_rec_for_task.incident_location_id   := l_servicerequest_rec.incident_location_id;
7772 	   l_sr_rec_for_task.obligation_date        := l_servicerequest_rec.obligation_date;
7773 	   l_sr_rec_for_task.exp_resolution_date    := l_servicerequest_rec.expected_resolution_date;
7774 	   l_sr_rec_for_task.incident_country       := l_servicerequest_rec.incident_country;
7775 	   l_sr_rec_for_task.incident_city          := l_servicerequest_rec.incident_city;
7776 	   l_sr_rec_for_task.incident_postal_code   := l_servicerequest_rec.incident_postal_code;
7777 	   l_sr_rec_for_task.incident_state         := l_servicerequest_rec.incident_state;
7778 	   l_sr_rec_for_task.incident_county        := l_servicerequest_rec.incident_county;
7779 	   l_sr_rec_for_task.incident_province      := l_servicerequest_rec.incident_province;
7780 	   l_sr_rec_for_task.severity_id            := l_servicerequest_rec.incident_severity_id;
7781 	   l_sr_rec_for_task.urgency_id             := l_servicerequest_rec.incident_urgency_id;
7782 	   l_sr_rec_for_task.status_id              := p_status_id;
7783 	   l_sr_rec_for_task.platform_id            := l_servicerequest_rec.platform_id;
7784 	   l_sr_rec_for_task.customer_site_id       := l_servicerequest_rec.customer_site_id;
7785 	   l_sr_rec_for_task.sr_creation_channel    := l_servicerequest_rec.sr_creation_channel;
7786 
7787            l_task_template_group_owner :=  FND_PROFILE.value('INC_DEFAULT_INCIDENT_TASK_OWNER');
7788 	   l_task_tmpl_group_owner_type := FND_PROFILE.value('INC_DEFAULT_INCIDENT_TASK_OWNER_TYPE');
7789 
7790 	   l_task_owner_name := JTF_TASK_UTL.get_owner(l_task_tmpl_group_owner_type,l_task_template_group_owner);
7791 
7792            IF l_task_owner_name IS NULL THEN
7793               l_task_template_group_owner :=  NULL;
7794 	      l_task_tmpl_group_owner_type := NULL;
7795             END IF;
7796 
7797 	   --Invoke auto generate task api
7798 	   CS_AutoGen_Task_PVT.Auto_Generate_Tasks
7799 	   ( p_api_version		   => 1.0,
7800 	     p_init_msg_list		   => fnd_api.g_false ,
7801 	     p_commit			   => p_commit,
7802              p_validation_level		   => p_validation_level,
7803              p_incident_id                 => p_request_id ,
7804              p_service_request_rec	   => l_sr_rec_for_task,
7805              p_task_template_group_owner   => l_task_template_group_owner,
7806              p_task_tmpl_group_owner_type  => l_task_tmpl_group_owner_type,
7807              p_task_template_group_rec	   => l_task_template_group_rec,
7808              p_task_template_table	   => l_task_template_table,
7809              x_auto_task_gen_rec	   => l_auto_task_gen_rec,
7810              x_return_status		   => l_return_status,
7811              x_msg_count		   => x_msg_count,
7812              x_msg_data			   => x_msg_data
7813            );
7814 
7815 	   IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7816                FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
7817 			            p_data  => x_msg_data );
7818            END IF;
7819         END IF; -- End of l_task_template_id is null and l_task_template_id <> -1 , if task_template_id null or -1, dont generate task
7820      END IF; -- end of p_auto_generate_tasks = 'Y'
7821     END IF; -- end of l_new_disallow_request_update <> 'Y'
7822 
7823     -- End of changes for 12.2 Auto Task Creation for Update_Status
7824 
7825     -- ------------------------------------------------------------------
7826     -- Cannot close the request by setting the status to a "closed"
7827     -- status when there is an active workflow process in progress.
7828     -- Unless this API itself was called from a workflow process.
7829     -- ------------------------------------------------------------------
7830     IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
7831 
7832       --Get the abort workflow on close flag from cs_incident_types
7833 
7834       BEGIN
7835 	  -- Initialize the return status.
7836        l_return_status := FND_API.G_RET_STS_SUCCESS;
7837 
7838        -- Verify the type ID against the database.
7839 
7840 	  SELECT autolaunch_workflow_flag,
7841                  abort_workflow_close_flag,
7842                  workflow
7843            INTO  l_autolaunch_workflow_flag,
7844                  l_abort_workflow_close_flag,
7845                  l_workflow_process_name
7846 	  FROM   cs_incident_types_b
7847 	  WHERE  incident_type_id = l_ServiceRequest_rec.incident_type_id
7848     	  AND    incident_subtype = G_SR_SUBTYPE
7849           ;
7850 
7851       EXCEPTION
7852 
7853 	   WHEN NO_DATA_FOUND THEN
7854 	       l_return_status := FND_API.G_RET_STS_ERROR;
7855 		  CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
7856                          ( p_token_an     => l_api_name_full,
7857 			   p_token_v      => TO_CHAR(l_ServiceRequest_rec.incident_type_id),
7858 			   p_token_p      => 'p_type_id' ,
7859                            p_table_name   => G_TABLE_NAME,
7860                            p_column_name => 'INCIDENT_TYPE_ID');
7861 
7862 			    RAISE FND_API.G_EXC_ERROR;
7863       END ;
7864 
7865      --Call Abort workflow, if the status is being changed to CLOSE and the abort workflow on close
7866       IF (l_abort_workflow_close_flag = 'Y') AND (l_closed_flag = 'Y') THEN
7867 
7868 	   IF (CS_Workflow_PKG.Is_Servereq_Item_Active
7869 		 (p_request_number  => l_ServiceRequest_rec.incident_number,
7870                   p_wf_process_id   => l_ServiceRequest_rec.workflow_process_id )  = 'Y') THEN
7871 
7872            CS_Workflow_PUB.Cancel_Servereq_Workflow
7873             ( p_api_version     => 1.0,
7874             p_return_status   => l_return_status,
7875             p_msg_count       => x_msg_count,
7876             p_msg_data        => x_msg_data,
7877             p_request_number  => l_ServiceRequest_rec.incident_number,
7878             p_wf_process_id   => l_ServiceRequest_rec.workflow_process_id,
7879             p_user_id         => p_last_updated_by
7880             );
7881            IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7882              RAISE FND_API.G_EXC_ERROR;
7883            END IF;
7884         END IF;
7885       END IF;
7886 
7887      END IF;
7888 
7889     -- ------------------------------------------------------------------
7890     -- Validate and set the closed date.  If the status is not a closed
7891     -- status, set the closed date to NULL (and give a warning if the
7892     -- closed date was passed in).  If the status is a closed status,
7893     -- then validate the closed date if it was passed in.  If not,
7894     -- default sysdate into the closed date.
7895     -- ------------------------------------------------------------------
7896 	-- for bug 3640344 - pkesani
7897 
7898     IF (l_closed_flag = 'Y') THEN
7899       IF (p_closed_date = FND_API.G_MISS_DATE OR p_closed_date IS NULL) THEN
7900         IF (l_ServiceRequest_rec.close_date IS NULL) THEN
7901           l_closed_date := SYSDATE;
7902         ELSE
7903           l_closed_date := l_ServiceRequest_rec.close_date;
7904         END IF;
7905       ELSE
7906         l_closed_date := p_closed_date;
7907      IF (p_closed_date IS NOT NULL) THEN
7908 
7909           CS_ServiceRequest_UTIL.Validate_Closed_Date(
7910           p_api_name       => G_PKG_NAME||'.'||l_api_name,
7911           p_parameter_name => 'p_closed_date',
7912           p_closed_date    => l_closed_date,
7913           p_request_date   => l_ServiceRequest_rec.incident_date,
7914           x_return_status  => l_return_status );
7915 
7916         END IF;
7917         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7918           RAISE FND_API.G_EXC_ERROR;
7919         END IF;
7920       END IF;
7921     ELSE
7922       l_closed_date := NULL;
7923 
7924       IF (p_closed_date = FND_API.G_MISS_DATE) OR
7925          (p_closed_date IS NULL) THEN
7926         NULL;
7927       ELSE
7928         CS_ServiceRequest_UTIL.Add_Param_Ignored_MSg
7929                           ( p_token_an     =>  l_api_name_full,
7930                             p_token_ip     =>  'p_closed_date',
7931                             p_table_name   =>  G_TABLE_NAME,
7932                             p_column_name  =>  'CLOSED_DATE');
7933       END IF;
7934     END IF;
7935 
7936 
7937 --- If the status is updated to close status then,check to see if the
7938 --- SR has any open tasks with restrict flag set to 'Y', If yes, return
7939 ---  error ( bug # 3512003).
7940 
7941     IF (l_closed_flag = 'Y') THEN
7942       CS_ServiceRequest_UTIL.TASK_RESTRICT_CLOSE_CROSS_VAL (
7943          p_incident_id           => p_request_id,
7944          p_status_id             => p_status_id,
7945          x_return_status         => l_return_status );
7946 
7947         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7948           RAISE FND_API.G_EXC_ERROR;
7949         END IF;
7950 
7951 
7952 	--  ----------------------------------------------
7953     --  Code Changes for 11.5.10 Auto Close SR project
7954     --  Restrict closure if SR children cant be closed.
7955     -- ----------------------------------------------
7956 
7957  -- For bug 3332985
7958   IF ( p_validate_sr_closure = 'Y'  OR p_validate_sr_closure = 'y') THEN
7959       CS_SR_STATUS_PROPAGATION_PKG.VALIDATE_SR_CLOSURE(
7960               p_api_version        => p_api_version,
7961               p_init_msg_list      => fnd_api.g_false ,
7962               p_commit             => p_commit,
7963               p_service_request_id => p_request_id,
7964               p_user_id            => p_last_updated_by,
7965               p_resp_appl_id       => p_resp_id,
7966               p_login_id           => p_last_update_login,
7967               x_return_status      => l_return_status,
7968               x_msg_count          => x_msg_count ,
7969               x_msg_data           => x_msg_data);
7970 
7971      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7972          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7973      ELSIF(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
7974        IF (p_auto_close_child_entities='Y' OR p_auto_close_child_entities='y')  THEN
7975 
7976          CS_SR_STATUS_PROPAGATION_PKG.CLOSE_SR_CHILDREN(
7977               p_api_version         => p_api_version,
7978               p_init_msg_list       => fnd_api.g_false ,
7979               p_commit              => p_commit,
7980               p_validation_required =>'N',
7981               p_action_required     => 'Y',
7982               p_service_request_id  => p_request_id,
7983               p_user_id             => p_last_updated_by,
7984               p_resp_appl_id        =>  p_resp_id,
7985               p_login_id            => p_last_update_login,
7986               x_return_status       => l_return_status,
7987               x_msg_count           => x_msg_count ,
7988               x_msg_data            => x_msg_data);
7989          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7990          RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7991          END IF;
7992       END IF;
7993      END IF;
7994   END IF;
7995     END IF;
7996 
7997     CS_SERVICEREQUEST_UTIL.get_reacted_resolved_dates
7998     ( p_incident_status_id         => p_status_id
7999     , p_old_incident_status_id     => l_servicerequest_rec.incident_status_id
8000     , p_old_incident_resolved_date => l_servicerequest_rec.incident_resolved_date
8001     , p_old_inc_responded_by_date  => l_servicerequest_rec.inc_responded_by_date
8002     , x_inc_responded_by_date      => l_inc_responded_by_date
8003     , x_incident_resolved_date     => l_incident_resolved_date
8004     , x_return_status              => l_return_status
8005     );
8006     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
8007     THEN
8008       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8009     END IF;
8010 
8011     --added by sanjana ra for bug 8507917
8012    IF l_inc_responded_by_date IS NULL THEN
8013      l_inc_responded_by_date:=l_servicerequest_rec.inc_responded_by_date;
8014     END IF;
8015     IF l_incident_resolved_date IS NULL THEN
8016           l_incident_resolved_date:=l_servicerequest_rec.incident_resolved_date;
8017     END IF;
8018    --end of addition by sanjana rao
8019 
8020     -- ----------------------------------------------
8021     -- Update the status and insert the audit record
8022     -- ----------------------------------------------
8023 
8024     l_orig_status_id := l_ServiceRequest_rec.incident_status_id;
8025     l_orig_closed_date := l_ServiceRequest_rec.close_date ;
8026 
8027    /* Added call to get_status_flag for enh 2655115, to get the status flag
8028       based on the closed flag by shijain date 27th nov 2002*/
8029 
8030    l_status_flag:= get_status_flag ( p_status_id);
8031 
8032     -- Update CS_INCIDENTS table
8033     -- for the bug 3027154 - wrong date in the SR Log
8034     UPDATE cs_incidents_all_b
8035        SET incident_status_id = p_status_id,
8036         close_date            = l_closed_date,
8037         inc_responded_by_date = l_inc_responded_by_date,
8038         incident_resolved_date= l_incident_resolved_date,
8039         last_updated_by       = p_last_updated_by,
8040         last_update_date      = SYSDATE,
8041         last_update_login     = p_last_update_login,
8042         -- Added for enh. 2655115
8043         status_flag           = l_status_flag,
8044         object_version_number = p_object_version_number+1
8045      --Fixed bug#2775580,changed the where clause from current of to
8046      --checking the incident_id
8047      WHERE incident_id = p_request_id;
8048 
8049     CLOSE l_ServiceRequest_csr;
8050 
8051     -- ------------------------------------------------------
8052     -- Insert a record into the audit table
8053     -- ------------------------------------------------------
8054 
8055     --Fixed bug#2775580,added these statements to populate values in all the
8056     --columns with changed flag as N, except status_id and status_flag which are
8057     --the only columns which will be changed by calling this procedure.
8058 
8059 -- Commented out this code since call to SR Child Audit API has been added
8060 -- for audit record creation
8061 -- anmukher --10/15/03
8062 -- Removed the commented code which was used for the audit record assignment while calling the old audit api call.
8063 -- spusegao -- 03/23/2004
8064 
8065    CS_SR_CHILD_AUDIT_PKG.CS_SR_AUDIT_CHILD
8066   (P_incident_id           => p_request_id,
8067    P_updated_entity_code   => 'SR_HEADER',
8068    p_updated_entity_id     => p_request_id,
8069    p_entity_update_date    => SYSDATE,
8070    p_entity_activity_code  => 'U' ,
8071    p_status_id		   => p_status_id,
8072    p_old_status_id         => l_orig_status_id,
8073    p_closed_date	   => l_closed_date,
8074    p_old_closed_date       => l_orig_closed_date,
8075    p_owner_status_upd_flag => 'STATUS',
8076    p_user_id               => p_last_updated_by,
8077    p_old_inc_responded_by_date => l_servicerequest_rec.inc_responded_by_date,
8078    p_old_incident_resolved_date=> l_servicerequest_rec.incident_resolved_date,
8079    x_audit_id              => lx_audit_id,
8080    x_return_status         => lx_return_status,
8081    x_msg_count             => x_msg_count ,
8082    x_msg_data              => x_msg_data );
8083 
8084     IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
8085       RAISE FND_API.G_EXC_ERROR;
8086     ELSIF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
8087       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8088     END IF;
8089 
8090     -- ------------------------------------------------------
8091     -- Insert a record into the calls table if the caller is
8092     -- not a workflow process
8093     -- ------------------------------------------------------
8094     IF NOT FND_API.To_Boolean(p_called_by_workflow) THEN
8095       IF (l_return_status = fnd_api.g_ret_sts_error) THEN
8096          RAISE fnd_api.g_exc_error;
8097       ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
8098          RAISE fnd_api.g_exc_unexpected_error;
8099       END IF;
8100     END IF;     /* called by workflow */
8101 
8102       l_old_sr_rec.type_id                  := l_servicerequest_rec.incident_type_id;
8103       l_old_sr_rec.status_id                := l_servicerequest_rec.incident_status_id;
8104       l_old_sr_rec.severity_id              := l_servicerequest_rec.incident_severity_id;
8105       l_old_sr_rec.urgency_id               := l_servicerequest_rec.incident_urgency_id;
8106       l_old_sr_rec.owner_id                 := l_servicerequest_rec.incident_owner_id;
8107       l_old_sr_rec.owner_group_id           := l_servicerequest_rec.owner_group_id;
8108       l_old_sr_rec.customer_id              := l_servicerequest_rec.customer_id;
8109       l_old_sr_rec.customer_product_id      := l_servicerequest_rec.customer_product_id;
8110       l_old_sr_rec.inventory_item_id        := l_servicerequest_rec.inventory_item_id;
8111       l_old_sr_rec.problem_code             := l_servicerequest_rec.problem_code;
8112       l_old_sr_rec.summary                  := l_servicerequest_rec.summary;
8113       l_old_sr_rec.exp_resolution_date      := l_servicerequest_rec.expected_resolution_date;
8114       l_old_sr_rec.install_site_id          := l_servicerequest_rec.install_site_id;
8115       l_old_sr_rec.bill_to_site_id          := l_servicerequest_rec.bill_to_site_id;
8116       l_old_sr_rec.bill_to_contact_id       := l_servicerequest_rec.bill_to_contact_id;
8117       l_old_sr_rec.ship_to_site_id          := l_servicerequest_rec.ship_to_site_id;
8118       l_old_sr_rec.ship_to_contact_id       := l_servicerequest_rec.ship_to_contact_id;
8119       l_old_sr_rec.resolution_code          := l_servicerequest_rec.resolution_code;
8120       l_old_sr_rec.contract_service_id      := l_servicerequest_rec.contract_service_id;
8121       l_old_sr_rec.sr_creation_channel      := l_servicerequest_rec.sr_creation_channel;
8122       l_old_sr_rec.last_update_channel      := l_servicerequest_rec.last_update_channel;
8123       l_old_sr_rec.last_update_program_code := l_servicerequest_rec.last_update_program_code;
8124 
8125       l_new_sr_rec             := l_old_sr_rec ;
8126       l_new_sr_rec.status_id   := p_status_id  ;
8127       l_new_sr_rec.closed_date:= l_closed_date;
8128 
8129       CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT(
8130          p_api_version           => p_api_version,
8131          p_init_msg_list         => fnd_api.g_false ,
8132          p_commit                => p_commit,
8133          p_validation_level      => p_validation_level,
8134          p_event_code            => 'UPDATE_SERVICE_REQUEST',
8135          p_incident_number       => l_ServiceRequest_rec.incident_number,
8136          p_user_id               => p_last_updated_by,
8137          p_resp_id               => p_resp_id,
8138          p_resp_appl_id          => NULL,
8139          p_old_sr_rec            => l_old_sr_rec,
8140          p_new_sr_rec            => l_new_sr_rec,
8141          p_contacts_table        => l_contacts,
8142          p_link_rec              => NULL,  -- using default value
8143          p_wf_process_id         => p_workflow_process_id,
8144          p_owner_id              => NULL,  -- using default value
8145          p_wf_manual_launch      => 'N' ,  -- using default value
8146          x_wf_process_id         => l_workflow_process_id,
8147          x_return_status         => lx_return_status,
8148          x_msg_count             => x_msg_count,
8149          x_msg_data              => x_msg_data );
8150 
8151       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
8152          -- do nothing in this API. The BES wrapper API will have to trap this
8153          -- situation and send a notification to the SR owner that the BES has
8154          -- not been raised. If the BES API return back a failure status, it
8155          -- means only that the BES raise event has failed, and has nothing to
8156          -- do with the update of the SR.
8157          null;
8158       end if;
8159     -- Added this call for Misc ER: Owner auto assignment changes
8160 
8161         CS_SR_WORKITEM_PVT.Update_Workitem(
8162                 p_api_version           => 1.0,
8163                 p_init_msg_list         => fnd_api.g_false  ,
8164                 p_commit                => p_commit       ,
8165                 p_incident_id           => p_request_id,
8166                 p_old_sr_rec            => l_ServiceRequest_rec,
8167                 p_new_sr_rec            => l_new_sr_rec,
8168                 p_user_id               => p_last_updated_by,
8169                 p_resp_appl_id          => p_resp_id ,
8170                 x_return_status         => l_return_status,
8171                 x_msg_count             => x_msg_count,
8172                 x_msg_data              => x_msg_data);
8173 
8174        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8175            FND_MSG_PUB.Count_And_Get
8176         ( p_count => x_msg_count,
8177           p_data  => x_msg_data
8178          );
8179       END IF;
8180 
8181     IF FND_API.To_Boolean( p_commit ) THEN
8182       COMMIT WORK;
8183     END IF;
8184 
8185     FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8186                       p_data  => x_msg_data );
8187 
8188   EXCEPTION
8189     WHEN FND_API.G_EXC_ERROR THEN
8190       ROLLBACK TO Update_Status_PVT;
8191       IF (l_ServiceRequest_csr%ISOPEN) THEN
8192         CLOSE l_ServiceRequest_csr;
8193       END IF;
8194       x_return_status := FND_API.G_RET_STS_ERROR;
8195       FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
8196                         p_data      => x_msg_data );
8197 
8198     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8199       ROLLBACK TO Update_Status_PVT;
8200       IF (l_ServiceRequest_csr%ISOPEN) THEN
8201         CLOSE l_ServiceRequest_csr;
8202       END IF;
8203       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8204       FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
8205                         p_data      => x_msg_data );
8206 
8207     WHEN OTHERS THEN
8208       ROLLBACK TO Update_Status_PVT;
8209       IF (l_ServiceRequest_csr%ISOPEN) THEN
8210         CLOSE l_ServiceRequest_csr;
8211       END IF;
8212       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8213       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8214         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,
8215                         l_api_name );
8216       END IF;
8217       FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8218                         p_data       => x_msg_data );
8219 
8220 END Update_Status;
8221 
8222 -- -----------------------------------------------------------------------------
8223 -- Modification History
8224 -- Date     Name      Desc
8225 -- -------- --------- ----------------------------------------------------------
8226 -- 03/25/05 smisra    Bug 4028675
8227 --                    Modified this procedure to determine unassigned indicator
8228 --                    and updated SR table with the same
8229 -- 05/27/05 smisra    Bug 4227769
8230 --                    removed update to cs_incidents_all_tl table because it
8231 --                    was updating only obsolete columns owner and group owner.
8232 -- 07/11/05 smisra    called get_status_detail for SR status and if disallow
8233 --                    request update is Y then raise error
8234 -- 07/11/05 smisra    Bug 4489746
8235 --                    Passed UPDATE_OLD to validate_type call because we need to
8236 --                    just check user's access to SR
8237 -- 07/20/05 smisra    if parameter p_owner_group_id is passed as g_miss_num,
8238 --                    then g_miss_num is updated into database. to aviod this,
8239 --                    added a new variable l_owner_group_id. set this using
8240 --                    p_owner_group_id, if p_owner_group_id is g_miss_num then
8241 --                    set l_owner_group_id as value from Sr record.
8242 --                    Used l_owner_group_id in owner validation and further
8243 --                    processing.
8244 -- 07/21/05 smisra    Bug 3215462
8245 --                    Add a call to CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT
8246 -- 12/30/05 smisra    Bug 4773215
8247 --                    Passed x_resource_type and x_support_site_id to
8248 --                    validate owner call
8249 --                    Updated incident table with derived value of resource type
8250 --                    Passed derived value of resource type to audit procedure
8251 -- -----------------------------------------------------------------------------
8252 PROCEDURE Update_Owner
8253   ( p_api_version        IN   NUMBER,
8254     p_init_msg_list      IN   VARCHAR2 DEFAULT fnd_api.g_false,
8255     p_commit             IN   VARCHAR2 DEFAULT fnd_api.g_false,
8256     p_validation_level   IN   NUMBER   DEFAULT fnd_api.g_valid_level_full,
8257     x_return_status      OUT  NOCOPY VARCHAR2,
8258     x_msg_count          OUT  NOCOPY NUMBER,
8259     x_msg_data           OUT  NOCOPY VARCHAR2,
8260     p_request_id         IN   NUMBER,
8261     p_object_version_number   IN    NUMBER,
8262     p_resp_id            IN   NUMBER   DEFAULT NULL,
8263     p_resp_appl_id       IN   NUMBER   DEFAULT NULL,
8264     p_owner_id           IN   NUMBER,
8265     p_owner_group_id     IN   NUMBER,
8266     p_resource_type      IN   VARCHAR2,
8267     p_last_updated_by    IN   NUMBER,
8268     p_last_update_login  IN   NUMBER   DEFAULT NULL,
8269     p_last_update_date   IN   DATE,
8270     p_audit_comments     IN   VARCHAR2 DEFAULT NULL,
8271     p_called_by_workflow IN   VARCHAR2 DEFAULT fnd_api.g_false,
8272     p_workflow_process_id     IN   NUMBER   DEFAULT NULL,
8273     p_comments                IN   VARCHAR2 DEFAULT NULL,
8274     p_public_comment_flag     IN   VARCHAR2 DEFAULT fnd_api.g_false,
8275     p_parent_interaction_id   IN   NUMBER   DEFAULT NULL,
8276     x_interaction_id          OUT  NOCOPY NUMBER
8277   )
8278   IS
8279      l_api_name          CONSTANT VARCHAR2(30) := 'Update_Owner';
8280      l_api_version       CONSTANT NUMBER       := 2.0;
8281      l_api_name_full     CONSTANT VARCHAR2(62) := G_PKG_NAME||'.'||l_api_name;
8282      l_log_module         CONSTANT VARCHAR2(255)   := 'cs.plsql.' || l_api_name_full || '.';
8283      l_return_status        VARCHAR2(1);
8284      l_orig_owner_id        NUMBER;
8285      l_orig_owner_group_id  NUMBER;
8286      l_orig_group_type      VARCHAR2(30);
8287      l_orig_resource_type   VARCHAR2(30);
8288      l_audit_vals_rec	    sr_audit_rec_type;
8289      l_msg_id               NUMBER;
8290      l_msg_count            NUMBER;
8291      l_msg_data             VARCHAR2(2000);
8292 
8293      p_audit_id             NUMBER;
8294 
8295      -- Added for bug 2725543
8296      l_group_name           VARCHAR2(60);
8297 
8298 /* ****************
8299    l_old_ServiceRequest_rec is now changed to type sr_oldvalues_rec_type .
8300 
8301    Replacing the select list of columns with a select * so that the
8302    subtype defined in the spec can be used to pass the old SR values as
8303    a parameter to other procedures
8304 
8305 * *****************/
8306 
8307      CURSOR L_SERVICEREQUEST_CSR IS
8308      SELECT *
8309      from   cs_incidents_all_vl
8310      where  incident_id = p_request_id
8311      and    object_version_number = p_object_version_number
8312      for    update of incident_owner_id nowait;
8313 
8314  -- This rec type was changed to sr_oldvalues_rec_type as the
8315  -- workitem API (Misc ER owner Auto Assginment )needed a record type
8316  -- with old values , also the API validations needed the oldvalues_rec .
8317 
8318     --  l_ServiceRequest_rec      l_ServiceRequest_csr%ROWTYPE;
8319      l_ServiceRequest_rec    sr_oldvalues_rec_type;
8320      l_new_sr_rec            service_request_rec_type;
8321      l_old_sr_rec            service_request_rec_type;
8322 
8323      l_owner_name              VARCHAR2(240);
8324 	 l_owner_id                NUMBER;
8325      l_org_id                  NUMBER;
8326      l_audit_id                NUMBER;
8327 
8328    -- Local variable to store business usage for security validation
8329    l_business_usage       VARCHAR2(30);
8330 
8331    -- Local variable to store attribute if security is enabled for self service resps.
8332    l_ss_sr_type_restrict   VARCHAR2(10);
8333 
8334    -- Local variable to get the return status of validate type for security check
8335    lx_return_status              VARCHAR2(3);
8336 
8337    l_old_cmro_flag               VARCHAR2(3);
8338    l_old_maintenance_flag        VARCHAR2(3);
8339 
8340    -- Added for Auditing --anmukher --10/15/03
8341    lx_audit_id			 NUMBER;
8342 l_unasgn_ind                  NUMBER;
8343 l_sr_related_data             RELATED_DATA_TYPE;
8344 l_owner_group_id              jtf_rs_groups_b.group_id % TYPE;
8345 l_workflow_process_id         NUMBER;
8346 l_contacts                    contacts_table;
8347 l_resource_type               cs_incidents_all_b.resource_type   % TYPE;
8348 l_support_site_id             cs_incidents_all_b.site_id % TYPE;
8349 
8350 BEGIN
8351 
8352     -- ---------------------------------------
8353     -- Standard API stuff
8354     -- ---------------------------------------
8355     -- Establish savepoint
8356     SAVEPOINT Update_Owner_PVT;
8357 
8358     -- Check version number
8359     IF NOT FND_API.Compatible_API_Call( l_api_version,
8360                                         p_api_version,
8361                                         l_api_name,
8362                                         G_PKG_NAME )
8363     THEN
8364           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8365     END IF;
8366 
8367     -- Initialize message list if requested
8368     IF FND_API.to_Boolean( p_init_msg_list ) THEN
8369         FND_MSG_PUB.initialize;
8370     END IF;
8371 
8372     -- Initialize return status to SUCCESS
8373     x_return_status := FND_API.G_RET_STS_SUCCESS;
8374 
8375 ----------------------- FND Logging -----------------------------------
8376   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
8377   THEN
8378     FND_LOG.String
8379     ( FND_LOG.level_procedure , L_LOG_MODULE || 'start'
8380     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
8381     );
8382     FND_LOG.String
8383     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8384     , 'p_api_version:' || p_api_version
8385     );
8386     FND_LOG.String
8387     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8388     , 'p_init_msg_list:' || p_init_msg_list
8389     );
8390     FND_LOG.String
8391     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8392     , 'p_commit:' || p_commit
8393     );
8394     FND_LOG.String
8395     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8396     , 'p_validation_level:' || p_validation_level
8397     );
8398     FND_LOG.String
8399     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8400     , 'p_resp_appl_id:' || p_resp_appl_id
8401     );
8402     FND_LOG.String
8403     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8404     , 'p_resp_id:' || p_resp_id
8405     );
8406     FND_LOG.String
8407     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8408     , 'P_audit_comments:' || P_audit_comments
8409     );
8410     FND_LOG.String
8411     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8412     , 'P_object_version_number:' || P_object_version_number
8413     );
8414     FND_LOG.String
8415     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8416     , 'p_last_updated_by:' || p_last_updated_by
8417     );
8418     FND_LOG.String
8419     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8420     , 'p_last_update_login:' || p_last_update_login
8421     );
8422     FND_LOG.String
8423     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8424     , 'p_last_update_date:' || p_last_update_date
8425     );
8426     FND_LOG.String
8427     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8428     , 'P_owner_id:' || P_owner_id
8429     );
8430     FND_LOG.String
8431     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8432     , 'P_owner_group_id:' || P_owner_group_id
8433     );
8434     FND_LOG.String
8435     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8436     , 'P_Resource_Type:' || P_Resource_Type
8437     );
8438     FND_LOG.String
8439     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8440     , 'p_request_id:' || p_request_id
8441     );
8442     FND_LOG.String
8443     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8444     , 'p_parent_interaction_id:' || p_parent_interaction_id
8445     );
8446     FND_LOG.String
8447     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8448     , 'P_Public_Comment_Flag:' || P_Public_Comment_Flag
8449     );
8450     FND_LOG.String
8451     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8452     , 'P_Called_by_workflow:' || P_Called_by_workflow
8453     );
8454     FND_LOG.String
8455     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8456     , 'P_Workflow_process_id:' || P_Workflow_process_id
8457     );
8458     FND_LOG.String
8459     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8460     , 'P_audit_comments:' || P_audit_comments
8461     );
8462     FND_LOG.String
8463     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
8464     , 'P_Comments:' || P_Comments
8465     );
8466 
8467   END IF;
8468 
8469   -- Initialize the New Audit Record ******
8470      Initialize_audit_rec(
8471                         p_sr_audit_record  => l_audit_vals_rec) ;
8472   -- Initialize the new record and assign the required values for
8473   -- workitem call
8474 
8475      initialize_rec ( p_sr_record    => l_new_sr_rec );
8476 
8477      l_new_sr_rec.owner_id := p_owner_id ;
8478      l_new_sr_rec.resource_type := p_resource_type;
8479      l_new_sr_rec.public_comment_flag := p_public_comment_flag;
8480      l_new_sr_rec.parent_interaction_id:= p_parent_interaction_id;
8481 
8482 
8483     -- ----------------------------------------
8484     -- Open cursor for update
8485     -- ----------------------------------------
8486     -- Fetch the record for update
8487     OPEN  l_ServiceRequest_csr;
8488     FETCH l_ServiceRequest_csr INTO l_ServiceRequest_rec;
8489     IF (l_ServiceRequest_csr%NOTFOUND) THEN
8490 
8491         CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg(
8492                                p_token_an     => l_api_name_full,
8493                                p_token_v      => TO_CHAR(p_request_id),
8494                                p_token_p      => 'p_request_id',
8495                                p_table_name   => G_TABLE_NAME,
8496                                p_column_name  => 'REQUEST_ID' );
8497 
8498         RAISE FND_API.G_EXC_ERROR;
8499     END IF;
8500 
8501     IF p_owner_group_id = FND_API.G_MISS_NUM
8502     THEN
8503        l_owner_group_id := l_servicerequest_rec.owner_group_id;
8504     ELSE
8505        l_owner_group_id := p_owner_group_id;
8506     END IF;
8507     l_new_sr_rec.owner_group_id:= l_owner_group_id;
8508     -- --------------------------------------------------------
8509     -- If the new owner is the same as old, there's no need
8510     -- to continue
8511     -- --------------------------------------------------------
8512     IF ((p_owner_id = l_ServiceRequest_rec.incident_owner_id) AND
8513         (l_owner_group_id = l_ServiceRequest_rec.owner_group_id) ) THEN
8514 
8515         CS_ServiceRequest_UTIL.Add_Same_Val_Update_Msg(
8516                                p_token_an     =>  l_api_name_full,
8517                                p_token_p      =>  'p_owner_id/p_owner_group_id',
8518                                p_table_name   =>  G_TABLE_NAME,
8519                                p_column_name  =>  'OWNER_GROUP_ID');
8520 
8521         CLOSE l_ServiceRequest_csr;
8522         RETURN;
8523     END IF;
8524 
8525     -- -------------------------------------
8526     -- Perform validation when necessary
8527     -- -------------------------------------
8528     IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
8529        CS_ServiceRequest_UTIL.Validate_Who_Info(
8530                               p_api_name              => l_api_name_full,
8531                               p_parameter_name_usr    => 'p_last_updated_by',
8532                               p_parameter_name_login  => 'p_last_update_login',
8533                               p_user_id               => p_last_updated_by,
8534                               p_login_id              => p_last_update_login,
8535                               x_return_status         => l_return_status );
8536 
8537         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8538 
8539                RAISE FND_API.G_EXC_ERROR;
8540         END IF;
8541 
8542       -- Service security validation
8543       -- Validate if the current responsibility has access to the SR being update.
8544       -- Invoke the VALIDATE_TYPE procedure that has the logic to check for security
8545       -- access
8546 
8547       -- Get the business usage of the responsibility that is attempting to create
8548       -- the SR.
8549       get_business_usage (
8550          p_responsibility_id      => p_resp_id,
8551          p_application_id         => fnd_global.resp_appl_id,
8552          x_business_usage         => l_business_usage );
8553 
8554       -- Get indicator of self service security enabled or not
8555       if ( l_business_usage = 'SELF_SERVICE' ) then
8556          get_ss_sec_enabled (
8557 	    x_ss_sr_type_restrict => l_ss_sr_type_restrict );
8558       end if;
8559 
8560       -- For bug 3370562 - pass resp_id an appl_id
8561       -- validate security in update; first against old sr type
8562       cs_servicerequest_util.validate_type (
8563          p_parameter_name       => NULL,
8564          p_type_id   	        => l_servicerequest_rec.incident_type_id,
8565          p_subtype  	        => G_SR_SUBTYPE,
8566          p_status_id            => l_servicerequest_rec.incident_status_id, -- not used
8567          p_resp_id              => p_resp_id,
8568          p_resp_appl_id         => fnd_global.resp_appl_id,
8569          p_business_usage       => l_business_usage,
8570          p_ss_srtype_restrict   => l_ss_sr_type_restrict,
8571          p_operation            => 'UPDATE_OLD',
8572          x_return_status        => lx_return_status,
8573          x_cmro_flag            => l_old_cmro_flag,
8574          x_maintenance_flag     => l_old_maintenance_flag );
8575 
8576       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) then
8577          -- security violation; responsibility does not have access to SR Type
8578          -- being created. Stop and raise error.
8579          RAISE FND_API.G_EXC_ERROR;
8580       end if;
8581       CS_SERVICEREQUEST_UTIL.get_status_details
8582       ( p_status_id                  => l_servicerequest_rec.incident_status_id
8583       , x_close_flag                 => l_sr_related_data.close_flag
8584       , x_disallow_request_update    => l_sr_related_data.disallow_request_update
8585       , x_disallow_agent_dispatch    => l_sr_related_data.disallow_owner_update
8586       , x_disallow_product_update    => l_sr_related_data.disallow_product_update
8587       , x_pending_approval_flag      => l_sr_related_data.pending_approval_flag
8588       , x_intermediate_status_id     => l_sr_related_data.intermediate_status_id
8589       , x_approval_action_status_id  => l_sr_related_data.approval_action_status_id
8590       , x_rejection_action_status_id => l_sr_related_data.rejection_action_status_id
8591       , x_return_status              => l_return_status
8592       );
8593       IF l_sr_related_data.disallow_request_update = 'Y'
8594       THEN
8595         FND_MESSAGE.set_name('CS', 'CS_API_SR_ONLY_STATUS_UPDATED');
8596         FND_MESSAGE.set_token('API_NAME', l_api_name_full);
8597         FND_MSG_PUB.add_detail
8598         ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.INCIDENT_OWNER_ID'
8599         );
8600         RAISE FND_API.G_EXC_ERROR;
8601       END IF;
8602 
8603       --
8604       -- Can't update the owner when there's an active workflow process
8605       --
8606         IF (l_ServiceRequest_rec.workflow_process_id IS NOT NULL) AND
8607             CS_Workflow_PKG.Is_Servereq_Item_Active
8608                ( p_request_number  => l_ServiceRequest_rec.incident_number,
8609                  p_wf_process_id   => l_ServiceRequest_rec.workflow_process_id)
8610             = 'Y'
8611         AND ((FND_API.To_Boolean(p_called_by_workflow) = FALSE)
8612         OR   (l_ServiceRequest_rec.incident_owner_id IS NOT NULL
8613         AND   p_owner_id IS NULL)
8614         OR   (l_ServiceRequest_rec.owner_group_id <> l_owner_group_id)
8615         OR   (NOT (l_ServiceRequest_rec.workflow_process_id=p_workflow_process_id)))
8616         THEN
8617              IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8618                    FND_MESSAGE.Set_Name('CS', 'CS_API_SR_OWNER_READONLY');
8619                    FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
8620                    FND_MSG_PUB.ADD;
8621              END IF;
8622              RAISE FND_API.G_EXC_ERROR;
8623         END IF;
8624 
8625     --Commented this code after moving it to CS_SR_AUDIT_CHILD API
8626     --in CS_SR_CHILD_AUDIT package. This API will be calling the Child
8627     -- Audit API henceforth for audit record creation.
8628     -- anmukher --10/16/03
8629       /* Made changes by shijain for bug 2747616*/
8630 /*
8631       l_orig_owner_id       := l_ServiceRequest_rec.incident_owner_id;
8632       l_orig_owner_group_id := l_ServiceRequest_rec.owner_group_id;
8633       l_orig_group_type     := l_ServiceRequest_rec.group_type;
8634       l_orig_resource_type  := l_ServiceRequest_rec.resource_type;
8635 
8636       IF ((p_owner_id IS NOT NULL
8637          AND l_orig_owner_id IS NULL)
8638          OR (p_owner_id IS NULL
8639          AND l_orig_owner_id IS NOT NULL)
8640          OR (p_owner_id IS NOT NULL
8641          AND l_orig_owner_id IS NOT NULL
8642          AND p_owner_id <> l_orig_owner_id)) THEN
8643 
8644              l_audit_vals_rec.CHANGE_INCIDENT_OWNER_FLAG := 'Y';
8645              l_audit_vals_rec.OLD_INCIDENT_OWNER_ID      := l_orig_owner_id;
8646              l_audit_vals_rec.INCIDENT_OWNER_ID          := p_owner_id;
8647       ELSE
8648              l_audit_vals_rec.CHANGE_INCIDENT_OWNER_FLAG := 'N';
8649              l_audit_vals_rec.OLD_INCIDENT_OWNER_ID      := l_orig_owner_id;
8650              l_audit_vals_rec.INCIDENT_OWNER_ID          := l_orig_owner_id;
8651       END IF;
8652 
8653       IF ((p_owner_group_id IS NOT NULL
8654          AND l_orig_owner_group_id IS NULL)
8655          OR (p_owner_group_id IS NULL
8656          AND l_orig_owner_group_id IS NOT NULL)
8657          OR (p_owner_group_id IS NOT NULL
8658          AND l_orig_owner_group_id IS NOT NULL
8659          AND p_owner_group_id <> l_orig_owner_group_id)) THEN
8660 
8661              l_audit_vals_rec.change_group_flag := 'Y';
8662              l_audit_vals_rec.old_group_id      := l_orig_owner_group_id ;
8663              l_audit_vals_rec.group_id          := p_owner_group_id ;
8664       ELSE
8665              l_audit_vals_rec.change_group_flag := 'N';
8666              l_audit_vals_rec.old_group_id      := l_orig_owner_group_id ;
8667              l_audit_vals_rec.group_id          := l_orig_owner_group_id ;
8668       END IF;
8669 
8670       IF (p_owner_group_id IS NOT NULL AND p_owner_group_id<>FND_API.G_MISS_NUM)
8671       THEN
8672              l_audit_vals_rec.group_type:='RS_GROUP';
8673       ELSE
8674              l_audit_vals_rec.group_type:=NULL;
8675       END IF;
8676 
8677       IF ((l_audit_vals_rec.group_type IS NOT NULL
8678           AND l_audit_vals_rec.old_group_type IS NULL)
8679           OR (l_audit_vals_rec.group_type IS NULL
8680           AND l_audit_vals_rec.old_group_type IS NOT NULL))
8681       THEN
8682              l_audit_vals_rec.change_group_type_flag   := 'Y';
8683              l_audit_vals_rec.old_group_type           := l_orig_group_type ;
8684       ELSE
8685              l_audit_vals_rec.change_group_type_flag   := 'N';
8686              l_audit_vals_rec.old_group_type           := l_orig_group_type ;
8687              l_audit_vals_rec.group_type               := l_orig_group_type ;
8688       END IF;
8689 
8690       IF ((p_resource_type IS NOT NULL
8691          AND l_orig_resource_type IS NULL)
8692          OR (p_resource_type IS NULL
8693          AND l_orig_resource_type IS NOT NULL)
8694          OR (p_resource_type IS NOT NULL
8695          AND l_orig_resource_type IS NOT NULL
8696          AND p_resource_type <> l_orig_resource_type)) THEN
8697 
8698              l_audit_vals_rec.change_resource_type_flag   := 'Y';
8699              l_audit_vals_rec.old_resource_type      := l_orig_resource_type ;
8700              l_audit_vals_rec.resource_type          := p_resource_type ;
8701       ELSE
8702              l_audit_vals_rec.change_resource_type_flag   := 'N';
8703              l_audit_vals_rec.old_resource_type      := l_orig_resource_type ;
8704              l_audit_vals_rec.resource_type          := l_orig_resource_type ;
8705       END IF;
8706 */
8707 
8708       -- Added for bug 2725543
8709         IF (p_owner_group_id <> FND_API.G_MISS_NUM) THEN
8710               CS_ServiceRequest_UTIL.Validate_Group_Id
8711                 ( p_api_name       => l_api_name_full,
8712                   p_parameter_name => 'p_owner_group_id',
8713                   p_group_type     => 'RS_GROUP',
8714                   p_owner_group_id => p_owner_group_id,
8715                   x_group_name     => l_group_name,
8716                   x_return_status  => l_return_status
8717                  );
8718 
8719               IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8720                   RAISE FND_API.G_EXC_ERROR;
8721               END IF;
8722          END IF;
8723 
8724          CS_ServiceRequest_UTIL.Validate_Owner
8725          ( p_api_name         => l_api_name_full
8726          , p_parameter_name   => 'p_owner_id'
8727          , p_owner_id         => p_owner_id
8728          , p_group_type       => 'RS_GROUP'
8729          , p_owner_group_id   => l_owner_group_id
8730          , p_org_id           => l_org_id
8731          , p_incident_type_id => l_ServiceRequest_rec.incident_type_id  -- new for 11.5.10
8732          , x_owner_name       => l_owner_name
8733          , x_owner_id         => l_owner_id
8734          , x_resource_type    => l_resource_type
8735          , x_support_site_id  => l_support_site_id
8736          , x_return_status    => l_return_status
8737          );
8738 
8739         IF (l_owner_id IS NULL)
8740         THEN
8741           RAISE FND_API.G_EXC_ERROR;
8742         END IF;
8743 
8744     END IF;
8745 
8746     -- Get unassigned_indicator
8747     l_unasgn_ind := CS_SERVICEREQUEST_UTIL.get_unassigned_indicator(p_owner_id, l_owner_group_id);
8748     -- ----------------------------------------------
8749     -- Update the owner and insert the audit record
8750     -- ----------------------------------------------
8751     -- Update CS_INCIDENTS table
8752 
8753     UPDATE cs_incidents_all_b
8754        SET incident_owner_id     = p_owner_id,
8755            owner_group_id        = l_owner_group_id,
8756            resource_type         = l_resource_type,
8757            last_updated_by       = p_last_updated_by,
8758            last_update_date      = p_last_update_date,
8759            last_update_login     = p_last_update_login,
8760            unassigned_indicator  = l_unasgn_ind,
8761            object_version_number = p_object_version_number+1
8762     WHERE incident_id = p_request_id ;
8763 
8764   CLOSE l_ServiceRequest_csr;
8765     -- ------------------------------------------------------
8766     -- Insert a record into the audit table --- check for audit
8767     -- ------------------------------------------------------
8768    --added this code on dec 14th, so that workflow can call this api
8769    --and the audit will work accordingly
8770    --Since this is update owner, all the other atributes will not be updated,
8771    --hence just use the values sitting in the db as the current values for log.
8772    --Put this field value in the audit table, dont set flag
8773 
8774 -- Commented out this code since a call to CS_SR_AUDIT_CHILD API is being added
8775 -- anmukher -- 10/15/03
8776 -- Removed the commented code used to populate the audit record structure which was used by the old call to
8777 -- the audit API. This call is replaced by the new call to the new child audit API.
8778 
8779    -- Added call to Child Audit API for audit record creation
8780    --anmukher --10/15/03
8781 
8782       l_orig_owner_id       := l_ServiceRequest_rec.incident_owner_id;
8783       l_orig_owner_group_id := l_ServiceRequest_rec.owner_group_id;
8784       l_orig_resource_type  := l_ServiceRequest_rec.resource_type ;
8785 
8786    CS_SR_CHILD_AUDIT_PKG.CS_SR_AUDIT_CHILD
8787   (P_incident_id           => p_request_id,
8788    P_updated_entity_code   => 'SR_HEADER',
8789    p_updated_entity_id     => p_request_id,
8790    p_entity_update_date    => p_last_update_date, -- sysdate
8791    p_entity_activity_code  => 'U' ,
8792    p_owner_id		   => p_owner_id,
8793    p_old_owner_id	   => l_orig_owner_id,
8794    p_owner_group_id	   => l_owner_group_id,
8795    p_old_owner_group_id	   => l_orig_owner_group_id,
8796    p_resource_type	   => l_resource_type,
8797    p_old_resource_type	   => l_orig_resource_type,
8798    p_owner_status_upd_flag => 'OWNER',
8799    p_useR_id               => p_last_updated_by,
8800    x_audit_id              => lx_audit_id,
8801    x_return_status         => lx_return_status,
8802    x_msg_count             => x_msg_count ,
8803    x_msg_data              => x_msg_data );
8804 
8805     IF (lx_return_status = FND_API.G_RET_STS_ERROR) THEN
8806         RAISE FND_API.G_EXC_ERROR;
8807     ELSIF (lx_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
8808         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8809     END IF;
8810 
8811     -- ------------------------------------------------------
8812     -- Insert a record into the calls table if the caller is
8813     -- not a workflow process
8814     -- ------------------------------------------------------
8815     IF NOT FND_API.To_Boolean(p_called_by_workflow) THEN
8816       IF (p_parent_interaction_id IS NULL) THEN
8817         /* CREATE INTERACTION */ /* l_interaction_id := */
8818         NULL;
8819       END IF;
8820 
8821       --
8822       -- Create INTERACTION_ACTIVITY
8823       --
8824 
8825       IF (l_return_status = fnd_api.g_ret_sts_error) THEN
8826          RAISE fnd_api.g_exc_error;
8827       ELSIF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
8828          RAISE fnd_api.g_exc_unexpected_error;
8829       END IF;
8830     END IF;   /* called by workflow */
8831 
8832       l_old_sr_rec.type_id                  := l_servicerequest_rec.incident_type_id;
8833       l_old_sr_rec.status_id                := l_servicerequest_rec.incident_status_id;
8834       l_old_sr_rec.severity_id              := l_servicerequest_rec.incident_severity_id;
8835       l_old_sr_rec.urgency_id               := l_servicerequest_rec.incident_urgency_id;
8836       l_old_sr_rec.owner_id                 := l_servicerequest_rec.incident_owner_id;
8837       l_old_sr_rec.owner_group_id           := l_servicerequest_rec.owner_group_id;
8838       l_old_sr_rec.customer_id              := l_servicerequest_rec.customer_id;
8839       l_old_sr_rec.customer_product_id      := l_servicerequest_rec.customer_product_id;
8840       l_old_sr_rec.inventory_item_id        := l_servicerequest_rec.inventory_item_id;
8841       l_old_sr_rec.problem_code             := l_servicerequest_rec.problem_code;
8842       l_old_sr_rec.summary                  := l_servicerequest_rec.summary;
8843       l_old_sr_rec.exp_resolution_date      := l_servicerequest_rec.expected_resolution_date;
8844       l_old_sr_rec.install_site_id          := l_servicerequest_rec.install_site_id;
8845       l_old_sr_rec.bill_to_site_id          := l_servicerequest_rec.bill_to_site_id;
8846       l_old_sr_rec.bill_to_contact_id       := l_servicerequest_rec.bill_to_contact_id;
8847       l_old_sr_rec.ship_to_site_id          := l_servicerequest_rec.ship_to_site_id;
8848       l_old_sr_rec.ship_to_contact_id       := l_servicerequest_rec.ship_to_contact_id;
8849       l_old_sr_rec.resolution_code          := l_servicerequest_rec.resolution_code;
8850       l_old_sr_rec.contract_service_id      := l_servicerequest_rec.contract_service_id;
8851       l_old_sr_rec.sr_creation_channel      := l_servicerequest_rec.sr_creation_channel;
8852       l_old_sr_rec.last_update_channel      := l_servicerequest_rec.last_update_channel;
8853       l_old_sr_rec.last_update_program_code := l_servicerequest_rec.last_update_program_code;
8854 
8855       l_new_sr_rec                := l_old_sr_rec    ;
8856       l_new_sr_rec.owner_id       := p_owner_id      ;
8857       l_new_sr_rec.resource_type  := p_resource_type ;
8858       l_new_sr_rec.owner_group_id := l_owner_group_id;
8859 
8860       CS_WF_EVENT_PKG.RAISE_SERVICEREQUEST_EVENT(
8861          p_api_version           => p_api_version,
8862          p_init_msg_list         => fnd_api.g_false ,
8863          p_commit                => p_commit,
8864          p_validation_level      => p_validation_level,
8865          p_event_code            => 'UPDATE_SERVICE_REQUEST',
8866          p_incident_number       => l_ServiceRequest_rec.incident_number,
8867          p_user_id               => p_last_updated_by,
8868          p_resp_id               => p_resp_id,
8869          p_resp_appl_id          => p_resp_appl_id,
8870          p_old_sr_rec            => l_old_sr_rec,
8871          p_new_sr_rec            => l_new_sr_rec,
8872          p_contacts_table        => l_contacts,
8873          p_link_rec              => NULL,  -- using default value
8874          p_wf_process_id         => p_workflow_process_id,
8875          p_owner_id              => NULL,  -- using default value
8876          p_wf_manual_launch      => 'N' ,  -- using default value
8877          x_wf_process_id         => l_workflow_process_id,
8878          x_return_status         => lx_return_status,
8879          x_msg_count             => x_msg_count,
8880          x_msg_data              => x_msg_data );
8881 
8882       if ( lx_return_status <> FND_API.G_RET_STS_SUCCESS ) THEN
8883          -- do nothing in this API. The BES wrapper API will have to trap this
8884          -- situation and send a notification to the SR owner that the BES has
8885          -- not been raised. If the BES API return back a failure status, it
8886          -- means only that the BES raise event has failed, and has nothing to
8887          -- do with the update of the SR.
8888          null;
8889       end if;
8890 
8891      -- Added this call for Misc ER: Owner auto assignment changes
8892 
8893         CS_SR_WORKITEM_PVT.Update_Workitem(
8894                 p_api_version           => 1.0,
8895                 p_init_msg_list         => fnd_api.g_false  ,
8896                 p_commit                => p_commit       ,
8897                 p_incident_id           => p_request_id,
8898                 p_old_sr_rec            => l_ServiceRequest_rec,
8899                 p_new_sr_rec            => l_new_sr_rec,
8900                 p_user_id               => p_last_updated_by,
8901                 p_resp_appl_id          => p_resp_id ,
8902                 x_return_status         => l_return_status,
8903                 x_msg_count             => x_msg_count,
8904                 x_msg_data              => x_msg_data);
8905 
8906        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
8907            FND_MSG_PUB.Count_And_Get
8908         ( p_count => x_msg_count,
8909           p_data  => x_msg_data
8910          );
8911        END IF;
8912 
8913 
8914     IF FND_API.To_Boolean( p_commit ) THEN
8915       COMMIT WORK;
8916     END IF;
8917 
8918     FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8919                       p_data  => x_msg_data );
8920 
8921   EXCEPTION
8922     WHEN FND_API.G_EXC_ERROR THEN
8923       ROLLBACK TO Update_Owner_PVT;
8924 
8925       IF (l_ServiceRequest_csr%ISOPEN) THEN
8926           CLOSE l_ServiceRequest_csr;
8927       END IF;
8928 
8929       x_return_status := FND_API.G_RET_STS_ERROR;
8930 
8931       FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8932                                  p_data   => x_msg_data );
8933 
8934     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
8935       ROLLBACK TO Update_Owner_PVT;
8936 
8937       IF (l_ServiceRequest_csr%ISOPEN) THEN
8938           CLOSE l_ServiceRequest_csr;
8939       END IF;
8940 
8941       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8942 
8943       FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8944                                  p_data   => x_msg_data );
8945 
8946     WHEN OTHERS THEN
8947       ROLLBACK TO Update_Owner_PVT;
8948 
8949       IF (l_ServiceRequest_csr%ISOPEN) THEN
8950           CLOSE l_ServiceRequest_csr;
8951       END IF;
8952 
8953       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8954 
8955       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8956          FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name );
8957       END IF;
8958 
8959       FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
8960                                  p_data   => x_msg_data );
8961 
8962 END Update_Owner;
8963 
8964 -- -------------------------------------------------------------------
8965 -- Create_Audit_Record
8966 -- -------------------------------------------------------------------
8967   PROCEDURE Create_Audit_Record (
8968           p_api_version         IN NUMBER,
8969           p_init_msg_list       IN VARCHAR2 DEFAULT FND_API.G_FALSE,
8970           p_commit              IN VARCHAR2 DEFAULT FND_API.G_FALSE,
8971           x_return_status       OUT NOCOPY VARCHAR2,
8972           x_msg_count           OUT NOCOPY NUMBER,
8973           x_msg_data            OUT NOCOPY VARCHAR2,
8974           p_request_id          IN NUMBER,
8975           p_audit_id            IN NUMBER,
8976           p_audit_vals_rec      IN sr_audit_rec_type,
8977           p_action_id           IN NUMBER   DEFAULT FND_API.G_MISS_NUM,
8978           p_wf_process_name     IN VARCHAR2 DEFAULT FND_API.G_MISS_CHAR,
8979           p_wf_process_itemkey  IN VARCHAR2 DEFAULT FND_API.G_MISS_CHAR,
8980           p_user_id             IN NUMBER,
8981           p_login_id            IN NUMBER   DEFAULT NULL,
8982           p_last_update_date    IN DATE,
8983           p_creation_date       IN DATE,
8984           p_comments            IN VARCHAR2 DEFAULT NULL,
8985           x_audit_id            OUT NOCOPY NUMBER
8986      ) IS
8987     l_api_name   		CONSTANT VARCHAR2(30) := 'Create_Audit_Record';
8988     l_api_version 		CONSTANT NUMBER       := 2.0;
8989     l_audit_id             	NUMBER;
8990     l_incident_audit_id 	NUMBER;
8991     l_audit_vals_rec		sr_audit_rec_type := p_audit_vals_rec;
8992 
8993   BEGIN
8994     -- Establish savepoint
8995     SAVEPOINT Create_Audit_Record_PVT;
8996 
8997     -- Check version number
8998     IF NOT FND_API.Compatible_API_Call( l_api_version,
8999                             p_api_version,
9000                             l_api_name,
9001                             G_PKG_NAME ) THEN
9002       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9003     END IF;
9004 
9005     -- Initialize message list if requested
9006     IF FND_API.to_Boolean( p_init_msg_list ) THEN
9007       FND_MSG_PUB.initialize;
9008     END IF;
9009 
9010     -- Initialize return status to SUCCESS
9011     x_return_status := FND_API.G_RET_STS_SUCCESS;
9012 
9013     --  Added code for bug# 1874546------jngeorge ------07/18/01
9014     -- Check if owner has changed
9015     IF (p_audit_vals_rec.change_incident_owner_flag = 'Y' ) THEN
9016       IF (l_audit_vals_rec.old_resource_type = l_audit_vals_rec.resource_type ) THEN
9017          l_audit_vals_rec.change_resource_type_flag  :='N';
9018       END IF;
9019     END IF;
9020 
9021     IF (p_audit_vals_rec.create_manual_action = 'Y') THEN
9022 	IF (p_action_id <> FND_API.G_MISS_NUM) THEN
9023 		l_audit_vals_rec.action_id := p_action_id;
9024 	END IF;
9025     END IF;
9026 
9027     -- Check for new workflow
9028     IF (p_audit_vals_rec.new_workflow_flag = 'Y') THEN
9029 	IF (p_wf_process_name <> FND_API.G_MISS_CHAR) THEN
9030       		l_audit_vals_rec.workflow_process_name := p_wf_process_name;
9031 	END IF;
9032 
9033 	IF (p_wf_process_itemkey <> FND_API.G_MISS_CHAR) THEN
9034       		l_audit_vals_rec.workflow_process_itemkey := p_wf_process_itemkey;
9035 	END IF;
9036     END IF;
9037 
9038     --------Added code for bug# 1874546------jngeorge ------07/18/01
9039     IF (p_audit_vals_rec.change_resource_type_flag = 'Y') AND
9040        (p_audit_vals_rec.old_resource_type <> p_audit_vals_rec.resource_type) THEN
9041       l_audit_vals_rec.old_resource_type := p_audit_Vals_rec.old_resource_type;
9042       l_audit_vals_rec.resource_type     := p_audit_Vals_rec.resource_type;
9043     ELSE
9044       IF (p_audit_vals_rec.change_incident_owner_flag = 'N' ) THEN
9045         l_audit_vals_rec.resource_type     := p_audit_Vals_rec.resource_type;
9046       END IF;
9047     END IF;
9048 
9049    IF (p_audit_id IS NOT NULL AND
9050        p_audit_id <> FND_API.G_MISS_NUM) THEN
9051      l_audit_id := p_audit_id;
9052    ELSE
9053      SELECT cs_incidents_audit_s1.NEXTVAL INTO l_audit_id  FROM dual;
9054      x_audit_id := l_audit_id;
9055    END IF;
9056 
9057     INSERT INTO cs_incidents_audit_b (
9058                 incident_audit_id            ,
9059                 incident_id                  ,
9060                 last_update_date             ,
9061                 last_updated_by              ,
9062                 creation_date                ,
9063                 created_by                   ,
9064                 last_update_login            ,
9065                 creation_time                ,
9066                 incident_status_id           ,
9067                 old_incident_status_id       ,
9068                 change_incident_status_flag  ,
9069                 incident_type_id             ,
9070                 old_incident_type_id         ,
9071                 change_incident_type_flag    ,
9072                 incident_urgency_id          ,
9073                 old_incident_urgency_id      ,
9074                 change_incident_urgency_flag ,
9075                 incident_severity_id         ,
9076                 old_incident_severity_id     ,
9077                 change_incident_severity_flag,
9078                 incident_owner_id            ,
9079                 old_incident_owner_id        ,
9080                 change_incident_owner_flag   ,
9081                 create_manual_action         ,
9082                 action_id                    ,
9083                 expected_resolution_date     ,
9084                 old_expected_resolution_date ,
9085                 change_resolution_flag       ,
9086                 new_workflow_flag            ,
9087                 workflow_process_name        ,
9088                 workflow_process_itemkey     ,
9089                 group_id,
9090                 old_group_id,
9091 	        change_group_flag,
9092                 group_type,
9093                 old_group_type,
9094                 change_group_type_flag,
9095                 inv_platform_org_id,
9096                 old_inv_platform_org_id,
9097                 change_platform_org_id_flag,
9098                 owner_assigned_time,
9099                 old_owner_assigned_time,
9100                 change_assigned_time_flag,
9101 	        obligation_date,
9102 	        old_obligation_date,
9103 	        change_obligation_flag,
9104 		site_id,
9105 		old_site_id,
9106 		change_site_flag,
9107 		bill_to_contact_id,
9108 		old_bill_to_contact_id,
9109 		change_bill_to_flag,
9110 		ship_to_contact_id,
9111 		old_ship_to_contact_id,
9112 		change_ship_to_flag,
9113 		close_date,
9114 		old_close_date,
9115 		change_close_date_flag,
9116 		customer_product_id,
9117 		old_customer_product_id,
9118 		change_customer_product_flag,
9119 		platform_id,
9120 		old_platform_id,
9121 		change_platform_id_flag,
9122                 product_revision,
9123                 old_product_revision,
9124                 change_product_revision_flag,
9125                 component_version,
9126                 old_component_version,
9127                 change_comp_ver_flag,
9128                 subcomponent_version,
9129                 old_subcomponent_version,
9130                 change_subcomp_ver_flag,
9131 		cp_component_id,
9132 		old_cp_component_id,
9133 		change_cp_component_id_flag,
9134 		cp_component_version_id,
9135 		old_cp_component_version_id,
9136 		change_cp_comp_ver_id_flag,
9137 		cp_subcomponent_id,
9138 		old_cp_subcomponent_id,
9139 		change_cp_subcomponent_id_flag,
9140 		cp_subcomponent_version_id,
9141 		old_cp_subcomponent_version_id,
9142 		change_cp_subcomp_ver_id_flag,
9143 		cp_revision_id,
9144 		old_cp_revision_id,
9145 		change_cp_revision_id_flag,
9146  		inv_item_revision,
9147  		old_inv_item_revision,
9148  		change_inv_item_revision,
9149  		inv_component_id,
9150  		old_inv_component_id,
9151  		change_inv_component_id,
9152 		inv_component_version,
9153  		old_inv_component_version,
9154  		change_inv_component_version,
9155 		inv_subcomponent_id,
9156  		old_inv_subcomponent_id,
9157  		change_inv_subcomponent_id,
9158 		inv_subcomponent_version,
9159  		old_inv_subcomponent_version,
9160  		change_inv_subcomp_version,
9161 		territory_id,
9162 		old_territory_id,
9163 		change_territory_id_flag,
9164 		resource_type,
9165 		old_resource_type,
9166 		change_resource_type_flag,
9167          	object_version_number,
9168 		audit_field,
9169                 inventory_item_id ,
9170                 old_inventory_item_id,
9171                 change_inventory_item_flag,
9172                 inv_organization_id,
9173                 old_inv_organization_id,
9174                 change_inv_organization_flag,
9175                 status_flag ,
9176                 old_status_flag ,
9177                 change_status_flag ,
9178                 incident_date,
9179                 old_incident_date,
9180                 change_incident_date_flag,
9181                 platform_version_id,
9182                 old_platform_version_id,
9183                 change_plat_ver_id_flag,
9184                 language_id,
9185                 old_language_id,
9186                 change_language_id_flag,
9187            --   primary_contact_id ,
9188            --   change_primary_contact_flag ,
9189            --   old_primary_contact_id,
9190                 -- Added new audit columns for 11.5.10 Auditing project --anmukher --09/10/03
9191                 UPGRADE_FLAG_FOR_CREATE                  ,
9192                 OLD_INCIDENT_NUMBER                      ,
9193                 INCIDENT_NUMBER                          ,
9194                 OLD_CUSTOMER_ID                          ,
9195                 CUSTOMER_ID                              ,
9196                 OLD_BILL_TO_SITE_USE_ID                  ,
9197                 BILL_TO_SITE_USE_ID                      ,
9198                 OLD_EMPLOYEE_ID                          ,
9199                 EMPLOYEE_ID                              ,
9200                 OLD_SHIP_TO_SITE_USE_ID                  ,
9201                 SHIP_TO_SITE_USE_ID                      ,
9202                 OLD_PROBLEM_CODE                         ,
9203                 PROBLEM_CODE                             ,
9204                 OLD_ACTUAL_RESOLUTION_DATE               ,
9205                 ACTUAL_RESOLUTION_DATE                   ,
9206                 OLD_INSTALL_SITE_USE_ID                  ,
9207                 INSTALL_SITE_USE_ID                      ,
9208                 OLD_CURRENT_SERIAL_NUMBER                ,
9209                 CURRENT_SERIAL_NUMBER                    ,
9210                 OLD_SYSTEM_ID                            ,
9211                 SYSTEM_ID                                ,
9212                 OLD_INCIDENT_ATTRIBUTE_1                 ,
9213                 INCIDENT_ATTRIBUTE_1                     ,
9214                 OLD_INCIDENT_ATTRIBUTE_2                 ,
9215                 INCIDENT_ATTRIBUTE_2                     ,
9216                 OLD_INCIDENT_ATTRIBUTE_3                 ,
9217                 INCIDENT_ATTRIBUTE_3                     ,
9218                 OLD_INCIDENT_ATTRIBUTE_4                 ,
9219                 INCIDENT_ATTRIBUTE_4                     ,
9220                 OLD_INCIDENT_ATTRIBUTE_5                 ,
9221                 INCIDENT_ATTRIBUTE_5                     ,
9222                 OLD_INCIDENT_ATTRIBUTE_6                 ,
9223                 INCIDENT_ATTRIBUTE_6                     ,
9224                 OLD_INCIDENT_ATTRIBUTE_7                 ,
9225                 INCIDENT_ATTRIBUTE_7                     ,
9226                 OLD_INCIDENT_ATTRIBUTE_8                 ,
9227                 INCIDENT_ATTRIBUTE_8                     ,
9228                 OLD_INCIDENT_ATTRIBUTE_9                 ,
9229                 INCIDENT_ATTRIBUTE_9                     ,
9230                 OLD_INCIDENT_ATTRIBUTE_10                ,
9231                 INCIDENT_ATTRIBUTE_10                    ,
9232                 OLD_INCIDENT_ATTRIBUTE_11                ,
9233                 INCIDENT_ATTRIBUTE_11                    ,
9234                 OLD_INCIDENT_ATTRIBUTE_12                ,
9235                 INCIDENT_ATTRIBUTE_12                    ,
9236                 OLD_INCIDENT_ATTRIBUTE_13                ,
9237                 INCIDENT_ATTRIBUTE_13                    ,
9238                 OLD_INCIDENT_ATTRIBUTE_14                ,
9239                 INCIDENT_ATTRIBUTE_14                    ,
9240                 OLD_INCIDENT_ATTRIBUTE_15                ,
9241                 INCIDENT_ATTRIBUTE_15                    ,
9242                 OLD_INCIDENT_CONTEXT                     ,
9243                 INCIDENT_CONTEXT                         ,
9244                 OLD_RESOLUTION_CODE                      ,
9245                 RESOLUTION_CODE                          ,
9246                 OLD_ORIGINAL_ORDER_NUMBER                ,
9247                 ORIGINAL_ORDER_NUMBER                    ,
9248                 OLD_ORG_ID                               ,
9249                 ORG_ID                                   ,
9250                 OLD_PURCHASE_ORDER_NUMBER                ,
9251                 PURCHASE_ORDER_NUMBER                    ,
9252                 OLD_PUBLISH_FLAG                         ,
9253                 PUBLISH_FLAG                             ,
9254                 OLD_QA_COLLECTION_ID                     ,
9255                 QA_COLLECTION_ID                         ,
9256                 OLD_CONTRACT_ID                          ,
9257                 CONTRACT_ID                              ,
9258                 OLD_CONTRACT_NUMBER                      ,
9259                 CONTRACT_NUMBER                          ,
9260                 OLD_CONTRACT_SERVICE_ID                  ,
9261                 CONTRACT_SERVICE_ID                      ,
9262                 OLD_TIME_ZONE_ID                         ,
9263                 TIME_ZONE_ID                             ,
9264                 OLD_ACCOUNT_ID                           ,
9265                 ACCOUNT_ID                               ,
9266                 OLD_TIME_DIFFERENCE                      ,
9267                 TIME_DIFFERENCE                          ,
9268                 OLD_CUSTOMER_PO_NUMBER                   ,
9269                 CUSTOMER_PO_NUMBER                       ,
9270                 OLD_CUSTOMER_TICKET_NUMBER               ,
9271                 CUSTOMER_TICKET_NUMBER                   ,
9272                 OLD_CUSTOMER_SITE_ID                     ,
9273                 CUSTOMER_SITE_ID                         ,
9274                 OLD_CALLER_TYPE                          ,
9275                 CALLER_TYPE                              ,
9276 --                OLD_OBJECT_VERSION_NUMBER                ,
9277                 OLD_SECURITY_GROUP_ID                    ,
9278                 OLD_ORIG_SYSTEM_REFERENCE                ,
9279                 ORIG_SYSTEM_REFERENCE                    ,
9280                 OLD_ORIG_SYSTEM_REFERENCE_ID             ,
9281                 ORIG_SYSTEM_REFERENCE_ID                 ,
9282                 REQUEST_ID                           ,
9283                 PROGRAM_APPLICATION_ID               ,
9284                 PROGRAM_ID                           ,
9285                 PROGRAM_UPDATE_DATE                  ,
9286                 OLD_PROJECT_NUMBER                       ,
9287                 PROJECT_NUMBER                           ,
9288                 OLD_PLATFORM_VERSION                     ,
9289                 PLATFORM_VERSION                         ,
9290                 OLD_DB_VERSION                           ,
9291                 DB_VERSION                               ,
9292                 OLD_CUST_PREF_LANG_ID                    ,
9293 		CUST_PREF_LANG_ID                        ,
9294                 OLD_TIER                                 ,
9295                 TIER                                     ,
9296                 OLD_CATEGORY_ID                          ,
9297                 CATEGORY_ID                              ,
9298                 OLD_OPERATING_SYSTEM                     ,
9299                 OPERATING_SYSTEM                         ,
9300                 OLD_OPERATING_SYSTEM_VERSION             ,
9301                 OPERATING_SYSTEM_VERSION                 ,
9302                 OLD_DATABASE                             ,
9303                 DATABASE                                 ,
9304                 OLD_GROUP_TERRITORY_ID                   ,
9305                 GROUP_TERRITORY_ID                       ,
9306                 OLD_COMM_PREF_CODE                       ,
9307                 COMM_PREF_CODE                           ,
9308                 OLD_LAST_UPDATE_CHANNEL                  ,
9309                 LAST_UPDATE_CHANNEL                      ,
9310                 OLD_CUST_PREF_LANG_CODE                  ,
9311                 CUST_PREF_LANG_CODE                      ,
9312                 OLD_ERROR_CODE                           ,
9313                 ERROR_CODE                               ,
9314                 OLD_CATEGORY_SET_ID                      ,
9315                 CATEGORY_SET_ID                          ,
9316                 OLD_EXTERNAL_REFERENCE                   ,
9317                 EXTERNAL_REFERENCE                       ,
9318                 OLD_INCIDENT_OCCURRED_DATE               ,
9319                 INCIDENT_OCCURRED_DATE                   ,
9320                 OLD_INCIDENT_RESOLVED_DATE               ,
9321                 INCIDENT_RESOLVED_DATE                   ,
9322                 OLD_INC_RESPONDED_BY_DATE                ,
9323                 INC_RESPONDED_BY_DATE                    ,
9324                 OLD_INCIDENT_LOCATION_ID                 ,
9325                 INCIDENT_LOCATION_ID                     ,
9326                 OLD_INCIDENT_ADDRESS                     ,
9327                 INCIDENT_ADDRESS                         ,
9328                 OLD_INCIDENT_CITY                        ,
9329                 INCIDENT_CITY                            ,
9330                 OLD_INCIDENT_STATE                       ,
9331                 INCIDENT_STATE                           ,
9332                 OLD_INCIDENT_COUNTRY                     ,
9333                 INCIDENT_COUNTRY                         ,
9334                 OLD_INCIDENT_PROVINCE                    ,
9335                 INCIDENT_PROVINCE                        ,
9336                 OLD_INCIDENT_POSTAL_CODE                 ,
9337                 INCIDENT_POSTAL_CODE                     ,
9338                 OLD_INCIDENT_COUNTY                      ,
9339                 INCIDENT_COUNTY                          ,
9340                 OLD_SR_CREATION_CHANNEL                  ,
9341                 SR_CREATION_CHANNEL                      ,
9342                 OLD_DEF_DEFECT_ID                        ,
9343                 DEF_DEFECT_ID                            ,
9344                 OLD_DEF_DEFECT_ID2                       ,
9345                 DEF_DEFECT_ID2                           ,
9346                 OLD_EXTERNAL_ATTRIBUTE_1                 ,
9347                 EXTERNAL_ATTRIBUTE_1                     ,
9348                 OLD_EXTERNAL_ATTRIBUTE_2                 ,
9349                 EXTERNAL_ATTRIBUTE_2                     ,
9350                 OLD_EXTERNAL_ATTRIBUTE_3                 ,
9351                 EXTERNAL_ATTRIBUTE_3                     ,
9352                 OLD_EXTERNAL_ATTRIBUTE_4                 ,
9353                 EXTERNAL_ATTRIBUTE_4                     ,
9354                 OLD_EXTERNAL_ATTRIBUTE_5                 ,
9355                 EXTERNAL_ATTRIBUTE_5                     ,
9356                 OLD_EXTERNAL_ATTRIBUTE_6                 ,
9357                 EXTERNAL_ATTRIBUTE_6                     ,
9358                 OLD_EXTERNAL_ATTRIBUTE_7                 ,
9359                 EXTERNAL_ATTRIBUTE_7                     ,
9360                 OLD_EXTERNAL_ATTRIBUTE_8                 ,
9361                 EXTERNAL_ATTRIBUTE_8                     ,
9362                 OLD_EXTERNAL_ATTRIBUTE_9                 ,
9363                 EXTERNAL_ATTRIBUTE_9                     ,
9364                 OLD_EXTERNAL_ATTRIBUTE_10                ,
9365                 EXTERNAL_ATTRIBUTE_10                    ,
9366                 OLD_EXTERNAL_ATTRIBUTE_11                ,
9367                 EXTERNAL_ATTRIBUTE_11                    ,
9368                 OLD_EXTERNAL_ATTRIBUTE_12                ,
9369                 EXTERNAL_ATTRIBUTE_12                    ,
9370                 OLD_EXTERNAL_ATTRIBUTE_13                ,
9371                 EXTERNAL_ATTRIBUTE_13                    ,
9372                 OLD_EXTERNAL_ATTRIBUTE_14                ,
9373                 EXTERNAL_ATTRIBUTE_14                    ,
9374                 OLD_EXTERNAL_ATTRIBUTE_15                ,
9375                 EXTERNAL_ATTRIBUTE_15                    ,
9376                 OLD_EXTERNAL_CONTEXT                     ,
9377                 EXTERNAL_CONTEXT                         ,
9378                 OLD_LAST_UPDATE_PROGRAM_CODE             ,
9379                 LAST_UPDATE_PROGRAM_CODE                 ,
9380                 OLD_CREATION_PROGRAM_CODE		 ,
9381                 CREATION_PROGRAM_CODE                    ,
9382                 OLD_COVERAGE_TYPE                        ,
9383                 COVERAGE_TYPE                            ,
9384                 OLD_BILL_TO_ACCOUNT_ID                   ,
9385                 BILL_TO_ACCOUNT_ID                       ,
9386                 OLD_SHIP_TO_ACCOUNT_ID                   ,
9387                 SHIP_TO_ACCOUNT_ID                       ,
9388                 OLD_CUSTOMER_EMAIL_ID                    ,
9389                 CUSTOMER_EMAIL_ID                        ,
9390                 OLD_CUSTOMER_PHONE_ID                    ,
9391                 CUSTOMER_PHONE_ID                        ,
9392                 OLD_BILL_TO_PARTY_ID                     ,
9393                 BILL_TO_PARTY_ID                         ,
9394                 OLD_SHIP_TO_PARTY_ID                     ,
9395                 SHIP_TO_PARTY_ID                         ,
9396                 OLD_BILL_TO_SITE_ID                      ,
9397                 BILL_TO_SITE_ID                          ,
9398                 OLD_SHIP_TO_SITE_ID                      ,
9399                 SHIP_TO_SITE_ID                          ,
9400                 OLD_PROGRAM_LOGIN_ID                     ,
9401                 PROGRAM_LOGIN_ID                         ,
9402                 OLD_INCIDENT_POINT_OF_INTEREST           ,
9403                 INCIDENT_POINT_OF_INTEREST               ,
9404                 OLD_INCIDENT_CROSS_STREET                ,
9405                 INCIDENT_CROSS_STREET                    ,
9406                 OLD_INCIDENT_DIRECTION_QUALIF            ,
9407                 INCIDENT_DIRECTION_QUALIF                ,
9408                 OLD_INCIDENT_DISTANCE_QUALIF             ,
9409                 INCIDENT_DISTANCE_QUALIF                 ,
9410                 OLD_INCIDENT_DISTANCE_QUAL_UOM           ,
9411                 INCIDENT_DISTANCE_QUAL_UOM               ,
9412                 OLD_INCIDENT_ADDRESS2                    ,
9413                 INCIDENT_ADDRESS2                        ,
9414                 OLD_INCIDENT_ADDRESS3                    ,
9415                 INCIDENT_ADDRESS3                        ,
9416                 OLD_INCIDENT_ADDRESS4                    ,
9417                 INCIDENT_ADDRESS4                        ,
9418                 OLD_INCIDENT_ADDRESS_STYLE               ,
9419                 INCIDENT_ADDRESS_STYLE                   ,
9420                 OLD_INCIDENT_ADDR_LNS_PHONETIC           ,
9421                 INCIDENT_ADDR_LNS_PHONETIC               ,
9422                 OLD_INCIDENT_PO_BOX_NUMBER               ,
9423                 INCIDENT_PO_BOX_NUMBER                   ,
9424                 OLD_INCIDENT_HOUSE_NUMBER                ,
9425                 INCIDENT_HOUSE_NUMBER                    ,
9426                 OLD_INCIDENT_STREET_SUFFIX               ,
9427                 INCIDENT_STREET_SUFFIX                  ,
9428                 OLD_INCIDENT_STREET                      ,
9429                 INCIDENT_STREET                          ,
9430                 OLD_INCIDENT_STREET_NUMBER               ,
9431                 INCIDENT_STREET_NUMBER                   ,
9432                 OLD_INCIDENT_FLOOR                       ,
9433                 INCIDENT_FLOOR                           ,
9434                 OLD_INCIDENT_SUITE                       ,
9435                 INCIDENT_SUITE                           ,
9436                 OLD_INCIDENT_POSTAL_PLUS4_CODE           ,
9437                 INCIDENT_POSTAL_PLUS4_CODE               ,
9438                 OLD_INCIDENT_POSITION                    ,
9439                 INCIDENT_POSITION                        ,
9440                 OLD_INCIDENT_LOC_DIRECTIONS              ,
9441                 INCIDENT_LOC_DIRECTIONS                  ,
9442                 OLD_INCIDENT_LOC_DESCRIPTION             ,
9443                 INCIDENT_LOC_DESCRIPTION                 ,
9444                 OLD_INSTALL_SITE_ID                      ,
9445                 INSTALL_SITE_ID                          ,
9446                 INCIDENT_LAST_MODIFIED_DATE              ,
9447                 UPDATED_ENTITY_CODE                      ,
9448                 UPDATED_ENTITY_ID                        ,
9449                 ENTITY_ACTIVITY_CODE                     ,
9450                 OLD_TIER_VERSION                         ,
9451                 TIER_VERSION                             ,
9452                 --anmukher --09/12/03
9453                 OLD_INC_OBJECT_VERSION_NUMBER            ,
9454  		INC_OBJECT_VERSION_NUMBER                ,
9455  		OLD_INC_REQUEST_ID                       ,
9456  		INC_REQUEST_ID                           ,
9457  		OLD_INC_PROGRAM_APPLICATION_ID           ,
9458  		INC_PROGRAM_APPLICATION_ID               ,
9459  		OLD_INC_PROGRAM_ID                       ,
9460  		INC_PROGRAM_ID                           ,
9461  		OLD_INC_PROGRAM_UPDATE_DATE              ,
9462  		INC_PROGRAM_UPDATE_DATE                  ,
9463 		OLD_OWNING_DEPARTMENT_ID                 ,
9464  		OWNING_DEPARTMENT_ID                     ,
9465  		OLD_INCIDENT_LOCATION_TYPE               ,
9466  		INCIDENT_LOCATION_TYPE                   ,
9467  		OLD_UNASSIGNED_INDICATOR                 ,
9468  		UNASSIGNED_INDICATOR                     ,
9469 		OLD_MAINT_ORGANIZATION_ID                ,
9470 		MAINT_ORGANIZATION_ID                    ,
9471       --siahmed 12.2+ project
9472     old_project_id                           ,
9473     project_id                               ,
9474     old_project_task_id                      ,
9475     project_task_id                          ,
9476     old_expenditure_org_id                           ,
9477     expenditure_org_id                         ,
9478     --end of addition siahmed 12.2+
9479     --15995804. Auditing price_list_header_id  and SLA dates
9480 		OLD_PRICE_LIST_HEADER_ID                 ,
9481 		PRICE_LIST_HEADER_ID                     ,
9482 		CHANGE_SLA_DATE_1_FLAG                   ,
9483 		OLD_SLA_DATE_1                           ,
9484 		SLA_DATE_1                               ,
9485 		CHANGE_SLA_DATE_2_FLAG                   ,
9486 		OLD_SLA_DATE_2                           ,
9487 		SLA_DATE_2                               ,
9488 		CHANGE_SLA_DATE_3_FLAG                   ,
9489 		OLD_SLA_DATE_3                           ,
9490 		SLA_DATE_3                               ,
9491 		CHANGE_SLA_DATE_4_FLAG                   ,
9492 		OLD_SLA_DATE_4                           ,
9493 		SLA_DATE_4                               ,
9494 		CHANGE_SLA_DATE_5_FLAG                   ,
9495 		OLD_SLA_DATE_5                           ,
9496 		SLA_DATE_5                               ,
9497 		CHANGE_SLA_DATE_6_FLAG                   ,
9498 		OLD_SLA_DATE_6                           ,
9499 		SLA_DATE_6                               ,
9500 		CHANGE_SLA_DURATION_1_FLAG               ,
9501 		OLD_SLA_DURATION_1                       ,
9502 		SLA_DURATION_1                           ,
9503 		CHANGE_SLA_DURATION_2_FLAG               ,
9504 		OLD_SLA_DURATION_2                       ,
9505 		SLA_DURATION_2
9506     )
9507     VALUES(
9508                 l_audit_id,
9509                 p_request_id,
9510                 p_last_update_date,
9511                 p_user_id,
9512                 p_last_update_date,
9513                 p_user_id,
9514                 P_login_id,
9515                 TO_CHAR(p_creation_date,'HH24:MI:SS'),
9516                 l_audit_vals_rec.incident_status_id           ,
9517                 l_audit_vals_rec.old_incident_status_id       ,
9518                 l_audit_vals_rec.change_incident_status_flag  ,
9519                 l_audit_vals_rec.incident_type_id             ,
9520                 l_audit_vals_rec.old_incident_type_id         ,
9521                 l_audit_vals_rec.change_incident_type_flag    ,
9522                 l_audit_vals_rec.incident_urgency_id          ,
9523                 l_audit_vals_rec.old_incident_urgency_id      ,
9524                 l_audit_vals_rec.change_incident_urgency_flag ,
9525                 l_audit_vals_rec.incident_severity_id         ,
9526                 l_audit_vals_rec.old_incident_severity_id     ,
9527                 l_audit_vals_rec.change_incident_severity_flag,
9528                 l_audit_vals_rec.incident_owner_id            ,
9529                 l_audit_vals_rec.old_incident_owner_id        ,
9530                 l_audit_vals_rec.change_incident_owner_flag   ,
9531                 l_audit_vals_rec.create_manual_action         ,
9532                 l_audit_vals_rec.action_id                    ,
9533                 l_audit_vals_rec.expected_resolution_date     ,
9534                 l_audit_vals_rec.old_expected_resolution_date ,
9535                 l_audit_vals_rec.change_resolution_flag       ,
9536                 l_audit_vals_rec.new_workflow_flag            ,
9537                 l_audit_vals_rec.workflow_process_name        ,
9538                 l_audit_vals_rec.workflow_process_itemkey     ,
9539 		l_audit_vals_rec.group_id,
9540 		l_audit_vals_rec.old_group_id,
9541 		l_audit_vals_rec.change_group_flag,
9542                 l_audit_vals_rec.group_type,
9543                 l_audit_vals_rec.old_group_type,
9544                 l_audit_vals_rec.change_group_type_flag,
9545                 l_audit_vals_rec.inv_platform_org_id,
9546                 l_audit_vals_rec.old_inv_platform_org_id,
9547                 l_audit_vals_rec.change_platform_org_id_flag,
9548                 l_audit_vals_rec.owner_assigned_time,
9549                 l_audit_vals_rec.old_owner_assigned_time,
9550                 l_audit_vals_rec.change_assigned_time_flag,
9551 		l_audit_vals_rec.obligation_date,
9552 		l_audit_vals_rec.old_obligation_date,
9553 		l_audit_vals_rec.change_obligation_flag,
9554 		l_audit_vals_rec.site_id,
9555 		l_audit_vals_rec.old_site_id,
9556 		l_audit_vals_rec.change_site_flag,
9557 		l_audit_vals_rec.bill_to_contact_id,
9558 		l_audit_vals_rec.old_bill_to_contact_id,
9559 		l_audit_vals_rec.change_bill_to_flag,
9560 		l_audit_vals_rec.ship_to_contact_id,
9561 		l_audit_vals_rec.old_ship_to_contact_id,
9562 		l_audit_vals_rec.change_ship_to_flag,
9563 		l_audit_vals_rec.close_date,
9564 		l_audit_vals_rec.old_close_date,
9565 		l_audit_vals_rec.change_close_date_flag,
9566 		l_audit_vals_rec.customer_product_id,
9567 		l_audit_vals_rec.old_customer_product_id,
9568 		l_audit_vals_rec.change_customer_product_flag,
9569 		l_audit_vals_rec.platform_id,
9570 		l_audit_vals_rec.old_platform_id,
9571 		l_audit_vals_rec.change_platform_id_flag,
9572                 l_audit_vals_rec.product_revision,
9573                 l_audit_vals_rec.old_product_revision,
9574                 l_audit_vals_rec.change_product_revision_flag,
9575                 l_audit_vals_rec.component_version,	-- cp component versions
9576                 l_audit_vals_rec.old_component_version,
9577                 l_audit_vals_rec.change_comp_ver_flag,
9578                 l_audit_vals_rec.subcomponent_version,
9579                 l_audit_vals_rec.old_subcomponent_version,
9580                 l_audit_vals_rec.change_subcomp_ver_flag,
9581 		l_audit_vals_rec.cp_component_id,
9582 		l_audit_vals_rec.old_cp_component_id,
9583 		l_audit_vals_rec.change_cp_component_id_flag,
9584 		l_audit_vals_rec.cp_component_version_id,
9585 		l_audit_vals_rec.old_cp_component_version_id,
9586 		l_audit_vals_rec.change_cp_comp_ver_id_flag,
9587 		l_audit_vals_rec.cp_subcomponent_id,
9588 		l_audit_vals_rec.old_cp_subcomponent_id,
9589 		l_audit_vals_rec.change_cp_subcomponent_id_flag,
9590 		l_audit_vals_rec.cp_subcomponent_version_id,
9591 		l_audit_vals_rec.old_cp_subcomponent_version_id,
9592 		l_audit_vals_rec.change_cp_subcomp_ver_id_flag,
9593 		l_audit_vals_rec.cp_revision_id,
9594 		l_audit_vals_rec.old_cp_revision_id,
9595 		l_audit_vals_rec.change_cp_revision_id_flag,
9596  		l_audit_vals_rec.inv_item_revision,
9597  		l_audit_vals_rec.old_inv_item_revision,
9598  		l_audit_vals_rec.change_inv_item_revision,
9599  		l_audit_vals_rec.inv_component_id,
9600  		l_audit_vals_rec.old_inv_component_id,
9601  		l_audit_vals_rec.change_inv_component_id,
9602 		l_audit_vals_rec.inv_component_version,
9603  		l_audit_vals_rec.old_inv_component_version,
9604  		l_audit_vals_rec.change_inv_component_version,
9605 		l_audit_vals_rec.inv_subcomponent_id,
9606  		l_audit_vals_rec.old_inv_subcomponent_id,
9607  		l_audit_vals_rec.change_inv_subcomponent_id,
9608 		l_audit_vals_rec.inv_subcomponent_version,
9609  		l_audit_vals_rec.old_inv_subcomponent_version,
9610  		l_audit_vals_rec.change_inv_subcomp_version,
9611 		l_audit_vals_rec.territory_id,
9612 		l_audit_vals_rec.old_territory_id,
9613 		l_audit_vals_rec.change_territory_id_flag,
9614 		l_audit_vals_rec.resource_type,
9615 		l_audit_vals_rec.old_resource_type,
9616 		l_audit_vals_rec.change_resource_type_flag,
9617 		1,
9618 		'',
9619                 l_audit_vals_rec.inventory_item_id  ,
9620                 l_audit_vals_rec.old_inventory_item_id,
9621                 l_audit_vals_rec.change_inventory_item_flag,
9622                 l_audit_vals_rec.inv_organization_id,
9623                 l_audit_vals_rec.old_inv_organization_id,
9624                 l_audit_vals_rec.change_inv_organization_flag,
9625                 l_audit_vals_rec.status_flag,
9626                 l_audit_vals_rec.old_status_flag,
9627                 l_audit_vals_rec.change_status_flag,
9628                 l_audit_vals_rec.incident_date,
9629                 l_audit_vals_rec.old_incident_date,
9630                 l_audit_vals_rec.change_incident_date_flag,
9631                 l_audit_vals_rec.platform_version_id,
9632                 l_audit_vals_rec.old_platform_version_id,
9633                 l_audit_vals_rec.change_plat_ver_id_flag,
9634                 l_audit_vals_rec.language_id,
9635                 l_audit_vals_rec.old_language_id,
9636                 l_audit_vals_rec.change_language_id_flag,
9637                 --l_audit_vals_rec.primary_contact_id,
9638                 --l_audit_vals_rec.change_primary_contact_flag,
9639                 --l_audit_vals_rec.old_primary_contact_id,
9640                 -- Added new audit columns for 11.5.10 Auditing project --anmukher --09/10/03
9641                 l_audit_vals_rec.UPGRADE_FLAG_FOR_CREATE                  ,
9642                 l_audit_vals_rec.OLD_INCIDENT_NUMBER                      ,
9643                 l_audit_vals_rec.INCIDENT_NUMBER                          ,
9644                 l_audit_vals_rec.OLD_CUSTOMER_ID                          ,
9645                 l_audit_vals_rec.CUSTOMER_ID                              ,
9646                 l_audit_vals_rec.OLD_BILL_TO_SITE_USE_ID                  ,
9647                 l_audit_vals_rec.BILL_TO_SITE_USE_ID                      ,
9648                 l_audit_vals_rec.OLD_EMPLOYEE_ID                          ,
9649                 l_audit_vals_rec.EMPLOYEE_ID                              ,
9650                 l_audit_vals_rec.OLD_SHIP_TO_SITE_USE_ID                  ,
9651                 l_audit_vals_rec.SHIP_TO_SITE_USE_ID                      ,
9652                 l_audit_vals_rec.OLD_PROBLEM_CODE                         ,
9653                 l_audit_vals_rec.PROBLEM_CODE                             ,
9654                 l_audit_vals_rec.OLD_ACTUAL_RESOLUTION_DATE               ,
9655                 l_audit_vals_rec.ACTUAL_RESOLUTION_DATE                   ,
9656                 l_audit_vals_rec.OLD_INSTALL_SITE_USE_ID                  ,
9657                 l_audit_vals_rec.INSTALL_SITE_USE_ID                      ,
9658                 l_audit_vals_rec.OLD_CURRENT_SERIAL_NUMBER                ,
9659                 l_audit_vals_rec.CURRENT_SERIAL_NUMBER                    ,
9660                 l_audit_vals_rec.OLD_SYSTEM_ID                            ,
9661                 l_audit_vals_rec.SYSTEM_ID                                ,
9662                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_1                 ,
9663                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_1                     ,
9664                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_2                 ,
9665                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_2                     ,
9666                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_3                 ,
9667                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_3                     ,
9668                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_4                 ,
9669                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_4                     ,
9670                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_5                 ,
9671                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_5                     ,
9672                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_6                 ,
9673                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_6                     ,
9674                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_7                 ,
9675                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_7                     ,
9676                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_8                 ,
9677                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_8                     ,
9678                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_9                 ,
9679                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_9                     ,
9680                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_10                ,
9681                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_10                    ,
9682                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_11                ,
9683                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_11                    ,
9684                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_12                ,
9685                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_12                    ,
9686                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_13                ,
9687                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_13                    ,
9688                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_14                ,
9689                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_14                    ,
9690                 l_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_15                ,
9691                 l_audit_vals_rec.INCIDENT_ATTRIBUTE_15                    ,
9692                 l_audit_vals_rec.OLD_INCIDENT_CONTEXT                     ,
9693                 l_audit_vals_rec.INCIDENT_CONTEXT                         ,
9694                 l_audit_vals_rec.OLD_RESOLUTION_CODE                      ,
9695                 l_audit_vals_rec.RESOLUTION_CODE                          ,
9696                 l_audit_vals_rec.OLD_ORIGINAL_ORDER_NUMBER                ,
9697                 l_audit_vals_rec.ORIGINAL_ORDER_NUMBER                    ,
9698                 l_audit_vals_rec.OLD_ORG_ID                               ,
9699                 l_audit_vals_rec.ORG_ID                                   ,
9700                 l_audit_vals_rec.OLD_PURCHASE_ORDER_NUMBER                ,
9701                 l_audit_vals_rec.PURCHASE_ORDER_NUMBER                    ,
9702                 l_audit_vals_rec.OLD_PUBLISH_FLAG                         ,
9703                 l_audit_vals_rec.PUBLISH_FLAG                             ,
9704                 l_audit_vals_rec.OLD_QA_COLLECTION_ID                     ,
9705                 l_audit_vals_rec.QA_COLLECTION_ID                         ,
9706                 l_audit_vals_rec.OLD_CONTRACT_ID                          ,
9707                 l_audit_vals_rec.CONTRACT_ID                              ,
9708                 l_audit_vals_rec.OLD_CONTRACT_NUMBER                      ,
9709                 l_audit_vals_rec.CONTRACT_NUMBER                          ,
9710                 l_audit_vals_rec.OLD_CONTRACT_SERVICE_ID                  ,
9711                 l_audit_vals_rec.CONTRACT_SERVICE_ID                      ,
9712                 l_audit_vals_rec.OLD_TIME_ZONE_ID                         ,
9713                 l_audit_vals_rec.TIME_ZONE_ID                             ,
9714                 l_audit_vals_rec.OLD_ACCOUNT_ID                           ,
9715                 l_audit_vals_rec.ACCOUNT_ID                               ,
9716                 l_audit_vals_rec.OLD_TIME_DIFFERENCE                      ,
9717                 l_audit_vals_rec.TIME_DIFFERENCE                          ,
9718                 l_audit_vals_rec.OLD_CUSTOMER_PO_NUMBER                   ,
9719                 l_audit_vals_rec.CUSTOMER_PO_NUMBER                       ,
9720                 l_audit_vals_rec.OLD_CUSTOMER_TICKET_NUMBER               ,
9721                 l_audit_vals_rec.CUSTOMER_TICKET_NUMBER                   ,
9722                 l_audit_vals_rec.OLD_CUSTOMER_SITE_ID                     ,
9723                 l_audit_vals_rec.CUSTOMER_SITE_ID                         ,
9724                 l_audit_vals_rec.OLD_CALLER_TYPE                          ,
9725                 l_audit_vals_rec.CALLER_TYPE                              ,
9726 --                l_audit_vals_rec.OLD_OBJECT_VERSION_NUMBER                ,
9727                 l_audit_vals_rec.OLD_SECURITY_GROUP_ID                    ,
9728                 l_audit_vals_rec.OLD_ORIG_SYSTEM_REFERENCE                ,
9729                 l_audit_vals_rec.ORIG_SYSTEM_REFERENCE                    ,
9730                 l_audit_vals_rec.OLD_ORIG_SYSTEM_REFERENCE_ID             ,
9731                 l_audit_vals_rec.ORIG_SYSTEM_REFERENCE_ID                 ,
9732                 l_audit_vals_rec.REQUEST_ID                           ,
9733                 l_audit_vals_rec.PROGRAM_APPLICATION_ID               ,
9734                 l_audit_vals_rec.PROGRAM_ID                           ,
9735                 l_audit_vals_rec.PROGRAM_UPDATE_DATE                  ,
9736                 l_audit_vals_rec.OLD_PROJECT_NUMBER                       ,
9737                 l_audit_vals_rec.PROJECT_NUMBER                           ,
9738                 l_audit_vals_rec.OLD_PLATFORM_VERSION                     ,
9739                 l_audit_vals_rec.PLATFORM_VERSION                         ,
9740                 l_audit_vals_rec.OLD_DB_VERSION                           ,
9741                 l_audit_vals_rec.DB_VERSION                               ,
9742                 l_audit_vals_rec.OLD_CUST_PREF_LANG_ID                    ,
9743                 l_audit_vals_rec.CUST_PREF_LANG_ID                        ,
9744                 l_audit_vals_rec.OLD_TIER                                 ,
9745                 l_audit_vals_rec.TIER                                     ,
9746                 l_audit_vals_rec.OLD_CATEGORY_ID                          ,
9747                 l_audit_vals_rec.CATEGORY_ID                              ,
9748                 l_audit_vals_rec.OLD_OPERATING_SYSTEM                     ,
9749                 l_audit_vals_rec.OPERATING_SYSTEM                         ,
9750                 l_audit_vals_rec.OLD_OPERATING_SYSTEM_VERSION             ,
9751                 l_audit_vals_rec.OPERATING_SYSTEM_VERSION                 ,
9752                 l_audit_vals_rec.OLD_DATABASE                             ,
9753                 l_audit_vals_rec.DATABASE                                 ,
9754                 l_audit_vals_rec.OLD_GROUP_TERRITORY_ID                   ,
9755                 l_audit_vals_rec.GROUP_TERRITORY_ID                       ,
9756                 l_audit_vals_rec.OLD_COMM_PREF_CODE                       ,
9757                 l_audit_vals_rec.COMM_PREF_CODE                           ,
9758                 l_audit_vals_rec.OLD_LAST_UPDATE_CHANNEL                  ,
9759                 l_audit_vals_rec.LAST_UPDATE_CHANNEL                      ,
9760                 l_audit_vals_rec.OLD_CUST_PREF_LANG_CODE                  ,
9761                 l_audit_vals_rec.CUST_PREF_LANG_CODE                      ,
9762                 l_audit_vals_rec.OLD_ERROR_CODE                           ,
9763                 l_audit_vals_rec.ERROR_CODE                               ,
9764                 l_audit_vals_rec.OLD_CATEGORY_SET_ID                      ,
9765                 l_audit_vals_rec.CATEGORY_SET_ID                          ,
9766                 l_audit_vals_rec.OLD_EXTERNAL_REFERENCE                   ,
9767                 l_audit_vals_rec.EXTERNAL_REFERENCE                       ,
9768                 l_audit_vals_rec.OLD_INCIDENT_OCCURRED_DATE               ,
9769                 l_audit_vals_rec.INCIDENT_OCCURRED_DATE                   ,
9770                 l_audit_vals_rec.OLD_INCIDENT_RESOLVED_DATE               ,
9771                 l_audit_vals_rec.INCIDENT_RESOLVED_DATE                   ,
9772                 l_audit_vals_rec.OLD_INC_RESPONDED_BY_DATE                ,
9773                 l_audit_vals_rec.INC_RESPONDED_BY_DATE                    ,
9774                 l_audit_vals_rec.OLD_INCIDENT_LOCATION_ID                 ,
9775                 l_audit_vals_rec.INCIDENT_LOCATION_ID                     ,
9776                 l_audit_vals_rec.OLD_INCIDENT_ADDRESS                     ,
9777                 l_audit_vals_rec.INCIDENT_ADDRESS                         ,
9778                 l_audit_vals_rec.OLD_INCIDENT_CITY                        ,
9779                 l_audit_vals_rec.INCIDENT_CITY                            ,
9780                 l_audit_vals_rec.OLD_INCIDENT_STATE                       ,
9781                 l_audit_vals_rec.INCIDENT_STATE                           ,
9782                 l_audit_vals_rec.OLD_INCIDENT_COUNTRY                     ,
9783                 l_audit_vals_rec.INCIDENT_COUNTRY                         ,
9784                 l_audit_vals_rec.OLD_INCIDENT_PROVINCE                    ,
9785                 l_audit_vals_rec.INCIDENT_PROVINCE                        ,
9786                 l_audit_vals_rec.OLD_INCIDENT_POSTAL_CODE                 ,
9787                 l_audit_vals_rec.INCIDENT_POSTAL_CODE                     ,
9788                 l_audit_vals_rec.OLD_INCIDENT_COUNTY                      ,
9789                 l_audit_vals_rec.INCIDENT_COUNTY                          ,
9790                 l_audit_vals_rec.OLD_SR_CREATION_CHANNEL                  ,
9791                 l_audit_vals_rec.SR_CREATION_CHANNEL                      ,
9792                 l_audit_vals_rec.OLD_DEF_DEFECT_ID                        ,
9793                 l_audit_vals_rec.DEF_DEFECT_ID                            ,
9794                 l_audit_vals_rec.OLD_DEF_DEFECT_ID2                       ,
9795                 l_audit_vals_rec.DEF_DEFECT_ID2                           ,
9796                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_1                 ,
9797                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_1                     ,
9798                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_2                 ,
9799                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_2                     ,
9800                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_3                 ,
9801                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_3                     ,
9802                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_4                 ,
9803                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_4                     ,
9804                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_5                 ,
9805                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_5                     ,
9806                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_6                 ,
9807                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_6                     ,
9808                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_7                 ,
9809                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_7                     ,
9810                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_8                 ,
9811                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_8                     ,
9812                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_9                 ,
9813                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_9                     ,
9814                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_10                ,
9815                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_10                    ,
9816                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_11                ,
9817                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_11                    ,
9818                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_12                ,
9819                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_12                    ,
9820                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_13                ,
9821                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_13                    ,
9822                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_14                ,
9823                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_14                    ,
9824                 l_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_15                ,
9825                 l_audit_vals_rec.EXTERNAL_ATTRIBUTE_15                    ,
9826                 l_audit_vals_rec.OLD_EXTERNAL_CONTEXT                     ,
9827                 l_audit_vals_rec.EXTERNAL_CONTEXT                         ,
9828                 l_audit_vals_rec.OLD_LAST_UPDATE_PROGRAM_CODE             ,
9829                 l_audit_vals_rec.LAST_UPDATE_PROGRAM_CODE                 ,
9830                 l_audit_vals_rec.OLD_CREATION_PROGRAM_CODE           ,
9831                 l_audit_vals_rec.CREATION_PROGRAM_CODE               ,
9832                 l_audit_vals_rec.OLD_COVERAGE_TYPE                        ,
9833                 l_audit_vals_rec.COVERAGE_TYPE                            ,
9834                 l_audit_vals_rec.OLD_BILL_TO_ACCOUNT_ID                   ,
9835                 l_audit_vals_rec.BILL_TO_ACCOUNT_ID                       ,
9836                 l_audit_vals_rec.OLD_SHIP_TO_ACCOUNT_ID                   ,
9837                 l_audit_vals_rec.SHIP_TO_ACCOUNT_ID                       ,
9838                 l_audit_vals_rec.OLD_CUSTOMER_EMAIL_ID                    ,
9839                 l_audit_vals_rec.CUSTOMER_EMAIL_ID                        ,
9840                 l_audit_vals_rec.OLD_CUSTOMER_PHONE_ID                    ,
9841                 l_audit_vals_rec.CUSTOMER_PHONE_ID                        ,
9842                 l_audit_vals_rec.OLD_BILL_TO_PARTY_ID                     ,
9843                 l_audit_vals_rec.BILL_TO_PARTY_ID                         ,
9844                 l_audit_vals_rec.OLD_SHIP_TO_PARTY_ID                     ,
9845                 l_audit_vals_rec.SHIP_TO_PARTY_ID                         ,
9846                 l_audit_vals_rec.OLD_BILL_TO_SITE_ID                      ,
9847                 l_audit_vals_rec.BILL_TO_SITE_ID                          ,
9848                 l_audit_vals_rec.OLD_SHIP_TO_SITE_ID                      ,
9849                 l_audit_vals_rec.SHIP_TO_SITE_ID                          ,
9850                 l_audit_vals_rec.OLD_PROGRAM_LOGIN_ID                     ,
9851                 l_audit_vals_rec.PROGRAM_LOGIN_ID                         ,
9852                 l_audit_vals_rec.OLD_INCIDENT_POINT_OF_INTEREST           ,
9853                 l_audit_vals_rec.INCIDENT_POINT_OF_INTEREST               ,
9854                 l_audit_vals_rec.OLD_INCIDENT_CROSS_STREET                ,
9855                 l_audit_vals_rec.INCIDENT_CROSS_STREET                    ,
9856                 l_audit_vals_rec.OLD_INCIDENT_DIRECTION_QUALIF            ,
9857                 l_audit_vals_rec.INCIDENT_DIRECTION_QUALIF                ,
9858                 l_audit_vals_rec.OLD_INCIDENT_DISTANCE_QUALIF             ,
9859                 l_audit_vals_rec.INCIDENT_DISTANCE_QUALIF                 ,
9860                 l_audit_vals_rec.OLD_INCIDENT_DISTANCE_QUAL_UOM           ,
9861                 l_audit_vals_rec.INCIDENT_DISTANCE_QUAL_UOM               ,
9862                 l_audit_vals_rec.OLD_INCIDENT_ADDRESS2                    ,
9863                 l_audit_vals_rec.INCIDENT_ADDRESS2                        ,
9864                 l_audit_vals_rec.OLD_INCIDENT_ADDRESS3                    ,
9865                 l_audit_vals_rec.INCIDENT_ADDRESS3                        ,
9866                 l_audit_vals_rec.OLD_INCIDENT_ADDRESS4                    ,
9867                 l_audit_vals_rec.INCIDENT_ADDRESS4                        ,
9868                 l_audit_vals_rec.OLD_INCIDENT_ADDRESS_STYLE               ,
9869                 l_audit_vals_rec.INCIDENT_ADDRESS_STYLE                   ,
9870                 l_audit_vals_rec.OLD_INCIDENT_ADDR_LNS_PHONETIC           ,
9871                 l_audit_vals_rec.INCIDENT_ADDR_LNS_PHONETIC               ,
9872                 l_audit_vals_rec.OLD_INCIDENT_PO_BOX_NUMBER               ,
9873                 l_audit_vals_rec.INCIDENT_PO_BOX_NUMBER                   ,
9874                 l_audit_vals_rec.OLD_INCIDENT_HOUSE_NUMBER                ,
9875                 l_audit_vals_rec.INCIDENT_HOUSE_NUMBER                    ,
9876                 l_audit_vals_rec.OLD_INCIDENT_STREET_SUFFIX               ,
9877                 l_audit_vals_rec.INCIDENT_STREET_SUFFIX                  ,
9878                 l_audit_vals_rec.OLD_INCIDENT_STREET                      ,
9879                 l_audit_vals_rec.INCIDENT_STREET                          ,
9880                 l_audit_vals_rec.OLD_INCIDENT_STREET_NUMBER               ,
9881                 l_audit_vals_rec.INCIDENT_STREET_NUMBER                   ,
9882                 l_audit_vals_rec.OLD_INCIDENT_FLOOR                       ,
9883                 l_audit_vals_rec.INCIDENT_FLOOR                           ,
9884                 l_audit_vals_rec.OLD_INCIDENT_SUITE                       ,
9885                 l_audit_vals_rec.INCIDENT_SUITE                           ,
9886                 l_audit_vals_rec.OLD_INCIDENT_POSTAL_PLUS4_CODE           ,
9887                 l_audit_vals_rec.INCIDENT_POSTAL_PLUS4_CODE               ,
9888                 l_audit_vals_rec.OLD_INCIDENT_POSITION                    ,
9889                 l_audit_vals_rec.INCIDENT_POSITION                        ,
9890                 l_audit_vals_rec.OLD_INCIDENT_LOC_DIRECTIONS              ,
9891                 l_audit_vals_rec.INCIDENT_LOC_DIRECTIONS                  ,
9892                 l_audit_vals_rec.OLD_INCIDENT_LOC_DESCRIPTION             ,
9893                 l_audit_vals_rec.INCIDENT_LOC_DESCRIPTION                 ,
9894                 l_audit_vals_rec.OLD_INSTALL_SITE_ID                      ,
9895                 l_audit_vals_rec.INSTALL_SITE_ID                          ,
9896                 l_audit_vals_rec.INCIDENT_LAST_MODIFIED_DATE              ,
9897                 l_audit_vals_rec.UPDATED_ENTITY_CODE                      ,
9898                 l_audit_vals_rec.UPDATED_ENTITY_ID                        ,
9899                 l_audit_vals_rec.ENTITY_ACTIVITY_CODE                     ,
9900                 l_audit_vals_rec.OLD_TIER_VERSION                         ,
9901                 l_audit_vals_rec.TIER_VERSION                             ,
9902                 --anmukher --09/12/03
9903                 l_audit_vals_rec.OLD_INC_OBJECT_VERSION_NUMBER            ,
9904  		l_audit_vals_rec.INC_OBJECT_VERSION_NUMBER                ,
9905  		l_audit_vals_rec.OLD_INC_REQUEST_ID                       ,
9906  		l_audit_vals_rec.INC_REQUEST_ID                           ,
9907  		l_audit_vals_rec.OLD_INC_PROGRAM_APPLICATION_ID           ,
9908  		l_audit_vals_rec.INC_PROGRAM_APPLICATION_ID               ,
9909  		l_audit_vals_rec.OLD_INC_PROGRAM_ID                       ,
9910  		l_audit_vals_rec.INC_PROGRAM_ID                           ,
9911  		l_audit_vals_rec.OLD_INC_PROGRAM_UPDATE_DATE              ,
9912  		l_audit_vals_rec.INC_PROGRAM_UPDATE_DATE                  ,
9913 		l_audit_vals_rec.OLD_OWNING_DEPARTMENT_ID                 ,
9914  		l_audit_vals_rec.OWNING_DEPARTMENT_ID                     ,
9915  		l_audit_vals_rec.OLD_INCIDENT_LOCATION_TYPE               ,
9916  		l_audit_vals_rec.INCIDENT_LOCATION_TYPE                   ,
9917  		l_audit_vals_rec.OLD_UNASSIGNED_INDICATOR                 ,
9918  		l_audit_vals_rec.UNASSIGNED_INDICATOR                     ,
9919  		l_audit_vals_rec.OLD_MAINT_ORGANIZATION_ID                ,
9920  		l_audit_vals_rec.MAINT_ORGANIZATION_ID                    ,
9921      --added by siahmed 12.2+ project auditing project attributes
9922  		l_audit_vals_rec.old_project_id             ,
9923  		l_audit_vals_rec.project_id                 ,
9924  		l_audit_vals_rec.old_project_task_id        ,
9925  		l_audit_vals_rec.project_task_id            ,
9926  		l_audit_vals_rec.old_expenditure_org_id             ,
9927  		l_audit_vals_rec.expenditure_org_id         ,
9928 --end of addition siahmed 12.2+ project
9929           --15995804. Auditing price_list_header_id  and SLA dates
9930 		l_audit_vals_rec.OLD_PRICE_LIST_HEADER_ID                 ,
9931 		l_audit_vals_rec.PRICE_LIST_HEADER_ID                     ,
9932                 l_audit_vals_rec.CHANGE_SLA_DATE_1_FLAG                   ,
9933 		l_audit_vals_rec.OLD_SLA_DATE_1                           ,
9934 		l_audit_vals_rec.SLA_DATE_1                               ,
9935 		l_audit_vals_rec.CHANGE_SLA_DATE_2_FLAG                   ,
9936 		l_audit_vals_rec.OLD_SLA_DATE_2                           ,
9937 		l_audit_vals_rec.SLA_DATE_2                               ,
9938 		l_audit_vals_rec.CHANGE_SLA_DATE_3_FLAG                   ,
9939 		l_audit_vals_rec.OLD_SLA_DATE_3                           ,
9940 		l_audit_vals_rec.SLA_DATE_3                               ,
9941 		l_audit_vals_rec.CHANGE_SLA_DATE_4_FLAG                   ,
9942 		l_audit_vals_rec.OLD_SLA_DATE_4                           ,
9943 		l_audit_vals_rec.SLA_DATE_4                               ,
9944 		l_audit_vals_rec.CHANGE_SLA_DATE_5_FLAG                   ,
9945 		l_audit_vals_rec.OLD_SLA_DATE_5                           ,
9946 		l_audit_vals_rec.SLA_DATE_5                               ,
9947 		l_audit_vals_rec.CHANGE_SLA_DATE_6_FLAG                   ,
9948 		l_audit_vals_rec.OLD_SLA_DATE_6                           ,
9949 		l_audit_vals_rec.SLA_DATE_6                               ,
9950                 l_audit_vals_rec.CHANGE_SLA_DURATION_1_FLAG               ,
9951 		l_audit_vals_rec.OLD_SLA_DURATION_1                       ,
9952 		l_audit_vals_rec.SLA_DURATION_1                           ,
9953 		l_audit_vals_rec.CHANGE_SLA_DURATION_2_FLAG               ,
9954 		l_audit_vals_rec.OLD_SLA_DURATION_2                       ,
9955 		l_audit_vals_rec.SLA_DURATION_2
9956      )
9957             RETURNING incident_audit_id INTO l_Incident_Audit_Id;
9958 
9959    INSERT INTO cs_incidents_audit_tl (
9960         incident_audit_id,
9961         incident_id,
9962         LANGUAGE,
9963         source_lang,
9964         last_update_date,
9965         last_updated_by,
9966         creation_date,
9967         created_by,
9968         change_description
9969     ) SELECT
9970         l_incident_audit_id,
9971         p_request_id,
9972         L.LANGUAGE_CODE,
9973         USERENV('LANG'),
9974         SYSDATE,
9975         p_user_id,
9976         SYSDATE,
9977         p_user_id,
9978         p_comments
9979       FROM FND_LANGUAGES L
9980       WHERE l.installed_flag IN ('I', 'B')
9981       AND NOT EXISTS
9982       (SELECT NULL
9983        FROM cs_incidents_audit_tl t
9984        WHERE t.incident_audit_id = l_incident_audit_id
9985        AND t.LANGUAGE = l.language_code
9986      ) ;
9987 
9988     IF FND_API.To_Boolean( p_commit ) THEN
9989       COMMIT WORK;
9990     END IF;
9991 
9992     FND_MSG_PUB.Count_And_Get( p_count  => x_msg_count,
9993                                p_data  => x_msg_data );
9994 
9995   EXCEPTION
9996     WHEN FND_API.G_EXC_ERROR THEN
9997       ROLLBACK TO Create_Audit_Record_PVT;
9998       x_return_status := FND_API.G_RET_STS_ERROR;
9999       FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
10000                                  p_data  => x_msg_data );
10001 
10002     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
10003       ROLLBACK TO Create_Audit_Record_PVT;
10004       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10005       FND_MSG_PUB.Count_And_Get( p_count => x_msg_count,
10006                                  p_data  => x_msg_data );
10007 
10008     WHEN OTHERS THEN
10009       ROLLBACK TO Create_Audit_Record_PVT;
10010       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
10011       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
10012         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME, l_api_name );
10013       END IF;
10014       FND_MSG_PUB.Count_And_Get( p_count     => x_msg_count,
10015                                  p_data      => x_msg_data );
10016 
10017   END Create_Audit_Record;
10018 --------------------------------------------------------------------------
10019 -- Validate_ServiceRequest_Record
10020 --------------------------------------------------------------------------
10021 
10022 -- Modification History
10023 -- Date     Name     Desc
10024 -- -------  -------- -----------------------------------------------------------
10025 -- 02/28/05 smisra   Bug 4083288 passed category_set_id to
10026 --                   validate_category_id procedure.
10027 -- 03/25/05 smisra   Bug 4239975 Modified call to validate_current_serial_number
10028 --                   Now it is called only if both customer product and current
10029 --                   serial number are not null and not G_MISS_XXX
10030 -- 05/05/05 smisra   Added validation for maint_organization_id
10031 -- 06/07/05 smisra   Added p_maint_organization_id to util.validate_product call
10032 --                   Removed p_maintenance_flag parameter from
10033 --                   validate_inventory_org call
10034 -- 07/20/05 smisra   bug 3900208
10035 --                   changed the value of parameter p_parameter_name to
10036 --                   p_product_revision from component_version so that error
10037 --                   message is appropriate.
10038 -- 08/01/05 smisra   EAM-IB01AUG
10039 --                   passed addtional parameter p_inv_org_master_org_flag to
10040 --                   validate_maint_organization_id,
10041 --                   validate_customer_product_id and validate_inventory_org_id
10042 -- 08/03/05 smisra   Passed maint_organization_id to validate_owning_dept
10043 --                   procedure
10044 --                   Passed l_inv_org_master_org_flag to validate_product
10045 -- 08/11/05 smisra   Called validate_owning_dept only in Create Mode. in updated
10046 --                   more it is called from servicerequest_cross_val
10047 -- 12/14/05 smisra   removed call to validate_inc_location_id. Now it is called
10048 --                   from vltd_sr_rec
10049 -- 12/23/05 smisra   Bug 4894942
10050 --                   Removed call to validate_contract_service_id and
10051 --                   contracts_cross_val. This code is now executed from
10052 --                   vldt_sr_rec
10053 -- 12/30/05 smisra   Bug 4773215
10054 --                   Removed call to validate resource type and site_id because
10055 --                   these are now derived based on resource id
10056 -- 06/06/06 spusegao Bug # 4773215
10057 --                   Modified the check for value in profile option CS_PUBLISH_FLAG_UPDATE
10058 --                   This check will not allow creation of service request only if the profile
10059 --                   option is set to NULL.
10060 -- 06/13/06 spusegao Modified fix big 5278488
10061 --                       1. Reverted the changes made in Validate_ServiceRequest_Record.
10062 -- 07/11/06 spusegao Modified to fix bug # 5361090.
10063 --                   Added call to Validate_Platform_id procedure to validate platform_id.
10064 -- 09/20/06 spusegao Modified to not validate the publish_flag in the CREATE p_sr_mode.
10065 --------------------------------------------------------------------------------
10066 PROCEDURE Validate_ServiceRequest_Record
10067 ( p_api_name        		IN   VARCHAR2,
10068   p_service_request_rec  	IN                Request_Validation_Rec_Type,
10069   p_request_date    		IN   DATE         := FND_API.G_MISS_DATE,
10070   p_org_id          		IN   NUMBER       := NULL,
10071   p_resp_appl_id    		IN   NUMBER       := NULL,
10072   p_resp_id         		IN   NUMBER       := NULL,
10073   p_user_id         		IN   NUMBER       := NULL,
10074   p_operation       		IN   VARCHAR2     := NULL,
10075   p_close_flag      		OUT NOCOPY VARCHAR2,
10076   p_disallow_request_update 	OUT NOCOPY VARCHAR2,
10077   p_disallow_owner_update  	OUT NOCOPY VARCHAR2,
10078   p_disallow_product_update  	OUT NOCOPY VARCHAR2,
10079   p_employee_name   	 OUT  NOCOPY VARCHAR2,
10080   p_inventory_item_id    OUT  NOCOPY NUMBER,
10081   p_contract_id          OUT  NOCOPY NUMBER,
10082   p_contract_number      OUT  NOCOPY VARCHAR2,
10083   x_bill_to_site_id      OUT NOCOPY NUMBER,
10084   x_ship_to_site_id      OUT NOCOPY NUMBER,
10085   x_bill_to_site_use_id  OUT NOCOPY NUMBER,
10086   x_ship_to_site_use_id  OUT NOCOPY NUMBER,
10087   x_return_status        OUT  NOCOPY VARCHAR2,
10088   x_group_name           OUT  NOCOPY VARCHAR2,
10089   x_owner_name           OUT  NOCOPY VARCHAR2,
10090   x_product_revision        OUT NOCOPY VARCHAR2,
10091   x_component_version       OUT NOCOPY VARCHAR2,
10092   x_subcomponent_version    OUT NOCOPY VARCHAR2,
10093   -- for cmro
10094   p_cmro_flag             IN  VARCHAR2,
10095   p_maintenance_flag      IN  VARCHAR2,
10096   p_sr_mode               IN  VARCHAR2
10097 )
10098 IS
10099   l_return_status   	VARCHAR2(1);
10100   l_can_update      	VARCHAR2(1);
10101   l_cp_customer_id  	NUMBER    := NULL;
10102   l_customer_id         NUMBER    ;
10103   l_bill_to_customer_id NUMBER    := NULL;
10104   l_ship_to_customer_id NUMBER    := NULL;
10105   l_install_customer_id NUMBER    := NULL;
10106   l_owner_name          VARCHAR2(240); -- dummy variable
10107   l_contract_number     VARCHAR2(120);
10108   l_contract_id         NUMBER  := NULL;
10109   l_contra_id           NUMBER  := NULL;
10110   l_customer_type       VARCHAR2(30);
10111   x_owner_id            NUMBER;
10112   lx_cmro_flag          VARCHAR2(10);  -- new for 11.5.10
10113   lx_maintenance_flag   VARCHAR2(10);  -- new for 11.5.10
10114   -- contracts : 3224828 for 11.5.10
10115   l_busi_proc_id        NUMBER;
10116   lx_return_status   	VARCHAR2(3);
10117   l_old_type_id         NUMBER;
10118 
10119 l_maint_organization_id cs_incidents_all_b.maint_organization_id % TYPE;
10120 l_inv_org_master_org_flag VARCHAR2(1);
10121 l_serial_controlled_flag  VARCHAR2(3);
10122 
10123 BEGIN
10124 
10125   -- Initialize return status to success
10126   x_return_status := FND_API.G_RET_STS_SUCCESS;
10127 
10128   --Assign value to l_customer_id based on caller type
10129 
10130   IF (p_service_request_rec.caller_type = 'ORGANIZATION') THEN
10131     l_customer_id := p_service_request_rec.customer_id ;
10132   ELSIF (p_service_request_rec.caller_type = 'PERSON' ) THEN
10133     l_customer_id := p_service_request_rec.customer_id ;--Added for Bug 2167129
10134   END IF;
10135 
10136   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(p_api_name, 'step val sr rec #1');
10137   -- Validate all non-missing attributes
10138 
10139   /***** dj api cleanup
10140   -- commenting out call to validate type as this is done as the first step in
10141   -- both the create and update procedures
10142   IF FND_API.To_Boolean(p_service_request_rec.validate_type) THEN
10143     IF FND_API.To_Boolean(p_service_request_rec.status_id_change) THEN
10144        -- dj api cleanup
10145        CS_ServiceRequest_UTIL.Validate_Type (
10146 	p_parameter_name      => 'p_type_id',
10147         p_type_id             => p_service_request_rec.type_id,
10148         p_subtype             => G_SR_SUBTYPE,
10149         P_status_id           => p_service_request_rec.updated_status_id,
10150         p_resp_id             => p_resp_id,
10151 	p_resp_appl_id        => NVL(p_resp_appl_id,fnd_global.resp_appl_id) -- new for 11.5.10
10152 	p_business_usage      => NULL, -- new for 11.5.10
10153 	p_ss_srtype_restrict  => NULL, -- new for 11.5.10
10154         p_operation           => p_operation,
10155         x_return_status       => l_return_status,
10156 	x_cmro_flag           => lx_cmro_flag,  -- new for 11.5.10
10157 	x_maintenance_flag    => lx_maintenance_flag );  -- new for 11.5.10
10158 
10159     ELSE
10160       CS_ServiceRequest_UTIL.Validate_Type (
10161 	  p_parameter_name => 'p_type_id',
10162           p_type_id        => p_service_request_rec.type_id,
10163           p_subtype        => G_SR_SUBTYPE,
10164           P_status_id      => p_service_request_rec.status_id,
10165           p_resp_id        => p_resp_id,
10166 	  p_resp_appl_id        => NVL(p_resp_appl_id,fnd_global.resp_appl_id) -- new for 11.5.10
10167 	  p_business_usage      => NULL, -- new for 11.5.10
10168 	  p_ss_srtype_restrict  => NULL, -- new for 11.5.10
10169           p_operation      => p_operation,
10170           x_return_status  => l_return_status,
10171 	  x_cmro_flag           => lx_cmro_flag,  -- new for 11.5.10
10172 	x_maintenance_flag    => lx_maintenance_flag );  -- new for 11.5.10
10173     END IF;
10174 
10175     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10176       x_return_status := FND_API.G_RET_STS_ERROR;
10177       RETURN;
10178     END IF;
10179 
10180   END IF;
10181 
10182   end comment of type ********/
10183 
10184   IF FND_API.To_Boolean(p_service_request_rec.validate_status) THEN
10185     CS_ServiceRequest_UTIL.Validate_Status
10186       ( p_api_name       => p_api_name,
10187         p_parameter_name => 'p_status_id',
10188         p_status_id      => p_service_request_rec.status_id,
10189         p_subtype        => G_SR_SUBTYPE,
10190         p_type_id        => p_service_request_rec.type_id,
10191 	   p_resp_id        => p_resp_id,
10192         p_close_flag     => p_close_flag,
10193 	   p_operation      => p_sr_mode,
10194         x_return_status  => l_return_status
10195       );
10196     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10197       x_return_status := FND_API.G_RET_STS_ERROR;
10198       RETURN;
10199     END IF;
10200   END IF;
10201 
10202   IF FND_API.To_Boolean(p_service_request_rec.validate_updated_status) THEN
10203 
10204      IF p_service_request_rec.old_type_id <> FND_API.G_MISS_NUM AND
10205 	   p_service_request_rec.old_type_id IS NOT NULL THEN
10206 	   l_old_type_id := p_service_request_rec.old_type_id;
10207 	ELSE
10208 	   l_old_type_id := p_service_request_rec.type_id;
10209 	END IF ;
10210 
10211     CS_ServiceRequest_UTIL.Validate_Updated_Status
10212       ( p_api_name       => p_api_name,
10213         p_parameter_name => 'p_status_id',
10214         p_resp_id        =>  p_resp_id  ,
10215         p_new_status_id  => p_service_request_rec.updated_status_id,
10216         p_old_status_id  => p_service_request_rec.status_id,
10217         p_subtype        => G_SR_SUBTYPE,
10218         p_type_id        => p_service_request_rec.type_id,
10219 	   p_old_type_id    => l_old_type_id,
10220         p_close_flag     => p_close_flag,
10221         p_disallow_request_update  => p_disallow_request_update,
10222         p_disallow_owner_update    => p_disallow_owner_update,
10223         p_disallow_product_update  => p_disallow_product_update,
10224         x_return_status  => l_return_status
10225       );
10226     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10227       x_return_status := FND_API.G_RET_STS_ERROR;
10228       RETURN;
10229     END IF;
10230   END IF;
10231 
10232   -- CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(p_api_name, 'step val sr rec #3');
10233 
10234   IF (p_service_request_rec.severity_id <> FND_API.G_MISS_NUM) THEN
10235 
10236     CS_ServiceRequest_UTIL.Validate_Severity
10237       ( p_api_name       => p_api_name,
10238         p_parameter_name => 'p_severity_id',
10239         p_severity_id    => p_service_request_rec.severity_id,
10240         p_subtype        => G_SR_SUBTYPE,
10241         x_return_status  => l_return_status
10242       );
10243     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10244       x_return_status := FND_API.G_RET_STS_ERROR;
10245       RETURN;
10246     END IF;
10247   END IF;
10248 
10249   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(p_api_name, 'step val sr rec #4');
10250 
10251   IF (p_service_request_rec.urgency_id <> FND_API.G_MISS_NUM) THEN
10252 
10253     CS_ServiceRequest_UTIL.Validate_Urgency
10254       ( p_api_name       => p_api_name,
10255         p_parameter_name => 'p_urgency_id',
10256         p_urgency_id     => p_service_request_rec.urgency_id,
10257         x_return_status  => l_return_status
10258       );
10259     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10260       x_return_status := FND_API.G_RET_STS_ERROR;
10261       RETURN;
10262     END IF;
10263   END IF;
10264 
10265   -- For bug 3635269
10266   -- Validate SR_CREATION_CHANNEL
10267 
10268     IF (p_service_request_rec.sr_creation_channel <> FND_API.G_MISS_CHAR ) THEN
10269 
10270           CS_ServiceRequest_UTIL.Validate_SR_Channel(
10271           p_api_name              => p_api_name,
10272           p_parameter_name        => 'p_sr_creation_channel',
10273           p_sr_creation_channel   => p_service_request_rec.sr_creation_channel,
10274           x_return_status         => l_return_status);
10275 
10276         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10277           x_return_status := FND_API.G_RET_STS_ERROR;
10278           RETURN;
10279         END IF;
10280     END IF;
10281 
10282   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(p_api_name, 'step val sr rec #6');
10283 
10284   IF (p_service_request_rec.publish_flag <> FND_API.G_MISS_CHAR) AND
10285       p_sr_mode <> 'CREATE' THEN
10286 
10287     FND_PROFILE.Get('INC_PUBLISH_FLAG_UPDATE', l_can_update) ;
10288 
10289     IF ((l_can_update = 'N' ) OR (l_can_update IS NULL)) THEN
10290       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
10291         FND_MESSAGE.Set_Name('CS', 'CS_API_SR_CANT_CHANGE_PUBLISH');
10292         FND_MESSAGE.Set_Token('API_NAME', p_api_name);
10293         FND_MSG_PUB.ADD;
10294       END IF;
10295       x_return_status := FND_API.G_RET_STS_ERROR;
10296       RETURN;
10297     END IF;
10298   END IF;
10299 
10300   IF FND_API.To_Boolean(p_service_request_rec.validate_customer) THEN
10301 
10302     CS_ServiceRequest_UTIL.Validate_Customer
10303       ( p_api_name       => p_api_name,
10304         p_parameter_name => 'p_customer_id',
10305 	p_caller_type    => p_service_request_rec.caller_type,    --Bug 3666089
10306         p_customer_id    => p_service_request_rec.customer_id,
10307         x_return_status  => l_return_status
10308       );
10309 
10310     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10311       x_return_status := FND_API.G_RET_STS_ERROR;
10312       RETURN;
10313     END IF;
10314   END IF;
10315 
10316   IF (p_service_request_rec.contact_id <> FND_API.G_MISS_NUM) THEN
10317     CS_ServiceRequest_UTIL.Validate_Customer_Contact
10318       ( p_api_name            => p_api_name,
10319         p_parameter_name      => 'p_contact_id',
10320         p_customer_contact_id => p_service_request_rec.contact_id,
10321         p_customer_id         => p_service_request_rec.customer_id,
10322         p_org_id              => p_org_id,
10323         p_customer_type       => p_service_request_rec.caller_type,
10324         x_return_status       => l_return_status
10325       );
10326     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10327       x_return_status := FND_API.G_RET_STS_ERROR;
10328       RETURN;
10329     END IF;
10330   END IF;
10331 
10332   IF FND_API.To_Boolean(p_service_request_rec.validate_employee) THEN
10333     CS_ServiceRequest_UTIL.Validate_Employee
10334       (   p_api_name          => p_api_name,
10335           p_parameter_name    => 'p_employee_id',
10336           p_employee_id       => p_service_request_rec.employee_id,
10337           p_org_id            => p_org_id,
10338           p_employee_name     => p_employee_name,
10339           x_return_status     => l_return_status
10340       );
10341     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10342       x_return_status := FND_API.G_RET_STS_ERROR;
10343       RETURN;
10344     END IF;
10345 
10346     -- If employee_id is passed, use the CP owning customer to verify the
10347     -- RMA, bill to site, and ship to site information.
10348 
10349     -- l_cp_customer_id has null value in this case..
10350        l_customer_id := l_cp_customer_id ;
10351 
10352   END IF;
10353 
10354    -- For bug 2743507 , moving the call to validate inv org id before
10355    -- the validation of inv item id.
10356 
10357   IF (p_service_request_rec.inventory_org_id <> FND_API.G_MISS_NUM) THEN
10358     CS_ServiceRequest_UTIL.Validate_Inventory_Org
10359     ( p_api_name          => p_api_name,
10360       p_parameter_name    => 'Inventory Organization',
10361       p_inv_org_id        => p_service_request_rec.inventory_org_id,
10362       x_inv_org_master_org_flag => l_inv_org_master_org_flag,
10363       x_return_status     => l_return_status
10364     );
10365     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10366       x_return_status := FND_API.G_RET_STS_ERROR;
10367       RETURN;
10368     END IF;
10369   END IF;
10370 
10371   -- validate maintenance organization id
10372   IF (p_service_request_rec.maint_organization_id <> FND_API.G_MISS_NUM AND
10373       p_service_request_rec.maint_organization_id IS NOT NULL )
10374   THEN
10375     CS_SERVICEREQUEST_UTIL.validate_maint_organization_id
10376     ( p_maint_organization_id => p_service_request_rec.maint_organization_id
10377     , p_inventory_org_id      => p_service_request_rec.inventory_org_id
10378     , p_inv_org_master_org_flag => l_inv_org_master_org_flag
10379     , x_return_status         => l_return_status
10380     );
10381     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10382       x_return_status := FND_API.G_RET_STS_ERROR;
10383       RETURN;
10384     END IF ;
10385   END IF ;
10386   --
10387 
10388   IF (p_service_request_rec.inventory_item_id <> FND_API.G_MISS_NUM)
10389      AND (p_sr_mode = 'CREATE') THEN
10390     IF ((p_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) OR
10391         (p_service_request_rec.inventory_org_id IS NULL)) THEN
10392 
10393       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
10394                        ( p_token_an     => p_api_name,
10395                          p_token_np     => 'p_inventory_org_id',
10396                          p_table_name   => G_TABLE_NAME,
10397                          p_column_name  => 'INV_ORGANIZATION_ID');
10398 
10399       x_return_status := FND_API.G_RET_STS_ERROR;
10400       RETURN;
10401     END IF;
10402     CS_ServiceRequest_UTIL.Validate_Product
10403       ( p_api_name          => p_api_name,
10404         p_parameter_name    => 'p_inventory_item_id',
10405         p_inventory_item_id => p_service_request_rec.inventory_item_id,
10406         p_inventory_org_id  => p_service_request_rec.inventory_org_id,
10407         x_return_status     => l_return_status,
10408         p_maintenance_flag  => p_maintenance_flag,
10409         p_maint_organization_id => p_service_request_rec.maint_organization_id,
10410         p_inv_org_master_org_flag => l_inv_org_master_org_flag
10411       );
10412     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10413       x_return_status := FND_API.G_RET_STS_ERROR;
10414       RETURN;
10415     END IF;
10416   END IF;
10417 
10418  /* For bug 3340433
10419     Moved validate_customer_product before other validations that
10420     uses inventory item id */
10421 
10422 
10423 
10424     p_inventory_item_id := p_service_request_rec.inventory_item_id;
10425 
10426     IF (p_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM)
10427      AND (p_sr_mode = 'CREATE') THEN
10428     IF ((p_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) OR
10429         (p_service_request_rec.inventory_org_id IS NULL)) THEN
10430 
10431       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
10432                      ( p_token_an    => p_api_name,
10433                        p_token_np    => 'p_inventory_org_id',
10434                        p_table_name  => G_TABLE_NAME,
10435                        p_column_name => 'INV_ORGANIZATION_ID');
10436 
10437       x_return_status := FND_API.G_RET_STS_ERROR;
10438       RETURN;
10439     END IF;
10440     IF p_service_request_rec.maint_organization_id = FND_API.G_MISS_NUM
10441     THEN
10442       l_maint_organization_id := NULL;
10443     ELSE
10444       l_maint_organization_id := p_service_request_rec.maint_organization_id;
10445     ENd IF;
10446     CS_ServiceRequest_UTIL.Validate_Customer_Product_id
10447         (p_customer_product_id => p_service_request_rec.customer_product_id,
10448         p_customer_id         => p_service_request_rec.customer_id,
10449         p_inventory_item_id   => p_inventory_item_id,
10450         p_inventory_org_id    => p_service_request_rec.inventory_org_id,
10451         p_maint_organization_id=> l_maint_organization_id,
10452         p_inv_org_master_org_flag => l_inv_org_master_org_flag,
10453         x_return_status       => l_return_status
10454       );
10455 
10456     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10457       x_return_status := FND_API.G_RET_STS_ERROR;
10458       RETURN;
10459     END IF;
10460 
10461     -- For bug 3340433
10462     IF (nvl(p_service_request_rec.inventory_item_id,-99) <> FND_API.G_MISS_NUM) then
10463 	      If (p_service_request_rec.inventory_item_id <> p_inventory_item_id) then
10464                      --Raise an ignore message;
10465 		      CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
10466 		             p_token_an	=>  p_api_name,
10467 		             p_token_ip	=>  'p_inventory_item_id' );
10468               End if;
10469     END IF;
10470 
10471   END IF;
10472 
10473   /* For bug 3340433
10474      Passing p_inventory_item_id intead of
10475      p_service_request_rec.inventory_item_id */
10476 
10477   -- if customer product is NULL then current serial can be free format. 3/25/05 smisra
10478   IF (p_service_request_rec.current_serial_number <> FND_API.G_MISS_CHAR) AND
10479      (p_service_request_rec.customer_product_id   <> FND_API.G_MISS_NUM)
10480      AND (p_sr_mode = 'CREATE') THEN
10481 
10482     CS_ServiceRequest_UTIL.Validate_Current_Serial
10483         ( p_api_name              => p_api_name,
10484 	  p_parameter_name        => 'p_current_serial_number',
10485           p_inventory_item_id     => p_inventory_item_id,
10486 	  p_inventory_org_id      => p_service_request_rec.inventory_org_id,
10487 	  p_customer_product_id   =>  p_service_request_rec.customer_product_id,
10488 	  p_customer_id           =>  p_service_request_rec.customer_id,
10489 	  p_current_serial_number => p_service_request_rec.current_serial_number,
10490 	  x_return_status         => l_return_status
10491 		  );
10492 	 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10493       	  x_return_status := FND_API.G_RET_STS_ERROR;
10494 	   RETURN;
10495       END IF;
10496   END IF;
10497 
10498 
10499 -- for cmro_eam
10500 
10501   IF p_service_request_rec.owning_dept_id <> FND_API.G_MISS_NUM AND
10502      p_sr_mode = 'CREATE'
10503   THEN
10504     CS_ServiceRequest_UTIL.Validate_Owning_department
10505     ( p_api_name         => p_api_name
10506     , p_parameter_name   => 'Owning Department'
10507     , p_inv_org_id       => p_service_request_rec.maint_organization_id
10508     , p_owning_dept_id   => p_service_request_rec.owning_dept_id
10509     , p_maintenance_flag => p_maintenance_flag
10510     , x_return_status    => l_return_status
10511     );
10512     IF l_return_status <> FND_API.G_RET_STS_SUCCESS
10513     THEN
10514       x_return_status := FND_API.G_RET_STS_ERROR;
10515       RETURN;
10516     END IF;
10517   END IF;
10518 
10519 -- end of cmro_eam
10520 
10521   IF (p_service_request_rec.problem_code <> FND_API.G_MISS_CHAR)
10522       AND (p_sr_mode = 'CREATE') THEN
10523 
10524     CS_ServiceRequest_UTIL.Validate_Problem_Code
10525       ( p_api_name          => p_api_name,
10526         p_parameter_name    => 'p_problem_code',
10527         p_problem_code      => p_service_request_rec.problem_code,
10528         p_incident_type_id  => p_service_request_rec.type_id,
10529         p_inventory_item_id => p_inventory_item_id,
10530 	p_inventory_org_id  => p_service_request_rec.inventory_org_id,
10531 	p_category_id       => p_service_request_rec.category_id,
10532         x_return_status     => l_return_status
10533       );
10534     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10535       x_return_status := FND_API.G_RET_STS_ERROR;
10536       RETURN;
10537     END IF;
10538   END IF;
10539 
10540 -----------Added for enhancement ---11.5.6----jngeorge-----07/20/01
10541 -----------Validation is required for Cust_Pref_Lang_Id,Comm_Pref_Code and
10542 -----------Category_Id.
10543 
10544   IF (p_service_request_rec.cust_pref_lang_code <> FND_API.G_MISS_CHAR) THEN
10545     CS_ServiceRequest_UTIL.Validate_Cust_Pref_Lang_Code
10546       ( p_api_name             => p_api_name,
10547         p_parameter_name       => 'p_cust_pref_lang_code',
10548         p_cust_pref_lang_code  => p_service_request_rec.cust_pref_lang_code,
10549         x_return_status        => l_return_status
10550       );
10551     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10552       x_return_status := FND_API.G_RET_STS_ERROR;
10553       RETURN;
10554     END IF;
10555   END IF;
10556 
10557   IF (p_service_request_rec.category_set_id <> FND_API.G_MISS_NUM)
10558      AND (p_sr_mode = 'CREATE') THEN
10559     CS_ServiceRequest_UTIL.Validate_Category_Set_Id
10560       ( p_api_name           => p_api_name,
10561         p_parameter_name     => 'p_category_set_id',
10562         p_category_id        => p_service_request_rec.category_id,
10563         p_category_set_id    => p_service_request_rec.category_set_id,
10564         p_inventory_item_id  => p_inventory_item_id,
10565 	p_inventory_org_id   => p_service_request_rec.inventory_org_id,
10566         x_return_status      => l_return_status
10567       );
10568     /* added inv org id parameter for Bug 2661668/2648017 */
10569     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10570       x_return_status := FND_API.G_RET_STS_ERROR;
10571       RETURN;
10572     END IF;
10573   END IF;
10574 
10575   IF (p_service_request_rec.external_reference <> FND_API.G_MISS_CHAR)
10576      AND (p_sr_mode = 'CREATE') THEN
10577      -- For bug 3746983
10578      CS_ServiceRequest_UTIL.Validate_External_Reference
10579         ( p_api_name             => p_api_name,
10580           p_parameter_name       => 'p_external_reference',
10581           p_external_reference   => p_service_request_rec.external_reference,
10582           p_customer_product_id  => p_service_request_rec.customer_product_id,
10583 	  p_inventory_item_id    => p_inventory_item_id,
10584 	  p_inventory_org_id     => p_service_request_rec.inventory_org_id,
10585 	  p_customer_id          => p_service_request_rec.customer_id,
10586           x_return_status        => l_return_status
10587         );
10588      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10589         x_return_status := FND_API.G_RET_STS_ERROR;
10590         RETURN;
10591      END IF;
10592   END IF;
10593 
10594   IF (p_service_request_rec.system_id <> FND_API.G_MISS_NUM) THEN
10595     CS_ServiceRequest_UTIL.Validate_System_Id
10596       ( p_api_name          => p_api_name,
10597         p_parameter_name    => 'p_system_id',
10598         p_system_id         => p_service_request_rec.system_id,
10599         x_return_status     => l_return_status
10600       );
10601     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10602       x_return_status := FND_API.G_RET_STS_ERROR;
10603       RETURN;
10604     END IF;
10605   END IF;
10606 
10607   IF (p_service_request_rec.comm_pref_code <> FND_API.G_MISS_CHAR) THEN
10608     CS_ServiceRequest_UTIL.Validate_Comm_Pref_Code
10609       ( p_api_name       => p_api_name,
10610         p_parameter_name => 'p_comm_pref_code',
10611         p_comm_pref_code  => p_service_request_rec.comm_pref_code,
10612         x_return_status  => l_return_status
10613       );
10614     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10615       x_return_status := FND_API.G_RET_STS_ERROR;
10616       RETURN;
10617     END IF;
10618   END IF;
10619 
10620   IF (p_service_request_rec.category_id <> FND_API.G_MISS_NUM AND
10621       (p_service_request_rec.category_set_id = FND_API.G_MISS_NUM OR
10622        p_service_request_rec.category_set_id IS NULL) )
10623 	  AND (p_sr_mode = 'CREATE')  THEN
10624     CS_ServiceRequest_UTIL.Validate_Category_Id
10625       ( p_api_name       => p_api_name,
10626         p_parameter_name => 'p_category_id',
10627         p_category_id    => p_service_request_rec.category_id,
10628         p_category_set_id=> p_service_request_rec.category_set_id,
10629         x_return_status  => l_return_status
10630       );
10631     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10632       x_return_status := FND_API.G_RET_STS_ERROR;
10633       RETURN;
10634     END IF;
10635   END IF;
10636 
10637   IF (p_service_request_rec.group_type <> FND_API.G_MISS_CHAR) THEN
10638     CS_ServiceRequest_UTIL.Validate_Group_Type
10639       ( p_api_name         => p_api_name,
10640         p_parameter_name   => 'p_group_type',
10641         p_group_type       => p_service_request_rec.group_type,
10642         --p_resource_type  => p_service_request_rec.resource_type,
10643         x_return_status    => l_return_status
10644       );
10645 
10646     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10647       x_return_status := FND_API.G_RET_STS_ERROR;
10648       RETURN;
10649     END IF;
10650   END IF;
10651 
10652   IF (p_service_request_rec.owner_group_id <> FND_API.G_MISS_NUM) THEN
10653     CS_ServiceRequest_UTIL.Validate_Group_Id
10654       ( p_api_name       => p_api_name,
10655         p_parameter_name => 'p_owner_group_id',
10656         p_group_type     => p_service_request_rec.group_type,
10657         p_owner_group_id => p_service_request_rec.owner_group_id,
10658         x_group_name     => x_group_name,
10659         x_return_status  => l_return_status
10660       );
10661 
10662     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10663       x_return_status := FND_API.G_RET_STS_ERROR;
10664       RETURN;
10665     END IF;
10666   END IF;
10667 
10668   IF (p_service_request_rec.exp_resolution_date <> FND_API.G_MISS_DATE) THEN
10669     CS_ServiceRequest_UTIL.Validate_Exp_Resolution_Date
10670       ( p_api_name            => p_api_name,
10671         p_parameter_name      => 'p_exp_resolution_date',
10672         p_exp_resolution_date => p_service_request_rec.exp_resolution_date,
10673         p_request_date        => p_request_date,
10674         x_return_status       => l_return_status
10675       );
10676     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10677       x_return_status := FND_API.G_RET_STS_ERROR;
10678       RETURN;
10679     END IF;
10680   END IF;
10681 
10682   -- IF FND_API.To_Boolean(p_service_request_rec.validate_bill_to_party) THEN
10683   -- Added one more parameter as customer_type to get the bill_to_customer_type
10684   -- which will be used in validate_bill_to_ship_to_ct
10685   -- Getting the value of l_customer_type from header caller_type
10686   -- done by shijain
10687 
10688      l_customer_type:= p_service_request_rec.caller_type;
10689 
10690   IF (p_service_request_rec.bill_to_party_id <> FND_API.G_MISS_NUM) THEN
10691     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Party
10692       ( p_api_name            => p_api_name,
10693         p_parameter_name      => 'Bill_To Party',
10694         p_bill_to_party_id    => p_service_request_rec.bill_to_party_id,
10695         p_customer_id         => p_service_request_rec.customer_id,
10696         x_customer_type       => l_customer_type,
10697         x_return_status       => l_return_status
10698       );
10699     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10700       x_return_status := FND_API.G_RET_STS_ERROR;
10701       RETURN;
10702     END IF;
10703   END IF;
10704 
10705 /******************************************************************
10706 Commented now but should be uncommented for 11.5.10
10707   IF (FND_API.To_Boolean(p_service_request_rec.validate_bill_to_site) OR
10708      (p_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM))  THEN
10709 
10710     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
10711       ( p_api_name            => p_api_name,
10712         p_parameter_name      => 'Bill_To Site ',
10713         p_bill_to_site_id     => p_service_request_rec.bill_to_site_id,
10714         p_bill_to_party_id    => p_service_request_rec.bill_to_party_id,
10715 	p_site_use_type	      => 'BILL_TO',
10716         x_site_use_id         => x_site_use_id,
10717         x_return_status       => l_return_status
10718       );
10719     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10720       x_return_status := FND_API.G_RET_STS_ERROR;
10721       RETURN;
10722     END IF;
10723   END IF;
10724 Commented now but should be uncommented for 11.5.10
10725 *****************************************************************/
10726 
10727     IF  (p_service_request_rec.bill_to_Contact_id <> FND_API.G_MISS_NUM)
10728 	  AND (p_sr_mode = 'CREATE') THEN
10729 	    CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Ct
10730 	      ( p_api_name            => p_api_name,
10731 		p_parameter_name      => 'Bill_To Contact',
10732 		p_bill_to_contact_id  => p_service_request_rec.bill_to_contact_id,
10733 		p_bill_to_party_id    => p_service_request_rec.bill_to_party_id ,
10734 		p_customer_type       => l_customer_type ,
10735 		x_return_status       => l_return_status
10736 	      );
10737 	    IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10738 	      x_return_status := FND_API.G_RET_STS_ERROR;
10739 	      RETURN;
10740 	    END IF;
10741      END IF;
10742 
10743   -- Validate the Ship_To_Party - Use the validate_bill_to_party procedure
10744   -- IF FND_API.To_Boolean(p_service_request_rec.validate_bill_to_party) THEN
10745   -- Added one more parameter as customer_type to get the bill_to_customer_type
10746   -- which will be used in validate_bill_to_ship_to_ct
10747   -- Getting the value of l_customer_type from header caller_type
10748   -- done by shijain
10749 
10750       l_customer_type:= p_service_request_rec.caller_type;
10751 
10752   IF (p_service_request_rec.ship_to_party_id <> FND_API.G_MISS_NUM) THEN
10753     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Party
10754       ( p_api_name            => p_api_name,
10755         p_parameter_name      => 'Ship_To Party',
10756         p_bill_to_party_id    => p_service_request_rec.ship_to_party_id,
10757         p_customer_id         => p_service_request_rec.customer_id,
10758         x_customer_type       => l_customer_type,
10759         x_return_status       => l_return_status
10760       );
10761     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10762       x_return_status := FND_API.G_RET_STS_ERROR;
10763       RETURN;
10764     END IF;
10765   END IF;
10766 
10767 /******************************************************************
10768 Should be uncommented for 115.10
10769   -- Validate the Ship_To_Site  - Use the validate_bill_to_site  procedure itself
10770 
10771   IF (FND_API.To_Boolean(p_service_request_rec.validate_ship_to_site) OR
10772      (p_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM)) THEN
10773 
10774     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
10775       ( p_api_name            => p_api_name,
10776         p_parameter_name      => 'Ship_To Site ',
10777         p_bill_to_site_id     => p_service_request_rec.ship_to_site_id,
10778         p_bill_to_party_id    => p_service_request_rec.ship_to_party_id,
10779 	p_site_use_type	      => 'SHIP_TO',
10780         x_site_use_id         => x_site_use_id,
10781         x_return_status       => l_return_status
10782       );
10783     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10784       x_return_status := FND_API.G_RET_STS_ERROR;
10785       RETURN;
10786     END IF;
10787   END IF;
10788 Should be uncommented for 11.5.10
10789 ********************************************************************/
10790 
10791   -- Validate the Ship_To_Contact  - Use the validate_bill_to_Contact  procedure itself
10792 
10793      IF  (p_service_request_rec.ship_to_Contact_id <> FND_API.G_MISS_NUM)
10794 	  AND (p_sr_mode = 'CREATE') THEN
10795 	    CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Ct
10796 	  (     p_api_name            => p_api_name,
10797 		p_parameter_name      => 'Ship_To Contact',
10798 		p_bill_to_contact_id  => p_service_request_rec.ship_to_contact_id,
10799 		p_bill_to_party_id    => p_service_request_rec.ship_to_party_id ,
10800 		p_customer_type       => l_customer_type ,
10801 		x_return_status       => l_return_status
10802 	      );
10803 	    IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10804 	      x_return_status := FND_API.G_RET_STS_ERROR;
10805 	      RETURN;
10806 	    END IF;
10807       END IF;
10808 
10809   --Code added to validate install site
10810   --IF FND_API.To_Boolean(p_service_request_rec.validate_install_site) THEN
10811   IF ( p_service_request_rec.install_site_id <> FND_API.G_MISS_NUM  AND
10812        p_service_request_rec.install_site_id IS NOT NULL)  THEN
10813         CS_ServiceRequest_UTIL.Validate_Install_Site (
10814                 p_parameter_name      => 'Install Site',
10815                 p_install_site_id     => p_service_request_rec.install_site_id,
10816                 p_customer_id         => l_customer_id,
10817                 x_return_status       => l_return_status
10818            );
10819     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10820       x_return_status := FND_API.G_RET_STS_ERROR;
10821       RETURN;
10822     END IF;
10823   END IF;
10824 
10825   IF ( p_service_request_rec.install_site_use_id <> FND_API.G_MISS_NUM AND
10826        p_service_request_rec.install_site_use_id IS NOT NULL)  THEN
10827          CS_ServiceRequest_UTIL.Validate_Install_Site (
10828                    p_parameter_name      => 'Install Site Use',
10829                    p_install_site_id     => p_service_request_rec.install_site_use_id,
10830                    p_customer_id         => l_customer_id,
10831                    x_return_status       => l_return_status
10832           );
10833     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10834       x_return_status := FND_API.G_RET_STS_ERROR;
10835       RETURN;
10836     END IF;
10837   END IF;
10838 
10839  IF (  ( p_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM  AND
10840          p_service_request_rec.ship_to_site_id IS NOT NULL ) AND
10841        ( p_service_request_rec.ship_to_site_use_id  <> FND_API.G_MISS_NUM AND
10842          p_service_request_rec.ship_to_site_use_id  IS NOT NULL ) AND
10843 	   ( p_sr_mode = 'CREATE') ) THEN
10844 
10845     CS_ServiceRequest_UTIL.Validate_Site_Site_Use
10846       ( p_api_name            => p_api_name,
10847         p_parameter_name      => 'Ship_To Site and/or Site Use ',
10848         p_site_id             => p_service_request_rec.ship_to_site_id,
10849         p_site_use_id         => p_service_request_rec.ship_to_site_use_id,
10850         p_party_id            => p_service_request_rec.ship_to_party_id,
10851         p_site_use_type       => 'SHIP_TO',
10852         x_return_status       => l_return_status
10853       );
10854     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10855       x_return_status := FND_API.G_RET_STS_ERROR;
10856       RETURN;
10857     END IF;
10858   ELSIF ( ( p_service_request_rec.ship_to_site_use_id <> FND_API.G_MISS_NUM AND
10859             p_service_request_rec.ship_to_site_use_id IS NOT NULL )  AND
10860           ( p_service_request_rec.ship_to_site_id IS NULL  OR
10861             p_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM ) AND
10862 		  ( p_sr_mode = 'CREATE') ) THEN
10863 
10864       CS_ServiceRequest_UTIL.Validate_Bill_Ship_Site_Use
10865       ( p_api_name            => p_api_name,
10866         p_parameter_name      => 'Ship_To Site Use ',
10867         p_site_use_id         => p_service_request_rec.ship_to_site_use_id,
10868         p_party_id            => p_service_request_rec.ship_to_party_id,
10869         p_site_use_type       => 'SHIP_TO',
10870         x_site_id             => x_ship_to_site_id,
10871         x_return_status       => l_return_status
10872        );
10873      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10874       x_return_status := FND_API.G_RET_STS_ERROR;
10875       RETURN;
10876     END IF;
10877   ELSIF ( ( p_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM AND
10878             p_service_request_rec.ship_to_site_id IS NOT NULL )  AND
10879           ( p_service_request_rec.ship_to_site_use_id IS NULL  OR
10880             p_service_request_rec.ship_to_site_use_id = FND_API.G_MISS_NUM ) AND
10881           ( p_sr_mode = 'CREATE') ) THEN
10882 
10883     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
10884       ( p_api_name            => p_api_name,
10885         p_parameter_name      => 'Ship_To Site ',
10886         p_bill_to_site_id     => p_service_request_rec.ship_to_site_id,
10887         p_bill_to_party_id    => p_service_request_rec.ship_to_party_id,
10888         p_site_use_type       => 'SHIP_TO',
10889         x_site_use_id         => x_ship_to_site_use_id,
10890         x_return_status       => l_return_status
10891       );
10892     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10893       x_return_status := FND_API.G_RET_STS_ERROR;
10894       RETURN;
10895     END IF;
10896   END IF;
10897 
10898 
10899  IF (  ( p_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM  AND
10900          p_service_request_rec.bill_to_site_id IS NOT NULL ) AND
10901        ( p_service_request_rec.bill_to_site_use_id  <> FND_API.G_MISS_NUM AND
10902          p_service_request_rec.bill_to_site_use_id  IS NOT NULL ) AND
10903        ( p_sr_mode = 'CREATE') ) THEN
10904 
10905     CS_ServiceRequest_UTIL.Validate_Site_Site_Use
10906       ( p_api_name            => p_api_name,
10907         p_parameter_name      => 'Bill_to Site and/or Site Use ',
10908         p_site_id             => p_service_request_rec.bill_to_site_id,
10909         p_site_use_id         => p_service_request_rec.bill_to_site_use_id,
10910         p_party_id            => p_service_request_rec.bill_to_party_id,
10911         p_site_use_type       => 'BILL_TO',
10912         x_return_status       => l_return_status
10913       );
10914     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10915       x_return_status := FND_API.G_RET_STS_ERROR;
10916       RETURN;
10917     END IF;
10918   ELSIF ( ( p_service_request_rec.bill_to_site_use_id <> FND_API.G_MISS_NUM AND
10919             p_service_request_rec.bill_to_site_use_id IS NOT NULL )  AND
10920           ( p_service_request_rec.bill_to_site_id IS NULL  OR
10921             p_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM ) AND
10922           ( p_sr_mode = 'CREATE') ) THEN
10923 
10924       CS_ServiceRequest_UTIL.Validate_Bill_Ship_Site_Use
10925       ( p_api_name            => p_api_name,
10926         p_parameter_name      => 'Bill_to Site Use ',
10927         p_site_use_id         => p_service_request_rec.bill_to_site_use_id,
10928         p_party_id            => p_service_request_rec.bill_to_party_id,
10929         p_site_use_type       => 'BILL_TO',
10930         x_site_id             => x_bill_to_site_id,
10931         x_return_status       => l_return_status
10932        );
10933      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10934       x_return_status := FND_API.G_RET_STS_ERROR;
10935       RETURN;
10936     END IF;
10937 
10938   ELSIF ( ( p_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM AND
10939             p_service_request_rec.bill_to_site_id IS NOT NULL )  AND
10940           ( p_service_request_rec.bill_to_site_use_id IS NULL  OR
10941             p_service_request_rec.bill_to_site_use_id = FND_API.G_MISS_NUM ) AND
10942           ( p_sr_mode = 'CREATE') ) THEN
10943     CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Site
10944       ( p_api_name            => p_api_name,
10945         p_parameter_name      => 'Bill_to Site ',
10946         p_bill_to_site_id     => p_service_request_rec.bill_to_site_id,
10947         p_bill_to_party_id    => p_service_request_rec.bill_to_party_id,
10948         p_site_use_type       => 'BILL_TO',
10949         x_site_use_id         => x_bill_to_site_use_id,
10950         x_return_status       => l_return_status
10951       );
10952     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10953       x_return_status := FND_API.G_RET_STS_ERROR;
10954       RETURN;
10955     END IF;
10956   END IF;
10957 
10958   IF (p_service_request_rec.resolution_code <> FND_API.G_MISS_CHAR)
10959      AND (p_sr_mode = 'CREATE')  THEN
10960 
10961      cs_servicerequest_util.resolution_code_cross_val (
10962         p_parameter_name          => 'p_resolution_code',
10963         p_resolution_code         => p_service_request_rec.resolution_code,
10964         p_problem_code            => p_service_request_rec.problem_code,
10965         p_incident_type_id        => p_service_request_rec.type_id,
10966         p_category_id             => p_service_request_rec.category_id,
10967         p_inventory_item_id       => p_inventory_item_id,
10968         p_inventory_org_id        => p_service_request_rec.inventory_org_id,
10969         x_return_status           => l_return_status  );
10970 
10971     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10972       x_return_status := FND_API.G_RET_STS_ERROR;
10973       RETURN;
10974     END IF;
10975   END IF;
10976 
10977   IF (p_service_request_rec.act_resolution_date <> FND_API.G_MISS_DATE) THEN
10978     CS_ServiceRequest_UTIL.Validate_Act_Resolution_Date
10979       ( p_api_name            => p_api_name,
10980         p_parameter_name      => 'p_act_resolution_date',
10981         p_act_resolution_date => p_service_request_rec.act_resolution_date,
10982         p_request_date        => p_request_date,
10983         x_return_status       => l_return_status
10984       );
10985     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
10986       x_return_status := FND_API.G_RET_STS_ERROR;
10987       RETURN;
10988     END IF;
10989   END IF;
10990 
10991   IF (p_service_request_rec.current_contact_time_diff <> FND_API.G_MISS_NUM) THEN
10992     IF ((p_service_request_rec.current_contact_time_diff < -24) OR
10993         (p_service_request_rec.current_contact_time_diff > 24)) THEN
10994 
10995       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
10996                    ( p_token_an    =>  'p_api_name',
10997                      p_token_v     =>  TO_CHAR(p_service_request_rec.current_contact_time_diff),
10998                      p_token_p     =>  'p_contact_time_diff',
10999                      p_table_name  => G_TABLE_NAME ,
11000                      p_column_name => 'CURRENT_CONTACT_TIME_DIFF');
11001 
11002       x_return_status := FND_API.G_RET_STS_ERROR;
11003       RETURN;
11004     END IF;
11005   END IF;
11006 
11007   IF (p_service_request_rec.rep_by_time_difference <> FND_API.G_MISS_NUM) THEN
11008     IF ((p_service_request_rec.rep_by_time_difference < -24) OR
11009         (p_service_request_rec.rep_by_time_difference > 24)) THEN
11010 
11011       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
11012                   ( p_token_an     =>  'p_api_name',
11013                     p_token_v      =>  TO_CHAR(p_service_request_rec.rep_by_time_difference),
11014                     p_token_p      =>  'p_represented_by_time_diff',
11015                     p_table_name   => G_TABLE_NAME ,
11016                     p_column_name  => 'REP_BY_TIME_DIFFERENCE' );
11017 
11018       x_return_status := FND_API.G_RET_STS_ERROR;
11019       RETURN;
11020     END IF;
11021   END IF;
11022 
11023     --
11024     -- Validate contract id 04/16/01
11025     --
11026     IF (p_service_request_rec.contract_id <> FND_API.G_MISS_NUM) AND
11027         (p_service_request_rec.contract_id IS NOT NULL) AND
11028         (p_service_request_rec.contract_service_id IS NULL OR
11029          p_service_request_rec.contract_service_id = FND_API.G_MISS_NUM) THEN
11030 
11031         CS_ServiceRequest_UTIL.Validate_Contract_Id(
11032           p_api_name         => p_api_name,
11033           p_parameter_name   => 'p_contract_id',
11034           p_contract_id      => p_service_request_rec.contract_id,
11035 	  x_contract_number  => p_contract_number,
11036           x_return_status    => l_return_status);
11037 
11038       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11039          x_return_status := FND_API.G_RET_STS_ERROR;
11040         RETURN;
11041       END IF;
11042 
11043       IF (p_service_request_rec.contract_id IS NOT NULL) AND
11044          (p_service_request_rec.contract_id <> FND_API.G_MISS_NUM) THEN
11045          p_contract_id := p_service_request_rec.contract_id;
11046       END IF;
11047     END IF;
11048 
11049 
11050 --04/16/01
11051     --
11052     -- Validate Account Id
11053     --
11054     IF (p_service_request_rec.account_id <> FND_API.G_MISS_NUM AND
11055         p_service_request_rec.account_id IS NOT NULL) THEN
11056 
11057        IF (p_service_request_rec.caller_type = 'ORGANIZATION') THEN
11058 
11059           --p_org_id           => p_org_id,
11060 
11061           CS_ServiceRequest_UTIL.Validate_Account_Id(
11062           p_api_name         => p_api_name,
11063           p_parameter_name   => 'p_account_id',
11064           p_account_id       => p_service_request_rec.account_id,
11065           p_customer_id      => p_service_request_rec.customer_id,
11066           x_return_status    => l_return_status);
11067 
11068          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11069               x_return_status := FND_API.G_RET_STS_ERROR;
11070              RETURN;
11071          END IF;
11072       ELSIF (p_service_request_rec.caller_type = 'PERSON') THEN
11073 
11074           CS_ServiceRequest_UTIL.Validate_Account_Id(
11075           p_api_name            => p_api_name,
11076           p_parameter_name      => 'p_account_id',
11077           p_account_id 		=> p_service_request_rec.account_id,
11078           p_customer_id         => p_service_request_rec.customer_id,
11079           x_return_status       => l_return_status);
11080 
11081           IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11082               x_return_status := FND_API.G_RET_STS_ERROR;
11083              RETURN;
11084           END IF;
11085      ELSE
11086            NULL;
11087      END IF;
11088   END IF;
11089 
11090     --
11091     -- Validate Platform Id
11092     --
11093 
11094     IF (p_service_request_rec.platform_id <> FND_API.G_MISS_NUM AND
11095         p_service_request_rec.platform_id IS NOT NULL) THEN
11096 
11097         CS_ServiceRequest_UTIL.Validate_Platform_Id(
11098           p_api_name               => p_api_name,
11099           p_parameter_name         => 'p_platform_id',
11100           p_platform_id            => p_service_request_rec.platform_id,
11101           p_organization_id        => p_service_request_rec.inv_platform_org_id,
11102           x_serial_controlled_flag => l_serial_controlled_flag,
11103           x_return_status          => l_return_status);
11104 
11105         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11106               x_return_status := FND_API.G_RET_STS_ERROR;
11107              RETURN;
11108        END IF;
11109    END IF;
11110 
11111    IF (NVL(l_serial_controlled_flag,'N') = 'Y' AND
11112        (p_service_request_rec.platform_version <> FND_API.G_MISS_CHAR AND
11113         p_service_request_rec.platform_version is NOT NULL)
11114       ) OR
11115       (
11116        p_service_request_rec.platform_version_id <> FND_API.G_MISS_NUM AND
11117        p_service_request_rec.platform_version_id is NOT NULL AND
11118        p_service_request_rec.platform_version <> FND_API.G_MISS_CHAR AND
11119        p_service_request_rec.platform_version is NOT NULL
11120       )THEN
11121        CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
11122                    ( p_token_an    => p_api_name,
11123                      p_token_v     => p_service_request_rec.platform_version,
11124                      p_token_p     => 'p_platform_version',
11125                      p_table_name  => G_TABLE_NAME ,
11126                      p_column_name => 'PLATFORM_VERSION');
11127 
11128        FND_MSG_PUB.Add;
11129        x_return_status := FND_API.G_RET_STS_ERROR;
11130        RETURN;
11131    END IF;
11132     --
11133     -- Validate Platform Version Id
11134     --
11135     IF (p_service_request_rec.platform_id <> FND_API.G_MISS_NUM AND
11136         p_service_request_rec.platform_id IS NOT NULL) AND
11137        (p_service_request_rec.platform_version_id <> FND_API.G_MISS_NUM AND
11138         p_service_request_rec.platform_version_id IS NOT NULL) THEN
11139 
11140         CS_ServiceRequest_UTIL.Validate_Platform_Version_Id(
11141           p_api_name             => p_api_name,
11142           p_parameter_name       => 'p_platform_Version_id',
11143           p_platform_id          => p_service_request_rec.platform_id,
11144           p_organization_id      => p_service_request_rec.inv_platform_org_id,
11145           p_platform_version_id  => p_service_request_rec.platform_Version_id,
11146           x_return_status        => l_return_status);
11147 
11148         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11149               x_return_status := FND_API.G_RET_STS_ERROR;
11150              RETURN;
11151        END IF;
11152    END IF;
11153 
11154 
11155 
11156    -- Validate Territory Id
11157    --
11158     IF (p_service_request_rec.territory_id <> FND_API.G_MISS_NUM AND
11159         p_service_request_rec.territory_id IS NOT NULL) THEN
11160 
11161           CS_ServiceRequest_UTIL.Validate_Territory_Id(
11162           p_api_name         => p_api_name,
11163           p_parameter_name   => 'p_territory_id',
11164           p_territory_id     => p_service_request_rec.territory_id,
11165           p_owner_id         => p_service_request_rec.owner_id,
11166           x_return_status    => l_return_status);
11167 
11168         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11169               x_return_status := FND_API.G_RET_STS_ERROR;
11170              RETURN;
11171         END IF;
11172     END IF;
11173 
11174    --Validate all the CP Fields only if customer_product_id is specified. If not, then
11175    --validate the Inv Fields.
11176 
11177    IF (p_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM AND
11178          p_service_request_rec.customer_product_id  IS NOT NULL) THEN
11179 
11180     IF (p_service_request_rec.cp_component_id <> FND_API.G_MISS_NUM AND
11181         p_service_request_rec.cp_component_id IS NOT NULL)
11182       AND (p_sr_mode = 'CREATE') THEN
11183 
11184         CS_ServiceRequest_UTIL.Validate_CP_Comp_Id(
11185           p_api_name             => p_api_name,
11186           p_parameter_name       => 'p_cp_component_id',
11187           p_cp_component_id      =>  p_service_request_rec.cp_component_id,
11188           p_customer_product_id  => p_service_request_rec.customer_product_id,
11189           p_org_id               => p_org_id,
11190           x_return_status        => l_return_status);
11191 
11192       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11193         x_return_status := FND_API.G_RET_STS_ERROR;
11194         RETURN;
11195       END IF;
11196 
11197       IF (p_service_request_rec.inv_component_id <> FND_API.G_MISS_NUM AND
11198         p_service_request_rec.inv_component_id IS NOT NULL) THEN
11199 
11200        CS_ServiceRequest_UTIL.INV_COMPONENT_CROSS_VAL (
11201          p_parameter_name       => 'Inventory component',
11202          p_cp_component_id      => p_service_request_rec.cp_component_id,
11203          p_inv_component_id     => p_service_request_rec.inv_component_id,
11204          x_return_status        => l_return_status );
11205 
11206       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11207          x_return_status := FND_API.G_RET_STS_ERROR;
11208          RETURN;
11209       END IF;
11210 
11211       END IF;
11212 
11213 
11214      END IF;
11215 
11216 
11217     --
11218     -- Validate Product Revision
11219     --
11220   x_product_revision := p_service_request_rec.product_revision;
11221     --IF (p_service_request_rec.product_revision <> FND_API.G_MISS_CHAR)
11222     IF (p_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM AND
11223         p_service_request_rec.customer_product_id IS NOT NULL)
11224       AND (p_sr_mode = 'CREATE') THEN
11225 
11226         CS_ServiceRequest_UTIL.Validate_Product_Version(
11227           p_parameter_name        => 'p_product_revision',
11228           p_product_version       =>  x_product_revision,
11229           p_instance_id           =>  p_service_request_rec.customer_product_id,
11230 	  p_inventory_org_id      =>  p_service_request_rec.inventory_org_id,
11231           x_return_status         =>  l_return_status);
11232         /***
11233         CS_ServiceRequest_UTIL.Validate_Product_Revision(
11234           p_api_name             => p_api_name,
11235           p_parameter_name       => 'p_product_revision',
11236           p_product_revision     =>  p_service_request_rec.product_revision,
11237           p_customer_product_id  => p_service_request_rec.customer_product_id,
11238           p_inventory_org_id     => p_service_request_rec.inventory_org_id,
11239           p_inventory_item_id    => p_inventory_item_id,
11240           x_return_status        => l_return_status);
11241         ******************************************/
11242 
11243       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11244         x_return_status := FND_API.G_RET_STS_ERROR;
11245         RETURN;
11246       END IF;
11247      END IF;
11248   -- END IF;
11249 
11250     --
11251     -- Validate CP Component Version
11252     --
11253   --IF (p_service_request_rec.component_version <> FND_API.G_MISS_CHAR AND
11254   --    p_service_request_rec.component_version IS NOT NULL)
11255   --  AND (p_sr_mode = 'CREATE') THEN
11256 
11257   --    -- For 3337848
11258   --    CS_ServiceRequest_UTIL.Validate_Component_Version(
11259   --      p_api_name              => p_api_name,
11260   --      p_parameter_name        => 'p_component_version',
11261   --      p_component_version     =>  p_service_request_rec.component_version,
11262   --      p_cp_component_id       => p_service_request_rec.cp_component_id,
11263   --      p_customer_product_id   => p_service_request_rec.customer_product_id,
11264   --      p_inventory_org_id      =>  p_service_request_rec.inventory_org_id,
11265   --      x_return_status         => l_return_status);
11266 
11267   --  IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11268   --    x_return_status := FND_API.G_RET_STS_ERROR;
11269   --    RETURN;
11270   --  END IF;
11271   -- END IF;
11272   x_component_version := p_service_request_rec.component_version;
11273     IF (p_service_request_rec.cp_component_id <> FND_API.G_MISS_NUM AND
11274         p_service_request_rec.cp_component_id IS NOT NULL)
11275       AND (p_sr_mode = 'CREATE') THEN
11276 
11277         -- For 3337848
11278         CS_ServiceRequest_UTIL.Validate_Product_Version(
11279           p_parameter_name        => 'p_component_version',
11280           p_product_version       =>  x_component_version,
11281           p_instance_id           =>  p_service_request_rec.cp_component_id,
11282 	  p_inventory_org_id      =>  p_service_request_rec.inventory_org_id,
11283           x_return_status         =>  l_return_status);
11284 
11285       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11286         x_return_status := FND_API.G_RET_STS_ERROR;
11287         RETURN;
11288       END IF;
11289     END IF;
11290 
11291     -- Validate CP Sub Component Id
11292     --
11293     IF (p_service_request_rec.cp_subcomponent_id <> FND_API.G_MISS_NUM AND
11294         p_service_request_rec.cp_subcomponent_id IS NOT NULL)
11295       AND (p_sr_mode = 'CREATE') THEN
11296 
11297        CS_ServiceRequest_UTIL.Validate_CP_SubComp_Id(
11298           p_api_name               => p_api_name,
11299           p_parameter_name         => 'p_cp_subcomponent_id',
11300           p_cp_subcomponent_id     => p_service_request_rec.cp_subcomponent_id,
11301           p_cp_component_id        => p_service_request_rec.cp_component_id,
11302           p_customer_product_id    => p_service_request_rec.customer_product_id,
11303           p_org_id                 => p_org_id,
11304           x_return_status          => l_return_status);
11305 
11306       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11307         x_return_status := FND_API.G_RET_STS_ERROR;
11308         RETURN;
11309       END IF;
11310 
11311       -- For bug 3324210
11312       IF (p_service_request_rec.inv_subcomponent_id <> FND_API.G_MISS_NUM AND
11313         p_service_request_rec.inv_subcomponent_id IS NOT NULL) THEN
11314 
11315          CS_ServiceRequest_UTIL.INV_SUBCOMPONENT_CROSS_VAL (
11316          p_parameter_name       => 'inv subcomponent',
11317          p_inv_subcomponent_id  => p_service_request_rec.inv_subcomponent_id,
11318          p_cp_subcomponent_id   => p_service_request_rec.cp_subcomponent_id,
11319          x_return_status        => l_return_status );
11320 
11321 
11322       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11323         x_return_status := FND_API.G_RET_STS_ERROR;
11324         RETURN;
11325       END IF;
11326 
11327       END IF;
11328      END IF ;
11329 
11330 
11331     --
11332     -- Validate CP Subcomponent Version
11333     --
11334   --IF (p_service_request_rec.subcomponent_version <> FND_API.G_MISS_CHAR AND
11335   --    p_service_request_rec.subcomponent_version IS NOT NULL)
11336   --  AND (p_sr_mode = 'CREATE') THEN
11337 
11338        -- For bug 3337848
11339   --    CS_ServiceRequest_UTIL.Validate_Subcomponent_Version(
11340   --      p_api_name                 => p_api_name,
11341   --      p_parameter_name           => 'p_subcomponent_version',
11342   --      p_subcomponent_version     =>  p_service_request_rec.subcomponent_version,
11343   --      p_cp_component_id          => p_service_request_rec.cp_component_id,
11344   --      p_cp_subcomponent_id       => p_service_request_rec.cp_subcomponent_id,
11345   --      p_customer_product_id      => p_service_request_rec.customer_product_id,
11346   --      p_inventory_org_id         =>  p_service_request_rec.inventory_org_id,
11347   --      x_return_status            => l_return_status);
11348 
11349   --  IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11350   --    x_return_status := FND_API.G_RET_STS_ERROR;
11351   --    RETURN;
11352   --  END IF;
11353 
11354   --END IF;
11355   --END IF;
11356     x_subcomponent_version := p_service_request_rec.subcomponent_version;
11357     IF (p_service_request_rec.cp_subcomponent_id <> FND_API.G_MISS_NUM AND
11358         p_service_request_rec.cp_subcomponent_id IS NOT NULL)
11359       AND (p_sr_mode = 'CREATE') THEN
11360 
11361        -- For bug 3337848
11362         CS_ServiceRequest_UTIL.Validate_Product_Version(
11363           p_parameter_name      => 'p_subcomponent_version',
11364           p_product_version     =>  x_subcomponent_version,
11365           p_instance_id         => p_service_request_rec.cp_subcomponent_id,
11366 	  p_inventory_org_id    =>  p_service_request_rec.inventory_org_id,
11367           x_return_status       => l_return_status);
11368 
11369       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11370         x_return_status := FND_API.G_RET_STS_ERROR;
11371         RETURN;
11372       END IF;
11373 
11374     END IF;
11375 -----------------------------------
11376 
11377   ELSE
11378     -- customer_product_id is not specified, so validate the INV fields
11379 
11380     -- Validate INV ITEM REVISION
11381     --
11382     IF (p_service_request_rec.inv_item_revision <> FND_API.G_MISS_CHAR )
11383 	    AND (p_sr_mode = 'CREATE') THEN
11384 
11385         CS_ServiceRequest_UTIL.Validate_Inv_Item_Rev(
11386           p_api_name           => p_api_name,
11387           p_parameter_name     => 'p_inv_item_revision',
11388           p_inv_item_revision  => p_service_request_rec.inv_item_revision,
11389           p_inventory_item_id  => p_inventory_item_id,
11390           p_inventory_org_id   => p_service_request_rec.inventory_org_id,
11391           x_return_status      => l_return_status );
11392 
11393       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11394         x_return_status := FND_API.G_RET_STS_ERROR;
11395         RETURN;
11396       END IF;
11397     END IF;
11398 
11399     ---- Validate INV COMP ID
11400     --
11401 
11402     IF (p_service_request_rec.inv_component_id <> FND_API.G_MISS_NUM AND
11403         p_service_request_rec.inv_component_id IS NOT NULL)
11404         AND (p_sr_mode = 'CREATE') THEN
11405 
11406         CS_ServiceRequest_UTIL.Validate_Inv_Comp_Id(
11407           p_api_name          => p_api_name,
11408           p_parameter_name    => 'p_inv_component_id',
11409           p_inventory_org_id  => p_service_request_rec.inventory_org_id,
11410           p_inv_component_id  => p_service_request_rec.inv_component_id,
11411           p_inventory_item_id => p_inventory_item_id,
11412           x_return_status     => l_return_status );
11413 
11414       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11415         x_return_status := FND_API.G_RET_STS_ERROR;
11416         RETURN;
11417       END IF;
11418     END IF;
11419 
11420     -- Validate INV COMP VER
11421     --
11422     IF (p_service_request_rec.inv_component_version <> FND_API.G_MISS_CHAR AND
11423         p_service_request_rec.inv_component_version  IS NOT NULL)
11424       AND (p_sr_mode = 'CREATE') THEN
11425 
11426         CS_ServiceRequest_UTIL.Validate_Inv_Comp_Ver(
11427           p_api_name                => p_api_name,
11428           p_parameter_name          => 'p_inv_component_version',
11429           p_inventory_org_id        => p_service_request_rec.inventory_org_id,
11430           p_inv_component_id        => p_service_request_rec.inv_component_id,
11431           p_inv_component_version   => p_service_request_rec.inv_component_version,
11432           x_return_status           => l_return_status );
11433 
11434       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11435         x_return_status := FND_API.G_RET_STS_ERROR;
11436         RETURN;
11437       END IF;
11438     END IF;
11439 
11440 
11441     -- Validate INV SUBCOMP ID
11442     --
11443     IF (p_sr_mode = 'CREATE' AND
11444         p_service_request_rec.inv_subcomponent_id <> FND_API.G_MISS_NUM AND
11445         p_service_request_rec.inv_subcomponent_id IS NOT NULL) THEN
11446 
11447         CS_ServiceRequest_UTIL.Validate_Inv_SubComp_Id(
11448           p_api_name            => p_api_name,
11449           p_parameter_name      => 'p_inv_subcomponent_id',
11450           p_inventory_org_id    => p_service_request_rec.inventory_org_id,
11451           p_inv_subcomponent_id => p_service_request_rec.inv_subcomponent_id,
11452           p_inv_component_id    =>p_service_request_rec.inv_component_id,
11453           x_return_status       => l_return_status );
11454 
11455       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11456         x_return_status := FND_API.G_RET_STS_ERROR;
11457         RETURN;
11458       END IF;
11459 
11460     END IF;
11461 
11462     -- Validate INV SUBCOMP VER
11463     --
11464     IF (p_service_request_rec.inv_subcomponent_version <> FND_API.G_MISS_CHAR AND
11465         p_service_request_rec.inv_subcomponent_version IS NOT NULL)
11466       AND (p_sr_mode = 'CREATE') THEN
11467 
11468         CS_ServiceRequest_UTIL.Validate_Inv_SubComp_Ver(
11469           p_api_name                 => p_api_name,
11470           p_parameter_name           => 'p_inv_subcomponent_version',
11471           p_inventory_org_id         => p_service_request_rec.inventory_org_id,
11472           p_inv_subcomponent_id      =>p_service_request_rec.inv_subcomponent_id,
11473           p_inv_subcomponent_version => p_service_request_rec.inv_subcomponent_version,
11474           x_return_status            => l_return_status );
11475 
11476       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11477         x_return_status := FND_API.G_RET_STS_ERROR;
11478         RETURN;
11479       END IF;
11480     END IF;
11481 
11482   END IF;  /* IF customer_product_id is specified condition*/
11483 
11484   -- Added for Enh# 1830701
11485   -- Validate INC REPORTED DATE
11486   --
11487   IF (p_request_date <> FND_API.G_MISS_DATE AND
11488       p_request_date IS NOT NULL) AND
11489      (p_service_request_rec.incident_occurred_date <> FND_API.G_MISS_DATE AND
11490       p_service_request_rec.incident_occurred_date IS NOT NULL) THEN
11491 
11492       CS_ServiceRequest_UTIL.Validate_Inc_Reported_Date(
11493         p_api_name                 => p_api_name,
11494         p_parameter_name           => 'p_incident_date',
11495         p_request_date             => p_request_date,
11496         p_inc_occurred_date        => p_service_request_rec.incident_occurred_date,
11497         x_return_status            => l_return_status );
11498 
11499     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11500       x_return_status := FND_API.G_RET_STS_ERROR;
11501       RETURN;
11502     END IF;
11503   END IF;
11504 
11505   -- Validate INC OCCURRED DATE
11506   --
11507   IF (p_service_request_rec.incident_occurred_date <> FND_API.G_MISS_DATE AND
11508       p_service_request_rec.incident_occurred_date IS NOT NULL) AND
11509      (p_request_date <> FND_API.G_MISS_DATE AND
11510       p_request_date IS NOT NULL) THEN
11511 
11512       CS_ServiceRequest_UTIL.Validate_Inc_Occurred_Date(
11513         p_api_name                 => p_api_name,
11514         p_parameter_name           => 'p_incident_occurred_date',
11515         p_inc_occurred_date        => p_service_request_rec.incident_occurred_date,
11516         p_request_date             => p_request_date,
11517         x_return_status            => l_return_status );
11518 
11519     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11520       x_return_status := FND_API.G_RET_STS_ERROR;
11521       RETURN;
11522     END IF;
11523   END IF;
11524 
11525   -- Validate INC RESOLVED DATE
11526   --
11527   IF (p_service_request_rec.incident_resolved_date <> FND_API.G_MISS_DATE AND
11528       p_service_request_rec.incident_resolved_date IS NOT NULL) THEN
11529 
11530       CS_ServiceRequest_UTIL.Validate_Inc_Resolved_Date(
11531         p_api_name                 => p_api_name,
11532         p_parameter_name           => 'p_incident_resolved_date',
11533         p_inc_resolved_date        => p_service_request_rec.incident_resolved_date,
11534         p_request_date             => p_request_date,
11535         x_return_status            => l_return_status );
11536 
11537     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11538       x_return_status := FND_API.G_RET_STS_ERROR;
11539       RETURN;
11540     END IF;
11541   END IF;
11542 
11543   -- Validate INC RESPONDED BY DATE
11544   --
11545   IF (p_service_request_rec.inc_responded_by_date <> FND_API.G_MISS_DATE AND
11546       p_service_request_rec.inc_responded_by_date IS NOT NULL) THEN
11547 
11548       CS_ServiceRequest_UTIL.Validate_Inc_Responded_Date(
11549         p_api_name                 => p_api_name,
11550         p_parameter_name           => 'p_inc_responded_by_date',
11551         p_inc_responded_by_date    => p_service_request_rec.inc_responded_by_date,
11552         p_request_date             => p_request_date,
11553         x_return_status            => l_return_status );
11554 
11555     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11556       x_return_status := FND_API.G_RET_STS_ERROR;
11557       RETURN;
11558     END IF;
11559   END IF;
11560 
11561   -- Added for Enh# 222054
11562   -- Validate INCIDENT LOCATION ID
11563   -- KP Incident Locaton should be valid for the customer product, if it's passed.
11564   --  9/19 changes
11565 
11566   /* Bug 4386870 smisra 12/13/05
11567   this code is moved to vldt_sr_rec procedure
11568   IF (p_service_request_rec.incident_location_id <> FND_API.G_MISS_NUM AND
11569       p_service_request_rec.incident_location_id IS NOT NULL)
11570        THEN
11571         CS_ServiceRequest_UTIL.Validate_Inc_Location_Id(
11572          p_api_name                 => p_api_name,
11573          p_parameter_name           => 'p_incident_location_id',
11574          p_incident_location_type   => p_service_request_rec.incident_location_type,
11575          p_incident_location_id     => p_service_request_rec.incident_location_id,
11576          x_return_status            => l_return_status );
11577 
11578     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11579       x_return_status := FND_API.G_RET_STS_ERROR;
11580       RETURN;
11581     END IF;
11582   END IF;
11583   */
11584 
11585   -- Validate INCIDENT COUNTRY
11586   --
11587   IF (p_service_request_rec.incident_country <> FND_API.G_MISS_CHAR AND
11588       p_service_request_rec.incident_country IS NOT NULL) THEN
11589 
11590       CS_ServiceRequest_UTIL.Validate_Incident_Country(
11591         p_api_name                 => p_api_name,
11592         p_parameter_name           => 'p_incident_country',
11593         p_incident_country         => p_service_request_rec.incident_country,
11594         x_return_status            => l_return_status );
11595 
11596     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11597       x_return_status := FND_API.G_RET_STS_ERROR;
11598       RETURN;
11599     END IF;
11600   END IF;
11601 
11602   -- Added For ER# 2433831
11603   -- Validate Bill To Account
11604 
11605   IF (p_service_request_rec.bill_to_account_id <> FND_API.G_MISS_NUM AND
11606       p_service_request_rec.bill_to_account_id IS NOT NULL)
11607 	  AND (p_sr_mode = 'CREATE') THEN
11608 
11609       CS_ServiceRequest_UTIL.Validate_Bill_To_Ship_To_Acct
11610            ( p_api_name            => p_api_name,
11611              p_parameter_name      => 'Bill_To Account',
11612              p_account_id  	   => p_service_request_rec.bill_to_account_id,
11613              p_party_id    	   => p_service_request_rec.bill_to_party_id,
11614              x_return_status       => l_return_status);
11615 
11616       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11617          x_return_status := FND_API.G_RET_STS_ERROR;
11618          RETURN;
11619       END IF ;
11620    END IF ;
11621 
11622   -- Added For ER# 2433831
11623   -- Validate Ship To Account
11624 
11625   -- Use the Same Procedure bill_to_account_id
11626   IF (p_service_request_rec.ship_to_account_id <> FND_API.G_MISS_NUM AND
11627       p_service_request_rec.ship_to_account_id IS NOT NULL)
11628 	  AND (p_sr_mode = 'CREATE') THEN
11629 
11630       CS_ServiceRequest_UTIL.Validate_bill_To_Ship_To_Acct
11631            ( p_api_name            => p_api_name,
11632              p_parameter_name      => 'Ship_To Account',
11633              p_account_id  	   => p_service_request_rec.ship_to_account_id,
11634              p_party_id 	   => p_service_request_rec.ship_to_party_id,
11635              x_return_status       => l_return_status);
11636 
11637       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11638          x_return_status := FND_API.G_RET_STS_ERROR;
11639          RETURN;
11640       END IF ;
11641    END IF ;
11642 
11643   -- Added for ER# 2463321
11644   -- Validate Customer's Non Primary Phone Id
11645 
11646   IF (p_service_request_rec.customer_phone_id <> FND_API.G_MISS_NUM AND
11647       p_service_request_rec.customer_phone_id IS NOT NULL ) THEN
11648 
11649          CS_ServiceRequest_UTIL.Validate_Per_Contact_Point_Id
11650                 ( p_api_name           => p_api_name,
11651                   p_parameter_name     => 'p_contact_point_id',
11652                   p_contact_point_type => 'PHONE',
11653                   p_contact_point_id   => p_service_request_rec.customer_phone_id,
11654                   p_party_id           => l_customer_id ,
11655                   x_return_status      => l_return_status );
11656 
11657       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11658          x_return_status := FND_API.G_RET_STS_ERROR;
11659          RETURN;
11660       END IF ;
11661 
11662   END IF ;
11663 
11664   -- Added for ER# 2463321
11665   -- Validate Customer's Non Primary Email Id
11666 
11667   IF (p_service_request_rec.customer_email_id <> FND_API.G_MISS_NUM AND
11668       p_service_request_rec.customer_email_id IS NOT NULL ) THEN
11669 
11670          CS_ServiceRequest_UTIL.Validate_Per_Contact_Point_Id
11671                 ( p_api_name           => p_api_name,
11672                   p_parameter_name     => 'p_contact_point_id',
11673                   p_contact_point_type => 'EMAIL',
11674                   p_contact_point_id   => p_service_request_rec.customer_email_id,
11675                   p_party_id           => l_customer_id ,
11676                   x_return_status      => l_return_status );
11677 
11678       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11679          x_return_status := FND_API.G_RET_STS_ERROR;
11680          RETURN;
11681       END IF ;
11682 
11683   END IF ;
11684 
11685    -- 15995804 Validate Price List Header Id
11686   IF (p_service_request_rec.price_list_header_id <> FND_API.G_MISS_NUM AND
11687       p_service_request_rec.price_list_header_id IS NOT NULL ) THEN
11688 
11689          CS_ServiceRequest_UTIL.VALIDATE_PRICE_LIST_HEADER
11690                 ( p_api_name             => p_api_name,
11691                   p_parameter_name       => 'p_price_list_header_id',
11692                   p_price_list_header_id => p_service_request_rec.price_list_header_id,
11693                   p_org_id               => p_org_id,
11694                   x_return_status      => l_return_status );
11695       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
11696          x_return_status := FND_API.G_RET_STS_ERROR;
11697          RETURN;
11698       END IF ;
11699 
11700   END IF;
11701 
11702 END Validate_ServiceRequest_Record;
11703 
11704 -- -----------------------------------------------------------------------------
11705 -- Modification History
11706 -- Date     Name      Desc
11707 -- -------- --------- ----------------------------------------------------------
11708 -- 02/28/05 smisra    Bug 4083288 Defaulted category_set_id if it is not
11709 --                    passed and category id is passed.
11710 -- 05/05/05 smisra    Rel 12 changes. Replaced validation of p_org_id based on
11711 --                    profile 'ORG_ID' with new validation based on
11712 --                    hr_all_operating_units.
11713 --                    copied maint_organization_id col to validation record.
11714 -- 05/13/05 smisra    Removed the code that set customer product related
11715 --                    parameters to null for EAM SRs
11716 -- 05/27/05 smisra    Bug 4227769
11717 --                    removed the code that sets obsolete col group_owner and
11718 --                    owner (_tl table columns)
11719 -- 07/15/05 smisra    Bug 4489746
11720 --                    removed start and end active dates from query on
11721 --                    cs_incident_types. Validate type will take care of
11722 --                    date effectivity check.
11723 -- 07/15/05 smisra    Bug 4398562
11724 --                    moved the code that sets group_type and
11725 --                    change_group_type_flag after call to SR auto assignment
11726 -- 07/15/05 smisra    Bug 3875584
11727 --                    passed p_mode='CREATE' to validate_owner procedure. This
11728 --                    of p_mode will force validate_owner procedure to give
11729 --                    warning in case of invalid owner.
11730 -- 07/21/05 smisra    moved the  code that sets expected resolution and
11731 --                    obligation dates in audit record from this procedure
11732 --                    to create service request just before call to
11733 --                    create audit rec procedure.
11734 --                    This was needed because call to get contract may
11735 --                    set these dates.
11736 -- 11/16/05 smisra    Removed assignment of coverage_type to audit record
11737 --                    coverage type may be determined based on contract service
11738 --                    id in create service request procedure after call to
11739 --                    create_sr_validation. Now this assignment is done in
11740 --                    create_servicerequest just before the call to
11741 --                    create_audit.
11742 -- 12/14/05 smisra    set incident_country to null if incident_location_id is
11743 --                    passed
11744 --                    moved the code setting incident_country, inc_location_id
11745 --                    and incident_location_type attribute of audit record to
11746 --                    create_servicerequest just before call to create audit
11747 -- 12/23/05 smisra    bug 4894942
11748 --                    Removed call to Assignment manager API. now it is called
11749 --                    from vldt_sr_rec
11750 --                    Removed the code to set following audit record attribute
11751 --                    a. resource_type
11752 --                    b. group_type
11753 --                    c. incident_owner_id
11754 --                    d. group_owner_id
11755 --                    e. owner_assigned_time
11756 --                    f. territory_id
11757 --                    These attribute are now set in create_servicerequest
11758 --                    procedure just before the call to create audit
11759 -- 12/30/05 smisra    Bug 4773215, 4869065
11760 --                    Removed the call to validate resource id.
11761 --                    Now this validation will be performed from vldt_sr_rec
11762 --                    Moved the code to set site cols of audit record to
11763 --                    create_servicerequest procedure just before call to
11764 --                    create audit
11765 -- 04/18/06 spusegao  Modified to validate service_request_rec.created_by and
11766 --                    service_request_rec.last_updateD_by parameter values.
11767 -- 06/13/06 spusegao  Modified ver 120.36 to fix big 5278488
11768 --                     1. Modified Create_SR_Validation to default the publish_flag
11769 --                        to 'N' if not passed.
11770 -- 09/14/06 spusegao  Modified version 120.42 to comment out following code line
11771 --                     --l_service_request_val_rec.publish_flag    := l_service_request_rec.publish_flag;
11772 --                    For bug # 5517017.
11773 -- 04/24/07 romehrot Bug Fix : 5501340 Added the code to pass the system_id
11774 -- -----------------------------------------------------------------------------
11775 PROCEDURE Create_SR_Validation(
11776   p_api_name              IN      VARCHAR2,
11777   p_service_request_rec   IN      service_request_rec_type,
11778   p_contacts              IN      contacts_table,
11779   p_resp_id               IN      NUMBER     DEFAULT NULL,
11780   p_resp_appl_id          IN      NUMBER     DEFAULT NULL,
11781   p_user_id               IN      NUMBER,
11782   p_login_id              IN      NUMBER     DEFAULT NULL,
11783   p_org_id                IN      NUMBER     DEFAULT NULL,
11784   p_request_id            IN      NUMBER     DEFAULT NULL,
11785   p_request_number        IN      VARCHAR2   DEFAULT NULL,
11786   p_validation_level      IN      NUMBER     DEFAULT fnd_api.g_valid_level_full,
11787   p_commit                IN      VARCHAR2   DEFAULT fnd_api.g_false,
11788   x_msg_count             OUT     NOCOPY NUMBER,
11789   x_msg_data              OUT     NOCOPY VARCHAR2,
11790   x_return_status         OUT     NOCOPY VARCHAR2,
11791   x_contra_id             OUT     NOCOPY NUMBER,
11792   x_contract_number       OUT     NOCOPY VARCHAR2,
11793   x_owner_assigned_flag   OUT     NOCOPY VARCHAR2,
11794   x_req_id                OUT     NOCOPY NUMBER,
11795   x_request_id            OUT     NOCOPY NUMBER,
11796   x_req_num               OUT     NOCOPY VARCHAR2,
11797   x_request_number        OUT     NOCOPY VARCHAR2,
11798   x_autolaunch_wkf_flag   OUT     NOCOPY VARCHAR2,
11799   x_abort_wkf_close_flag  OUT     NOCOPY VARCHAR2,
11800   x_wkf_process_name      OUT     NOCOPY VARCHAR2,
11801   x_audit_vals_rec        OUT     NOCOPY sr_audit_rec_type,
11802   x_service_request_rec   OUT     NOCOPY service_request_rec_type,
11803   -- for cmro
11804   p_cmro_flag             IN     VARCHAR2,
11805   p_maintenance_flag      IN     VARCHAR2,
11806   p_auto_assign           IN     VARCHAR2 := 'N',
11807    --15995804. Add price_list_header_id
11808   p_price_list_header_id  IN     NUMBER
11809  ) AS
11810 
11811      l_api_name                   CONSTANT VARCHAR2(30)    := 'Create_SR_Validation';
11812      l_api_version                CONSTANT NUMBER          := 2.0;
11813      l_api_name_full              CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
11814      l_return_status              VARCHAR2(1);
11815      l_service_request_val_rec    Request_Validation_Rec_Type;
11816      l_service_request_rec        service_request_rec_type DEFAULT p_service_request_rec;
11817      --
11818      l_close_flag                 VARCHAR2(1);
11819      l_autolaunch_workflow_flag   VARCHAR2(1);
11820      l_abort_workflow_close_flag  VARCHAR2(1);
11821      l_workflow_process_name      VARCHAR2(30);
11822 
11823      l_workflow_process_id        NUMBER;
11824      l_contra_id                  NUMBER;
11825 
11826      l_cp_item_id                 NUMBER;
11827      l_inventory_org_id           NUMBER ;
11828 
11829      l_request_id                 NUMBER         := p_request_id;
11830      l_request_number             VARCHAR2(64)   := p_request_number;
11831      l_req_id                     NUMBER;
11832      l_req_num                    VARCHAR2(64);
11833      l_temp_id                    NUMBER;
11834      l_temp_num                   VARCHAR2(64);
11835      l_sysdate                    DATE           := SYSDATE;
11836 
11837      --
11838      l_note_index                 BINARY_INTEGER;
11839      l_note_id                    NUMBER;
11840      l_note_context_id            NUMBER;
11841      l_notes_detail               VARCHAR2(32767);
11842      l_contact_index              BINARY_INTEGER;
11843 
11844      l_jtf_note_id                NUMBER ;
11845 
11846      l_interaction_id             NUMBER;
11847      l_employee_name              VARCHAR2(240);
11848      l_bill_to_customer_id        NUMBER;
11849      l_bill_to_location_id        NUMBER;
11850      l_ship_to_customer_id        NUMBER;
11851      l_ship_to_location_id        NUMBER;
11852      l_install_customer_id        NUMBER;
11853      l_install_location_id        NUMBER;
11854 
11855      l_primary_contact_id         NUMBER  := NULL;
11856 
11857      l_bind_data_id               NUMBER;
11858 
11859      l_primary_contact_found      VARCHAR2(1) := 'N' ;
11860      l_contacts_passed            VARCHAR2(1) :=  'N';
11861      l_owner_assigned_flag        VARCHAR2(1) := 'N';
11862 
11863      l_disallow_request_update VARCHAR2(1);
11864      l_disallow_owner_update VARCHAR2(1);
11865      l_disallow_product_update VARCHAR2(1);
11866 
11867      -- For Workflow Hook
11868      l_workflow_item_key         NUMBER;
11869 
11870      l_test  NUMBER;
11871 
11872      l_org_id    NUMBER;
11873 
11874      l_profile_org_id   NUMBER  ;
11875 
11876      l_msg_id   NUMBER;
11877      l_msg_count    NUMBER;
11878      l_msg_data   VARCHAR2(2000);
11879      --Fixed bug#2802393, changed length from 40 to 2000
11880      l_uwq_body1 VARCHAR2(2000)   :=  'has been assigned to you on';
11881      l_uwq_body2 VARCHAR2(120)   :=  TO_CHAR(SYSDATE,'MM-DD-YYYY');
11882      l_uwq_body3 VARCHAR2(120)   :=  TO_CHAR(SYSDATE,'HH24:MI');
11883      --Fixed bug#2802393, changed length from 255 to 2500
11884      l_uwq_body  VARCHAR2(2500);
11885 
11886      l_contract_number   VARCHAR2(120) ;
11887      l_contract_id       NUMBER;
11888      l_group_name        VARCHAR2(60);
11889      l_owner_name        VARCHAR2(360);
11890      l_owner_id          jtf_rs_resource_extns.resource_id % TYPE;
11891      l_operation         VARCHAR2(300):='created';
11892      l_bill_to_site_id           NUMBER;
11893      l_ship_to_site_id           NUMBER;
11894      l_bill_to_site_use_id       NUMBER;
11895      l_ship_to_site_use_id       NUMBER;
11896      l_auto_assign_level fnd_profile_option_values.profile_option_value % type;
11897      l_asgn_owner_id     cs_incidents_all_b.incident_owner_id % type;
11898      l_asgn_group_id     cs_incidents_all_b.owner_group_id    % type;
11899      l_asgn_owner_type   cs_incidents_all_b.resource_type     % type;
11900      l_territory_id      number;
11901      l_orig_group_type_null varchar2(1) := 'N';
11902      l_responded_flag    cs_incident_statuses_b.responded_flag % type;
11903      l_resolved_flag     cs_incident_statuses_b.resolved_flag  % type;
11904 BEGIN
11905 
11906   -- Initialize the New Auit Record
11907   Initialize_audit_rec(
11908   p_sr_audit_record         =>           x_audit_vals_rec) ;
11909 
11910   --
11911   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #1');
11912 
11913   -- Check if the mandatory parameters are specified. If not, return error.
11914 
11915   IF (l_service_request_rec.type_id = FND_API.G_MISS_NUM  OR
11916       l_service_request_rec.type_id  IS NULL) THEN
11917 
11918       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
11919                         (p_token_an    => l_api_name_full,
11920                          p_token_np    => 'SR Type',
11921                          p_table_name  => G_TABLE_NAME,
11922                          p_column_name => 'INCIDENT_TYPE_ID');
11923 
11924       RAISE FND_API.G_EXC_ERROR;
11925   END IF;
11926 
11927 
11928   IF (l_service_request_rec.status_id = FND_API.G_MISS_NUM  OR
11929       l_service_request_rec.status_id  IS NULL) THEN
11930 
11931       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
11932                         (p_token_an    => l_api_name_full,
11933                          p_token_np    => 'SR Status',
11934                          p_table_name  => G_TABLE_NAME,
11935                          p_column_name => 'INCIDENT_STATUS_ID');
11936 
11937       RAISE FND_API.G_EXC_ERROR;
11938   END IF;
11939 
11940 
11941   IF (l_service_request_rec.severity_id = FND_API.G_MISS_NUM  OR
11942       l_service_request_rec.severity_id  IS NULL) THEN
11943 
11944       CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
11945                         (p_token_an    => l_api_name_full,
11946                          p_token_np    => 'SR Severity',
11947                          p_table_name  => G_TABLE_NAME,
11948                          p_column_name => 'SEVERITY_ID');
11949 
11950       RAISE FND_API.G_EXC_ERROR;
11951   END IF;
11952 
11953   -- Request Date is a reqd field, so check if passed, else return error
11954   IF (l_service_request_rec.request_date = FND_API.G_MISS_DATE OR
11955     l_service_request_rec.request_date IS NULL) THEN
11956 
11957     CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
11958                       (p_token_an    => l_api_name_full,
11959                        p_token_np    => 'SR Request Date',
11960                        p_table_name  => G_TABLE_NAME,
11961                        p_column_name => 'REQUEST_DATE');
11962 
11963     RAISE FND_API.G_EXC_ERROR;
11964   END IF;
11965 
11966   -- Summary is a reqd field, so check if passed, else return error
11967   IF (l_service_request_rec.summary = FND_API.G_MISS_CHAR OR
11968       l_service_request_rec.summary IS NULL) THEN
11969 
11970     CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
11971                       (p_token_an    => l_api_name_full,
11972                        p_token_np    => 'SR Summary',
11973                        p_table_name  => G_TABLE_NAME,
11974                        p_column_name => 'SUMMARY');
11975 
11976     RAISE FND_API.G_EXC_ERROR;
11977   END IF;
11978 
11979 -- for cmro_eam
11980 
11981    IF (p_maintenance_flag = 'Y' OR p_maintenance_flag = 'y') THEN
11982         IF (l_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) THEN
11983                 CS_ServiceRequest_UTIL.Add_Missing_Param_Msg(l_api_name_full, 'Inventory Org ID');
11984                 RAISE FND_API.G_EXC_ERROR;
11985         ELSIF (l_service_request_rec.inventory_org_id IS NULL) THEN
11986                 CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'Inventory Org ID');
11987                 RAISE FND_API.G_EXC_ERROR;
11988         END IF;
11989    END IF;
11990    -- end of cmro_eam
11991 
11992   -- Added all the 8 checks for bug#2800884
11993   -- bill_to_party_id is a reqd field if bill_to_account_id
11994   -- is passed, so check if passed, else return error
11995   IF ((l_service_request_rec.bill_to_account_id <> FND_API.G_MISS_NUM AND
11996       l_service_request_rec.bill_to_account_id IS NOT NULL))
11997   THEN
11998      IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM OR
11999          l_service_request_rec.bill_to_party_id IS NULL) THEN
12000 
12001                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12002                   fnd_message.set_token ('CHILD_PARAM','bill_to_account_id');
12003                   fnd_message.set_token ('PARENT_PARAM','bill_to_party_id');
12004                   fnd_msg_pub.ADD;
12005 
12006                   RAISE FND_API.G_EXC_ERROR;
12007      END IF;
12008   END IF;
12009 
12010   -- bill_to_party_id is a reqd field if bill_to_contact_id is passed,so check
12011   -- if passed, else return error
12012   IF ((l_service_request_rec.bill_to_contact_id <> FND_API.G_MISS_NUM AND
12013       l_service_request_rec.bill_to_contact_id IS NOT NULL))
12014   THEN
12015      IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM OR
12016          l_service_request_rec.bill_to_party_id IS NULL) THEN
12017 
12018                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12019                   fnd_message.set_token ('CHILD_PARAM','bill_to_contact_id');
12020                   fnd_message.set_token ('PARENT_PARAM','bill_to_party_id');
12021                   fnd_msg_pub.ADD;
12022 
12023                   RAISE FND_API.G_EXC_ERROR;
12024      END IF;
12025   END IF;
12026 
12027   -- bill_to_party_id is a reqd field if bill_to_site_id is passed, so check
12028   -- if passed, else return error
12029   IF ((l_service_request_rec.bill_to_site_id <> FND_API.G_MISS_NUM AND
12030       l_service_request_rec.bill_to_site_id IS NOT NULL))
12031   THEN
12032      IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM OR
12033          l_service_request_rec.bill_to_party_id IS NULL) THEN
12034 
12035                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12036                   fnd_message.set_token ('CHILD_PARAM','bill_to_site_id');
12037                   fnd_message.set_token ('PARENT_PARAM','bill_to_party_id');
12038                   fnd_msg_pub.ADD;
12039 
12040                   RAISE FND_API.G_EXC_ERROR;
12041      END IF;
12042   END IF;
12043 
12044   -- bill_to_party_id is a reqd field if bill_to_site_use_id is passed,
12045   -- so check if passed, else return error
12046   IF ((l_service_request_rec.bill_to_site_use_id <> FND_API.G_MISS_NUM AND
12047       l_service_request_rec.bill_to_site_use_id IS NOT NULL))
12048   THEN
12049      IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM OR
12050          l_service_request_rec.bill_to_party_id IS NULL) THEN
12051 
12052                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12053                   fnd_message.set_token ('CHILD_PARAM','bill_to_site_use_id');
12054                   fnd_message.set_token ('PARENT_PARAM','bill_to_party_id');
12055                   fnd_msg_pub.ADD;
12056 
12057                   RAISE FND_API.G_EXC_ERROR;
12058      END IF;
12059   END IF;
12060 
12061   -- ship_to_party_id is a reqd field if ship_to_account_id
12062   -- is passed, so check if passed, else return error
12063   IF ((l_service_request_rec.ship_to_account_id <> FND_API.G_MISS_NUM AND
12064       l_service_request_rec.ship_to_account_id IS NOT NULL))
12065   THEN
12066      IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM OR
12067          l_service_request_rec.ship_to_party_id IS NULL) THEN
12068 
12069                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12070                   fnd_message.set_token ('CHILD_PARAM','ship_to_account_id');
12071                   fnd_message.set_token ('PARENT_PARAM','ship_to_party_id');
12072                   fnd_msg_pub.ADD;
12073 
12074                   RAISE FND_API.G_EXC_ERROR;
12075      END IF;
12076   END IF;
12077 
12078   -- ship_to_party_id is a reqd field if ship_to_contact_id is passed,so check
12079   -- if passed, else return error
12080   IF ((l_service_request_rec.ship_to_contact_id <> FND_API.G_MISS_NUM AND
12081       l_service_request_rec.ship_to_contact_id IS NOT NULL))
12082   THEN
12083      IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM OR
12084          l_service_request_rec.ship_to_party_id IS NULL) THEN
12085 
12086                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12087                   fnd_message.set_token ('CHILD_PARAM','ship_to_contact_id');
12088                   fnd_message.set_token ('PARENT_PARAM','ship_to_party_id');
12089                   fnd_msg_pub.ADD;
12090 
12091                   RAISE FND_API.G_EXC_ERROR;
12092      END IF;
12093   END IF;
12094 
12095   -- ship_to_party_id is a reqd field if ship_to_site_id is passed, so check
12096   -- if passed, else return error
12097   IF ((l_service_request_rec.ship_to_site_id <> FND_API.G_MISS_NUM AND
12098       l_service_request_rec.ship_to_site_id IS NOT NULL))
12099   THEN
12100      IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM OR
12101          l_service_request_rec.ship_to_party_id IS NULL) THEN
12102 
12103                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12104                   fnd_message.set_token ('CHILD_PARAM','ship_to_site_id');
12105                   fnd_message.set_token ('PARENT_PARAM','ship_to_party_id');
12106                   fnd_msg_pub.ADD;
12107 
12108                   RAISE FND_API.G_EXC_ERROR;
12109      END IF;
12110   END IF;
12111 
12112   -- ship_to_party_id is a reqd field if ship_to_site_use_id is passed,
12113   -- so check if passed, else return error
12114   IF ((l_service_request_rec.ship_to_site_use_id <> FND_API.G_MISS_NUM AND
12115       l_service_request_rec.ship_to_site_use_id IS NOT NULL))
12116   THEN
12117      IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM OR
12118          l_service_request_rec.ship_to_party_id IS NULL) THEN
12119 
12120                   fnd_message.set_name ('CS', 'CS_SR_PARENT_CHILD_CHECK');
12121                   fnd_message.set_token ('CHILD_PARAM','ship_to_site_use_id');
12122                   fnd_message.set_token ('PARENT_PARAM','ship_to_party_id');
12123                   fnd_msg_pub.ADD;
12124 
12125                   RAISE FND_API.G_EXC_ERROR;
12126      END IF;
12127   END IF;
12128 
12129   -- Added this code for source changes for 11.5.9 by shijain dated oct 11 2002
12130   -- this code is to check if the creation_program_code is passed and is not
12131   -- null as this is a mandatory parameter.
12132 
12133   IF (l_service_request_rec.creation_program_code = FND_API.G_MISS_CHAR  OR
12134       l_service_request_rec.creation_program_code  IS NULL) THEN
12135 
12136       /*Commented this code for backward compatibility, that if someone
12137         passes a creation program code as NULL or G_MISS_CHAR, we are supporting
12138         it now and defaulting it to UNKNOWN
12139         CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
12140                         (p_token_an    => l_api_name_full,
12141                          p_token_np    => 'SR Creation Program Code',
12142                          p_table_name  => G_TABLE_NAME,
12143                          p_column_name => 'CREATION_PROGRAM_CODE');
12144 
12145        RAISE FND_API.G_EXC_ERROR;
12146        */
12147        l_service_request_rec.creation_program_code:='UNKNOWN';
12148   END IF;
12149 
12150 /* Commented it for bug 2725543,getting the group_name and resource_name
12151    from the validation procedures itself.
12152   -- Added for Enh# 2216664
12153   -- Added If conditions for Bug# 2297626
12154   -- For populating the owner in TL table
12155      IF (l_service_request_rec.owner_id IS NOT NULL AND
12156         l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) THEN
12157 
12158         SELECT resource_name
12159           INTO l_service_request_rec.owner
12160           FROM jtf_rs_resource_extns_tl
12161          WHERE resource_id = l_service_request_rec.owner_id
12162            AND LANGUAGE =  USERENV('LANG');
12163      END IF;
12164 
12165   -- For populating the group_owner in TL table
12166      IF (l_service_request_rec.owner_group_id IS NOT NULL AND
12167          l_service_request_rec.owner_group_id <> FND_API.G_MISS_NUM) THEN
12168        IF l_service_request_rec.group_type = 'RS_GROUP' THEN
12169 
12170           SELECT group_name INTO l_service_request_rec.group_owner
12171           FROM jtf_rs_groups_tl
12172           WHERE group_id =l_service_request_rec.owner_group_id
12173           AND LANGUAGE = USERENV('LANG');
12174 
12175        ELSIF (l_service_request_rec.group_type = 'RS_TEAM') THEN
12176 
12177           SELECT team_name INTO l_service_request_rec.group_owner
12178           FROM jtf_rs_teams_tl
12179           WHERE team_id =l_service_request_rec.owner_group_id
12180           AND LANGUAGE = USERENV('LANG');
12181 
12182        END IF;
12183      END IF;
12184 */
12185 
12186   -- Check if any records are passed in the contacts table.
12187   -- If so, get the primary contact id.
12188   -- Only one record with primary flag set to Y must be passed.
12189 
12190   l_contact_index := p_contacts.FIRST;
12191 
12192   -- Flag to indicate records have been passed
12193   IF (l_contact_index IS NULL) THEN
12194     l_contacts_passed := 'N';
12195   ELSE
12196     l_contacts_passed := 'Y';
12197   END IF;
12198 
12199   IF (l_service_request_rec.caller_type = 'ORGANIZATION') THEN
12200     IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
12201       --
12202       -- customer_id/company_number is mandatory
12203       -- customer_firstname etc. ignored
12204       --
12205          IF ((l_service_request_rec.customer_id = FND_API.G_MISS_NUM OR
12206                  l_service_request_rec.customer_id IS NULL )AND
12207                  (l_service_request_rec.customer_number = FND_API.G_MISS_CHAR OR
12208                   l_service_request_rec.customer_number IS NULL)) THEN
12209 
12210                 --AND(l_service_request_rec.customer_company_name = FND_API.G_MISS_CHAR OR
12211                 -- l_service_request_rec.customer_company_name IS NULL)
12212 
12213              CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
12214                                (p_token_an    => l_api_name_full,
12215                                 p_token_np     => 'SR Customer',
12216                                 p_table_name  => null,
12217                                 p_column_name => 'CUSTOMER_COMPANY_NAME');
12218 
12219              RAISE FND_API.G_EXC_ERROR;
12220          END IF;
12221 
12222      IF (l_service_request_rec.customer_id <> FND_API.G_MISS_NUM AND
12223                 l_service_request_rec.customer_id IS NOT NULL )   THEN
12224 
12225         l_service_request_val_rec.validate_customer := FND_API.G_TRUE;
12226         l_service_request_val_rec.customer_id       := l_service_request_rec.customer_id;
12227         x_service_request_rec.customer_id := l_service_request_rec.customer_id;
12228 
12229      ELSE
12230           --Customer Id is not passed, but customer number may be passed
12231           --Retrieve the customer_id from the customer_number
12232           CS_ServiceRequest_UTIL.Convert_Customer_To_ID(
12233                  p_api_name=>l_api_name,
12234                  p_parameter_name_nb=>'l_service_request_rec.customer_number',
12235                  p_parameter_name_n=> 'Customer_Name',
12236                  p_customer_number=>l_service_request_rec.customer_number,
12237                  -- Made changes for bug#2859360, getting the value of
12238                  -- customer id in l_service_request_rec.customer_id
12239                  p_customer_id    => l_service_request_rec.customer_id,
12240                  x_return_status => l_return_status);
12241 
12242        --Check return status
12243        IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12244              RAISE FND_API.G_EXC_ERROR;
12245           END IF;
12246 
12247        l_service_request_val_rec.validate_customer := FND_API.G_TRUE;
12248        -- Made changes for bug#2859360, uncommented this call
12249        l_service_request_val_rec.customer_id       := l_service_request_rec.customer_id;
12250      END IF;
12251 
12252     --Need the first flag cause contacts table is made mandatory now, when caller type is ORG
12253     --If records are passed in the contacts table, at least one record with primary flag
12254     --set to Y must be passed
12255 
12256     -- Check if the table is passed with records.
12257 
12258    END IF;
12259 
12260   ELSIF (l_service_request_rec.caller_type = 'PERSON') THEN
12261     IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
12262       --
12263       -- customer ignored
12264       -- at least one contact with primary flag=Y should be specified in the contacts table.
12265 
12266 --    END IF;
12267 --    raise error if customer_id is not passed . bug #3299567
12268      IF ((l_service_request_rec.customer_id = FND_API.G_MISS_NUM OR
12269           l_service_request_rec.customer_id IS NULL              )) THEN
12270 
12271 			 CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'SR Customer');
12272              RAISE FND_API.G_EXC_ERROR;
12273 
12274         END IF;
12275 
12276     END IF;
12277 
12278 
12279   ELSE
12280     -- caller type passed is not valid
12281 
12282     CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
12283                       ( p_token_an =>  l_api_name_full,
12284                         p_token_v  =>  l_service_request_rec.caller_type,
12285                         p_token_p  =>  'p_caller_type',
12286                         p_table_name  => G_TABLE_NAME ,
12287                         p_column_name => 'CALLER_TYPE' );
12288 
12289    RAISE FND_API.G_EXC_ERROR;
12290   END IF;
12291 
12292   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2');
12293   --
12294   /*11.5.10 Misc ER added logic to handle usability related changes*/
12295 
12296   -- For bug 3512501 - added begin..exception
12297   begin
12298   SELECT  responded_flag,resolved_flag
12299   INTO l_responded_flag,l_resolved_flag
12300   FROM  cs_incident_statuses_vl
12301   WHERE incident_status_id=l_service_request_rec.status_id ;
12302   exception
12303     when no_data_found then
12304       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg( p_token_an    => l_api_name_full,
12305 	              	      p_token_v     => TO_CHAR(l_service_request_rec.status_id),
12306 			      p_token_p     => 'p_status_id',
12307                               p_table_name  => G_TABLE_NAME,
12308                               p_column_name => 'INCIDENT_STATUS_ID' );
12309      RAISE FND_API.G_EXC_ERROR;
12310     end;
12311 
12312   IF ((l_responded_flag='Y') OR (l_resolved_flag ='Y')) THEN
12313      IF((l_responded_flag='Y' ) AND (l_service_request_rec.inc_responded_by_date is NULL OR
12314        l_service_request_rec.inc_responded_by_date= FND_API.G_MISS_DATE ))THEN
12315        l_service_request_rec.inc_responded_by_date := SYSDATE;
12316      END IF;
12317 
12318      IF((l_resolved_flag ='Y' ) AND (l_service_request_rec.incident_resolved_date is NULL
12319         OR l_service_request_rec.incident_resolved_date = FND_API.G_MISS_DATE ))THEN
12320         l_service_request_rec.incident_resolved_date := SYSDATE;
12321       END IF;
12322   END IF;
12323 
12324   -- ----------------------------------------------------------------------
12325   -- Apply business-rule validation to all required and passed parameters
12326   -- if validation level is set.
12327   -- ----------------------------------------------------------------------
12328   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
12329     --
12330     -- Check for uniqueness of request_id/request_number
12331     --
12332     IF (p_request_id IS NOT NULL) THEN
12333 
12334          -- Check if the request id passed is unique
12335       DECLARE
12336         l_test          NUMBER;
12337       BEGIN
12338         SELECT incident_id
12339          INTO l_test
12340          FROM cs_incidents_all_b
12341         WHERE incident_id = p_request_id;
12342 
12343         CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
12344                           ( p_token_an    =>  l_api_name_full,
12345                             p_token_v     =>  p_request_id,
12346                             p_token_p     =>  'p_request_id' ,
12347                             p_table_name  => G_TABLE_NAME ,
12348                             p_column_name => 'INCIDENT_ID');
12349 
12350         RAISE FND_API.G_EXC_ERROR;
12351       EXCEPTION
12352         WHEN NO_DATA_FOUND THEN
12353           NULL;
12354         WHEN OTHERS THEN
12355           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12356       END;
12357 
12358     END IF;
12359 
12360 
12361     IF (p_request_number IS NOT NULL) THEN
12362 
12363          --Check if the request number passed is unique
12364       DECLARE
12365         l_test          VARCHAR2(250);
12366       BEGIN
12367         SELECT incident_number
12368         INTO l_test
12369         FROM cs_incidents_all_b
12370         WHERE incident_number = p_request_number;
12371 
12372         CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
12373                           ( p_token_an    => l_api_name_full,
12374                             p_token_v     => p_request_number,
12375                             p_token_p     => 'p_request_number',
12376                             p_table_name  => G_TABLE_NAME,
12377                             p_column_name => 'INCIDENT_NUMBER' );
12378 
12379         RAISE FND_API.G_EXC_ERROR;
12380       EXCEPTION
12381         WHEN NO_DATA_FOUND THEN
12382           NULL;
12383         WHEN OTHERS THEN
12384           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
12385       END;
12386 
12387 
12388     END IF;
12389 
12390    -- replaced validation of org_id with the procedure call below and set local variable
12391    -- to p_org_id
12392    IF p_org_id IS NOT NULL
12393    THEN
12394      CS_SERVICEREQUEST_UTIL.validate_org_id
12395      ( p_org_id        => p_org_id
12396      , x_return_status => l_return_status
12397      );
12398      IF (l_return_status <> FND_API.G_RET_STS_SUCCESS)
12399      THEN
12400         RAISE FND_API.G_EXC_ERROR;
12401      END IF;
12402    END IF;
12403    l_org_id := p_org_id;
12404 
12405 
12406     --
12407     -- Validate the user and login id's
12408     --
12409     CS_ServiceRequest_UTIL.Validate_Who_Info
12410       ( p_api_name             => l_api_name_full,
12411         p_parameter_name_usr   => 'p_user_id',
12412         p_parameter_name_login => 'p_login_id',
12413         p_user_id              => p_user_id,
12414         p_login_id             => p_login_id,
12415         x_return_status        => l_return_status);
12416     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12417       RAISE FND_API.G_EXC_ERROR;
12418     END IF;
12419 
12420     -- Validate the created_by added for bug #5153581
12421     --
12422     IF l_service_request_rec.created_by IS NOT NULL AND
12423        l_service_request_rec.created_by <> FND_API.G_Miss_NUM THEN
12424 
12425          CS_ServiceRequest_UTIL.Validate_Who_Info
12426            ( p_api_name             => l_api_name_full,
12427              p_parameter_name_usr   => 'p_created_by',
12428              p_parameter_name_login => NULL,
12429              p_user_id              => l_service_request_rec.created_by,
12430              p_login_id             => NULL,
12431              x_return_status        => l_return_status);
12432 
12433          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12434            RAISE FND_API.G_EXC_ERROR;
12435          END IF;
12436 
12437     END IF ;
12438 
12439     -- Validate the updated_by added for bug #5153581
12440     --
12441       IF l_service_request_rec.last_updated_by IS NOT NULL AND
12442          l_service_request_rec.last_updated_by <> FND_API.G_Miss_NUM THEN
12443 
12444          CS_ServiceRequest_UTIL.Validate_Who_Info
12445            ( p_api_name             => l_api_name_full,
12446              p_parameter_name_usr   => 'p_last_updated_by',
12447              p_parameter_name_login => NULL,
12448              p_user_id              => l_service_request_rec.last_updated_by,
12449              p_login_id             => NULL,
12450              x_return_status        => l_return_status);
12451 
12452          IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12453            RAISE FND_API.G_EXC_ERROR;
12454          END IF;
12455 
12456       END IF ;
12457 
12458     --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.1');
12459 
12460 
12461     --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.2');
12462 
12463     --
12464     -- Type, status, severity, resource_type, owner and publish flag are always validated
12465     -- Urgency, problem code, expected resolution date, resolution code, and
12466     -- actual resolution date are validated if passed (not NULL)
12467     --
12468     l_service_request_val_rec.validate_type   := FND_API.G_TRUE;
12469     l_service_request_val_rec.validate_status := FND_API.G_TRUE;
12470     l_service_request_val_rec.type_id         := l_service_request_rec.type_id;
12471     l_service_request_val_rec.status_id       := l_service_request_rec.status_id;
12472     l_service_request_val_rec.severity_id     := l_service_request_rec.severity_id;
12473     --l_service_request_val_rec.resource_type   := l_service_request_rec.resource_type;
12474     --l_service_request_val_rec.owner_id        := l_service_request_rec.owner_id;
12475     --l_service_request_val_rec.publish_flag    := l_service_request_rec.publish_flag;
12476 
12477     IF (l_service_request_rec.urgency_id IS NOT NULL
12478        AND l_service_request_rec.urgency_id <> FND_API.G_MISS_NUM) THEN
12479       l_service_request_val_rec.urgency_id          := l_service_request_rec.urgency_id;
12480     END IF;
12481 
12482     IF (l_service_request_rec.resource_type IS NOT NULL
12483        AND l_service_request_rec.resource_type <> FND_API.G_MISS_CHAR) THEN
12484       l_service_request_val_rec.resource_type := l_service_request_rec.resource_type;
12485     END IF;
12486 
12487 ---
12488     IF (l_service_request_rec.owner_id IS NOT NULL
12489        AND l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) THEN
12490       l_service_request_val_rec.owner_id := l_service_request_rec.owner_id;
12491     END IF;
12492 
12493        IF (l_service_request_rec.customer_id <> FND_API.G_MISS_NUM AND
12494                 l_service_request_rec.customer_id IS NOT NULL  )THEN
12495           l_service_request_val_rec.validate_customer := FND_API.G_TRUE;
12496            l_service_request_val_rec.customer_id   := l_service_request_rec.customer_id;
12497        END IF;
12498 
12499     IF (l_service_request_rec.problem_code IS NOT NULL
12500      AND l_service_request_rec.problem_code <> FND_API.G_MISS_CHAR) THEN
12501       l_service_request_val_rec.problem_code        := l_service_request_rec.problem_code;
12502     END IF;
12503 
12504 ---Added for bug 5278488 (FP For Bug # 5192499) spusegao 06/13/06
12505 
12506     If ( l_service_request_rec.publish_flag = FND_API.G_MISS_CHAR) Then
12507         l_service_request_rec.publish_flag := 'N' ;
12508         l_service_request_val_rec.publish_flag := FND_API.G_MISS_CHAR ;
12509     End If ;
12510 
12511 -----Added for enhancement 1803588--11.5.6 ---jngeorge ----07/20/01
12512     IF (l_service_request_rec.cust_pref_lang_id IS NOT NULL
12513      AND l_service_request_rec.cust_pref_lang_id <> FND_API.G_MISS_NUM) THEN
12514       l_service_request_val_rec.cust_pref_lang_id := l_service_request_rec.cust_pref_lang_id;
12515     END IF;
12516 
12517 -----Added for enhancement 1806657--11.5.6 ---jngeorge ----07/20/01
12518     IF (l_service_request_rec.comm_pref_code IS NOT NULL
12519      AND l_service_request_rec.comm_pref_code <> FND_API.G_MISS_CHAR) THEN
12520       l_service_request_val_rec.comm_pref_code := l_service_request_rec.comm_pref_code;
12521     END IF;
12522 
12523 ---------
12524     IF (l_service_request_rec.exp_resolution_date IS NOT NULL
12525      AND l_service_request_rec.exp_resolution_date <> FND_API.G_MISS_DATE) THEN
12526       l_service_request_val_rec.exp_resolution_date := l_service_request_rec.exp_resolution_date;
12527     END IF;
12528 
12529     IF (l_service_request_rec.resolution_code IS NOT NULL
12530      AND l_service_request_rec.resolution_code <> FND_API.G_MISS_CHAR)  THEN
12531       l_service_request_val_rec.resolution_code     := l_service_request_rec.resolution_code;
12532     END IF;
12533 
12534     IF (l_service_request_rec.act_resolution_date IS NOT NULL
12535      AND l_service_request_rec.act_resolution_date <> FND_API.G_MISS_DATE) THEN
12536       l_service_request_val_rec.act_resolution_date := l_service_request_rec.act_resolution_date;
12537     END IF;
12538 
12539   --- Added for Enh# 1830701
12540     l_service_request_val_rec.request_date := l_service_request_rec.request_date;
12541 
12542     IF (l_service_request_rec.incident_occurred_date IS NOT NULL
12543      AND l_service_request_rec.incident_occurred_date <> FND_API.G_MISS_DATE) THEN
12544       l_service_request_val_rec.incident_occurred_date := l_service_request_rec.incident_occurred_date;
12545     END IF;
12546 
12547     IF (l_service_request_rec.incident_resolved_date IS NOT NULL
12548      AND l_service_request_rec.incident_resolved_date <> FND_API.G_MISS_DATE) THEN
12549       l_service_request_val_rec.incident_resolved_date := l_service_request_rec.incident_resolved_date;
12550     END IF;
12551 
12552     IF (l_service_request_rec.inc_responded_by_date IS NOT NULL
12553      AND l_service_request_rec.inc_responded_by_date <> FND_API.G_MISS_DATE) THEN
12554       l_service_request_val_rec.inc_responded_by_date := l_service_request_rec.inc_responded_by_date;
12555     END IF;
12556 
12557   --- Added for Enh# 1830701
12558     IF (l_service_request_rec.incident_location_id IS NOT NULL
12559      AND l_service_request_rec.incident_location_id <> FND_API.G_MISS_NUM) THEN
12560       l_service_request_val_rec.incident_location_id := l_service_request_rec.incident_location_id;
12561       -- Bug 4386870 12/12/05 smisra
12562       -- if incident location is passed then ignore passed value of incident country
12563       -- incident country will be derived based on location
12564       l_service_request_rec.incident_country := null;
12565     ELSE
12566       -- Bug 3420335
12567       -- if location id is null then location type too should be null.
12568       l_service_request_rec.incident_location_type := null;
12569     END IF;
12570 
12571     IF (l_service_request_rec.incident_country IS NOT NULL
12572      AND l_service_request_rec.incident_country <> FND_API.G_MISS_CHAR) THEN
12573       l_service_request_val_rec.incident_country := l_service_request_rec.incident_country;
12574     END IF;
12575 
12576     --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.3');
12577 
12578     IF (nvl(l_service_request_rec.bill_to_site_id,-99) <> FND_API.G_MISS_NUM) THEN
12579       l_service_request_val_rec.validate_bill_to_site := FND_API.G_TRUE;
12580       l_service_request_val_rec.bill_to_site_id := l_service_request_rec.bill_to_site_id;
12581     END IF;
12582 
12583     IF (nvl(l_service_request_rec.bill_to_site_use_id, -99) <> FND_API.G_MISS_NUM) THEN
12584       l_service_request_val_rec.bill_to_site_use_id := l_service_request_rec.bill_to_site_use_id;
12585     END IF;
12586 
12587     IF (nvl(l_service_request_rec.bill_to_contact_id, -99) <> FND_API.G_MISS_NUM) THEN
12588       l_service_request_val_rec.bill_to_contact_id := l_service_request_rec.bill_to_contact_id;
12589     END IF;
12590 
12591     IF (nvl(l_service_request_rec.bill_to_party_id, -99) <> FND_API.G_MISS_NUM) THEN
12592       l_service_request_val_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id;
12593     END IF;
12594 
12595     --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.4');
12596 
12597     IF (nvl(l_service_request_rec.ship_to_site_id, -99) <> FND_API.G_MISS_NUM) THEN
12598       l_service_request_val_rec.validate_ship_to_site := FND_API.G_TRUE;
12599       l_service_request_val_rec.ship_to_site_id := l_service_request_rec.ship_to_site_id;
12600     END IF;
12601 
12602     IF (nvl(l_service_request_rec.ship_to_site_use_id, -99) <> FND_API.G_MISS_NUM) THEN
12603       l_service_request_val_rec.ship_to_site_use_id := l_service_request_rec.ship_to_site_use_id;
12604     END IF;
12605 
12606     IF (nvl(l_service_request_rec.ship_to_contact_id,-99) <> FND_API.G_MISS_NUM) THEN
12607       l_service_request_val_rec.ship_to_contact_id := l_service_request_rec.ship_to_contact_id;
12608     END IF;
12609 
12610 
12611     IF (nvl(l_service_request_rec.ship_to_party_id,-99) <> FND_API.G_MISS_NUM) THEN
12612       l_service_request_val_rec.ship_to_party_id := l_service_request_rec.ship_to_party_id;
12613     END IF;
12614 
12615     --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.5');
12616 
12617     IF ( l_service_request_rec.install_site_id <> FND_API.G_MISS_NUM ) THEN
12618       l_service_request_val_rec.validate_install_site := FND_API.G_TRUE;
12619       l_service_request_val_rec.install_site_id := l_service_request_rec.install_site_id;
12620     ELSE
12621       l_service_request_val_rec.install_site_id := null;
12622     END IF;
12623 
12624     IF ( l_service_request_rec.install_site_use_id  <> FND_API.G_MISS_NUM) THEN
12625       l_service_request_val_rec.validate_install_site := FND_API.G_TRUE;
12626       l_service_request_val_rec.install_site_use_id := l_service_request_rec.install_site_use_id;
12627     END IF;
12628 
12629     ---************************
12630     --Assign all the fields to be validated
12631     IF (l_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM AND
12632         l_service_request_rec.contract_service_id IS NOT NULL) THEN
12633       l_service_request_val_rec.contract_service_id := l_service_request_rec.contract_service_id;
12634     END IF;
12635 
12636     IF (l_service_request_rec.contract_id <> FND_API.G_MISS_NUM AND
12637         l_service_request_rec.contract_id IS NOT NULL) THEN
12638       l_service_request_val_rec.contract_id := l_service_request_rec.contract_id;
12639     END IF;
12640 
12641     IF (l_service_request_rec.project_number <> FND_API.G_MISS_CHAR AND
12642         l_service_request_rec.project_number IS NOT NULL) THEN
12643       l_service_request_val_rec.project_number := l_service_request_rec.project_number;
12644     END IF;
12645 
12646     --Caller_type and primary_contact_id is needed for account_id validation
12647     l_service_request_val_rec.caller_type := l_service_request_rec.caller_type;
12648     l_service_request_val_rec.primary_contact_id := l_primary_contact_id;
12649 
12650     IF (l_service_request_rec.account_id <> FND_API.G_MISS_NUM AND
12651         l_service_request_rec.account_id IS NOT NULL) THEN
12652       l_service_request_val_rec.account_id := l_service_request_rec.account_id;
12653     ELSE
12654       l_service_request_val_rec.account_id := null;
12655 
12656     END IF;
12657 
12658     IF (l_service_request_rec.platform_id <> FND_API.G_MISS_NUM AND
12659         l_service_request_rec.platform_id IS NOT NULL) THEN
12660       l_service_request_val_rec.platform_id := l_service_request_rec.platform_id;
12661     END IF;
12662 
12663     IF (l_service_request_rec.platform_version_id <> FND_API.G_MISS_NUM AND
12664         l_service_request_rec.platform_version_id IS NOT NULL) THEN
12665       l_service_request_val_rec.platform_version_id := l_service_request_rec.platform_version_id;
12666     END IF;
12667 
12668     IF (l_service_request_rec.inv_platform_org_id <> FND_API.G_MISS_NUM AND
12669       l_service_request_rec.inv_platform_org_id IS NOT NULL) THEN
12670       l_service_request_val_rec.inv_platform_org_id := l_service_request_rec.inv_platform_org_id;
12671     END IF;
12672 
12673     IF (l_service_request_rec.platform_version <> FND_API.G_MISS_CHAR AND
12674         l_service_request_rec.platform_version IS NOT NULL) THEN
12675         l_service_request_val_rec.platform_version := l_service_request_rec.platform_version;
12676     END IF;
12677 
12678     IF (l_service_request_rec.territory_id <> FND_API.G_MISS_NUM AND
12679         l_service_request_rec.territory_id IS NOT NULL) THEN
12680       l_service_request_val_rec.territory_id := l_service_request_rec.territory_id;
12681     END IF;
12682 
12683 
12684     IF (l_service_request_rec.site_id <> FND_API.G_MISS_NUM AND
12685         l_service_request_rec.site_id IS NOT NULL) THEN
12686       l_service_request_val_rec.site_id := l_service_request_rec.site_id;
12687     END IF;
12688 
12689     IF (l_service_request_rec.customer_product_id  <> FND_API.G_MISS_NUM AND
12690         l_service_request_rec.customer_product_id  IS NOT NULL) THEN
12691       l_service_request_val_rec.customer_product_id  := l_service_request_rec.customer_product_id ;
12692     ELSE
12693       l_service_request_val_rec.customer_product_id  := null ;
12694     END IF;
12695 
12696 /* Start : 5501340 */
12697     IF (l_service_request_rec.system_id  <> FND_API.G_MISS_NUM AND
12698         l_service_request_rec.system_id  IS NOT NULL) THEN
12699       l_service_request_val_rec.system_id  := l_service_request_rec.system_id ;
12700     ELSE
12701       l_service_request_val_rec.system_id  := null ;
12702     END IF;
12703 /* End : 5501340 */
12704 
12705    IF (l_service_request_rec.current_serial_number  <> FND_API.G_MISS_CHAR AND
12706                   l_service_request_rec.current_serial_number  IS NOT NULL) THEN
12707       l_service_request_val_rec.current_serial_number  := l_service_request_rec.current_serial_number  ;
12708   END IF;
12709 
12710 
12711    IF (l_service_request_rec.group_territory_id  <> FND_API.G_MISS_NUM AND
12712        l_service_request_rec.group_territory_id  IS NOT NULL) THEN
12713       l_service_request_val_rec.group_territory_id  := l_service_request_rec.group_territory_id  ;
12714   END IF;
12715 -----------Added for Enhancements 11.5.6----------
12716 
12717 --   IF (l_service_request_rec.product_revision  <> FND_API.G_MISS_CHAR AND
12718 --       l_service_request_rec.product_revision  IS NOT NULL) THEN
12719       l_service_request_val_rec.product_revision  := l_service_request_rec.product_revision  ;
12720 --  END IF;
12721 
12722 -- IF (l_service_request_rec.component_version  <> FND_API.G_MISS_CHAR AND
12723 --     l_service_request_rec.component_version  IS NOT NULL) THEN
12724       l_service_request_val_rec.component_version  := l_service_request_rec.component_version  ;
12725 --END IF;
12726 
12727 -- IF (l_service_request_rec.subcomponent_version  <> FND_API.G_MISS_CHAR AND
12728 --     l_service_request_rec.subcomponent_version  IS NOT NULL) THEN
12729       l_service_request_val_rec.subcomponent_version  := l_service_request_rec.subcomponent_version  ;
12730 --END IF;
12731 -----------------------------------------
12732 
12733     -- If inventory org id is passed in, assign it to the validate rec
12734     IF (l_service_request_rec.inventory_org_id  <> FND_API.G_MISS_NUM AND
12735           l_service_request_rec.inventory_org_id  IS NOT NULL) THEN
12736      l_service_request_val_rec.inventory_org_id  := l_service_request_rec.inventory_org_id ;
12737     ELSE
12738      l_service_request_val_rec.inventory_org_id  := null ;
12739     END IF;
12740 
12741     -- If inventory item id is passed in, assign it to the validate rec
12742     IF (l_service_request_rec.inventory_item_id  <> FND_API.G_MISS_NUM AND
12743         l_service_request_rec.inventory_item_id  IS NOT NULL) THEN
12744         l_service_request_val_rec.inventory_item_id  := l_service_request_rec.inventory_item_id ;
12745     ELSE
12746         l_service_request_val_rec.inventory_item_id  := null;
12747     END IF;
12748 
12749     IF (l_service_request_rec.cp_component_id <> FND_API.G_MISS_NUM AND
12750         l_service_request_rec.cp_component_id IS NOT NULL) THEN
12751       l_service_request_val_rec.cp_component_id  := l_service_request_rec.cp_component_id ;
12752     END IF;
12753 
12754     IF (l_service_request_rec.cp_component_version_id <> FND_API.G_MISS_NUM AND
12755         l_service_request_rec.cp_component_version_id IS NOT NULL) THEN
12756       l_service_request_val_rec.cp_component_version_id  := l_service_request_rec.cp_component_version_id ;
12757     END IF;
12758 
12759     IF (l_service_request_rec.cp_subcomponent_id <> FND_API.G_MISS_NUM AND
12760         l_service_request_rec.cp_subcomponent_id IS NOT NULL) THEN
12761       l_service_request_val_rec.cp_subcomponent_id   := l_service_request_rec.cp_subcomponent_id  ;
12762     END IF;
12763 
12764     IF (l_service_request_rec.cp_subcomponent_version_id <> FND_API.G_MISS_NUM AND
12765         l_service_request_rec.cp_subcomponent_version_id IS NOT NULL) THEN
12766       l_service_request_val_rec.cp_subcomponent_version_id   := l_service_request_rec.cp_subcomponent_version_id  ;
12767     END IF;
12768 
12769 
12770     IF (l_service_request_rec.cp_revision_id <> FND_API.G_MISS_NUM AND
12771         l_service_request_rec.cp_revision_id IS NOT NULL) THEN
12772       l_service_request_val_rec.cp_revision_id   := l_service_request_rec.cp_revision_id ;
12773     END IF;
12774 
12775     IF (l_service_request_rec.inv_item_revision <> FND_API.G_MISS_CHAR AND
12776         l_service_request_rec.inv_item_revision IS NOT NULL) THEN
12777       l_service_request_val_rec.inv_item_revision    := l_service_request_rec.inv_item_revision  ;
12778     END IF;
12779 
12780     IF (l_service_request_rec.inv_component_id <> FND_API.G_MISS_NUM AND
12781         l_service_request_rec.inv_component_id IS NOT NULL) THEN
12782       l_service_request_val_rec.inv_component_id   := l_service_request_rec.inv_component_id ;
12783     END IF;
12784 
12785     IF (l_service_request_rec.inv_component_version <> FND_API.G_MISS_CHAR AND
12786         l_service_request_rec.inv_component_version  IS NOT NULL) THEN
12787       l_service_request_val_rec.inv_component_version    := l_service_request_rec.inv_component_version ;
12788     END IF;
12789 
12790     IF (l_service_request_rec.inv_subcomponent_id <> FND_API.G_MISS_NUM AND
12791         l_service_request_rec.inv_subcomponent_id IS NOT NULL) THEN
12792       l_service_request_val_rec.inv_subcomponent_id    := l_service_request_rec.inv_subcomponent_id ;
12793     END IF;
12794 
12795    IF (l_service_request_rec.inv_subcomponent_version <> FND_API.G_MISS_CHAR AND
12796 
12797         l_service_request_rec.inv_subcomponent_version IS NOT NULL) THEN
12798       l_service_request_val_rec.inv_subcomponent_version    := l_service_request_rec.inv_subcomponent_version ;
12799    END IF;
12800 
12801    --  Added bill_to_account_id         - ER# 2433831
12802 
12803    IF (l_service_request_rec.bill_to_account_id <> FND_API.G_MISS_NUM AND
12804        l_service_request_rec.bill_to_account_id IS NOT NULL) THEN
12805        l_service_request_val_rec.bill_to_account_id := l_service_request_rec.bill_to_account_id ;
12806    END IF;
12807 
12808    --  Added ship_to_account_id         - ER# 2433831
12809 
12810    IF (l_service_request_rec.ship_to_account_id <> FND_API.G_MISS_NUM AND
12811        l_service_request_rec.ship_to_account_id IS NOT NULL) THEN
12812        l_service_request_val_rec.ship_to_account_id := l_service_request_rec.ship_to_account_id ;
12813    END IF;
12814 
12815    --  Added customer_phone_id   - ER# 2463321
12816 
12817    IF (l_service_request_rec.customer_phone_id <> FND_API.G_MISS_NUM AND
12818        l_service_request_rec.customer_phone_id IS NOT NULL) THEN
12819        l_service_request_val_rec.customer_phone_id := l_service_request_rec.customer_phone_id ;
12820    END IF;
12821 
12822    --  Added customer_email_id   - ER# 2463321
12823 
12824    IF (l_service_request_rec.customer_email_id <> FND_API.G_MISS_NUM AND
12825        l_service_request_rec.customer_email_id IS NOT NULL) THEN
12826        l_service_request_val_rec.customer_email_id := l_service_request_rec.customer_email_id ;
12827    END IF;
12828 
12829    --Made changes for bug #2786844
12830    IF (l_service_request_rec.external_reference <> FND_API.G_MISS_CHAR AND
12831        l_service_request_rec.external_reference IS NOT NULL) THEN
12832        l_service_request_val_rec.external_reference := l_service_request_rec.external_reference ;
12833    END IF;
12834 
12835    -- for cmro_eam
12836    IF (l_service_request_rec.owning_dept_id <> FND_API.G_MISS_NUM AND
12837        l_service_request_rec.owning_dept_id IS NOT NULL) THEN
12838        l_service_request_val_rec.owning_dept_id := l_service_request_rec.owning_dept_id ;
12839    END IF;
12840 
12841    -- end of cmro_eam
12842 
12843    -- Added incident location type for Misc ERs project of 11.5.10 --anmukher --08/25/03
12844    IF (l_service_request_rec.incident_location_type IS NOT NULL
12845      AND l_service_request_rec.incident_location_type <> FND_API.G_MISS_CHAR) THEN
12846       l_service_request_val_rec.incident_location_type := l_service_request_rec.incident_location_type;
12847    END IF;
12848 
12849    -- Added to fix issue in bug # 3288806.
12850    IF ((l_service_request_rec.category_id IS NOT NULL) AND (l_service_request_rec.category_id <> FND_API.G_MISS_NUM)) THEN
12851        l_service_request_val_rec.category_id := l_service_request_rec.category_id ;
12852        IF (l_service_request_rec.category_set_id = FND_API.G_MISS_NUM) THEN
12853          l_service_request_rec.category_set_id := FND_PROFILE.value('CS_SR_DEFAULT_CATEGORY_SET');
12854        END IF;
12855        l_service_request_val_rec.category_set_id := l_service_request_rec.category_set_id ;
12856    END IF ;
12857 
12858    -- Added to fix issue in bug # 3288806.
12859    IF ((l_service_request_rec.category_set_id IS NOT NULL) AND (l_service_request_rec.category_set_id <> FND_API.G_MISS_NUM)) THEN
12860        l_service_request_val_rec.category_set_id := l_service_request_rec.category_set_id ;
12861    END IF ;
12862    IF (l_service_request_rec.group_type  <> FND_API.G_MISS_CHAR AND
12863        l_service_request_rec.group_type  IS NOT NULL) THEN
12864       l_service_request_val_rec.group_type  := l_service_request_rec.group_type;
12865   END IF;
12866 
12867    IF (l_service_request_rec.owner_group_id  <> FND_API.G_MISS_NUM AND
12868        l_service_request_rec.owner_group_id  IS NOT NULL) THEN
12869       l_service_request_val_rec.owner_group_id  := l_service_request_rec.owner_group_id  ;
12870   END IF;
12871 
12872    -- Added for bug 3635269
12873 
12874   IF (l_service_request_rec.sr_creation_channel  <> FND_API.G_MISS_CHAR AND
12875        l_service_request_rec.sr_creation_channel  IS NOT NULL) THEN
12876       l_service_request_val_rec.sr_creation_channel  := l_service_request_rec.sr_creation_channel  ;
12877   END IF;
12878 
12879   -- <bug5224245>
12880   IF (l_service_request_rec.system_id  <> FND_API.G_MISS_NUM AND
12881       l_service_request_rec.system_id IS NOT NULL) THEN
12882       l_service_request_val_rec.system_id  := l_service_request_rec.system_id;
12883   END IF;
12884   -- </bug5224245>
12885 
12886     /*15995804. Add price_list_header_id, check if p_price_list_header_id is passed from user hook
12887     If so, pass the same value to validation procedure, else use the default one passed in p_servicerequest_rec
12888   */
12889   IF  p_price_list_header_id  IS NOT NULL THEN
12890       l_service_request_val_rec.price_list_header_id  := p_price_list_header_id;
12891       l_service_request_rec.price_list_header_id  := p_price_list_header_id;
12892   ELSIF (l_service_request_rec.price_list_header_id  <> FND_API.G_MISS_NUM AND
12893       l_service_request_rec.price_list_header_id IS NOT NULL) THEN
12894       l_service_request_val_rec.price_list_header_id  := l_service_request_rec.price_list_header_id;
12895   END IF;
12896 
12897   -- there is no need to check if maint_org is equal to FND_API.G_MISS_NUM or not.
12898   -- val rec always have it's value as G_MISS_NUM. so it might replace G_MISS_NUM
12899   -- with G_MISS_NUM. No need to check for NULL too because validate_SR_record
12900   -- checks for null value too before calling any validation
12901   l_service_request_val_rec.maint_organization_id  :=
12902     l_service_request_rec.maint_organization_id;
12903 
12904     -- --------------------------------------------------------------------
12905     -- Validate all non-missing attributes by calling the utility procedure.
12906     -- --------------------------------------------------------------------
12907     Validate_ServiceRequest_Record
12908       (   p_api_name                => l_api_name_full,
12909           p_service_request_rec     => l_service_request_val_rec,
12910           p_request_date            => l_service_request_rec.request_date,
12911           p_org_id                  => l_org_id,
12912           p_resp_appl_id            => p_resp_appl_id,
12913           p_resp_id                 => p_resp_id,
12914           p_user_id                 => p_user_id,
12915           p_operation               => l_operation,
12916           p_close_flag              => l_close_flag,
12917           p_disallow_request_update => l_disallow_request_update,
12918           p_disallow_owner_update   => l_disallow_owner_update,
12919           p_disallow_product_update => l_disallow_product_update,
12920           p_employee_name           => l_employee_name,
12921           p_inventory_item_id       => l_cp_item_id,
12922           p_contract_id             => x_contra_id,
12923           p_contract_number         => x_contract_number,
12924           x_bill_to_site_id         => l_bill_to_site_id,
12925           x_ship_to_site_id         => l_ship_to_site_id,
12926           x_bill_to_site_use_id     => l_bill_to_site_use_id,
12927           x_ship_to_site_use_id     => l_ship_to_site_use_id,
12928           x_return_status           => x_return_status,
12929           x_group_name              => l_group_name,
12930           x_owner_name              => l_owner_name,
12931           x_product_revision        => l_service_request_rec.product_revision ,
12932           x_component_version       => l_service_request_rec.component_version,
12933           x_subcomponent_version    => l_service_request_rec.subcomponent_version,
12934  	   -- cmro_eam
12935           p_cmro_flag               => p_cmro_flag,
12936           p_maintenance_flag        => p_maintenance_flag,
12937 		  p_sr_mode                 => 'CREATE'
12938       );
12939 
12940     IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12941       RAISE FND_API.G_EXC_ERROR;
12942     END IF;
12943 
12944     -- Done the changes for bug 2725543
12945 
12946     IF l_ship_to_site_id <> FND_API.G_MISS_NUM THEN
12947          l_service_request_rec.ship_to_site_id := l_ship_to_site_id;
12948     END IF;
12949     IF l_ship_to_site_use_id <> FND_API.G_MISS_NUM THEN
12950          l_service_request_rec.ship_to_site_use_id := l_ship_to_site_use_id;
12951     END IF;
12952 
12953     IF l_bill_to_site_id <> FND_API.G_MISS_NUM THEN
12954          l_service_request_rec.bill_to_site_id := l_bill_to_site_id;
12955     END IF;
12956     IF l_bill_to_site_use_id <> FND_API.G_MISS_NUM THEN
12957          l_service_request_rec.bill_to_site_use_id := l_bill_to_site_use_id;
12958     END IF;
12959 
12960     --cs_sERviceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #2.7');
12961 
12962     --
12963     -- If customer product ID is passed in and validated, use the inventory
12964     -- item ID retrieved from the CS_CUSTOMER_PRODUCTS_ALL table.
12965     --
12966     -- If customer_product_id is specified then the inventory item id
12967     -- specified in the record type is always overwritten by the inventory item
12968     -- id value in the
12969     -- CS_CUSTOMER_PRODUCTS_ALL for that customer_product_id
12970     IF (l_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM) THEN
12971       l_service_request_rec.inventory_item_id := l_cp_item_id;
12972     END IF;
12973 
12974 
12975     -- --------------------------------------------------------------------
12976     -- Validate the closed date if the status is a "closed" status, meaning
12977     -- that if the CLOSE_FLAG of the status is 'Y'. If not, ignore the
12978     -- closed date.  If it is a closed status, and the close date is not
12979     -- passed in, use the system date as the default close date.
12980     -- --------------------------------------------------------------------
12981     IF (l_close_flag = 'Y') THEN
12982       IF ((l_service_request_rec.closed_date = FND_API.G_MISS_DATE) OR
12983           (l_service_request_rec.closed_date IS NULL)) THEN
12984         l_service_request_rec.closed_date := SYSDATE;
12985       ELSIF (l_service_request_rec.closed_date IS NOT NULL) THEN
12986 
12987         CS_ServiceRequest_UTIL.Validate_Closed_Date
12988           ( p_api_name       => l_api_name_full,
12989             p_parameter_name => 'p_closed_date',
12990             p_closed_date    => l_service_request_rec.closed_date,
12991             p_request_date   => l_service_request_rec.request_date,
12992             x_return_status  => l_return_status
12993           );
12994         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
12995           RAISE FND_API.G_EXC_ERROR;
12996         END IF;
12997       END IF;
12998     ELSE
12999       IF ((l_service_request_rec.closed_date <> FND_API.G_MISS_DATE) AND
13000           (l_service_request_rec.closed_date IS NOT NULL)) THEN
13001 
13002         CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg
13003                           (p_token_an    => l_api_name_full,
13004                            p_token_ip     => 'p_closed_date',
13005                            p_table_name  => G_TABLE_NAME,
13006                            p_column_name => 'CLOSED_DATE');
13007       END IF;
13008       l_service_request_rec.closed_date := NULL;
13009     END IF;
13010 
13011     -- Validate SR_CREATION_CHANNEL
13012     -- For bug 3635269
13013   /*  IF (l_service_request_rec.sr_creation_channel <> FND_API.G_MISS_CHAR AND
13014         l_service_request_rec.sr_creation_channel IS NOT NULL) THEN
13015 
13016           CS_ServiceRequest_UTIL.Validate_SR_Channel(
13017           p_api_name         => l_api_name_full,
13018           p_parameter_name   => 'p_sr_creation_channel',
13019           p_sr_creation_channel   => l_service_request_rec.sr_creation_channel,
13020           x_return_status    => l_return_status);
13021 
13022         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
13023           RAISE FND_API.G_EXC_ERROR;
13024         END IF;
13025     END IF;  */
13026 
13027 
13028 
13029   END IF; /* IF p_validation_level >= FND_API.G_VALID_LEVEL_NONE THEN */
13030 
13031   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #3');
13032 
13033   --
13034   -- The request_id needs to be generated here because it is needed when
13035   -- inserting records into CS_HZ_SR_CONTACT_POINTS
13036   -- This generation is done here because the earlier check to see if
13037   -- request id is unique is done only if validation level is set.
13038   --Commenting this because , selecting from dual is not supported anymore
13039   --because of performance reasons.
13040 
13041   --CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg(l_api_name_full, 'step #4');
13042 
13043    -- -------------------------------------------------------------
13044    --  Check if the passsed type_id has AutoLaunch Workflow flag set to 'Y'.
13045    --  If so, we need to call the workflow lauch API. We need to do this irrespective
13046    --  of the validation level set
13047    -- -------------------------------------------------------------
13048 
13049    BEGIN
13050      -- Initialize the return status.
13051      l_return_status := FND_API.G_RET_STS_SUCCESS;
13052 
13053      -- Verify the type ID against the database.
13054      -- Done here cause, these flags need to get their values
13055      SELECT autolaunch_workflow_flag, abort_workflow_close_flag, workflow
13056      INTO   x_autolaunch_wkf_flag, x_abort_wkf_close_flag, x_wkf_process_name
13057      FROM   cs_incident_types_b
13058      WHERE  incident_type_id = l_service_request_rec.type_id
13059      AND    incident_subtype = G_SR_SUBTYPE
13060      ;
13061 
13062    EXCEPTION
13063 
13064       WHEN NO_DATA_FOUND THEN
13065       l_return_status := FND_API.G_RET_STS_ERROR;
13066 
13067       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
13068                         ( p_token_an    => l_api_name_full,
13069                           p_token_v     => TO_CHAR(l_service_request_rec.type_id),
13070                           p_token_p     => 'p_type_id',
13071                           p_table_name  => G_TABLE_NAME ,
13072                           p_column_name => 'INCIDENT_TYPE_ID');
13073 
13074        RAISE FND_API.G_EXC_ERROR;
13075 
13076    END ;
13077 
13078 -- for the bug 3050727
13079 l_service_request_rec.status_flag := get_status_flag(l_service_request_rec.status_id);
13080 --- AUDIT
13081 
13082  IF (l_service_request_rec.urgency_id = FND_API.G_MISS_NUM) OR
13083      (l_service_request_rec.urgency_id IS NULL) THEN
13084     x_audit_vals_rec.change_incident_urgency_flag := 'N';
13085   ELSE
13086     x_audit_vals_rec.change_incident_urgency_FLAG := 'Y';
13087     x_audit_vals_rec.incident_urgency_id        := l_service_request_rec.urgency_id;
13088   END IF;
13089 
13090 
13091 /*  IF (l_service_request_rec.owner_group_id = FND_API.G_MISS_NUM) OR
13092     (l_service_request_rec.owner_group_id IS NULL) THEN
13093     x_audit_vals_rec.change_owner_group_id_flag := 'N';
13094   ELSE
13095     x_audit_vals_rec.change_owner_group_id_FLAG := 'Y';
13096     x_audit_vals_rec.owner_group_id        := l_service_request_rec.owner_group_id;
13097   END IF;
13098 */
13099 
13100   IF (l_service_request_rec.product_revision = FND_API.G_MISS_CHAR) OR
13101     (l_service_request_rec.product_revision IS NULL) THEN
13102     x_audit_vals_rec.change_product_revision_flag := 'N';
13103   ELSE
13104     x_audit_vals_rec.change_product_revision_FLAG := 'Y';
13105     x_audit_vals_rec.product_revision        := l_service_request_rec.product_revision;
13106   END IF;
13107 
13108   IF (l_service_request_rec.component_version = FND_API.G_MISS_CHAR) OR
13109     (l_service_request_rec.component_version IS NULL) THEN
13110     x_audit_vals_rec.CHANGE_COMP_VER_FLAG := 'N';
13111   ELSE
13112     x_audit_vals_rec.CHANGE_COMP_VER_FLAG := 'Y';
13113     x_audit_vals_rec.component_version        := l_service_request_rec.component_version;
13114   END IF;
13115 
13116   IF (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR) OR
13117     (l_service_request_rec.subcomponent_version IS NULL) THEN
13118     x_audit_vals_rec.CHANGE_SUBCOMP_VER_FLAG := 'N';
13119   ELSE
13120     x_audit_vals_rec.CHANGE_SUBCOMP_VER_FLAG := 'Y';
13121     x_audit_vals_rec.subcomponent_version       := l_service_request_rec.subcomponent_version;
13122   END IF;
13123 
13124   IF (l_service_request_rec.platform_id = FND_API.G_MISS_NUM) OR
13125     (l_service_request_rec.platform_id IS NULL) THEN
13126     x_audit_vals_rec.change_platform_id_flag := 'N';
13127   ELSE
13128     x_audit_vals_rec.change_platform_id_FLAG := 'Y';
13129     x_audit_vals_rec.platform_id        := l_service_request_rec.platform_id;
13130   END IF;
13131 
13132   IF (l_service_request_rec.customer_product_id = FND_API.G_MISS_NUM) OR
13133     (l_service_request_rec.customer_product_id IS NULL) THEN
13134     x_audit_vals_rec.CHANGE_CUSTOMER_PRODUCT_FLAG := 'N';
13135   ELSE
13136     x_audit_vals_rec.CHANGE_CUSTOMER_PRODUCT_FLAG := 'Y';
13137     x_audit_vals_rec.customer_product_id        := l_service_request_rec.customer_product_id;
13138   END IF;
13139 
13140   IF (l_service_request_rec.cp_component_id = FND_API.G_MISS_NUM) OR
13141     (l_service_request_rec.cp_component_id IS NULL) THEN
13142     x_audit_vals_rec.CHANGE_CP_COMPONENT_ID_FLAG := 'N';
13143   ELSE
13144     x_audit_vals_rec.CHANGE_CP_COMPONENT_ID_FLAG := 'Y';
13145     x_audit_vals_rec.cp_component_id        := l_service_request_rec.cp_component_id;
13146   END IF;
13147 
13148   IF (l_service_request_rec.cp_component_version_id  = FND_API.G_MISS_NUM) OR
13149     (l_service_request_rec.cp_component_version_id  IS NULL) THEN
13150     x_audit_vals_rec.CHANGE_CP_COMP_VER_ID_FLAG := 'N';
13151   ELSE
13152     x_audit_vals_rec.CHANGE_CP_COMP_VER_ID_FLAG := 'Y';
13153     x_audit_vals_rec.cp_component_version_id        := l_service_request_rec.cp_component_version_id;
13154   END IF;
13155 
13156   IF (l_service_request_rec.cp_subcomponent_id  = FND_API.G_MISS_NUM) OR
13157     (l_service_request_rec.cp_subcomponent_id  IS NULL) THEN
13158     x_audit_vals_rec.change_cp_subcomponent_id_flag := 'N';
13159   ELSE
13160     x_audit_vals_rec.change_cp_subcomponent_id_FLAG := 'Y';
13161     x_audit_vals_rec.cp_subcomponent_id        := l_service_request_rec.cp_subcomponent_id;
13162   END IF;
13163 
13164   IF (l_service_request_rec.cp_subcomponent_version_id = FND_API.G_MISS_NUM) OR
13165     (l_service_request_rec.cp_subcomponent_version_id  IS NULL) THEN
13166     x_audit_vals_rec.CHANGE_CP_SUBCOMP_VER_ID_FLAG := 'N';
13167   ELSE
13168     x_audit_vals_rec.CHANGE_CP_SUBCOMP_VER_ID_FLAG := 'Y';
13169     x_audit_vals_rec.cp_subcomponent_version_id        := l_service_request_rec.cp_subcomponent_version_id;
13170   END IF;
13171 
13172   IF (l_service_request_rec.cp_revision_id = FND_API.G_MISS_NUM) OR
13173     (l_service_request_rec.cp_revision_id  IS NULL) THEN
13174     x_audit_vals_rec.change_cp_revision_id_flag := 'N';
13175   ELSE
13176     x_audit_vals_rec.change_cp_revision_id_FLAG := 'Y';
13177     x_audit_vals_rec.cp_revision_id        := l_service_request_rec.cp_revision_id;
13178   END IF;
13179 
13180   IF (l_service_request_rec.inv_item_revision = FND_API.G_MISS_CHAR) OR
13181     (l_service_request_rec.inv_item_revision  IS NULL) THEN
13182     x_audit_vals_rec.change_inv_item_revision := 'N';
13183   ELSE
13184     x_audit_vals_rec.change_inv_item_revision := 'Y';
13185     x_audit_vals_rec.inv_item_revision        := l_service_request_rec.inv_item_revision;
13186   END IF;
13187 
13188   IF (l_service_request_rec.inv_component_id = FND_API.G_MISS_NUM) OR
13189     (l_service_request_rec.inv_component_id IS NULL) THEN
13190     x_audit_vals_rec.change_inv_component_id := 'N';
13191   ELSE
13192     x_audit_vals_rec.change_inv_component_id := 'Y';
13193     x_audit_vals_rec.inv_component_id        := l_service_request_rec.inv_component_id;
13194   END IF;
13195 
13196   IF (l_service_request_rec.inv_component_version = FND_API.G_MISS_CHAR) OR
13197     (l_service_request_rec.inv_component_version  IS NULL) THEN
13198     x_audit_vals_rec.change_inv_component_version := 'N';
13199   ELSE
13200     x_audit_vals_rec.change_inv_component_version := 'Y';
13201     x_audit_vals_rec.inv_component_version        := l_service_request_rec.inv_component_version;
13202   END IF;
13203 
13204   IF (l_service_request_rec.inv_subcomponent_id = FND_API.G_MISS_NUM) OR
13205     (l_service_request_rec.inv_subcomponent_id IS NULL) THEN
13206     x_audit_vals_rec.change_inv_subcomponent_id := 'N';
13207   ELSE
13208     x_audit_vals_rec.change_inv_subcomponent_id := 'Y';
13209     x_audit_vals_rec.inv_subcomponent_id        := l_service_request_rec.inv_subcomponent_id;
13210   END IF;
13211 
13212   IF (l_service_request_rec.inv_subcomponent_version = FND_API.G_MISS_CHAR) OR
13213     (l_service_request_rec.inv_subcomponent_version  IS NULL) THEN
13214     x_audit_vals_rec.CHANGE_INV_SUBCOMP_VERSION := 'N';
13215   ELSE
13216     x_audit_vals_rec.CHANGE_INV_SUBCOMP_VERSION := 'Y';
13217     x_audit_vals_rec.inv_subcomponent_version        := l_service_request_rec.inv_subcomponent_version;
13218   END IF;
13219 
13220   IF (l_service_request_rec.inventory_item_id = FND_API.G_MISS_NUM) OR
13221     (l_service_request_rec.inventory_item_id IS NULL) THEN
13222     x_audit_vals_rec.CHANGE_INVENTORY_ITEM_FLAG := 'N';
13223   ELSE
13224     x_audit_vals_rec.CHANGE_INVENTORY_ITEM_FLAG := 'Y';
13225     x_audit_vals_rec.inventory_item_id        := l_service_request_rec.inventory_item_id;
13226   END IF;
13227 
13228   IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) OR
13229     (l_service_request_rec.inv_platform_org_id IS NULL) THEN
13230     x_audit_vals_rec.CHANGE_PLATFORM_ORG_ID_FLAG := 'N';
13231   ELSE
13232     x_audit_vals_rec.CHANGE_PLATFORM_ORG_ID_FLAG := 'Y';
13233     x_audit_vals_rec.inv_platform_org_id        := l_service_request_rec.inv_platform_org_id;
13234   END IF;
13235 
13236   /* move to create_serevicerequest just before call to create audit rec 7/21/05 smisra
13237   This was need because these dates returned by get_contract were not stamped on audit rec
13238   IF (l_service_request_rec.exp_resolution_date = FND_API.G_MISS_DATE) OR
13239     (l_service_request_rec.exp_resolution_date IS NULL) THEN
13240     x_audit_vals_rec.CHANGE_RESOLUTION_FLAG := 'N';
13241   ELSE
13242     x_audit_vals_rec.CHANGE_RESOLUTION_FLAG := 'Y';
13243     x_audit_vals_rec.EXPECTED_RESOLUTION_DATE        := l_service_request_rec.exp_resolution_date;
13244   END IF;
13245 
13246   IF (l_service_request_rec.obligation_date = FND_API.G_MISS_DATE) OR
13247     (l_service_request_rec.obligation_date IS NULL) THEN
13248     x_audit_vals_rec.CHANGE_OBLIGATION_FLAG := 'N';
13249   ELSE
13250     x_audit_vals_rec.CHANGE_OBLIGATION_FLAG := 'Y';
13251     x_audit_vals_rec.obligation_date        := l_service_request_rec.obligation_date;
13252   END IF;
13253   ************************************************************************************/
13254 
13255   IF (l_service_request_rec.territory_id = FND_API.G_MISS_NUM) OR
13256      (l_service_request_rec.territory_id IS NULL) THEN
13257     x_audit_vals_rec.CHANGE_TERRITORY_ID_FLAG := 'N';
13258   ELSE
13259     x_audit_vals_rec.CHANGE_TERRITORY_ID_FLAG := 'Y';
13260     x_audit_vals_rec.territory_id        := l_service_request_rec.territory_id;
13261   END IF;
13262 
13263   IF (l_service_request_rec.bill_to_contact_id = FND_API.G_MISS_NUM ) OR
13264      (l_service_request_rec.bill_to_contact_id IS NULL) THEN
13265     x_audit_vals_rec.CHANGE_BILL_TO_FLAG := 'N';
13266   ELSE
13267     x_audit_vals_rec.CHANGE_BILL_TO_FLAG := 'Y';
13268     x_audit_vals_rec.bill_to_contact_id        := l_service_request_rec.bill_to_contact_id;
13269   END IF;
13270 
13271   IF (l_service_request_rec.ship_to_contact_id = FND_API.G_MISS_NUM ) OR
13272      (l_service_request_rec.ship_to_contact_id IS NULL) THEN
13273     x_audit_vals_rec.CHANGE_SHIP_TO_FLAG := 'N';
13274   ELSE
13275     x_audit_vals_rec.CHANGE_SHIP_TO_FLAG := 'Y';
13276     x_audit_vals_rec.ship_to_contact_id        := l_service_request_rec.ship_to_contact_id;
13277   END IF;
13278 
13279   IF (l_service_request_rec.status_id = FND_API.G_MISS_NUM) OR
13280     (l_service_request_rec.status_id IS NULL) THEN
13281     x_audit_vals_rec.change_incident_status_flag := 'N';
13282   ELSE
13283     x_audit_vals_rec.change_incident_status_flag := 'Y';
13284     x_audit_vals_rec.incident_status_id        := l_service_request_rec.status_id;
13285   END IF;
13286 
13287  -- Added following block of code to populate the close date audit columns on SR creation in close status.
13288  -- spusegao 04/05/2004
13289 
13290   IF NVL(l_close_flag,'N') = 'Y' THEN
13291      x_audit_vals_rec.close_date := l_service_request_rec.closed_date ;
13292      x_audit_vals_rec.old_close_date := null;
13293      x_audit_vals_rec.change_close_date_flag := 'Y';
13294   ELSE
13295      x_audit_vals_rec.close_date := null;
13296      x_audit_vals_rec.old_close_date := null;
13297      x_audit_vals_rec.change_close_date_flag := 'N' ;
13298   END IF ;
13299 
13300     IF (l_service_request_rec.TYPE_ID = FND_API.G_MISS_NUM) OR
13301     (l_service_request_rec.TYPE_ID IS NULL) THEN
13302     x_audit_vals_rec.CHANGE_INCIDENT_TYPE_FLAG := 'N';
13303   ELSE
13304     x_audit_vals_rec.CHANGE_INCIDENT_TYPE_FLAG := 'Y';
13305     x_audit_vals_rec.INCIDENT_TYPE_ID        := l_service_request_rec.TYPE_ID;
13306   END IF;
13307 
13308   IF (l_service_request_rec.SEVERITY_ID  = FND_API.G_MISS_NUM) OR
13309     (l_service_request_rec.SEVERITY_ID  IS NULL) THEN
13310     x_audit_vals_rec.CHANGE_INCIDENT_SEVERITY_FLAG  := 'N';
13311   ELSE
13312     x_audit_vals_rec.CHANGE_INCIDENT_SEVERITY_FLAG  := 'Y';
13313     x_audit_vals_rec.INCIDENT_SEVERITY_ID         := l_service_request_rec.SEVERITY_ID ;
13314   END IF;
13315 
13316   IF (l_service_request_rec.REQUEST_DATE = FND_API.G_MISS_DATE) OR
13317     (l_service_request_rec.REQUEST_DATE IS NULL) THEN
13318     x_audit_vals_rec.CHANGE_INCIDENT_DATE_FLAG  := 'N';
13319   ELSE
13320     x_audit_vals_rec.CHANGE_INCIDENT_DATE_FLAG  := 'Y';
13321     x_audit_vals_rec.INCIDENT_DATE        := l_service_request_rec.REQUEST_DATE;
13322   END IF;
13323 
13324   IF (l_service_request_rec.PLATFORM_VERSION_ID = FND_API.G_MISS_NUM) OR
13325     (l_service_request_rec.PLATFORM_VERSION_ID IS NULL) THEN
13326     x_audit_vals_rec.CHANGE_PLAT_VER_ID_FLAG  := 'N';
13327   ELSE
13328     x_audit_vals_rec.CHANGE_PLAT_VER_ID_FLAG  := 'Y';
13329     x_audit_vals_rec.PLATFORM_VERSION_ID        := l_service_request_rec.PLATFORM_VERSION_ID;
13330   END IF;
13331 
13332   IF (l_service_request_rec.LANGUAGE_ID = FND_API.G_MISS_NUM) OR
13333     (l_service_request_rec.LANGUAGE_ID IS NULL) THEN
13334     x_audit_vals_rec.CHANGE_LANGUAGE_ID_FLAG  := 'N';
13335   ELSE
13336     x_audit_vals_rec.CHANGE_LANGUAGE_ID_FLAG  := 'Y';
13337     x_audit_vals_rec.LANGUAGE_ID        := l_service_request_rec.LANGUAGE_ID;
13338   END IF;
13339 
13340 
13341   IF (l_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) OR
13342     (l_service_request_rec.inventory_org_id IS NULL) THEN
13343     x_audit_vals_rec.CHANGE_INV_ORGANIZATION_FLAG  := 'N';
13344   ELSE
13345     x_audit_vals_rec.CHANGE_INV_ORGANIZATION_FLAG  := 'Y';
13346     x_audit_vals_rec.INV_ORGANIZATION_ID        := l_service_request_rec.inventory_org_id;
13347   END IF;
13348 
13349   IF (l_service_request_rec.STATUS_FLAG = FND_API.G_MISS_CHAR) OR
13350     (l_service_request_rec.STATUS_FLAG IS NULL) THEN
13351     x_audit_vals_rec.CHANGE_STATUS_FLAG  := 'N';
13352   ELSE
13353     x_audit_vals_rec.CHANGE_STATUS_FLAG  := 'Y';
13354     x_audit_vals_rec.STATUS_FLAG        := l_service_request_rec.STATUS_FLAG;
13355   END IF;
13356 
13357   --- BUG 3640344 -  pkesani
13358 
13359   IF (l_service_request_rec.closed_date = FND_API.G_MISS_DATE) OR
13360     (l_service_request_rec.closed_date IS NULL) THEN
13361     x_audit_vals_rec.CHANGE_CLOSE_DATE_FLAG  := 'N';
13362   ELSE
13363     x_audit_vals_rec.CHANGE_CLOSE_DATE_FLAG  := 'Y';
13364     x_audit_vals_rec.CLOSE_DATE        := l_service_request_rec.closed_date;
13365   END IF;
13366 
13367   IF (l_service_request_rec.PRIMARY_CONTACT_ID = FND_API.G_MISS_NUM) OR
13368     (l_service_request_rec.PRIMARY_CONTACT_ID IS NULL) THEN
13369     x_audit_vals_rec.CHANGE_PRIMARY_CONTACT_FLAG  := 'N';
13370   ELSE
13371     x_audit_vals_rec.CHANGE_PRIMARY_CONTACT_FLAG  := 'Y';
13372     x_audit_vals_rec.PRIMARY_CONTACT_ID        := l_service_request_rec.PRIMARY_CONTACT_ID;
13373   END IF;
13374 
13375   -- Added for Auditing project of 11.5.10 --anmukher --09/03/03
13376 
13377   IF (l_service_request_rec.CUSTOMER_ID <> FND_API.G_MISS_NUM) AND
13378     (l_service_request_rec.CUSTOMER_ID IS NOT NULL) THEN
13379     x_audit_vals_rec.CUSTOMER_ID		:= l_service_request_rec.CUSTOMER_ID;
13380   END IF;
13381 
13382   IF (l_service_request_rec.BILL_TO_SITE_USE_ID <> FND_API.G_MISS_NUM) AND
13383     (l_service_request_rec.BILL_TO_SITE_USE_ID IS NOT NULL) THEN
13384     x_audit_vals_rec.BILL_TO_SITE_USE_ID	:= l_service_request_rec.BILL_TO_SITE_USE_ID;
13385   END IF;
13386 
13387   IF (l_service_request_rec.EMPLOYEE_ID <> FND_API.G_MISS_NUM) AND
13388     (l_service_request_rec.EMPLOYEE_ID IS NOT NULL) THEN
13389     x_audit_vals_rec.EMPLOYEE_ID		:= l_service_request_rec.EMPLOYEE_ID;
13390   END IF;
13391 
13392   IF (l_service_request_rec.SHIP_TO_SITE_USE_ID <> FND_API.G_MISS_NUM) AND
13393     (l_service_request_rec.SHIP_TO_SITE_USE_ID IS NOT NULL) THEN
13394     x_audit_vals_rec.SHIP_TO_SITE_USE_ID	:= l_service_request_rec.SHIP_TO_SITE_USE_ID;
13395   END IF;
13396 
13397   IF (l_service_request_rec.PROBLEM_CODE <> FND_API.G_MISS_CHAR) AND
13398     (l_service_request_rec.PROBLEM_CODE IS NOT NULL) THEN
13399     x_audit_vals_rec.PROBLEM_CODE		:= l_service_request_rec.PROBLEM_CODE;
13400   END IF;
13401 
13402   IF (l_service_request_rec.ACT_RESOLUTION_DATE <> FND_API.G_MISS_DATE) AND
13403     (l_service_request_rec.ACT_RESOLUTION_DATE IS NOT NULL) THEN
13404     x_audit_vals_rec.ACTUAL_RESOLUTION_DATE	:= l_service_request_rec.ACT_RESOLUTION_DATE;
13405   END IF;
13406 
13407   IF (l_service_request_rec.INSTALL_SITE_USE_ID <> FND_API.G_MISS_NUM) AND
13408     (l_service_request_rec.INSTALL_SITE_USE_ID IS NOT NULL) THEN
13409     x_audit_vals_rec.INSTALL_SITE_USE_ID	:= l_service_request_rec.INSTALL_SITE_USE_ID;
13410   END IF;
13411 
13412   IF (l_service_request_rec.CURRENT_SERIAL_NUMBER <> FND_API.G_MISS_CHAR) AND
13413     (l_service_request_rec.CURRENT_SERIAL_NUMBER IS NOT NULL) THEN
13414     x_audit_vals_rec.CURRENT_SERIAL_NUMBER	:= l_service_request_rec.CURRENT_SERIAL_NUMBER;
13415   END IF;
13416 
13417   IF (l_service_request_rec.SYSTEM_ID <> FND_API.G_MISS_NUM) AND
13418     (l_service_request_rec.SYSTEM_ID IS NOT NULL) THEN
13419     x_audit_vals_rec.SYSTEM_ID			:= l_service_request_rec.SYSTEM_ID;
13420   END IF;
13421 
13422 --01/23/04 request and external context were not processed for g_miss_char
13423   IF (l_service_request_rec.REQUEST_ATTRIBUTE_1 <> FND_API.G_MISS_CHAR) AND
13424     (l_service_request_rec.REQUEST_ATTRIBUTE_1 IS NOT NULL) THEN
13425     x_audit_vals_rec.INCIDENT_ATTRIBUTE_1	:= l_service_request_rec.REQUEST_ATTRIBUTE_1;
13426   END IF;
13427 
13428   IF (l_service_request_rec.REQUEST_ATTRIBUTE_2 <> FND_API.G_MISS_CHAR) AND
13429     (l_service_request_rec.REQUEST_ATTRIBUTE_2 IS NOT NULL) THEN
13430     x_audit_vals_rec.INCIDENT_ATTRIBUTE_2	:= l_service_request_rec.REQUEST_ATTRIBUTE_2;
13431   END IF;
13432 
13433   IF (l_service_request_rec.REQUEST_ATTRIBUTE_3 <> FND_API.G_MISS_CHAR) AND
13434     (l_service_request_rec.REQUEST_ATTRIBUTE_3 IS NOT NULL) THEN
13435     x_audit_vals_rec.INCIDENT_ATTRIBUTE_3	:= l_service_request_rec.REQUEST_ATTRIBUTE_3;
13436   END IF;
13437 
13438   IF (l_service_request_rec.REQUEST_ATTRIBUTE_4 <> FND_API.G_MISS_CHAR) AND
13439     (l_service_request_rec.REQUEST_ATTRIBUTE_4 IS NOT NULL) THEN
13440     x_audit_vals_rec.INCIDENT_ATTRIBUTE_4	:= l_service_request_rec.REQUEST_ATTRIBUTE_4;
13441   END IF;
13442 
13443   IF (l_service_request_rec.REQUEST_ATTRIBUTE_5 <> FND_API.G_MISS_CHAR) AND
13444     (l_service_request_rec.REQUEST_ATTRIBUTE_5 IS NOT NULL) THEN
13445     x_audit_vals_rec.INCIDENT_ATTRIBUTE_5	:= l_service_request_rec.REQUEST_ATTRIBUTE_5;
13446   END IF;
13447 
13448   IF (l_service_request_rec.REQUEST_ATTRIBUTE_6 <> FND_API.G_MISS_CHAR) AND
13449     (l_service_request_rec.REQUEST_ATTRIBUTE_6 IS NOT NULL) THEN
13450     x_audit_vals_rec.INCIDENT_ATTRIBUTE_6	:= l_service_request_rec.REQUEST_ATTRIBUTE_6;
13451   END IF;
13452 
13453   IF (l_service_request_rec.REQUEST_ATTRIBUTE_7 <> FND_API.G_MISS_CHAR) AND
13454     (l_service_request_rec.REQUEST_ATTRIBUTE_7 IS NOT NULL) THEN
13455     x_audit_vals_rec.INCIDENT_ATTRIBUTE_7	:= l_service_request_rec.REQUEST_ATTRIBUTE_7;
13456   END IF;
13457 
13458   IF (l_service_request_rec.REQUEST_ATTRIBUTE_8 <> FND_API.G_MISS_CHAR) AND
13459     (l_service_request_rec.REQUEST_ATTRIBUTE_8 IS NOT NULL) THEN
13460     x_audit_vals_rec.INCIDENT_ATTRIBUTE_8	:= l_service_request_rec.REQUEST_ATTRIBUTE_8;
13461   END IF;
13462 
13463   IF (l_service_request_rec.REQUEST_ATTRIBUTE_9 <> FND_API.G_MISS_CHAR) AND
13464     (l_service_request_rec.REQUEST_ATTRIBUTE_9 IS NOT NULL) THEN
13465     x_audit_vals_rec.INCIDENT_ATTRIBUTE_9	:= l_service_request_rec.REQUEST_ATTRIBUTE_9;
13466   END IF;
13467 
13468   IF (l_service_request_rec.REQUEST_ATTRIBUTE_10 <> FND_API.G_MISS_CHAR) AND
13469     (l_service_request_rec.REQUEST_ATTRIBUTE_10 IS NOT NULL) THEN
13470     x_audit_vals_rec.INCIDENT_ATTRIBUTE_10	:= l_service_request_rec.REQUEST_ATTRIBUTE_10;
13471   END IF;
13472 
13473   IF (l_service_request_rec.REQUEST_ATTRIBUTE_11 <> FND_API.G_MISS_CHAR) AND
13474     (l_service_request_rec.REQUEST_ATTRIBUTE_11 IS NOT NULL) THEN
13475     x_audit_vals_rec.INCIDENT_ATTRIBUTE_11	:= l_service_request_rec.REQUEST_ATTRIBUTE_11;
13476   END IF;
13477 
13478   IF (l_service_request_rec.REQUEST_ATTRIBUTE_12 <> FND_API.G_MISS_CHAR) AND
13479     (l_service_request_rec.REQUEST_ATTRIBUTE_12 IS NOT NULL) THEN
13480     x_audit_vals_rec.INCIDENT_ATTRIBUTE_12	:= l_service_request_rec.REQUEST_ATTRIBUTE_12;
13481   END IF;
13482 
13483   IF (l_service_request_rec.REQUEST_ATTRIBUTE_13 <> FND_API.G_MISS_CHAR) AND
13484     (l_service_request_rec.REQUEST_ATTRIBUTE_13 IS NOT NULL) THEN
13485     x_audit_vals_rec.INCIDENT_ATTRIBUTE_13	:= l_service_request_rec.REQUEST_ATTRIBUTE_13;
13486   END IF;
13487 
13488   IF (l_service_request_rec.REQUEST_ATTRIBUTE_14 <> FND_API.G_MISS_CHAR) AND
13489     (l_service_request_rec.REQUEST_ATTRIBUTE_14 IS NOT NULL) THEN
13490     x_audit_vals_rec.INCIDENT_ATTRIBUTE_14	:= l_service_request_rec.REQUEST_ATTRIBUTE_14;
13491   END IF;
13492 
13493   IF (l_service_request_rec.REQUEST_ATTRIBUTE_15 <> FND_API.G_MISS_CHAR) AND
13494     (l_service_request_rec.REQUEST_ATTRIBUTE_15 IS NOT NULL) THEN
13495     x_audit_vals_rec.INCIDENT_ATTRIBUTE_15	:= l_service_request_rec.REQUEST_ATTRIBUTE_15;
13496   END IF;
13497 
13498   IF (l_service_request_rec.REQUEST_CONTEXT <> FND_API.G_MISS_CHAR) AND
13499     (l_service_request_rec.REQUEST_CONTEXT IS NOT NULL) THEN
13500     x_audit_vals_rec.INCIDENT_CONTEXT		:= l_service_request_rec.REQUEST_CONTEXT;
13501   END IF;
13502 
13503   IF (l_service_request_rec.RESOLUTION_CODE <> FND_API.G_MISS_CHAR) AND
13504     (l_service_request_rec.RESOLUTION_CODE IS NOT NULL) THEN
13505     x_audit_vals_rec.RESOLUTION_CODE		:= l_service_request_rec.RESOLUTION_CODE;
13506   END IF;
13507 
13508   IF (l_service_request_rec.ORIGINAL_ORDER_NUMBER <> FND_API.G_MISS_NUM) AND
13509     (l_service_request_rec.ORIGINAL_ORDER_NUMBER IS NOT NULL) THEN
13510     x_audit_vals_rec.ORIGINAL_ORDER_NUMBER	:= l_service_request_rec.ORIGINAL_ORDER_NUMBER;
13511   END IF;
13512 
13513   /* Could not populate this column as no equivalent column was found in l_service_request_rec */
13514   /*
13515   IF (l_service_request_rec.ORIGINAL_ORDER_NUMBER <> FND_API.G_MISS_NUM) AND
13516     (l_service_request_rec.ORIGINAL_ORDER_NUMBER IS NOT NULL) THEN
13517     x_audit_vals_rec.ORG_ID			:= l_service_request_rec.ORIGINAL_ORDER_NUMBER;
13518   END IF;
13519   */
13520 
13521   IF (l_service_request_rec.PURCHASE_ORDER_NUM <> FND_API.G_MISS_CHAR) AND
13522     (l_service_request_rec.PURCHASE_ORDER_NUM IS NOT NULL) THEN
13523     x_audit_vals_rec.PURCHASE_ORDER_NUMBER	:= l_service_request_rec.PURCHASE_ORDER_NUM;
13524   END IF;
13525 
13526   IF (l_service_request_rec.PUBLISH_FLAG <> FND_API.G_MISS_CHAR) AND
13527     (l_service_request_rec.PUBLISH_FLAG IS NOT NULL) THEN
13528     x_audit_vals_rec.PUBLISH_FLAG		:= l_service_request_rec.PUBLISH_FLAG;
13529   END IF;
13530 
13531   IF (l_service_request_rec.QA_COLLECTION_PLAN_ID <> FND_API.G_MISS_NUM) AND
13532     (l_service_request_rec.QA_COLLECTION_PLAN_ID IS NOT NULL) THEN
13533     x_audit_vals_rec.QA_COLLECTION_ID		:= l_service_request_rec.QA_COLLECTION_PLAN_ID;
13534   END IF;
13535 
13536   IF (l_service_request_rec.CONTRACT_ID <> FND_API.G_MISS_NUM) AND
13537     (l_service_request_rec.CONTRACT_ID IS NOT NULL) THEN
13538     x_audit_vals_rec.CONTRACT_ID		:= l_service_request_rec.CONTRACT_ID;
13539   END IF;
13540 
13541   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
13542   /*
13543   IF (l_service_request_rec.CONTRACT_ID <> FND_API.G_MISS_CHAR) AND
13544     (l_service_request_rec.CONTRACT_ID IS NOT NULL) THEN
13545     x_audit_vals_rec.CONTRACT_NUMBER		:= l_service_request_rec.CONTRACT_ID;
13546   END IF;
13547   */
13548 
13549   IF (l_service_request_rec.CONTRACT_SERVICE_ID <> FND_API.G_MISS_NUM) AND
13550     (l_service_request_rec.CONTRACT_SERVICE_ID IS NOT NULL) THEN
13551     x_audit_vals_rec.CONTRACT_SERVICE_ID	:= l_service_request_rec.CONTRACT_SERVICE_ID;
13552   END IF;
13553 
13554   IF (l_service_request_rec.TIME_ZONE_ID <> FND_API.G_MISS_NUM) AND
13555     (l_service_request_rec.TIME_ZONE_ID IS NOT NULL) THEN
13556     x_audit_vals_rec.TIME_ZONE_ID		:= l_service_request_rec.TIME_ZONE_ID;
13557   END IF;
13558 
13559   IF (l_service_request_rec.ACCOUNT_ID <> FND_API.G_MISS_NUM) AND
13560     (l_service_request_rec.ACCOUNT_ID IS NOT NULL) THEN
13561     x_audit_vals_rec.ACCOUNT_ID			:= l_service_request_rec.ACCOUNT_ID;
13562   END IF;
13563 
13564   IF (l_service_request_rec.TIME_DIFFERENCE <> FND_API.G_MISS_NUM) AND
13565     (l_service_request_rec.TIME_DIFFERENCE IS NOT NULL) THEN
13566     x_audit_vals_rec.TIME_DIFFERENCE		:= l_service_request_rec.TIME_DIFFERENCE;
13567   END IF;
13568 
13569   IF (l_service_request_rec.CUST_PO_NUMBER <> FND_API.G_MISS_CHAR) AND
13570     (l_service_request_rec.CUST_PO_NUMBER IS NOT NULL) THEN
13571     x_audit_vals_rec.CUSTOMER_PO_NUMBER		:= l_service_request_rec.CUST_PO_NUMBER;
13572   END IF;
13573 
13574   IF (l_service_request_rec.CUST_TICKET_NUMBER <> FND_API.G_MISS_CHAR) AND
13575     (l_service_request_rec.CUST_TICKET_NUMBER IS NOT NULL) THEN
13576     x_audit_vals_rec.CUSTOMER_TICKET_NUMBER	:= l_service_request_rec.CUST_TICKET_NUMBER;
13577   END IF;
13578 
13579   IF (l_service_request_rec.CUSTOMER_SITE_ID <> FND_API.G_MISS_NUM) AND
13580     (l_service_request_rec.CUSTOMER_SITE_ID IS NOT NULL) THEN
13581     x_audit_vals_rec.CUSTOMER_SITE_ID		:= l_service_request_rec.CUSTOMER_SITE_ID;
13582   END IF;
13583 
13584   IF (l_service_request_rec.CALLER_TYPE <> FND_API.G_MISS_CHAR) AND
13585     (l_service_request_rec.CALLER_TYPE IS NOT NULL) THEN
13586     x_audit_vals_rec.CALLER_TYPE		:= l_service_request_rec.CALLER_TYPE;
13587   END IF;
13588 
13589   IF (l_service_request_rec.PROJECT_NUMBER <> FND_API.G_MISS_CHAR) AND
13590     (l_service_request_rec.PROJECT_NUMBER IS NOT NULL) THEN
13591     x_audit_vals_rec.PROJECT_NUMBER		:= l_service_request_rec.PROJECT_NUMBER;
13592   END IF;
13593 
13594   IF (l_service_request_rec.PLATFORM_VERSION <> FND_API.G_MISS_CHAR) AND
13595     (l_service_request_rec.PLATFORM_VERSION IS NOT NULL) THEN
13596     x_audit_vals_rec.PLATFORM_VERSION		:= l_service_request_rec.PLATFORM_VERSION;
13597   END IF;
13598 
13599   IF (l_service_request_rec.DB_VERSION <> FND_API.G_MISS_CHAR) AND
13600     (l_service_request_rec.DB_VERSION IS NOT NULL) THEN
13601     x_audit_vals_rec.DB_VERSION			:= l_service_request_rec.DB_VERSION;
13602   END IF;
13603 
13604   IF (l_service_request_rec.DB_VERSION <> FND_API.G_MISS_CHAR) AND
13605     (l_service_request_rec.DB_VERSION IS NOT NULL) THEN
13606     x_audit_vals_rec.DB_VERSION			:= l_service_request_rec.DB_VERSION;
13607   END IF;
13608 
13609   IF (l_service_request_rec.CUST_PREF_LANG_ID <> FND_API.G_MISS_NUM) AND
13610     (l_service_request_rec.CUST_PREF_LANG_ID IS NOT NULL) THEN
13611     x_audit_vals_rec.CUST_PREF_LANG_ID		:= l_service_request_rec.CUST_PREF_LANG_ID;
13612   END IF;
13613 
13614   IF (l_service_request_rec.TIER <> FND_API.G_MISS_CHAR) AND
13615     (l_service_request_rec.TIER IS NOT NULL) THEN
13616     x_audit_vals_rec.TIER			:= l_service_request_rec.TIER;
13617   END IF;
13618 
13619   IF (l_service_request_rec.CATEGORY_ID <> FND_API.G_MISS_NUM) AND
13620     (l_service_request_rec.CATEGORY_ID IS NOT NULL) THEN
13621     x_audit_vals_rec.CATEGORY_ID		:= l_service_request_rec.CATEGORY_ID;
13622   END IF;
13623 
13624   IF (l_service_request_rec.OPERATING_SYSTEM <> FND_API.G_MISS_CHAR) AND
13625     (l_service_request_rec.OPERATING_SYSTEM IS NOT NULL) THEN
13626     x_audit_vals_rec.OPERATING_SYSTEM		:= l_service_request_rec.OPERATING_SYSTEM;
13627   END IF;
13628 
13629   IF (l_service_request_rec.OPERATING_SYSTEM_VERSION <> FND_API.G_MISS_CHAR) AND
13630     (l_service_request_rec.OPERATING_SYSTEM_VERSION IS NOT NULL) THEN
13631     x_audit_vals_rec.OPERATING_SYSTEM_VERSION	:= l_service_request_rec.OPERATING_SYSTEM_VERSION;
13632   END IF;
13633 
13634   IF (l_service_request_rec.DATABASE <> FND_API.G_MISS_CHAR) AND
13635     (l_service_request_rec.DATABASE IS NOT NULL) THEN
13636     x_audit_vals_rec.DATABASE			:= l_service_request_rec.DATABASE;
13637   END IF;
13638 
13639   IF (l_service_request_rec.GROUP_TERRITORY_ID <> FND_API.G_MISS_NUM) AND
13640     (l_service_request_rec.GROUP_TERRITORY_ID IS NOT NULL) THEN
13641     x_audit_vals_rec.GROUP_TERRITORY_ID		:= l_service_request_rec.GROUP_TERRITORY_ID;
13642   END IF;
13643 
13644   IF (l_service_request_rec.COMM_PREF_CODE <> FND_API.G_MISS_CHAR) AND
13645     (l_service_request_rec.COMM_PREF_CODE IS NOT NULL) THEN
13646     x_audit_vals_rec.COMM_PREF_CODE		:= l_service_request_rec.COMM_PREF_CODE;
13647   END IF;
13648 
13649   IF (l_service_request_rec.LAST_UPDATE_CHANNEL <> FND_API.G_MISS_CHAR) AND
13650     (l_service_request_rec.LAST_UPDATE_CHANNEL IS NOT NULL) THEN
13651     x_audit_vals_rec.LAST_UPDATE_CHANNEL	:= l_service_request_rec.LAST_UPDATE_CHANNEL;
13652   END IF;
13653 
13654   IF (l_service_request_rec.CUST_PREF_LANG_CODE <> FND_API.G_MISS_CHAR) AND
13655     (l_service_request_rec.CUST_PREF_LANG_CODE IS NOT NULL) THEN
13656     x_audit_vals_rec.CUST_PREF_LANG_CODE	:= l_service_request_rec.CUST_PREF_LANG_CODE;
13657   END IF;
13658 
13659   IF (l_service_request_rec.ERROR_CODE <> FND_API.G_MISS_CHAR) AND
13660     (l_service_request_rec.ERROR_CODE IS NOT NULL) THEN
13661     x_audit_vals_rec.ERROR_CODE			:= l_service_request_rec.ERROR_CODE;
13662   END IF;
13663 
13664   IF (l_service_request_rec.CATEGORY_SET_ID <> FND_API.G_MISS_NUM) AND
13665     (l_service_request_rec.CATEGORY_SET_ID IS NOT NULL) THEN
13666     x_audit_vals_rec.CATEGORY_SET_ID		:= l_service_request_rec.CATEGORY_SET_ID;
13667   END IF;
13668 
13669   IF (l_service_request_rec.EXTERNAL_REFERENCE <> FND_API.G_MISS_CHAR) AND
13670     (l_service_request_rec.EXTERNAL_REFERENCE IS NOT NULL) THEN
13671     x_audit_vals_rec.EXTERNAL_REFERENCE		:= l_service_request_rec.EXTERNAL_REFERENCE;
13672   END IF;
13673 
13674   IF (l_service_request_rec.INCIDENT_OCCURRED_DATE <> FND_API.G_MISS_DATE) AND
13675     (l_service_request_rec.INCIDENT_OCCURRED_DATE IS NOT NULL) THEN
13676     x_audit_vals_rec.INCIDENT_OCCURRED_DATE	:= l_service_request_rec.INCIDENT_OCCURRED_DATE;
13677   END IF;
13678 
13679   IF (l_service_request_rec.INCIDENT_RESOLVED_DATE <> FND_API.G_MISS_DATE) AND
13680     (l_service_request_rec.INCIDENT_RESOLVED_DATE IS NOT NULL) THEN
13681     x_audit_vals_rec.INCIDENT_RESOLVED_DATE	:= l_service_request_rec.INCIDENT_RESOLVED_DATE;
13682   END IF;
13683 
13684   IF (l_service_request_rec.INC_RESPONDED_BY_DATE <> FND_API.G_MISS_DATE) AND
13685     (l_service_request_rec.INC_RESPONDED_BY_DATE IS NOT NULL) THEN
13686     x_audit_vals_rec.INC_RESPONDED_BY_DATE	:= l_service_request_rec.INC_RESPONDED_BY_DATE;
13687   END IF;
13688 
13689   /* 12/13/05 smisra
13690   moved to create_servicerequest just before call to create audit
13691   IF (l_service_request_rec.INCIDENT_LOCATION_ID <> FND_API.G_MISS_NUM) AND
13692     (l_service_request_rec.INCIDENT_LOCATION_ID IS NOT NULL) THEN
13693     x_audit_vals_rec.INCIDENT_LOCATION_ID	:= l_service_request_rec.INCIDENT_LOCATION_ID;
13694   END IF;
13695   ****/
13696 
13697   IF (l_service_request_rec.INCIDENT_ADDRESS <> FND_API.G_MISS_CHAR) AND
13698     (l_service_request_rec.INCIDENT_ADDRESS IS NOT NULL) THEN
13699     x_audit_vals_rec.INCIDENT_ADDRESS		:= l_service_request_rec.INCIDENT_ADDRESS;
13700   END IF;
13701 
13702   IF (l_service_request_rec.INCIDENT_CITY <> FND_API.G_MISS_CHAR) AND
13703     (l_service_request_rec.INCIDENT_CITY IS NOT NULL) THEN
13704     x_audit_vals_rec.INCIDENT_CITY		:= l_service_request_rec.INCIDENT_CITY;
13705   END IF;
13706 
13707   IF (l_service_request_rec.INCIDENT_STATE <> FND_API.G_MISS_CHAR) AND
13708     (l_service_request_rec.INCIDENT_STATE IS NOT NULL) THEN
13709     x_audit_vals_rec.INCIDENT_STATE		:= l_service_request_rec.INCIDENT_STATE;
13710   END IF;
13711 
13712   /* 12/13/05 smisra
13713   moved to create_servicerequest just before call to create audit
13714   IF (l_service_request_rec.INCIDENT_COUNTRY <> FND_API.G_MISS_CHAR) AND
13715     (l_service_request_rec.INCIDENT_COUNTRY IS NOT NULL) THEN
13716     x_audit_vals_rec.INCIDENT_COUNTRY		:= l_service_request_rec.INCIDENT_COUNTRY;
13717   END IF;
13718   ***/
13719 
13720   IF (l_service_request_rec.INCIDENT_PROVINCE <> FND_API.G_MISS_CHAR) AND
13721     (l_service_request_rec.INCIDENT_PROVINCE IS NOT NULL) THEN
13722     x_audit_vals_rec.INCIDENT_PROVINCE		:= l_service_request_rec.INCIDENT_PROVINCE;
13723   END IF;
13724 
13725   IF (l_service_request_rec.INCIDENT_POSTAL_CODE <> FND_API.G_MISS_CHAR) AND
13726     (l_service_request_rec.INCIDENT_POSTAL_CODE IS NOT NULL) THEN
13727     x_audit_vals_rec.INCIDENT_POSTAL_CODE	:= l_service_request_rec.INCIDENT_POSTAL_CODE;
13728   END IF;
13729 
13730   IF (l_service_request_rec.INCIDENT_COUNTY <> FND_API.G_MISS_CHAR) AND
13731     (l_service_request_rec.INCIDENT_COUNTY IS NOT NULL) THEN
13732     x_audit_vals_rec.INCIDENT_COUNTY		:= l_service_request_rec.INCIDENT_COUNTY;
13733   END IF;
13734 
13735   IF (l_service_request_rec.SR_CREATION_CHANNEL <> FND_API.G_MISS_CHAR) AND
13736     (l_service_request_rec.SR_CREATION_CHANNEL IS NOT NULL) THEN
13737     x_audit_vals_rec.SR_CREATION_CHANNEL	:= l_service_request_rec.SR_CREATION_CHANNEL;
13738   END IF;
13739 
13740   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
13741   /*
13742   IF (l_service_request_rec. <> FND_API.G_MISS_NUM) AND
13743     (l_service_request_rec. IS NOT NULL) THEN
13744     x_audit_vals_rec.DEF_DEFECT_ID		:= l_service_request_rec.;
13745   END IF;
13746   */
13747 
13748   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
13749   /*
13750   IF (l_service_request_rec. <> FND_API.G_MISS_NUM) AND
13751     (l_service_request_rec. IS NOT NULL) THEN
13752     x_audit_vals_rec.DEF_DEFECT_ID2		:= l_service_request_rec.;
13753   END IF;
13754   */
13755 
13756   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_1 <> FND_API.G_MISS_CHAR) AND
13757     (l_service_request_rec.EXTERNAL_ATTRIBUTE_1 IS NOT NULL) THEN
13758     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_1	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_1;
13759   END IF;
13760 
13761   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_2 <> FND_API.G_MISS_CHAR) AND
13762     (l_service_request_rec.EXTERNAL_ATTRIBUTE_2 IS NOT NULL) THEN
13763     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_2	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_2;
13764   END IF;
13765 
13766   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_3 <> FND_API.G_MISS_CHAR) AND
13767     (l_service_request_rec.EXTERNAL_ATTRIBUTE_3 IS NOT NULL) THEN
13768     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_3	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_3;
13769   END IF;
13770 
13771   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_4 <> FND_API.G_MISS_CHAR) AND
13772     (l_service_request_rec.EXTERNAL_ATTRIBUTE_4 IS NOT NULL) THEN
13773     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_4	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_4;
13774   END IF;
13775 
13776   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_5 <> FND_API.G_MISS_CHAR) AND
13777     (l_service_request_rec.EXTERNAL_ATTRIBUTE_5 IS NOT NULL) THEN
13778     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_5	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_5;
13779   END IF;
13780 
13781   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_6 <> FND_API.G_MISS_CHAR) AND
13782     (l_service_request_rec.EXTERNAL_ATTRIBUTE_6 IS NOT NULL) THEN
13783     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_6	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_6;
13784   END IF;
13785 
13786   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_7 <> FND_API.G_MISS_CHAR) AND
13787     (l_service_request_rec.EXTERNAL_ATTRIBUTE_7 IS NOT NULL) THEN
13788     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_7	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_7;
13789   END IF;
13790 
13791   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_8 <> FND_API.G_MISS_CHAR) AND
13792     (l_service_request_rec.EXTERNAL_ATTRIBUTE_8 IS NOT NULL) THEN
13793     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_8	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_8;
13794   END IF;
13795 
13796   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_9 <> FND_API.G_MISS_CHAR) AND
13797     (l_service_request_rec.EXTERNAL_ATTRIBUTE_9 IS NOT NULL) THEN
13798     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_9	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_9;
13799   END IF;
13800 
13801   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_10 <> FND_API.G_MISS_CHAR) AND
13802     (l_service_request_rec.EXTERNAL_ATTRIBUTE_10 IS NOT NULL) THEN
13803     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_10	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_10;
13804   END IF;
13805 
13806   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_11 <> FND_API.G_MISS_CHAR) AND
13807     (l_service_request_rec.EXTERNAL_ATTRIBUTE_11 IS NOT NULL) THEN
13808     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_11	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_11;
13809   END IF;
13810 
13811   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_12 <> FND_API.G_MISS_CHAR) AND
13812     (l_service_request_rec.EXTERNAL_ATTRIBUTE_12 IS NOT NULL) THEN
13813     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_12	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_12;
13814   END IF;
13815 
13816   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_13 <> FND_API.G_MISS_CHAR) AND
13817     (l_service_request_rec.EXTERNAL_ATTRIBUTE_13 IS NOT NULL) THEN
13818     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_13	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_13;
13819   END IF;
13820 
13821   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_14 <> FND_API.G_MISS_CHAR) AND
13822     (l_service_request_rec.EXTERNAL_ATTRIBUTE_14 IS NOT NULL) THEN
13823     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_14	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_14;
13824   END IF;
13825 
13826   IF (l_service_request_rec.EXTERNAL_ATTRIBUTE_15 <> FND_API.G_MISS_CHAR) AND
13827     (l_service_request_rec.EXTERNAL_ATTRIBUTE_15 IS NOT NULL) THEN
13828     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_15	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_15;
13829   END IF;
13830 
13831   IF (l_service_request_rec.EXTERNAL_CONTEXT <> FND_API.G_MISS_CHAR) AND
13832     (l_service_request_rec.EXTERNAL_CONTEXT IS NOT NULL) THEN
13833     x_audit_vals_rec.EXTERNAL_CONTEXT		:= l_service_request_rec.EXTERNAL_CONTEXT;
13834   END IF;
13835 
13836   IF (l_service_request_rec.LAST_UPDATE_PROGRAM_CODE <> FND_API.G_MISS_CHAR) AND
13837     (l_service_request_rec.LAST_UPDATE_PROGRAM_CODE IS NOT NULL) THEN
13838     x_audit_vals_rec.LAST_UPDATE_PROGRAM_CODE	:= l_service_request_rec.LAST_UPDATE_PROGRAM_CODE;
13839   END IF;
13840 
13841   IF (l_service_request_rec.CREATION_PROGRAM_CODE <> FND_API.G_MISS_CHAR) AND
13842     (l_service_request_rec.CREATION_PROGRAM_CODE IS NOT NULL) THEN
13843     x_audit_vals_rec.CREATION_PROGRAM_CODE	:= l_service_request_rec.CREATION_PROGRAM_CODE;
13844   END IF;
13845 
13846   /****
13847   16th Nov 2005 smisra:
13848   coverage type is determined based on contract service id after
13849   call to create SR Validation.
13850   so moving this code to just before audit creation call
13851   --
13852   IF (l_service_request_rec.COVERAGE_TYPE <> FND_API.G_MISS_CHAR) AND
13853     (l_service_request_rec.COVERAGE_TYPE IS NOT NULL) THEN
13854     x_audit_vals_rec.COVERAGE_TYPE		:= l_service_request_rec.COVERAGE_TYPE;
13855   END IF;
13856   *******************************************************************************/
13857 
13858   IF (l_service_request_rec.BILL_TO_ACCOUNT_ID <> FND_API.G_MISS_NUM) AND
13859     (l_service_request_rec.BILL_TO_ACCOUNT_ID IS NOT NULL) THEN
13860     x_audit_vals_rec.BILL_TO_ACCOUNT_ID		:= l_service_request_rec.BILL_TO_ACCOUNT_ID;
13861   END IF;
13862 
13863   IF (l_service_request_rec.SHIP_TO_ACCOUNT_ID <> FND_API.G_MISS_NUM) AND
13864     (l_service_request_rec.SHIP_TO_ACCOUNT_ID IS NOT NULL) THEN
13865     x_audit_vals_rec.SHIP_TO_ACCOUNT_ID		:= l_service_request_rec.SHIP_TO_ACCOUNT_ID;
13866   END IF;
13867 
13868   IF (l_service_request_rec.CUSTOMER_EMAIL_ID <> FND_API.G_MISS_NUM) AND
13869     (l_service_request_rec.CUSTOMER_EMAIL_ID IS NOT NULL) THEN
13870     x_audit_vals_rec.CUSTOMER_EMAIL_ID		:= l_service_request_rec.CUSTOMER_EMAIL_ID;
13871   END IF;
13872 
13873   IF (l_service_request_rec.CUSTOMER_PHONE_ID <> FND_API.G_MISS_NUM) AND
13874     (l_service_request_rec.CUSTOMER_PHONE_ID IS NOT NULL) THEN
13875     x_audit_vals_rec.CUSTOMER_PHONE_ID		:= l_service_request_rec.CUSTOMER_PHONE_ID;
13876   END IF;
13877 
13878   IF (l_service_request_rec.BILL_TO_PARTY_ID <> FND_API.G_MISS_NUM) AND
13879     (l_service_request_rec.BILL_TO_PARTY_ID IS NOT NULL) THEN
13880     x_audit_vals_rec.BILL_TO_PARTY_ID		:= l_service_request_rec.BILL_TO_PARTY_ID;
13881   END IF;
13882 
13883   IF (l_service_request_rec.SHIP_TO_PARTY_ID <> FND_API.G_MISS_NUM) AND
13884     (l_service_request_rec.SHIP_TO_PARTY_ID IS NOT NULL) THEN
13885     x_audit_vals_rec.SHIP_TO_PARTY_ID		:= l_service_request_rec.SHIP_TO_PARTY_ID;
13886   END IF;
13887 
13888   IF (l_service_request_rec.BILL_TO_SITE_ID <> FND_API.G_MISS_NUM) AND
13889     (l_service_request_rec.BILL_TO_SITE_ID IS NOT NULL) THEN
13890     x_audit_vals_rec.BILL_TO_SITE_ID		:= l_service_request_rec.BILL_TO_SITE_ID;
13891   END IF;
13892 
13893   IF (l_service_request_rec.SHIP_TO_SITE_ID <> FND_API.G_MISS_NUM) AND
13894     (l_service_request_rec.SHIP_TO_SITE_ID IS NOT NULL) THEN
13895     x_audit_vals_rec.SHIP_TO_SITE_ID		:= l_service_request_rec.SHIP_TO_SITE_ID;
13896   END IF;
13897 
13898   IF (l_service_request_rec.PROGRAM_LOGIN_ID <> FND_API.G_MISS_NUM) AND
13899     (l_service_request_rec.PROGRAM_LOGIN_ID IS NOT NULL) THEN
13900     x_audit_vals_rec.PROGRAM_LOGIN_ID		:= l_service_request_rec.PROGRAM_LOGIN_ID;
13901   END IF;
13902 
13903   IF (l_service_request_rec.INCIDENT_POINT_OF_INTEREST <> FND_API.G_MISS_CHAR) AND
13904     (l_service_request_rec.INCIDENT_POINT_OF_INTEREST IS NOT NULL) THEN
13905     x_audit_vals_rec.INCIDENT_POINT_OF_INTEREST	:= l_service_request_rec.INCIDENT_POINT_OF_INTEREST;
13906   END IF;
13907 
13908   IF (l_service_request_rec.INCIDENT_CROSS_STREET <> FND_API.G_MISS_CHAR) AND
13909     (l_service_request_rec.INCIDENT_CROSS_STREET IS NOT NULL) THEN
13910     x_audit_vals_rec.INCIDENT_CROSS_STREET	:= l_service_request_rec.INCIDENT_CROSS_STREET;
13911   END IF;
13912 
13913   IF (l_service_request_rec.incident_direction_qualifier <> FND_API.G_MISS_CHAR) AND
13914     (l_service_request_rec.incident_direction_qualifier IS NOT NULL) THEN
13915     x_audit_vals_rec.INCIDENT_DIRECTION_QUALIF	:= l_service_request_rec.incident_direction_qualifier;
13916   END IF;
13917 
13918   IF (l_service_request_rec.incident_distance_qualifier <> FND_API.G_MISS_CHAR) AND
13919     (l_service_request_rec.incident_distance_qualifier IS NOT NULL) THEN
13920     x_audit_vals_rec.INCIDENT_DISTANCE_QUALIF	:= l_service_request_rec.incident_distance_qualifier;
13921   END IF;
13922 
13923   IF (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM <> FND_API.G_MISS_CHAR) AND
13924     (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM IS NOT NULL) THEN
13925     x_audit_vals_rec.INCIDENT_DISTANCE_QUAL_UOM	:= l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM;
13926   END IF;
13927 
13928   IF (l_service_request_rec.INCIDENT_ADDRESS2 <> FND_API.G_MISS_CHAR) AND
13929     (l_service_request_rec.INCIDENT_ADDRESS2 IS NOT NULL) THEN
13930     x_audit_vals_rec.INCIDENT_ADDRESS2		:= l_service_request_rec.INCIDENT_ADDRESS2;
13931   END IF;
13932 
13933   IF (l_service_request_rec.INCIDENT_ADDRESS3 <> FND_API.G_MISS_CHAR) AND
13934     (l_service_request_rec.INCIDENT_ADDRESS3 IS NOT NULL) THEN
13935     x_audit_vals_rec.INCIDENT_ADDRESS3		:= l_service_request_rec.INCIDENT_ADDRESS3;
13936   END IF;
13937 
13938   IF (l_service_request_rec.INCIDENT_ADDRESS4 <> FND_API.G_MISS_CHAR) AND
13939     (l_service_request_rec.INCIDENT_ADDRESS4 IS NOT NULL) THEN
13940     x_audit_vals_rec.INCIDENT_ADDRESS4		:= l_service_request_rec.INCIDENT_ADDRESS4;
13941   END IF;
13942 
13943   IF (l_service_request_rec.INCIDENT_ADDRESS_STYLE <> FND_API.G_MISS_CHAR) AND
13944     (l_service_request_rec.INCIDENT_ADDRESS_STYLE IS NOT NULL) THEN
13945     x_audit_vals_rec.INCIDENT_ADDRESS_STYLE	:= l_service_request_rec.INCIDENT_ADDRESS_STYLE;
13946   END IF;
13947 
13948   IF (l_service_request_rec.incident_addr_lines_phonetic <> FND_API.G_MISS_CHAR) AND
13949     (l_service_request_rec.incident_addr_lines_phonetic IS NOT NULL) THEN
13950     x_audit_vals_rec.INCIDENT_ADDR_LNS_PHONETIC	:= l_service_request_rec.incident_addr_lines_phonetic;
13951   END IF;
13952 
13953   IF (l_service_request_rec.INCIDENT_PO_BOX_NUMBER <> FND_API.G_MISS_CHAR) AND
13954     (l_service_request_rec.INCIDENT_PO_BOX_NUMBER IS NOT NULL) THEN
13955     x_audit_vals_rec.INCIDENT_PO_BOX_NUMBER	:= l_service_request_rec.INCIDENT_PO_BOX_NUMBER;
13956   END IF;
13957 
13958   IF (l_service_request_rec.INCIDENT_HOUSE_NUMBER <> FND_API.G_MISS_CHAR) AND
13959     (l_service_request_rec.INCIDENT_HOUSE_NUMBER IS NOT NULL) THEN
13960     x_audit_vals_rec.INCIDENT_HOUSE_NUMBER	:= l_service_request_rec.INCIDENT_HOUSE_NUMBER;
13961   END IF;
13962 
13963   IF (l_service_request_rec.INCIDENT_STREET_SUFFIX <> FND_API.G_MISS_CHAR) AND
13964     (l_service_request_rec.INCIDENT_STREET_SUFFIX IS NOT NULL) THEN
13965     x_audit_vals_rec.INCIDENT_STREET_SUFFIX	:= l_service_request_rec.INCIDENT_STREET_SUFFIX;
13966   END IF;
13967 
13968   IF (l_service_request_rec.INCIDENT_STREET <> FND_API.G_MISS_CHAR) AND
13969     (l_service_request_rec.INCIDENT_STREET IS NOT NULL) THEN
13970     x_audit_vals_rec.INCIDENT_STREET		:= l_service_request_rec.INCIDENT_STREET;
13971   END IF;
13972 
13973   IF (l_service_request_rec.INCIDENT_STREET_NUMBER <> FND_API.G_MISS_CHAR) AND
13974     (l_service_request_rec.INCIDENT_STREET_NUMBER IS NOT NULL) THEN
13975     x_audit_vals_rec.INCIDENT_STREET_NUMBER	:= l_service_request_rec.INCIDENT_STREET_NUMBER;
13976   END IF;
13977 
13978   IF (l_service_request_rec.INCIDENT_FLOOR <> FND_API.G_MISS_CHAR) AND
13979     (l_service_request_rec.INCIDENT_FLOOR IS NOT NULL) THEN
13980     x_audit_vals_rec.INCIDENT_FLOOR		:= l_service_request_rec.INCIDENT_FLOOR;
13981   END IF;
13982 
13983   IF (l_service_request_rec.INCIDENT_SUITE <> FND_API.G_MISS_CHAR) AND
13984     (l_service_request_rec.INCIDENT_SUITE IS NOT NULL) THEN
13985     x_audit_vals_rec.INCIDENT_SUITE		:= l_service_request_rec.INCIDENT_SUITE;
13986   END IF;
13987 
13988   IF (l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE <> FND_API.G_MISS_CHAR) AND
13989     (l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE IS NOT NULL) THEN
13990     x_audit_vals_rec.INCIDENT_POSTAL_PLUS4_CODE	:= l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE;
13991   END IF;
13992 
13993   IF (l_service_request_rec.INCIDENT_POSITION <> FND_API.G_MISS_CHAR) AND
13994     (l_service_request_rec.INCIDENT_POSITION IS NOT NULL) THEN
13995     x_audit_vals_rec.INCIDENT_POSITION		:= l_service_request_rec.INCIDENT_POSITION;
13996   END IF;
13997 
13998   IF (l_service_request_rec.incident_location_directions <> FND_API.G_MISS_CHAR) AND
13999     (l_service_request_rec.incident_location_directions IS NOT NULL) THEN
14000     x_audit_vals_rec.INCIDENT_LOC_DIRECTIONS	:= l_service_request_rec.incident_location_directions;
14001   END IF;
14002 
14003   IF (l_service_request_rec.incident_location_description <> FND_API.G_MISS_CHAR) AND
14004     (l_service_request_rec.incident_location_description IS NOT NULL) THEN
14005     x_audit_vals_rec.INCIDENT_LOC_DESCRIPTION	:= l_service_request_rec.incident_location_description;
14006   END IF;
14007 
14008   IF (l_service_request_rec.INSTALL_SITE_ID <> FND_API.G_MISS_NUM) AND
14009     (l_service_request_rec.INSTALL_SITE_ID IS NOT NULL) THEN
14010     x_audit_vals_rec.INSTALL_SITE_ID		:= l_service_request_rec.INSTALL_SITE_ID;
14011   END IF;
14012 
14013   IF (l_service_request_rec.TIER_VERSION <> FND_API.G_MISS_CHAR) AND
14014     (l_service_request_rec.TIER_VERSION IS NOT NULL) THEN
14015     x_audit_vals_rec.TIER_VERSION		:= l_service_request_rec.TIER_VERSION;
14016   END IF;
14017 
14018    --15995804. Add price_list_header_id and SLA dates for audit details
14019   IF (l_service_request_rec.PRICE_LIST_HEADER_ID <> FND_API.G_MISS_NUM) AND
14020     (l_service_request_rec.PRICE_LIST_HEADER_ID IS NOT NULL) THEN
14021     x_audit_vals_rec.PRICE_LIST_HEADER_ID	:= l_service_request_rec.PRICE_LIST_HEADER_ID;
14022   END IF;
14023   IF (l_service_request_rec.SLA_DATE_1 = FND_API.G_MISS_DATE) OR
14024     (l_service_request_rec.SLA_DATE_1 IS NULL) THEN
14025      x_audit_vals_rec.CHANGE_SLA_DATE_1_FLAG := 'N';
14026    ELSE
14027     x_audit_vals_rec.CHANGE_SLA_DATE_1_FLAG := 'Y';
14028     x_audit_vals_rec.SLA_DATE_1	:= l_service_request_rec.SLA_DATE_1;
14029   END IF;
14030   IF (l_service_request_rec.SLA_DATE_2 = FND_API.G_MISS_DATE) OR
14031     (l_service_request_rec.SLA_DATE_2 IS NULL) THEN
14032      x_audit_vals_rec.CHANGE_SLA_DATE_2_FLAG := 'N';
14033    ELSE
14034     x_audit_vals_rec.CHANGE_SLA_DATE_2_FLAG := 'Y';
14035     x_audit_vals_rec.SLA_DATE_2	:= l_service_request_rec.SLA_DATE_2;
14036   END IF;
14037   IF (l_service_request_rec.SLA_DATE_3 = FND_API.G_MISS_DATE) OR
14038     (l_service_request_rec.SLA_DATE_3 IS NULL) THEN
14039      x_audit_vals_rec.CHANGE_SLA_DATE_3_FLAG := 'N';
14040    ELSE
14041     x_audit_vals_rec.CHANGE_SLA_DATE_3_FLAG := 'Y';
14042     x_audit_vals_rec.SLA_DATE_3	:= l_service_request_rec.SLA_DATE_3;
14043   END IF;
14044   IF (l_service_request_rec.SLA_DATE_4 = FND_API.G_MISS_DATE) OR
14045     (l_service_request_rec.SLA_DATE_4 IS NULL) THEN
14046      x_audit_vals_rec.CHANGE_SLA_DATE_4_FLAG := 'N';
14047    ELSE
14048     x_audit_vals_rec.CHANGE_SLA_DATE_4_FLAG := 'Y';
14049     x_audit_vals_rec.SLA_DATE_4	:= l_service_request_rec.SLA_DATE_4;
14050   END IF;
14051   IF (l_service_request_rec.SLA_DATE_5 = FND_API.G_MISS_DATE) OR
14052     (l_service_request_rec.SLA_DATE_5 IS NULL) THEN
14053      x_audit_vals_rec.CHANGE_SLA_DATE_5_FLAG := 'N';
14054    ELSE
14055     x_audit_vals_rec.CHANGE_SLA_DATE_5_FLAG := 'Y';
14056     x_audit_vals_rec.SLA_DATE_5	:= l_service_request_rec.SLA_DATE_5;
14057   END IF;
14058   IF (l_service_request_rec.SLA_DATE_6 = FND_API.G_MISS_DATE) OR
14059     (l_service_request_rec.SLA_DATE_6 IS NULL) THEN
14060      x_audit_vals_rec.CHANGE_SLA_DATE_6_FLAG := 'N';
14061    ELSE
14062     x_audit_vals_rec.CHANGE_SLA_DATE_6_FLAG := 'Y';
14063     x_audit_vals_rec.SLA_DATE_6	:= l_service_request_rec.SLA_DATE_6;
14064   END IF;
14065   IF (l_service_request_rec.SLA_DURATION_1 = FND_API.G_MISS_NUM) OR
14066     (l_service_request_rec.SLA_DURATION_1 IS NULL) THEN
14067      x_audit_vals_rec.CHANGE_SLA_DURATION_1_FLAG := 'N';
14068    ELSE
14069     x_audit_vals_rec.CHANGE_SLA_DURATION_1_FLAG := 'Y';
14070     x_audit_vals_rec.SLA_DURATION_1  := l_service_request_rec.SLA_DURATION_1;
14071   END IF;
14072    IF (l_service_request_rec.SLA_DURATION_2 = FND_API.G_MISS_NUM) OR
14073     (l_service_request_rec.SLA_DURATION_2 IS NULL) THEN
14074      x_audit_vals_rec.CHANGE_SLA_DURATION_2_FLAG := 'N';
14075    ELSE
14076     x_audit_vals_rec.CHANGE_SLA_DURATION_2_FLAG := 'Y';
14077     x_audit_vals_rec.SLA_DURATION_2  := l_service_request_rec.SLA_DURATION_2;
14078   END IF;
14079    --15995804. END Add price_list_header_id and SLA dates for audit details
14080 
14081   --anmukher --09/12/03
14082 
14083   x_audit_vals_rec.INC_OBJECT_VERSION_NUMBER	:= 1;
14084 
14085   IF (l_service_request_rec.conc_request_id <> FND_API.G_MISS_NUM) AND
14086     (l_service_request_rec.conc_request_id IS NOT NULL) THEN
14087     x_audit_vals_rec.INC_REQUEST_ID		:= l_service_request_rec.conc_request_id;
14088   END IF;
14089 
14090   IF (l_service_request_rec.program_application_id <> FND_API.G_MISS_NUM) AND
14091     (l_service_request_rec.program_application_id IS NOT NULL) THEN
14092     x_audit_vals_rec.INC_PROGRAM_APPLICATION_ID	:= l_service_request_rec.program_application_id;
14093   END IF;
14094 
14095   IF (l_service_request_rec.program_id <> FND_API.G_MISS_NUM) AND
14096     (l_service_request_rec.program_id IS NOT NULL) THEN
14097     x_audit_vals_rec.INC_PROGRAM_ID		:= l_service_request_rec.program_id;
14098   END IF;
14099 
14100   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
14101   /*
14102   IF (l_service_request_rec. <> FND_API.G_MISS_DATE) AND
14103     (l_service_request_rec. IS NOT NULL) THEN
14104     x_audit_vals_rec.INC_PROGRAM_UPDATE_DATE	:= l_service_request_rec.;
14105   END IF;
14106   */
14107 
14108   IF (l_service_request_rec.owning_dept_id <> FND_API.G_MISS_NUM) AND
14109     (l_service_request_rec.owning_dept_id IS NOT NULL) THEN
14110     x_audit_vals_rec.OWNING_DEPARTMENT_ID	:= l_service_request_rec.owning_dept_id;
14111   END IF;
14112 
14113   /* 12/13/05 smisra
14114   moved to create_servicerequest just before call to create audit
14115   IF (l_service_request_rec.incident_location_type <> FND_API.G_MISS_CHAR) AND
14116     (l_service_request_rec.incident_location_type IS NOT NULL) THEN
14117     x_audit_vals_rec.INCIDENT_LOCATION_TYPE	:= l_service_request_rec.incident_location_type;
14118   END IF;
14119   ******/
14120 
14121   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
14122   /*
14123   IF (l_service_request_rec. <> FND_API.G_MISS_CHAR) AND
14124     (l_service_request_rec. IS NOT NULL) THEN
14125     x_audit_vals_rec.UNASSIGNED_INDICATOR	:= l_service_request_rec.;
14126   END IF;
14127   */
14128 
14129 
14130 ---- AUDIT
14131 
14132   --All the ids should be assigned NULL value before insert into the database
14133   --This  has to be done here cause the earlier checks are done only if
14134   --validation level is set.
14135 
14136   IF (l_service_request_rec.urgency_id = FND_API.G_MISS_NUM) THEN
14137     l_service_request_rec.urgency_id := NULL;
14138   END IF;
14139 
14140   IF (l_service_request_rec.employee_id IS NOT NULL ) THEN
14141     l_service_request_rec.employee_id := NULL;
14142   END IF;
14143 
14144   IF (l_service_request_rec.owner_group_id = FND_API.G_MISS_NUM) THEN
14145     l_service_request_rec.owner_group_id := NULL;
14146   END IF;
14147 
14148 ---- made null if not passed, since the mandatory check is no longer in use
14149 ---- Enhancements 11.5.6
14150   IF (l_service_request_rec.owner_id = FND_API.G_MISS_NUM) THEN
14151     l_service_request_rec.owner_id := NULL;
14152   END IF;
14153 
14154   IF (l_service_request_rec.product_revision = FND_API.G_MISS_CHAR) THEN
14155     l_service_request_rec.product_revision := NULL;
14156   END IF;
14157 
14158   IF (l_service_request_rec.component_version = FND_API.G_MISS_CHAR) THEN
14159     l_service_request_rec.component_version := NULL;
14160   END IF;
14161 
14162   IF (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR) THEN
14163     l_service_request_rec.subcomponent_version := NULL;
14164   END IF;
14165 -----------
14166   IF (l_service_request_rec.platform_id = FND_API.G_MISS_NUM) THEN
14167     l_service_request_rec.platform_id := NULL;
14168   END IF;
14169 
14170   IF (l_service_request_rec.platform_version = FND_API.G_MISS_CHAR) THEN
14171     l_service_request_rec.platform_version := NULL;
14172   END IF;
14173 
14174   IF (l_service_request_rec.platform_version_id = FND_API.G_MISS_NUM) THEN
14175     l_service_request_rec.platform_version_id := NULL;
14176   END IF;
14177 
14178   IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) THEN
14179     l_service_request_rec.inv_platform_org_id := NULL;
14180   END IF;
14181 
14182   IF (l_service_request_rec.db_version = FND_API.G_MISS_CHAR) THEN
14183     l_service_request_rec.db_version := NULL;
14184   END IF;
14185 
14186   IF (l_service_request_rec.customer_product_id = FND_API.G_MISS_NUM) THEN
14187     l_service_request_rec.customer_product_id := NULL;
14188   END IF;
14189 
14190   IF (l_service_request_rec.cp_component_id = FND_API.G_MISS_NUM) THEN
14191     l_service_request_rec.cp_component_id := NULL;
14192   END IF;
14193 
14194   IF (l_service_request_rec.cp_component_version_id  = FND_API.G_MISS_NUM) THEN
14195     l_service_request_rec.cp_component_version_id  := NULL;
14196   END IF;
14197 
14198   IF (l_service_request_rec.cp_subcomponent_id  = FND_API.G_MISS_NUM) THEN
14199     l_service_request_rec.cp_subcomponent_id  := NULL;
14200   END IF;
14201 
14202   IF (l_service_request_rec.cp_subcomponent_version_id = FND_API.G_MISS_NUM) THEN
14203     l_service_request_rec.cp_subcomponent_version_id  := NULL;
14204   END IF;
14205 
14206   IF (l_service_request_rec.cp_revision_id = FND_API.G_MISS_NUM) THEN
14207     l_service_request_rec.cp_revision_id  := NULL;
14208   END IF;
14209 
14210   IF (l_service_request_rec.inv_item_revision = FND_API.G_MISS_CHAR) THEN
14211     l_service_request_rec.inv_item_revision  := NULL;
14212   END IF;
14213 
14214   IF (l_service_request_rec.inv_component_id = FND_API.G_MISS_NUM) THEN
14215     l_service_request_rec.inv_component_id := NULL;
14216   END IF;
14217 
14218   IF (l_service_request_rec.inv_component_version = FND_API.G_MISS_CHAR) THEN
14219     l_service_request_rec.inv_component_version  := NULL;
14220   END IF;
14221 
14222   IF (l_service_request_rec.inv_subcomponent_id = FND_API.G_MISS_NUM) THEN
14223     l_service_request_rec.inv_subcomponent_id := NULL;
14224   END IF;
14225 
14226   IF (l_service_request_rec.inv_subcomponent_version = FND_API.G_MISS_CHAR) THEN
14227     l_service_request_rec.inv_subcomponent_version  := NULL;
14228   END IF;
14229 
14230 
14231   IF (l_service_request_rec.inventory_item_id = FND_API.G_MISS_NUM) THEN
14232     l_service_request_rec.inventory_item_id := NULL;
14233   END IF;
14234 
14235   IF (l_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) THEN
14236     l_service_request_rec.inventory_org_id := NULL;
14237   END IF;
14238 
14239   IF (l_service_request_rec.current_serial_number = FND_API.G_MISS_CHAR) THEN
14240     l_service_request_rec.current_serial_number := NULL;
14241   END IF;
14242 
14243   IF (l_service_request_rec.original_order_number = FND_API.G_MISS_NUM) THEN
14244     l_service_request_rec.original_order_number := NULL;
14245   END IF;
14246 
14247 
14248   IF (l_service_request_rec.purchase_order_num = FND_API.G_MISS_CHAR) THEN
14249     l_service_request_rec.purchase_order_num := NULL;
14250   END IF;
14251 
14252   IF (l_service_request_rec.problem_code = FND_API.G_MISS_CHAR) THEN
14253     l_service_request_rec.problem_code := NULL;
14254   END IF;
14255 
14256 -----------Added for enhancement 11.5.6 -----jngeorge-----07/20/01
14257 ----cust_pref_lang_id is customer preferred language
14258 ----tier and tier_versions
14259 ----operating_system and operating_system_version
14260 ----database
14261 ----category_id
14262 ----inv_platform_org_id
14263 ----comm_pref_code
14264 
14265   IF (l_service_request_rec.cust_pref_lang_id = FND_API.G_MISS_NUM) THEN
14266     l_service_request_rec.cust_pref_lang_id := NULL;
14267   END IF;
14268 
14269   IF (l_service_request_rec.last_update_channel = FND_API.G_MISS_CHAR) THEN
14270     l_service_request_rec.last_update_channel := NULL;
14271   END IF;
14272 
14273   IF (l_service_request_rec.cust_pref_lang_code = FND_API.G_MISS_CHAR) THEN
14274     l_service_request_rec.cust_pref_lang_code := NULL;
14275   END IF;
14276 
14277   IF (l_service_request_rec.comm_pref_code = FND_API.G_MISS_CHAR) THEN
14278     l_service_request_rec.comm_pref_code := NULL;
14279   END IF;
14280 
14281   IF (l_service_request_rec.tier = FND_API.G_MISS_CHAR) THEN
14282     l_service_request_rec.tier := NULL;
14283   END IF;
14284 
14285   IF (l_service_request_rec.tier_version = FND_API.G_MISS_CHAR) THEN
14286     l_service_request_rec.tier_version := NULL;
14287   END IF;
14288 
14289   IF (l_service_request_rec.operating_system = FND_API.G_MISS_CHAR) THEN
14290     l_service_request_rec.operating_system := NULL;
14291   END IF;
14292 
14293   IF (l_service_request_rec.operating_system_version = FND_API.G_MISS_CHAR) THEN
14294     l_service_request_rec.operating_system_version := NULL;
14295   END IF;
14296 
14297   IF (l_service_request_rec.DATABASE = FND_API.G_MISS_CHAR) THEN
14298     l_service_request_rec.DATABASE := NULL;
14299   END IF;
14300 
14301   IF (l_service_request_rec.category_id = FND_API.G_MISS_NUM) THEN
14302     l_service_request_rec.category_id := NULL;
14303   END IF;
14304 
14305   IF (l_service_request_rec.category_set_id = FND_API.G_MISS_NUM) THEN
14306     l_service_request_rec.category_set_id := NULL;
14307   END IF;
14308 
14309   IF (l_service_request_rec.external_reference = FND_API.G_MISS_CHAR) THEN
14310     l_service_request_rec.external_reference := NULL;
14311   END IF;
14312 
14313   IF (l_service_request_rec.system_id = FND_API.G_MISS_NUM) THEN
14314     l_service_request_rec.system_id := NULL;
14315   END IF;
14316 
14317   IF (l_service_request_rec.group_type = FND_API.G_MISS_CHAR) THEN
14318     l_service_request_rec.group_type := NULL;
14319   END IF;
14320 
14321   IF (l_service_request_rec.group_territory_id = FND_API.G_MISS_NUM) THEN
14322     l_service_request_rec.group_territory_id := NULL;
14323   END IF;
14324 
14325   IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) THEN
14326     l_service_request_rec.inv_platform_org_id := NULL;
14327   END IF;
14328 
14329 --------------------------
14330 
14331   IF (l_service_request_rec.exp_resolution_date = FND_API.G_MISS_DATE) THEN
14332     l_service_request_rec.exp_resolution_date := NULL;
14333   END IF;
14334 
14335   IF (l_service_request_rec.resolution_code = FND_API.G_MISS_CHAR) THEN
14336     l_service_request_rec.resolution_code := NULL;
14337   END IF;
14338 
14339   IF (l_service_request_rec.act_resolution_date = FND_API.G_MISS_DATE) THEN
14340     l_service_request_rec.act_resolution_date := NULL;
14341   END IF;
14342 
14343   IF (l_service_request_rec.contract_service_id = FND_API.G_MISS_NUM) THEN
14344     l_service_request_rec.contract_service_id := NULL;
14345   END IF;
14346 
14347   IF (l_service_request_rec.contract_id = FND_API.G_MISS_NUM) THEN
14348     l_service_request_rec.contract_id := NULL;
14349   END IF;
14350 
14351   IF (l_service_request_rec.project_number = FND_API.G_MISS_CHAR) THEN
14352     l_service_request_rec.project_number := NULL;
14353   END IF;
14354 
14355   IF (l_service_request_rec.qa_collection_plan_id = FND_API.G_MISS_NUM) THEN
14356     l_service_request_rec.qa_collection_plan_id := NULL;
14357   END IF;
14358 
14359   IF (l_service_request_rec.account_id = FND_API.G_MISS_NUM) THEN
14360     l_service_request_rec.account_id := NULL;
14361   END IF;
14362 
14363   IF (l_service_request_rec.resource_subtype_id = FND_API.G_MISS_NUM) THEN
14364     l_service_request_rec.resource_subtype_id := NULL;
14365   END IF;
14366 
14367   IF (l_service_request_rec.cust_po_number = FND_API.G_MISS_CHAR) THEN
14368     l_service_request_rec.cust_po_number := NULL;
14369   END IF;
14370 
14371   IF (l_service_request_rec.cust_ticket_number = FND_API.G_MISS_CHAR) THEN
14372     l_service_request_rec.cust_ticket_number := NULL;
14373   END IF;
14374 
14375   IF (l_service_request_rec.sr_creation_channel = FND_API.G_MISS_CHAR) THEN
14376     l_service_request_rec.sr_creation_channel := NULL;
14377   END IF;
14378 
14379   IF (l_service_request_rec.obligation_date = FND_API.G_MISS_DATE) THEN
14380     l_service_request_rec.obligation_date := NULL;
14381   END IF;
14382 
14383   IF (l_service_request_rec.error_code = FND_API.G_MISS_CHAR) THEN
14384     l_service_request_rec.error_code := NULL;
14385   END IF;
14386 
14387   IF (l_service_request_rec.resolution_summary = FND_API.G_MISS_CHAR) THEN
14388     l_service_request_rec.resolution_summary := NULL;
14389   END IF;
14390 
14391   IF (l_service_request_rec.incident_address = FND_API.G_MISS_CHAR) THEN
14392     l_service_request_rec.incident_address := NULL;
14393   END IF;
14394 
14395   IF (l_service_request_rec.incident_city = FND_API.G_MISS_CHAR) THEN
14396     l_service_request_rec.incident_city := NULL;
14397   END IF;
14398 
14399   IF (l_service_request_rec.incident_state = FND_API.G_MISS_CHAR) THEN
14400     l_service_request_rec.incident_state := NULL;
14401   END IF;
14402 
14403   IF (l_service_request_rec.incident_country = FND_API.G_MISS_CHAR) THEN
14404     l_service_request_rec.incident_country := NULL;
14405   END IF;
14406 
14407   IF (l_service_request_rec.incident_province = FND_API.G_MISS_CHAR) THEN
14408     l_service_request_rec.incident_province := NULL;
14409   END IF;
14410 
14411   IF (l_service_request_rec.incident_postal_code = FND_API.G_MISS_CHAR) THEN
14412     l_service_request_rec.incident_postal_code := NULL;
14413   END IF;
14414 
14415   IF (l_service_request_rec.incident_county = FND_API.G_MISS_CHAR) THEN
14416     l_service_request_rec.incident_county := NULL;
14417   END IF;
14418 
14419 
14420   -- Added for Enh# 1830701
14421   IF (l_service_request_rec.incident_occurred_date = FND_API.G_MISS_DATE) THEN
14422     l_service_request_rec.incident_occurred_date := NULL;
14423   END IF;
14424 
14425   IF (l_service_request_rec.incident_resolved_date = FND_API.G_MISS_DATE) THEN
14426     l_service_request_rec.incident_resolved_date := NULL;
14427   END IF;
14428 
14429   IF (l_service_request_rec.inc_responded_by_date = FND_API.G_MISS_DATE) THEN
14430     l_service_request_rec.inc_responded_by_date := NULL;
14431   END IF;
14432 
14433   -- Added for Enh# 1830701
14434   IF (l_service_request_rec.incident_location_id = FND_API.G_MISS_NUM) THEN
14435     l_service_request_rec.incident_location_id := NULL;
14436   END IF;
14437 
14438   IF (l_service_request_rec.time_zone_id = FND_API.G_MISS_NUM) THEN
14439     l_service_request_rec.time_zone_id := NULL;
14440   END IF;
14441 
14442   IF (l_service_request_rec.time_difference = FND_API.G_MISS_NUM) THEN
14443     l_service_request_rec.time_difference := NULL;
14444   END IF;
14445 
14446   IF (l_service_request_rec.site_id = FND_API.G_MISS_NUM) THEN
14447     l_service_request_rec.site_id := NULL;
14448   END IF;
14449 
14450   IF (l_service_request_rec.customer_site_id = FND_API.G_MISS_NUM) THEN
14451     l_service_request_rec.customer_site_id := NULL;
14452   END IF;
14453 
14454   IF (l_service_request_rec.territory_id = FND_API.G_MISS_NUM) THEN
14455     l_service_request_rec.territory_id := NULL;
14456   END IF;
14457 
14458   IF (l_service_request_rec.publish_flag = FND_API.G_MISS_CHAR) THEN
14459     l_service_request_rec.publish_flag := NULL;
14460   END IF;
14461 
14462   IF (l_service_request_rec.verify_cp_flag = FND_API.G_MISS_CHAR) THEN
14463     l_service_request_rec.verify_cp_flag := NULL;
14464   END IF;
14465 
14466   IF (l_service_request_rec.customer_id = FND_API.G_MISS_NUM ) THEN
14467       l_service_request_rec.customer_id := NULL;
14468   END IF;
14469 
14470   IF (l_service_request_rec.customer_number = FND_API.G_MISS_CHAR ) THEN
14471       l_service_request_rec.customer_number := NULL;
14472   END IF;
14473 
14474   IF (l_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM ) THEN
14475       l_service_request_rec.bill_to_site_id := NULL;
14476   END IF;
14477 
14478   IF (l_service_request_rec.bill_to_site_use_id = FND_API.G_MISS_NUM ) THEN
14479       l_service_request_rec.bill_to_site_use_id := NULL;
14480   END IF;
14481 
14482   IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM ) THEN
14483       l_service_request_rec.bill_to_party_id := NULL;
14484   END IF;
14485 
14486   IF (l_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM ) THEN
14487       l_service_request_rec.ship_to_site_id := NULL;
14488   END IF;
14489 
14490   IF (l_service_request_rec.ship_to_site_use_id = FND_API.G_MISS_NUM ) THEN
14491       l_service_request_rec.ship_to_site_use_id := NULL;
14492   END IF;
14493 
14494   IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM ) THEN
14495       l_service_request_rec.ship_to_party_id := NULL;
14496   END IF;
14497 
14498   IF (l_service_request_rec.install_site_id = FND_API.G_MISS_NUM ) THEN
14499       l_service_request_rec.install_site_id := NULL;
14500   END IF;
14501 
14502   IF (l_service_request_rec.install_site_use_id = FND_API.G_MISS_NUM ) THEN
14503       l_service_request_rec.install_site_use_id := NULL;
14504   END IF;
14505 
14506   /*Added to check if install site is passed then the install site use id should be populated and visa versa*/
14507   IF ( l_service_request_rec.install_site_id IS NULL AND
14508        l_service_request_rec.install_site_use_id IS NOT NULL) THEN
14509       l_service_request_rec.install_site_id := l_service_request_rec.install_site_use_id;
14510   END IF;
14511 
14512   IF ( l_service_request_rec.install_site_use_id IS NULL AND
14513        l_service_request_rec.install_site_id IS NOT NULL) THEN
14514       l_service_request_rec.install_site_use_id := l_service_request_rec.install_site_id;
14515   END IF;
14516 
14517   IF (l_service_request_rec.bill_to_contact_id = FND_API.G_MISS_NUM ) THEN
14518       l_service_request_rec.bill_to_contact_id := NULL;
14519   END IF;
14520 
14521   IF (l_service_request_rec.ship_to_contact_id = FND_API.G_MISS_NUM ) THEN
14522       l_service_request_rec.ship_to_contact_id := NULL;
14523   END IF;
14524 
14525 -------Bug Fix #1625002-------jngeorge--------05/29/01
14526   handle_missing_value(l_service_request_rec.request_context ,null);
14527   handle_missing_value(l_service_request_rec.external_context,null);
14528 
14529   IF (l_service_request_rec.request_attribute_1 = FND_API.G_MISS_CHAR ) THEN
14530       l_service_request_rec.request_attribute_1 := NULL;
14531   END IF;
14532 
14533   IF (l_service_request_rec.request_attribute_2 = FND_API.G_MISS_CHAR ) THEN
14534       l_service_request_rec.request_attribute_2 := NULL;
14535   END IF;
14536 
14537   IF (l_service_request_rec.request_attribute_3 = FND_API.G_MISS_CHAR ) THEN
14538       l_service_request_rec.request_attribute_3 := NULL;
14539   END IF;
14540 
14541   IF (l_service_request_rec.request_attribute_4 = FND_API.G_MISS_CHAR ) THEN
14542       l_service_request_rec.request_attribute_4 := NULL;
14543   END IF;
14544 
14545   IF (l_service_request_rec.request_attribute_5 = FND_API.G_MISS_CHAR ) THEN
14546       l_service_request_rec.request_attribute_5 := NULL;
14547   END IF;
14548 
14549   IF (l_service_request_rec.request_attribute_6 = FND_API.G_MISS_CHAR ) THEN
14550       l_service_request_rec.request_attribute_6 := NULL;
14551   END IF;
14552 
14553   IF (l_service_request_rec.request_attribute_7 = FND_API.G_MISS_CHAR ) THEN
14554       l_service_request_rec.request_attribute_7 := NULL;
14555   END IF;
14556 
14557   IF (l_service_request_rec.request_attribute_8 = FND_API.G_MISS_CHAR ) THEN
14558       l_service_request_rec.request_attribute_8 := NULL;
14559   END IF;
14560 
14561   IF (l_service_request_rec.request_attribute_9 = FND_API.G_MISS_CHAR ) THEN
14562       l_service_request_rec.request_attribute_9 := NULL;
14563   END IF;
14564 
14565   IF (l_service_request_rec.request_attribute_10 = FND_API.G_MISS_CHAR ) THEN
14566       l_service_request_rec.request_attribute_10 := NULL;
14567   END IF;
14568 
14569   IF (l_service_request_rec.request_attribute_11 = FND_API.G_MISS_CHAR ) THEN
14570       l_service_request_rec.request_attribute_11 := NULL;
14571   END IF;
14572 
14573   IF (l_service_request_rec.request_attribute_12 = FND_API.G_MISS_CHAR ) THEN
14574       l_service_request_rec.request_attribute_12 := NULL;
14575   END IF;
14576 
14577   IF (l_service_request_rec.request_attribute_13 = FND_API.G_MISS_CHAR ) THEN
14578       l_service_request_rec.request_attribute_13 := NULL;
14579   END IF;
14580 
14581   IF (l_service_request_rec.request_attribute_14 = FND_API.G_MISS_CHAR ) THEN
14582       l_service_request_rec.request_attribute_14 := NULL;
14583   END IF;
14584 
14585   IF (l_service_request_rec.request_attribute_15 = FND_API.G_MISS_CHAR ) THEN
14586       l_service_request_rec.request_attribute_15 := NULL;
14587   END IF;
14588 
14589   IF (l_service_request_rec.external_attribute_1 = FND_API.G_MISS_CHAR ) THEN
14590       l_service_request_rec.external_attribute_1 := NULL;
14591   END IF;
14592 
14593   IF (l_service_request_rec.external_attribute_2 = FND_API.G_MISS_CHAR ) THEN
14594       l_service_request_rec.external_attribute_2 := NULL;
14595   END IF;
14596 
14597   IF (l_service_request_rec.external_attribute_3 = FND_API.G_MISS_CHAR ) THEN
14598       l_service_request_rec.external_attribute_3 := NULL;
14599   END IF;
14600 
14601   IF (l_service_request_rec.external_attribute_4 = FND_API.G_MISS_CHAR ) THEN
14602       l_service_request_rec.external_attribute_4 := NULL;
14603   END IF;
14604 
14605   IF (l_service_request_rec.external_attribute_5 = FND_API.G_MISS_CHAR ) THEN
14606       l_service_request_rec.external_attribute_5 := NULL;
14607   END IF;
14608 
14609   IF (l_service_request_rec.external_attribute_6 = FND_API.G_MISS_CHAR ) THEN
14610       l_service_request_rec.external_attribute_6 := NULL;
14611   END IF;
14612 
14613   IF (l_service_request_rec.external_attribute_7 = FND_API.G_MISS_CHAR ) THEN
14614       l_service_request_rec.external_attribute_7 := NULL;
14615   END IF;
14616 
14617   IF (l_service_request_rec.external_attribute_8 = FND_API.G_MISS_CHAR ) THEN
14618       l_service_request_rec.external_attribute_8 := NULL;
14619   END IF;
14620 
14621   IF (l_service_request_rec.external_attribute_9 = FND_API.G_MISS_CHAR ) THEN
14622       l_service_request_rec.external_attribute_9 := NULL;
14623   END IF;
14624 
14625   IF (l_service_request_rec.external_attribute_10 = FND_API.G_MISS_CHAR ) THEN
14626       l_service_request_rec.external_attribute_10 := NULL;
14627   END IF;
14628 
14629   IF (l_service_request_rec.external_attribute_11 = FND_API.G_MISS_CHAR ) THEN
14630       l_service_request_rec.external_attribute_11 := NULL;
14631   END IF;
14632 
14633   IF (l_service_request_rec.external_attribute_12 = FND_API.G_MISS_CHAR ) THEN
14634       l_service_request_rec.external_attribute_12 := NULL;
14635   END IF;
14636 
14637   IF (l_service_request_rec.external_attribute_13 = FND_API.G_MISS_CHAR ) THEN
14638       l_service_request_rec.external_attribute_13 := NULL;
14639   END IF;
14640 
14641   IF (l_service_request_rec.external_attribute_14 = FND_API.G_MISS_CHAR ) THEN
14642       l_service_request_rec.external_attribute_14 := NULL;
14643   END IF;
14644 
14645   IF (l_service_request_rec.external_attribute_15 = FND_API.G_MISS_CHAR ) THEN
14646       l_service_request_rec.external_attribute_15 := NULL;
14647   END IF;
14648 
14649   --- Added for HA, the WHO columns should be derived before inserting
14650   --- if passed null or has G_MISS values.
14651 
14652   IF (l_service_request_rec.last_update_date = FND_API.G_MISS_DATE OR
14653       l_service_request_rec.last_update_date IS NULL ) THEN
14654 --      l_service_request_rec.last_update_date := SYSDATE;
14655       l_service_request_rec.last_update_date := l_sysdate;
14656   END IF;
14657 
14658   IF (l_service_request_rec.last_updated_by = FND_API.G_MISS_NUM OR
14659       l_service_request_rec.last_updated_by IS NULL ) THEN
14660       l_service_request_rec.last_updated_by := p_user_id;
14661   END IF;
14662 
14663   IF (l_service_request_rec.creation_date = FND_API.G_MISS_DATE OR
14664       l_service_request_rec.creation_date IS NULL ) THEN
14665 --      l_service_request_rec.creation_date := SYSDATE;
14666       l_service_request_rec.creation_date := l_sysdate;
14667   END IF;
14668 
14669   IF (l_service_request_rec.created_by = FND_API.G_MISS_NUM OR
14670       l_service_request_rec.created_by IS NULL ) THEN
14671       l_service_request_rec.created_by := p_user_id;
14672   END IF;
14673 
14674   IF (l_service_request_rec.last_update_login = FND_API.G_MISS_NUM OR
14675       l_service_request_rec.last_update_login IS NULL ) THEN
14676       l_service_request_rec.last_update_login := p_login_id;
14677   END IF;
14678 
14679   IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE ) THEN
14680       l_service_request_rec.owner_assigned_time := NULL;
14681   END IF;
14682 --------------jngeorge-------05/29/01
14683 
14684    -- Added  For   Coverage_type              - ER# 2320056
14685 
14686    IF (l_service_request_rec.Coverage_type= FND_API.G_MISS_CHAR ) THEN
14687        l_service_request_rec.Coverage_type := NULL;
14688    END IF;
14689 
14690 -- If the contract service id is null then coverage type should be null
14691 -- Added this check for 1159 by shijain dec6th 2002
14692    IF (l_service_request_rec.contract_service_id = FND_API.G_MISS_NUM)
14693    OR (l_service_request_rec.contract_service_id IS NULL)  THEN
14694            l_service_request_rec.coverage_type  := NULL;
14695    END IF;
14696 
14697    -- Added  For   bill_to_account_id         - ER# 2433831
14698 
14699    IF (l_service_request_rec.bill_to_account_id  = FND_API.G_MISS_NUM ) THEN
14700        l_service_request_rec.bill_to_account_id := NULL;
14701    END IF;
14702 
14703    -- Added  For   ship_to_account_id         - ER# 2433831
14704 
14705    IF (l_service_request_rec.ship_to_account_id  = FND_API.G_MISS_NUM ) THEN
14706        l_service_request_rec.ship_to_account_id := NULL;
14707    END IF;
14708 
14709    -- Added  For   customer_phone_id   - ER# 2463321   ---
14710 
14711    IF (l_service_request_rec.customer_phone_id  = FND_API.G_MISS_NUM ) THEN
14712        l_service_request_rec.customer_phone_id := NULL;
14713    END IF;
14714 
14715    -- Added  For   customer_email_id   - ER# 2463321
14716    IF (l_service_request_rec.customer_email_id  = FND_API.G_MISS_NUM ) THEN
14717        l_service_request_rec.customer_email_id := NULL;
14718    END IF;
14719 
14720    IF (l_service_request_rec.program_id  = FND_API.G_MISS_NUM ) THEN
14721        l_service_request_rec.program_id := NULL;
14722    END IF;
14723 
14724    IF (l_service_request_rec.program_application_id  = FND_API.G_MISS_NUM ) THEN
14725        l_service_request_rec.program_application_id := NULL;
14726    END IF;
14727 
14728    IF (l_service_request_rec.conc_request_id  = FND_API.G_MISS_NUM ) THEN
14729        l_service_request_rec.conc_request_id := NULL;
14730    END IF;
14731 
14732    IF (l_service_request_rec.program_login_id  = FND_API.G_MISS_NUM ) THEN
14733        l_service_request_rec.program_login_id := NULL;
14734    END IF;
14735 
14736    -- Added for address fields related changes by shijain
14737 
14738    IF (l_service_request_rec.incident_point_of_interest  = FND_API.G_MISS_CHAR)
14739    THEN
14740        l_service_request_rec.incident_point_of_interest  := NULL;
14741    END IF;
14742 
14743    IF (l_service_request_rec.incident_cross_street  = FND_API.G_MISS_CHAR) THEN
14744        l_service_request_rec.incident_cross_street  := NULL;
14745    END IF;
14746 
14747    IF (l_service_request_rec.incident_direction_qualifier = FND_API.G_MISS_CHAR)
14748    THEN
14749        l_service_request_rec.incident_direction_qualifier   := NULL;
14750    END IF;
14751 
14752    IF (l_service_request_rec.incident_distance_qualifier = FND_API.G_MISS_CHAR)
14753    THEN
14754        l_service_request_rec.incident_distance_qualifier    := NULL;
14755    END IF;
14756 
14757    IF (l_service_request_rec.incident_distance_qual_uom   = FND_API.G_MISS_CHAR)
14758    THEN
14759        l_service_request_rec.incident_distance_qual_uom  := NULL;
14760    END IF;
14761 
14762    IF (l_service_request_rec.incident_address2  = FND_API.G_MISS_CHAR)  THEN
14763        l_service_request_rec.incident_address2    := NULL;
14764    END IF;
14765 
14766    IF (l_service_request_rec.incident_address3    = FND_API.G_MISS_CHAR)  THEN
14767        l_service_request_rec.incident_address3    := NULL;
14768    END IF;
14769 
14770    IF (l_service_request_rec.incident_address4    = FND_API.G_MISS_CHAR) THEN
14771        l_service_request_rec.incident_address4   := NULL;
14772    END IF;
14773 
14774    IF (l_service_request_rec.incident_address_style  = FND_API.G_MISS_CHAR)
14775    THEN
14776        l_service_request_rec.incident_address_style    := NULL;
14777    END IF;
14778 
14779    IF (l_service_request_rec.incident_addr_lines_phonetic = FND_API.G_MISS_CHAR)
14780    THEN
14781        l_service_request_rec.incident_addr_lines_phonetic   := NULL;
14782    END IF;
14783 
14784    IF (l_service_request_rec.incident_po_box_number   = FND_API.G_MISS_CHAR)
14785    THEN
14786        l_service_request_rec.incident_po_box_number   := NULL;
14787    END IF;
14788 
14789    IF (l_service_request_rec.incident_house_number   = FND_API.G_MISS_CHAR) THEN
14790        l_service_request_rec.incident_house_number   := NULL;
14791    END IF;
14792 
14793    IF (l_service_request_rec.incident_street_suffix   = FND_API.G_MISS_CHAR)
14794    THEN
14795        l_service_request_rec.incident_street_suffix   := NULL;
14796    END IF;
14797 
14798    IF (l_service_request_rec.incident_street   = FND_API.G_MISS_CHAR)  THEN
14799        l_service_request_rec.incident_street  := NULL;
14800    END IF;
14801 
14802    IF (l_service_request_rec.incident_street_number   = FND_API.G_MISS_CHAR)
14803    THEN
14804        l_service_request_rec.incident_street_number  := NULL;
14805    END IF;
14806 
14807    IF (l_service_request_rec.incident_floor   = FND_API.G_MISS_CHAR)  THEN
14808        l_service_request_rec.incident_floor   := NULL;
14809    END IF;
14810 
14811    IF (l_service_request_rec.incident_suite   = FND_API.G_MISS_CHAR) THEN
14812        l_service_request_rec.incident_suite   := NULL;
14813    END IF;
14814 
14815    IF (l_service_request_rec.incident_postal_plus4_code   = FND_API.G_MISS_CHAR)
14816    THEN
14817        l_service_request_rec.incident_postal_plus4_code   := NULL;
14818    END IF;
14819 
14820    IF (l_service_request_rec.incident_position   = FND_API.G_MISS_CHAR)  THEN
14821        l_service_request_rec.incident_position  := NULL;
14822    END IF;
14823 
14824    IF (l_service_request_rec.incident_location_directions = FND_API.G_MISS_CHAR)
14825    THEN
14826        l_service_request_rec.incident_location_directions := NULL;
14827    END IF;
14828 
14829    IF (l_service_request_rec.incident_location_description= FND_API.G_MISS_CHAR)
14830    THEN
14831        l_service_request_rec.incident_location_description  := NULL;
14832    END IF;
14833 
14834    IF (l_service_request_rec.install_site_id   = FND_API.G_MISS_NUM)  THEN
14835        l_service_request_rec.install_site_id  := NULL;
14836    END IF;
14837 
14838    -- for cmro_eam
14839    IF (l_service_request_rec.owning_dept_id = FND_API.G_MISS_NUM) THEN
14840         l_service_request_rec.owning_dept_id := NULL;
14841    END IF;
14842 
14843    IF (l_service_request_rec.owner_assigned_flag  = FND_API.G_MISS_CHAR)  THEN
14844        l_service_request_rec.owner_assigned_flag    := NULL;
14845    END IF;
14846    IF (l_service_request_rec.resource_type  = FND_API.G_MISS_CHAR)  THEN
14847        l_service_request_rec.resource_type    := NULL;
14848    END IF;
14849    IF (l_service_request_rec.maint_organization_id = FND_API.G_MISS_NUM) THEN
14850      l_service_request_rec.maint_organization_id := NULL;
14851    END IF;
14852 
14853      --15995804. Add price_list_header_id and SLA dates
14854    IF (l_service_request_rec.price_list_header_id = FND_API.G_MISS_NUM) THEN
14855       l_service_request_rec.price_list_header_id := NULL;
14856    END IF;
14857    IF (l_service_request_rec.sla_date_1 = FND_API.G_MISS_DATE ) THEN
14858       l_service_request_rec.sla_date_1 := NULL;
14859    END IF;
14860    IF (l_service_request_rec.sla_date_2 = FND_API.G_MISS_DATE ) THEN
14861       l_service_request_rec.sla_date_2 := NULL;
14862    END IF;
14863    IF (l_service_request_rec.sla_date_3 = FND_API.G_MISS_DATE ) THEN
14864       l_service_request_rec.sla_date_3 := NULL;
14865    END IF;
14866    IF (l_service_request_rec.sla_date_4 = FND_API.G_MISS_DATE ) THEN
14867       l_service_request_rec.sla_date_4 := NULL;
14868    END IF;
14869    IF (l_service_request_rec.sla_date_5 = FND_API.G_MISS_DATE ) THEN
14870       l_service_request_rec.sla_date_5 := NULL;
14871    END IF;
14872    IF (l_service_request_rec.sla_date_6 = FND_API.G_MISS_DATE ) THEN
14873       l_service_request_rec.sla_date_6 := NULL;
14874    END IF;
14875    IF (l_service_request_rec.sla_duration_1 = FND_API.G_MISS_NUM) THEN
14876       l_service_request_rec.sla_duration_1 := NULL;
14877    END IF;
14878    IF (l_service_request_rec.sla_duration_2 = FND_API.G_MISS_NUM) THEN
14879       l_service_request_rec.sla_duration_2 := NULL;
14880    END IF;
14881      --15995804. END Add price_list_header_id and SLA dates
14882 
14883 
14884 
14885 
14886    -- for cmro_eam
14887   -- ----------------------------------------------------------------------
14888   -- Perform the database operation. Generate the request ID and request
14889   -- number from the sequences, then insert the sequence numbers and passed
14890   -- in attributes into the CS_INCIDENTS_ALL table.
14891   -- ----------------------------------------------------------------------
14892 
14893 /****
14894 
14895   If request id is not passed as a parameter to the API, then find the
14896   next id/number from the sequence and check whether the generated number
14897   already exists in the database. If it exists continue to generate the
14898   id/number till a unique id/number is found
14899 
14900 *******/
14901 
14902  IF l_request_id IS NULL THEN
14903    LOOP
14904      SELECT cs_incidents_s.NEXTVAL INTO x_req_id FROM dual;
14905      BEGIN
14906        SELECT incident_id INTO l_temp_id FROM cs_incidents_all_b
14907        WHERE incident_id = x_req_id;
14908      EXCEPTION
14909        WHEN NO_DATA_FOUND THEN
14910          EXIT;
14911        WHEN OTHERS THEN
14912          EXIT;
14913      END;
14914    END LOOP;
14915  ELSE
14916    x_request_id := l_request_id;
14917  END IF;
14918 
14919  IF l_request_number IS NULL THEN
14920    LOOP
14921      SELECT cs_incidents_number_s.NEXTVAL INTO x_req_num FROM dual;
14922      BEGIN
14923        SELECT incident_number INTO l_temp_num FROM cs_incidents_all_b
14924        WHERE incident_number = x_req_num;
14925      EXCEPTION
14926        WHEN NO_DATA_FOUND THEN
14927          EXIT;
14928        WHEN OTHERS THEN
14929          EXIT;
14930      END;
14931    END LOOP;
14932  ELSE
14933    x_request_number := l_request_number;
14934  END IF;
14935 
14936 --------Added owner_assigned_flag for the enhancements--11.5.6--
14937 --------
14938 --------
14939 
14940     IF (l_service_request_rec.owner_group_id IS NOT NULL AND
14941         l_service_request_rec.owner_id IS NOT NULL) OR
14942        (l_service_request_rec.owner_group_id IS NOT NULL AND
14943          l_service_request_rec.group_type = 'RS_TEAM') OR
14944        (l_service_request_rec.owner_group_id IS NOT NULL AND
14945          l_service_request_rec.group_type IS NULL) THEN
14946          l_service_request_rec.owner_assigned_flag := 'Y';
14947     ELSIF (l_service_request_rec.owner_group_id IS NULL) THEN
14948          l_service_request_rec.owner_assigned_flag := 'N';
14949     ELSE
14950          l_service_request_rec.owner_assigned_flag := 'N';
14951     END IF;
14952 
14953    ---- Added this code because the form is clearing the group,
14954    ---- when group_type is not entered.
14955     IF (l_service_request_rec.owner_group_id IS NOT NULL AND
14956         l_service_request_rec.group_type IS NULL) THEN
14957          l_service_request_rec.owner_group_id := NULL;
14958     END IF;
14959 
14960 --*************************************************
14961 --Added code to fix Bug# 1948054
14962 
14963 -- dj
14964 -- changed = to >
14965 -- contracts : 3224828 changed to = to get the values
14966 -- for contract_id and contract_number
14967 IF (p_validation_level = FND_API.G_VALID_LEVEL_NONE) THEN
14968 --IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
14969     --
14970     -- Validate contract service id
14971     --
14972     IF (l_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM AND
14973         l_service_request_rec.contract_service_id IS NOT NULL) THEN
14974 
14975         CS_ServiceRequest_UTIL.Validate_Contract_Service_Id(
14976           p_api_name         => l_api_name,
14977           p_parameter_name   => 'p_contract_service_id',
14978           p_contract_service_id => l_service_request_rec.contract_service_id,
14979           x_contract_id      =>x_contra_id,
14980           x_contract_number  =>x_contract_number,
14981           x_return_status    => x_return_status);
14982 
14983          IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
14984             x_return_status := FND_API.G_RET_STS_ERROR;
14985            RETURN;
14986          END IF;
14987 
14988      END IF;
14989     --
14990     -- Validate contract id 04/16/01
14991     --
14992     IF (l_service_request_rec.contract_id <> FND_API.G_MISS_NUM) AND
14993         (l_service_request_rec.contract_id IS NOT NULL) AND
14994         (l_service_request_rec.contract_service_id IS NULL OR
14995         l_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM) THEN
14996 
14997         CS_ServiceRequest_UTIL.Validate_Contract_Id(
14998           p_api_name         => l_api_name,
14999           p_parameter_name   => 'p_contract_id',
15000           p_contract_id => l_service_request_rec.contract_id,
15001                 x_contract_number  => x_contract_number,
15002           x_return_status    => l_return_status);
15003 
15004       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
15005          x_return_status := FND_API.G_RET_STS_ERROR;
15006         RETURN;
15007       END IF;
15008 
15009       x_contra_id := l_service_request_rec.contract_id;
15010 
15011      END IF;
15012 
15013 
15014 END IF;
15015 
15016     --
15017     -- Validate creation program code 10/11/02 shijain - This should be done everytime
15018     -- irrespective of validation level - since this does not come from an LOV
15019 	--
15020 
15021     IF (l_service_request_rec.creation_program_code <> FND_API.G_MISS_CHAR) AND
15022         (l_service_request_rec.creation_program_code IS NOT NULL) THEN
15023 
15024         CS_ServiceRequest_UTIL.Validate_source_program_code(
15025           p_api_name             => l_api_name,
15026           p_parameter_name       => 'p_creation_program_code',
15027           p_source_program_code  => l_service_request_rec.creation_program_code,
15028           x_return_status        => l_return_status);
15029 
15030       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
15031          x_return_status := FND_API.G_RET_STS_ERROR;
15032         RETURN;
15033       END IF;
15034    END IF;
15035 
15036 -- Added for address by shijain 05 dec 2002
15037    IF (l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER <> FND_API.G_MISS_CHAR) AND
15038         (l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER IS NOT NULL) THEN
15039 
15040         CS_ServiceRequest_UTIL.Validate_INC_DIRECTION_QUAL(
15041           p_api_name             => l_api_name,
15042           p_parameter_name       => 'p_INC_DIRECTION_QUAL',
15043           p_INC_DIRECTION_QUAL  => l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER,
15044           x_return_status        => l_return_status);
15045 
15046       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
15047          x_return_status := FND_API.G_RET_STS_ERROR;
15048         RETURN;
15049       END IF;
15050    END IF;
15051 
15052 -- Added for address by shijain 05 dec 2002
15053    IF (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM <> FND_API.G_MISS_CHAR) AND
15054         (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM IS NOT NULL) THEN
15055 
15056 
15057         CS_ServiceRequest_UTIL.Validate_INC_DIST_QUAL_UOM(
15058           p_api_name             => l_api_name,
15059           p_parameter_name       => 'p_INC_DIST_QUAL_UOM',
15060           p_INC_DIST_QUAL_UOM  => l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM,
15061           x_return_status        => l_return_status);
15062 
15063       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
15064          x_return_status := FND_API.G_RET_STS_ERROR;
15065         RETURN;
15066       END IF;
15067    END IF;
15068 /* Credit Card 9358401 */
15069 
15070    IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
15071      IF (l_service_request_rec.instrument_payment_use_id = FND_API.G_MISS_NUM)
15072       THEN
15073         l_service_request_rec.instrument_payment_use_id := NULL;
15074      END IF;
15075 
15076      IF l_service_request_rec.instrument_payment_use_id IS NOT NULL THEN
15077          CS_ServiceRequest_UTIL.validate_credit_card(
15078           p_api_name             => l_api_name,
15079           p_parameter_name       => 'P_INSTRUMENT_PAYMENT_USE_ID',
15080           p_instrument_payment_use_id  =>
15081 		                   l_service_request_rec.instrument_payment_use_id,
15082           p_bill_to_acct_id      => l_service_request_rec.bill_to_account_id,
15083 		p_called_from          => 'I',
15084           x_return_status        => l_return_status);
15085 
15086           IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
15087             /* Ignoring the value but SR needs to be created*/
15088             l_service_request_rec.instrument_payment_use_id := NULL;
15089           END IF;
15090      END IF;/* instrument_payment_use_id IS NOT NULL*/
15091 
15092     --14004721 . Additional SLA dates
15093     IF (l_service_request_rec.sla_date_1 = FND_API.G_MISS_DATE)
15094     THEN
15095         l_service_request_rec.sla_date_1 := NULL;
15096     END IF;
15097     IF (l_service_request_rec.sla_date_2 = FND_API.G_MISS_DATE)
15098     THEN
15099         l_service_request_rec.sla_date_2 := NULL;
15100     END IF;
15101     IF (l_service_request_rec.sla_date_3 = FND_API.G_MISS_DATE)
15102     THEN
15103         l_service_request_rec.sla_date_3 := NULL;
15104     END IF;
15105     IF (l_service_request_rec.sla_date_4 = FND_API.G_MISS_DATE)
15106     THEN
15107         l_service_request_rec.sla_date_4 := NULL;
15108     END IF;
15109     IF (l_service_request_rec.sla_date_5 = FND_API.G_MISS_DATE)
15110     THEN
15111         l_service_request_rec.sla_date_5 := NULL;
15112     END IF;
15113     IF (l_service_request_rec.sla_date_6 = FND_API.G_MISS_DATE)
15114     THEN
15115         l_service_request_rec.sla_date_6 := NULL;
15116     END IF;
15117     IF (l_service_request_rec.sla_duration_1 = FND_API.G_MISS_NUM)
15118     THEN
15119         l_service_request_rec.sla_duration_1 := NULL;
15120     END IF;
15121     IF (l_service_request_rec.sla_duration_2 = FND_API.G_MISS_NUM)
15122     THEN
15123         l_service_request_rec.sla_duration_2 := NULL;
15124     END IF;
15125     --End of changes for 14004721 . Additional SLA dates. shramana
15126 
15127     END IF; /* p_validation level*/
15128 
15129 -- Assigning the values to x_service_request_rec
15130 x_service_request_rec := l_service_request_rec;
15131 
15132 EXCEPTION
15133   WHEN FND_API.G_EXC_ERROR THEN
15134     ROLLBACK TO Create_ServiceRequest_PVT;
15135     x_return_status := FND_API.G_RET_STS_ERROR;
15136     FND_MSG_PUB.Count_And_Get
15137       ( p_count => x_msg_count,
15138         p_data  => x_msg_data
15139       );
15140   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
15141     ROLLBACK TO Create_ServiceRequest_PVT;
15142     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
15143     FND_MSG_PUB.Count_And_Get
15144       ( p_count => x_msg_count,
15145         p_data  => x_msg_data
15146       );
15147   WHEN OTHERS THEN
15148     ROLLBACK TO Create_ServiceRequest_PVT;
15149     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
15150     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
15151       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
15152     END IF;
15153     FND_MSG_PUB.Count_And_Get
15154       ( p_count => x_msg_count,
15155         p_data  => x_msg_data
15156       );
15157 
15158 END Create_SR_Validation;
15159 
15160 -- -----------------------------------------------------------------------------
15161 -- Modification History
15162 -- Date     Name      Desc
15163 -- -------- --------- ----------------------------------------------------------
15164 -- 02/28/05 smisra    Bug 4083288 Defaulted category_set_id if it is not
15165 --                    passed and category id is passed and existing value of
15166 --                    category_set_id is null.
15167 -- 05/09/05 smisra    set maint_organization_id from old value rec if passed
15168 --                    value is G_MISS_NUM
15169 --                    selected maint_organization_id column in
15170 --                    l_servicerequest_csr
15171 -- 05/13/05 smisra    Removed the code that set customer product related
15172 --                    parameters to null for EAM SRs
15173 -- 05/27/05 smisra    Bug 4227769
15174 --                    removed the code that sets obsolete col group_owner and
15175 --                    owner (_tl table columns)
15176 -- 06/07/05 smisra    Bug 4381751
15177 --                    Modified condition for auto assignment call and called it
15178 --                    only if disallow owner update is 'N' for assignment level
15179 --                    'INDIVIDUAL'. Disallow owner update flag value will not
15180 --                    have any impact for assignment level 'GROUP'
15181 -- 07/11/05 smisra    ERES changes. Changed processing related to disallow
15182 --                    request update as follows
15183 --                    if status passed to this procedure has pending approval
15184 --                    flag as 'Y' do not call update_status.
15185 --                    update_status is not capable of ERES processing.
15186 --                    If old status has pending approval flag as Y and last
15187 --                    update program code is not ERES then raise error. Such SRs
15188 --                    can be update only by ERES program.
15189 -- 07/15/05 smisra    Bug 4489746
15190 --                    removed start and end active dates from query on
15191 --                    cs_incident_types. Validate type will take care of
15192 --                    date effectivity check.
15193 -- 07/20/05 smisra    replaced individual vars from get_status_details call with
15194 --                    structure l_sr_related_data members
15195 --
15196 --                    Removed queries on cs_incident_statuses_b table that were
15197 --                    present inside comments. These queries are replaced with
15198 --                    cs_servicerequest_util.get_status_details call
15199 --
15200 --                    Modified condition for calling auto assignment and added
15201 --                    one more condition of disallow_request_update flag of
15202 --                    old status id. if this flag is Y then auto assignment
15203 --                    is not called.
15204 -- 10/07/05 smisra    Fixed byg 4653148
15205 --                    Removed variable l_close_flag_temp because another
15206 --                    variable with similar name already exists and is used
15207 --                    widely. Replaced it with l_closed_flag_temp
15208 -- 12/14/05 smisra    set incident_country to old value if incident_location_id
15209 --                    is not changed and it is not null
15210 --                    Copied incident_country to validation record only if
15211 --                    incident location is null and country has some value
15212 --                    moved the code setting incident_country, inc_location_id
15213 --                    and incident_location_type attribute of audit record to
15214 --                    create_servicerequest just before call to create audit
15215 -- 12/23/05 smisra    bug 4894942
15216 --                    Removed call to Assignment manager API. now it is called
15217 --                    from vldt_sr_rec
15218 --                    Removed the code to set following audit record attribute
15219 --                    a. resource_type
15220 --                    b. group_type
15221 --                    c. incident_owner_id
15222 --                    d. group_owner_id
15223 --                    e. owner_assigned_time
15224 --                    f. territory_id
15225 --                    These attribute are now set in update_servicerequest
15226 --                    procedure just before the call to create audit
15227 -- 12/30/05 smisra    Bug 4869065
15228 --                    Moved the code to set site cols of audit record to
15229 --                    create_servicerequest procedure just before call to
15230 --                    create audit
15231 -- 03/01/05 spusegao  Modified to exempt from raising 'OnlyUpdStatus' exception
15232 --                    ERES call back procedure i.e. when last_update_program_code = 'ERES'.
15233 --
15234 -- 04/18/06 spusegao  Modified to validate p_last_updated_by and service_request_rec.last_updateD_by parameter values.
15235 -- -----------------------------------------------------------------------------
15236 PROCEDURE Update_SR_Validation(
15237    p_api_version           IN     VARCHAR2,
15238    p_init_msg_list         IN     VARCHAR2 DEFAULT fnd_api.g_false,
15239    p_service_request_rec   IN     service_request_rec_type,
15240    p_invocation_mode       IN     VARCHAR2 := 'NORMAL',
15241    p_notes                 IN     notes_table,
15242    p_contacts              IN     contacts_table,
15243    p_audit_comments        IN     VARCHAR2 DEFAULT NULL,
15244    p_resp_id               IN     NUMBER     DEFAULT NULL,
15245    p_resp_appl_id          IN     NUMBER     DEFAULT NULL,
15246    p_request_id            IN     NUMBER,
15247    p_validation_level      IN     NUMBER     DEFAULT fnd_api.g_valid_level_full,
15248    p_commit                IN     VARCHAR2   DEFAULT fnd_api.g_false,
15249    p_last_updated_by       IN     NUMBER,
15250    p_last_update_login     IN     NUMBER     DEFAULT NULL,
15251    p_last_update_date      IN     DATE,
15252    p_object_version_number IN     NUMBER,
15253    x_return_status         OUT    NOCOPY VARCHAR2,
15254    x_contra_id             OUT    NOCOPY NUMBER,
15255    x_contract_number       OUT    NOCOPY VARCHAR2,
15256    x_owner_assigned_flag   OUT    NOCOPY VARCHAR2,
15257    x_msg_count             OUT    NOCOPY NUMBER,
15258    x_msg_data              OUT    NOCOPY VARCHAR2,
15259    x_audit_vals_rec        OUT    NOCOPY sr_audit_rec_type,
15260    x_service_request_rec   OUT    NOCOPY service_request_rec_type,
15261    x_autolaunch_wkf_flag   OUT    NOCOPY VARCHAR2,
15262    x_abort_wkf_close_flag  OUT    NOCOPY VARCHAR2,
15263    x_wkf_process_name      OUT    NOCOPY VARCHAR2,
15264    x_workflow_process_id   OUT    NOCOPY NUMBER,
15265    x_interaction_id        OUT    NOCOPY NUMBER,
15266    p_update_desc_flex      IN     VARCHAR2   DEFAULT fnd_api.g_false,
15267    p_called_by_workflow    IN     VARCHAR2   DEFAULT fnd_api.g_false,
15268    p_workflow_process_id   IN     NUMBER   DEFAULT NULL,
15269    -- for cmro
15270   p_cmro_flag             IN     VARCHAR2,
15271   p_maintenance_flag      IN     VARCHAR2,
15272   p_auto_assign           IN     VARCHAR2 := 'N'
15273   )
15274 
15275 IS
15276      l_api_name         CONSTANT VARCHAR2(30)    := 'Update_SR_Validation';
15277      l_api_name_full    CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
15278      l_return_status             VARCHAR2(1);
15279      l_cp_inventory_item_id      NUMBER;
15280      l_close_flag                VARCHAR2(1);
15281      l_service_request_rec       service_request_rec_type DEFAULT p_service_request_rec;
15282      l_contra_id                 NUMBER;
15283      l_contract_number           VARCHAR2(120) ;
15284 
15285      l_group_name        VARCHAR2(60);
15286      l_owner_name        VARCHAR2(360);
15287      l_owner_id          jtf_rs_resource_extns.resource_id % TYPE;
15288      l_operation         VARCHAR2(300):= 'updated' ;
15289      l_temp_close_flag  VARCHAR2(1);
15290 
15291      OnlyUpdStatus               EXCEPTION;
15292 
15293      CURSOR l_ServiceRequest_csr IS
15294      SELECT
15295             B.ROWID ROW_ID,
15296             B.INCIDENT_ID ,
15297             B.LAST_UPDATE_DATE ,
15298             B.LAST_UPDATED_BY ,
15299             B.CREATION_DATE ,
15300             B.CREATED_BY ,
15301             B.LAST_UPDATE_LOGIN ,
15302             B.INCIDENT_NUMBER ,
15303             B.INCIDENT_DATE ,
15304             B.INCIDENT_STATUS_ID ,
15305             B.INCIDENT_TYPE_ID ,
15306             B.INCIDENT_URGENCY_ID ,
15307             B.INCIDENT_SEVERITY_ID ,
15308             B.INCIDENT_OWNER_ID ,
15309             B.RESOURCE_TYPE ,
15310             B.RESOURCE_SUBTYPE_ID ,
15311             B.INVENTORY_ITEM_ID ,
15312             B.CUSTOMER_ID ,
15313             B.CUSTOMER_NUMBER ,
15314             B.ACCOUNT_ID ,
15315             B.BILL_TO_SITE_USE_ID ,
15316             B.PURCHASE_ORDER_NUM ,
15317             B.EMPLOYEE_ID ,
15318             B.FILED_BY_EMPLOYEE_FLAG ,
15319             B.SHIP_TO_SITE_USE_ID ,
15320             B.PROBLEM_CODE ,
15321             B.EXPECTED_RESOLUTION_DATE ,
15322             B.ACTUAL_RESOLUTION_DATE ,
15323             B.CUSTOMER_PRODUCT_ID ,
15324             B.BILL_TO_CONTACT_ID ,
15325             B.SHIP_TO_CONTACT_ID ,
15326             B.CURRENT_SERIAL_NUMBER ,
15327             B.PRODUCT_REVISION ,
15328             B.COMPONENT_VERSION,
15329             B.SUBCOMPONENT_VERSION,
15330             B.INCIDENT_ATTRIBUTE_1 ,
15331             B.INCIDENT_ATTRIBUTE_2 ,
15332             B.INCIDENT_ATTRIBUTE_3 ,
15333             B.INCIDENT_ATTRIBUTE_4 ,
15334             B.INCIDENT_ATTRIBUTE_5 ,
15335             B.INCIDENT_ATTRIBUTE_6 ,
15336             B.INCIDENT_ATTRIBUTE_7 ,
15337             B.INCIDENT_ATTRIBUTE_8 ,
15338             B.INCIDENT_ATTRIBUTE_9 ,
15339             B.INCIDENT_ATTRIBUTE_10 ,
15340             B.INCIDENT_ATTRIBUTE_11 ,
15341             B.INCIDENT_ATTRIBUTE_12 ,
15342             B.INCIDENT_ATTRIBUTE_13 ,
15343             B.INCIDENT_ATTRIBUTE_14 ,
15344             B.INCIDENT_ATTRIBUTE_15 ,
15345             B.INCIDENT_CONTEXT ,
15346             B.EXTERNAL_ATTRIBUTE_1 ,
15347             B.EXTERNAL_ATTRIBUTE_2 ,
15348             B.EXTERNAL_ATTRIBUTE_3 ,
15349             B.EXTERNAL_ATTRIBUTE_4 ,
15350             B.EXTERNAL_ATTRIBUTE_5 ,
15351             B.EXTERNAL_ATTRIBUTE_6 ,
15352             B.EXTERNAL_ATTRIBUTE_7 ,
15353             B.EXTERNAL_ATTRIBUTE_8 ,
15354             B.EXTERNAL_ATTRIBUTE_9 ,
15355             B.EXTERNAL_ATTRIBUTE_10 ,
15356             B.EXTERNAL_ATTRIBUTE_11 ,
15357             B.EXTERNAL_ATTRIBUTE_12 ,
15358             B.EXTERNAL_ATTRIBUTE_13 ,
15359             B.EXTERNAL_ATTRIBUTE_14 ,
15360             B.EXTERNAL_ATTRIBUTE_15 ,
15361             B.EXTERNAL_CONTEXT ,
15362             B.RECORD_IS_VALID_FLAG ,
15363             B.RESOLUTION_CODE ,
15364             B.ORG_ID ,
15365             B.ORIGINAL_ORDER_NUMBER ,
15366             B.WORKFLOW_PROCESS_ID ,
15367             B.CLOSE_DATE ,
15368             B.PUBLISH_FLAG ,
15369             B.ESTIMATE_ID ,
15370             B.ESTIMATE_BUSINESS_GROUP_ID ,
15371             B.INTERFACED_TO_DEPOT_FLAG ,
15372             B.QA_COLLECTION_ID ,
15373             B.CONTRACT_SERVICE_ID ,
15374             B.CONTRACT_ID,
15375             B.CONTRACT_NUMBER,
15376             B.PROJECT_NUMBER,
15377             B.TIME_ZONE_ID ,
15378             B.TIME_DIFFERENCE ,
15379             B.CUSTOMER_PO_NUMBER ,
15380             B.OWNER_GROUP_ID ,
15381             B.CUSTOMER_TICKET_NUMBER ,
15382             B.OBLIGATION_DATE ,
15383             B.SITE_ID ,
15384             B.CUSTOMER_SITE_ID ,
15385             B.CALLER_TYPE ,
15386             B.PLATFORM_ID ,
15387             B.PLATFORM_VERSION,
15388             B.DB_VERSION,
15389             B.PLATFORM_VERSION_ID ,
15390             B.CP_COMPONENT_ID ,
15391             B.CP_COMPONENT_VERSION_ID ,
15392             B.CP_SUBCOMPONENT_ID ,
15393             B.CP_SUBCOMPONENT_VERSION_ID ,
15394             B.CP_REVISION_ID ,
15395             B.INV_ITEM_REVISION,
15396             B.INV_COMPONENT_ID,
15397             B.INV_COMPONENT_VERSION,
15398             B.INV_SUBCOMPONENT_ID,
15399             B.INV_SUBCOMPONENT_VERSION,
15400             B.LANGUAGE_ID,
15401             B.TERRITORY_ID,
15402             B.INV_ORGANIZATION_ID,
15403             B.OBJECT_VERSION_NUMBER ,
15404             -- Added for enhancement 11.5.6
15405             B.CUST_PREF_LANG_ID,
15406             B.TIER,
15407             B.TIER_VERSION,
15408             B.OPERATING_SYSTEM,
15409             B.OPERATING_SYSTEM_VERSION,
15410             B.DATABASE,
15411             B.CATEGORY_ID,
15412             B.GROUP_TYPE,
15413             B.GROUP_TERRITORY_ID,
15414             B.OWNER_ASSIGNED_TIME,
15415             B.OWNER_ASSIGNED_FLAG,
15416             B.INV_PLATFORM_ORG_ID,
15417             B.COMM_PREF_CODE,
15418             B.CUST_PREF_LANG_CODE,
15419             B.LAST_UPDATE_CHANNEL,
15420             B.CATEGORY_SET_ID,
15421             B.EXTERNAL_REFERENCE,
15422             B.SYSTEM_ID,
15423             B.ERROR_CODE,
15424             B.INCIDENT_ADDRESS,
15425             B.INCIDENT_CITY,
15426             B.INCIDENT_STATE,
15427             B.INCIDENT_COUNTRY,
15428             B.INCIDENT_PROVINCE,
15429             B.INCIDENT_POSTAL_CODE,
15430             B.INCIDENT_COUNTY,
15431             B.SR_CREATION_CHANNEL,
15432             TL.RESOLUTION_SUMMARY,
15433             -- Added for Enh# 1830701
15434             B.INCIDENT_OCCURRED_DATE,
15435             B.INCIDENT_RESOLVED_DATE,
15436             B.INC_RESPONDED_BY_DATE,
15437             -- Added for Enh# 222054
15438             B.INCIDENT_LOCATION_ID,
15439             -- Added for ER# 2320056
15440             B.COVERAGE_TYPE,
15441             -- Added for ER#2433831
15442             B.BILL_TO_ACCOUNT_ID,
15443             B.SHIP_TO_ACCOUNT_ID,
15444             -- Added for ER#2463321
15445             B.CUSTOMER_PHONE_ID,
15446             B.CUSTOMER_EMAIL_ID,
15447 	    -- Added for 11.5.9
15448             B.BILL_TO_SITE_ID,
15449             B.SHIP_TO_SITE_ID,
15450             B.BILL_TO_PARTY_ID,
15451             B.SHIP_TO_PARTY_ID,
15452             B.CREATION_PROGRAM_CODE,
15453             B.LAST_UPDATE_PROGRAM_CODE,
15454             B.PROGRAM_ID,
15455             B.PROGRAM_APPLICATION_ID,
15456             B.REQUEST_ID,
15457             B.PROGRAM_LOGIN_ID,
15458             -- Added for Enh# 2216664
15459             TL.OWNER,
15460             TL.GROUP_OWNER,
15461             TL.LANGUAGE ,
15462             TL.SOURCE_LANG ,
15463             TL.SUMMARY ,
15464             B.INSTALL_SITE_ID,
15465             B.INSTALL_SITE_USE_ID,
15466             --TL.SR_CREATION_CHANNEL
15467             B.STATUS_FLAG,
15468             -- Added address columns by shijain 26thdec 2002
15469             B.INCIDENT_POINT_OF_INTEREST  ,
15470             B.INCIDENT_CROSS_STREET ,
15471             B.INCIDENT_DIRECTION_QUALIFIER ,
15472             B.INCIDENT_DISTANCE_QUALIFIER  ,
15473             B.INCIDENT_DISTANCE_QUAL_UOM  ,
15474             B.INCIDENT_ADDRESS2   ,
15475             B.INCIDENT_ADDRESS3 ,
15476             B.INCIDENT_ADDRESS4  ,
15477             B.INCIDENT_ADDRESS_STYLE ,
15478             B.INCIDENT_ADDR_LINES_PHONETIC  ,
15479             B.INCIDENT_PO_BOX_NUMBER  ,
15480             B.INCIDENT_HOUSE_NUMBER ,
15481             B.INCIDENT_STREET_SUFFIX ,
15482             B.INCIDENT_STREET ,
15483             B.INCIDENT_STREET_NUMBER ,
15484             B.INCIDENT_FLOOR,
15485             B.INCIDENT_SUITE  ,
15486             B.INCIDENT_POSTAL_PLUS4_CODE ,
15487             B.INCIDENT_POSITION  ,
15488             B.INCIDENT_LOCATION_DIRECTIONS,
15489             B.INCIDENT_LOCATION_DESCRIPTION,
15490 	    --for cmro_eam
15491             B.OWNING_DEPARTMENT_ID,
15492             --end of cmro_eam
15493             -- Added for Misc ERs project (11.5.10) --anmukher --08/26/03
15494             B.INCIDENT_LOCATION_TYPE  ,
15495             --B.PRIMARY_CONTACT_ID
15496             B.maint_organization_id,
15497             B.instrument_payment_use_id,
15498 	    --14004721 . Additional SLA dates
15499 	    B.sla_date_1,
15500 	    B.sla_date_2,
15501 	    B.sla_date_3,
15502 	    B.sla_date_4,
15503 	    B.sla_date_5,
15504 	    B.sla_date_6,
15505 	    B.sla_duration_1,
15506 	    B.sla_duration_2,
15507 	     --15995804. Add price_list_header_id
15508 	    B.price_list_header_id
15509        FROM cs_incidents_all_b b, cs_incidents_all_tl tl
15510           WHERE b.incident_id = p_request_id
15511           AND   b.incident_id = tl.incident_id
15512           AND   tl.LANGUAGE = DECODE(l_service_request_rec.LANGUAGE,
15513                                      FND_API.G_MISS_CHAR, USERENV('LANG'),
15514                                      NULL, USERENV('LANG'), l_service_request_rec.LANGUAGE)
15515        FOR UPDATE OF b.incident_id;
15516 
15517      l_old_ServiceRequest_rec l_ServiceRequest_csr%ROWTYPE;
15518 
15519      -- Validation record
15520      l_SR_Validation_rec         Request_Validation_Rec_Type;
15521 
15522      -- Some temp variables
15523      l_update_desc_flex           VARCHAR2(1) := p_update_desc_flex;
15524      l_type_id_temp               NUMBER;
15525      -- l_inventory_org_id        NUMBER;
15526      l_closed_flag_temp           VARCHAR2(1);
15527      l_status_validated           BOOLEAN:= FALSE;
15528      l_employee_name              VARCHAR2(240);
15529      l_contact_index              BINARY_INTEGER;
15530      l_primary_contact_id         NUMBER  := NULL;
15531      l_org_id                     NUMBER;
15532      l_primary_contact_found      VARCHAR2(1) := 'N';
15533      l_contacts_passed            VARCHAR2(1) := 'N' ;
15534      l_old_close_flag             VARCHAR2(1) ;
15535      l_new_close_flag             VARCHAR2(1) ;
15536      -- For Workflow Hook
15537      l_workflow_item_key          NUMBER;
15538      l_autolaunch_workflow_flag   VARCHAR2(1);
15539      l_abort_workflow_close_flag  VARCHAR2(1);
15540      l_disallow_request_update    VARCHAR2(1);
15541      l_disallow_owner_update      VARCHAR2(1);
15542      l_disallow_product_update    VARCHAR2(1);
15543      l_party_id_update            VARCHAR2(1);
15544      l_contact_point_id_update    VARCHAR2(1);
15545      l_contact_point_type_update  VARCHAR2(1);
15546      l_contact_type_update        VARCHAR2(1);
15547      l_primary_flag_update        VARCHAR2(1) ;
15548      l_old_party_id               NUMBER;
15549      l_old_contact_point_id       NUMBER;
15550      l_old_contact_point_type     VARCHAR2(30);
15551      l_old_contact_type           VARCHAR2(30);
15552      l_old_primary_flag           VARCHAR2(1) ;
15553 
15554      l_primary_contact_point_id   NUMBER;
15555      l_saved_primary_contact_id   NUMBER;
15556      l_saved_contact_point_id     NUMBER ;
15557      l_primary_contact_change     VARCHAR2(1) := 'N';
15558      l_count                      NUMBER;
15559 
15560      ---Added so that workflow can call Update SR API  instead of Calling Create Audit API
15561      ----bug 1485825
15562      l_wf_process_itemkey         VARCHAR2(30);
15563      l_workflow_process_name      VARCHAR2(30);
15564      l_workflow_process_id        NUMBER;
15565 
15566      l_bill_to_site_id           NUMBER;
15567      l_ship_to_site_id           NUMBER;
15568      l_bill_to_site_use_id       NUMBER;
15569      l_ship_to_site_use_id       NUMBER;
15570 
15571    l_auto_assign_level fnd_profile_option_values.profile_option_value % type :=
15572                                fnd_profile.value('CS_SR_OWNER_AUTO_ASSIGN_LEVEL');
15573    l_asgn_owner_id        cs_incidents_all_b.incident_owner_id % type;
15574    l_asgn_resource_type   cs_incidents_all_b.resource_type % type;
15575    l_asgn_owner_group_id  cs_incidents_all_b.owner_group_id % type;
15576    l_territory_id         number;
15577    l_call_asgn_resource   varchar2(1) := 'n';
15578 
15579    -- For bug 3333340
15580    p_passed_value	VARCHAR2(3);
15581    l_update_desc_flex_int      varchar2(1) := FND_API.G_FALSE;
15582    l_update_desc_flex_ext      varchar2(1) := FND_API.G_FALSE;
15583    l_ff_name                   varchar2(30);
15584    l_dummy0 cs_incidents_all_b.product_revision     % type;
15585    l_dummy1 cs_incidents_all_b.component_version    % type;
15586    l_dummy2 cs_incidents_all_b.subcomponent_version % type;
15587 
15588    l_pending_approval_flag    cs_incident_statuses_b.pending_approval_flag      % TYPE;
15589    l_intermediate_status_id   cs_incident_statuses_b.intermediate_status_id     % TYPE;
15590    l_approval_status_id       cs_incident_statuses_b.approval_action_status_id  % TYPE;
15591    l_rejection_status_id      cs_incident_statuses_b.rejection_action_status_id % TYPE;
15592 
15593    l_sr_related_data      RELATED_DATA_TYPE;
15594 
15595    --Added variable for bug 14242503
15596    l_cust_product_changed VARCHAR2(1) := 'Y';
15597 
15598 BEGIN
15599 
15600   x_return_status := FND_API.G_RET_STS_SUCCESS;
15601   -- Initialize the New Auit Record
15602   Initialize_audit_rec(
15603   p_sr_audit_record         =>           x_audit_vals_rec) ;
15604 
15605   -- Fetch and get the original values
15606   OPEN l_ServiceRequest_csr;
15607   FETCH l_ServiceRequest_csr INTO l_old_ServiceRequest_rec;
15608   IF (l_ServiceRequest_csr%NOTFOUND) THEN
15609 
15610     CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
15611                       ( p_token_an    =>  l_api_name_full,
15612                         p_token_v     =>  TO_CHAR(p_request_id),
15613                         p_token_p     =>  'p_request_id',
15614                         p_table_name  => G_TABLE_NAME,
15615                         p_column_name => 'INCIDENT_ID');
15616 
15617     RAISE FND_API.G_EXC_ERROR;
15618   END IF;
15619 
15620   -- Validate flex field segments
15621   -- Moved this code from cspsrb.pls on 01/23/04
15622   -- Reason for move: old values are not available in cspsrb.pls
15623   -- and all g_miss values are to be replaced by values in db
15624   --
15625   -- This check is already done in cspsrb.pls. But we need to do it here again
15626   -- because parameter p_update_desc_flex does not say whether internal FF is changed
15627   -- or external FF is changed. it says either one of them is changed.
15628   -- So to make sure that internal FF validation is executed only if any of
15629   -- internal segments are changed, we need to check these fields again and
15630   -- set l_update_desc_flex_int and execute FF validation beased on this variable instead
15631   -- of l_update_desc_flex
15632   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
15633      IF NOT (( l_service_request_rec.request_context  = FND_API.G_MISS_CHAR)  AND
15634          ( l_service_request_rec.request_attribute_1 = FND_API.G_MISS_CHAR)  AND
15635          ( l_service_request_rec.request_attribute_2 = FND_API.G_MISS_CHAR)  AND
15636          ( l_service_request_rec.request_attribute_3 = FND_API.G_MISS_CHAR)  AND
15637          ( l_service_request_rec.request_attribute_4 = FND_API.G_MISS_CHAR)  AND
15638          ( l_service_request_rec.request_attribute_5 = FND_API.G_MISS_CHAR)  AND
15639          ( l_service_request_rec.request_attribute_6 = FND_API.G_MISS_CHAR)  AND
15640          ( l_service_request_rec.request_attribute_7 = FND_API.G_MISS_CHAR)  AND
15641          ( l_service_request_rec.request_attribute_8 = FND_API.G_MISS_CHAR)  AND
15642          ( l_service_request_rec.request_attribute_9 = FND_API.G_MISS_CHAR)  AND
15643          ( l_service_request_rec.request_attribute_10 = FND_API.G_MISS_CHAR) AND
15644          ( l_service_request_rec.request_attribute_11 = FND_API.G_MISS_CHAR) AND
15645          ( l_service_request_rec.request_attribute_12 = FND_API.G_MISS_CHAR) AND
15646          ( l_service_request_rec.request_attribute_13 = FND_API.G_MISS_CHAR) AND
15647          ( l_service_request_rec.request_attribute_14 = FND_API.G_MISS_CHAR) AND
15648          ( l_service_request_rec.request_attribute_15 = FND_API.G_MISS_CHAR)     ) THEN
15649        l_update_desc_flex_int := FND_API.G_TRUE;
15650      END IF; -- to check if any flex field segment is updated
15651   END IF; -- to check validation level
15652 
15653     -- if context is changed then all g_miss_char will be replaced by null
15654     -- if context is not changed then all g_miss_char will be replaced with old value in database
15655     -- This is doen to make API behaviour same as SR FORM
15656     -- 01/23/04 smisra
15657     --
15658     -- This portion is out of validation level check. Reason: in old code too copy of old value to SR rec
15659     -- was outside validation level check. 1/28/04
15660     handle_missing_value(l_service_request_rec.request_context     ,l_old_servicerequest_rec.incident_context     );
15661     if ((l_service_request_rec.request_context is null and l_old_servicerequest_rec.incident_context is null) or
15662         (l_service_request_rec.request_context = l_old_servicerequest_rec.incident_context)) then
15663         -- request context is not changed. so set all g_miss_char to old value from db
15664         handle_missing_value(l_service_request_rec.request_attribute_1 ,l_old_servicerequest_rec.incident_attribute_1 );
15665         handle_missing_value(l_service_request_rec.request_attribute_2 ,l_old_servicerequest_rec.incident_attribute_2 );
15666         handle_missing_value(l_service_request_rec.request_attribute_3 ,l_old_servicerequest_rec.incident_attribute_3 );
15667         handle_missing_value(l_service_request_rec.request_attribute_4 ,l_old_servicerequest_rec.incident_attribute_4 );
15668         handle_missing_value(l_service_request_rec.request_attribute_5 ,l_old_servicerequest_rec.incident_attribute_5 );
15669         handle_missing_value(l_service_request_rec.request_attribute_6 ,l_old_servicerequest_rec.incident_attribute_6 );
15670         handle_missing_value(l_service_request_rec.request_attribute_7 ,l_old_servicerequest_rec.incident_attribute_7 );
15671         handle_missing_value(l_service_request_rec.request_attribute_8 ,l_old_servicerequest_rec.incident_attribute_8 );
15672         handle_missing_value(l_service_request_rec.request_attribute_9 ,l_old_servicerequest_rec.incident_attribute_9 );
15673         handle_missing_value(l_service_request_rec.request_attribute_10,l_old_servicerequest_rec.incident_attribute_10);
15674         handle_missing_value(l_service_request_rec.request_attribute_11,l_old_servicerequest_rec.incident_attribute_11);
15675         handle_missing_value(l_service_request_rec.request_attribute_12,l_old_servicerequest_rec.incident_attribute_12);
15676         handle_missing_value(l_service_request_rec.request_attribute_13,l_old_servicerequest_rec.incident_attribute_13);
15677         handle_missing_value(l_service_request_rec.request_attribute_14,l_old_servicerequest_rec.incident_attribute_14);
15678         handle_missing_value(l_service_request_rec.request_attribute_15,l_old_servicerequest_rec.incident_attribute_15);
15679     else
15680         -- incident context is changed. so set all g_miss_char to null except global data segments
15681         l_ff_name := 'CS_INCIDENTS_ALL_B';
15682         set_attribute_value(l_service_request_rec.request_attribute_1,l_old_servicerequest_rec.incident_attribute_1,
15683                                                             l_ff_name,'INCIDENT_ATTRIBUTE_1');
15684 
15685         set_attribute_value(l_service_request_rec.request_attribute_2,l_old_servicerequest_rec.incident_attribute_2,
15686                                                             l_ff_name,'INCIDENT_ATTRIBUTE_2');
15687 
15688         set_attribute_value(l_service_request_rec.request_attribute_3,l_old_servicerequest_rec.incident_attribute_3,
15689                                                             l_ff_name,'INCIDENT_ATTRIBUTE_3');
15690 
15691         set_attribute_value(l_service_request_rec.request_attribute_4,l_old_servicerequest_rec.incident_attribute_4,
15692                                                             l_ff_name,'INCIDENT_ATTRIBUTE_4');
15693 
15694         set_attribute_value(l_service_request_rec.request_attribute_5,l_old_servicerequest_rec.incident_attribute_5,
15695                                                             l_ff_name,'INCIDENT_ATTRIBUTE_5');
15696 
15697         set_attribute_value(l_service_request_rec.request_attribute_6,l_old_servicerequest_rec.incident_attribute_6,
15698                                                             l_ff_name,'INCIDENT_ATTRIBUTE_6');
15699 
15700         set_attribute_value(l_service_request_rec.request_attribute_7,l_old_servicerequest_rec.incident_attribute_7,
15701                                                             l_ff_name,'INCIDENT_ATTRIBUTE_7');
15702 
15703         set_attribute_value(l_service_request_rec.request_attribute_8,l_old_servicerequest_rec.incident_attribute_8,
15704                                                             l_ff_name,'INCIDENT_ATTRIBUTE_8');
15705 
15706         set_attribute_value(l_service_request_rec.request_attribute_9,l_old_servicerequest_rec.incident_attribute_9,
15707                                                             l_ff_name,'INCIDENT_ATTRIBUTE_9');
15708 
15709         set_attribute_value(l_service_request_rec.request_attribute_10,l_old_servicerequest_rec.incident_attribute_10,
15710                                                             l_ff_name,'INCIDENT_ATTRIBUTE_10');
15711 
15712         set_attribute_value(l_service_request_rec.request_attribute_11,l_old_servicerequest_rec.incident_attribute_11,
15713                                                             l_ff_name,'INCIDENT_ATTRIBUTE_11');
15714 
15715         set_attribute_value(l_service_request_rec.request_attribute_12,l_old_servicerequest_rec.incident_attribute_12,
15716                                                             l_ff_name,'INCIDENT_ATTRIBUTE_12');
15717 
15718         set_attribute_value(l_service_request_rec.request_attribute_13,l_old_servicerequest_rec.incident_attribute_13,
15719                                                             l_ff_name,'INCIDENT_ATTRIBUTE_13');
15720 
15721         set_attribute_value(l_service_request_rec.request_attribute_14,l_old_servicerequest_rec.incident_attribute_14,
15722                                                             l_ff_name,'INCIDENT_ATTRIBUTE_14');
15723 
15724         set_attribute_value(l_service_request_rec.request_attribute_15,l_old_servicerequest_rec.incident_attribute_15,
15725                                                             l_ff_name,'INCIDENT_ATTRIBUTE_15');
15726     end if;
15727 
15728     IF ( l_update_desc_flex_int = FND_API.G_TRUE and
15729          p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
15730         Cs_Servicerequest_Util.Validate_Desc_Flex(
15731 	    p_api_name               => l_api_name_full,
15732       	    p_application_short_name => 'CS',
15733       	    p_desc_flex_name         => 'CS_INCIDENTS_ALL_B',
15734       	    p_desc_segment1          => l_service_request_rec.request_attribute_1,
15735       	    p_desc_segment2          => l_service_request_rec.request_attribute_2,
15736       	    p_desc_segment3          => l_service_request_rec.request_attribute_3,
15737       	    p_desc_segment4          => l_service_request_rec.request_attribute_4,
15738       	    p_desc_segment5          => l_service_request_rec.request_attribute_5,
15739       	    p_desc_segment6          => l_service_request_rec.request_attribute_6,
15740       	    p_desc_segment7          => l_service_request_rec.request_attribute_7,
15741       	    p_desc_segment8          => l_service_request_rec.request_attribute_8,
15742       	    p_desc_segment9          => l_service_request_rec.request_attribute_9,
15743       	    p_desc_segment10         => l_service_request_rec.request_attribute_10,
15744       	    p_desc_segment11         => l_service_request_rec.request_attribute_11,
15745       	    p_desc_segment12         => l_service_request_rec.request_attribute_12,
15746       	    p_desc_segment13         => l_service_request_rec.request_attribute_13,
15747       	    p_desc_segment14         => l_service_request_rec.request_attribute_14,
15748       	    p_desc_segment15         => l_service_request_rec.request_attribute_15,
15749       	    p_desc_context           => l_service_request_rec.request_context,
15750       	    p_resp_appl_id           => p_resp_appl_id,
15751       	    p_resp_id                => p_resp_id,
15752       	    p_return_status          => l_return_status );
15753 
15754         IF (l_return_status = FND_API.G_RET_STS_ERROR) THEN
15755           raise FND_API.G_EXC_ERROR;
15756         ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
15757           raise FND_API.G_EXC_UNEXPECTED_ERROR;
15758         END IF;
15759     END IF;
15760 
15761 
15762     -- Externl Attributes
15763     -- whether value of flex field segment is changed or not, it is g_miss_char then it must be
15764     -- set to value from database. 11/25/2003 smisra
15765   -- End of Validate flex field segments
15766   --
15767   /******** Bug 5216510 spusegao **********/
15768    -- Validate flex field segments
15769   -- Moved this code from cspsrb.pls
15770   -- Reason for move: old values are not available in cspsrb.pls
15771   -- and all g_miss values are to be replaced by values in db
15772   --
15773   -- This check is already done in cspsrb.pls. But we need to do it here again
15774   -- because parameter p_update_desc_flex does not say whether internal FF is changed
15775   -- or external FF is changed. it says either one of them is changed.
15776   -- So to make sure that external FF validation is executed only if any of
15777   -- external segments are changed, we need to check these fields again and
15778   -- set l_update_desc_flex_ext and execute FF validation beased on this variable instead
15779   -- of l_update_desc_flex
15780   -- whether value of flex field segment is changed or not, it is g_miss_char then it must be
15781 
15782   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
15783      IF NOT (( l_service_request_rec.external_context  = FND_API.G_MISS_CHAR)  AND
15784          ( l_service_request_rec.external_attribute_1 = FND_API.G_MISS_CHAR)  AND
15785          ( l_service_request_rec.external_attribute_2 = FND_API.G_MISS_CHAR)  AND
15786          ( l_service_request_rec.external_attribute_3 = FND_API.G_MISS_CHAR)  AND
15787          ( l_service_request_rec.external_attribute_4 = FND_API.G_MISS_CHAR)  AND
15788          ( l_service_request_rec.external_attribute_5 = FND_API.G_MISS_CHAR)  AND
15789          ( l_service_request_rec.external_attribute_6 = FND_API.G_MISS_CHAR)  AND
15790          ( l_service_request_rec.external_attribute_7 = FND_API.G_MISS_CHAR)  AND
15791          ( l_service_request_rec.external_attribute_8 = FND_API.G_MISS_CHAR)  AND
15792         ( l_service_request_rec.external_attribute_9 = FND_API.G_MISS_CHAR)  AND
15793          ( l_service_request_rec.external_attribute_10 = FND_API.G_MISS_CHAR) AND
15794          ( l_service_request_rec.external_attribute_11 = FND_API.G_MISS_CHAR) AND
15795          ( l_service_request_rec.external_attribute_12 = FND_API.G_MISS_CHAR) AND
15796          ( l_service_request_rec.external_attribute_13 = FND_API.G_MISS_CHAR) AND
15797          ( l_service_request_rec.external_attribute_14 = FND_API.G_MISS_CHAR) AND
15798          ( l_service_request_rec.external_attribute_15 = FND_API.G_MISS_CHAR)     ) THEN
15799        l_update_desc_flex_ext := FND_API.G_TRUE;
15800      END IF; -- to check if any flex field segment is updated
15801   END IF; -- to check validation level
15802 
15803     -- if context is changed then all g_miss_char will be replaced by null
15804     -- if context is not changed then all g_miss_char will be replaced with old value in database
15805     -- This is doen to make API behaviour same as SR FORM
15806     --
15807     --
15808     -- This portion is out of validation level check. Reason: in old code too copy of old value to SR rec
15809     -- was outside validation level check. 1/28/04
15810 
15811     handle_missing_value(l_service_request_rec.external_context,l_old_servicerequest_rec.external_context);
15812     if ((l_service_request_rec.external_context is null and l_old_servicerequest_rec.external_context is null) or
15813         (l_service_request_rec.external_context = l_old_servicerequest_rec.external_context)) then
15814         --  context is not changed. so set all g_miss_char to old value from db
15815         handle_missing_value(l_service_request_rec.external_attribute_1 ,l_old_servicerequest_rec.external_attribute_1);
15816         handle_missing_value(l_service_request_rec.external_attribute_2 ,l_old_servicerequest_rec.external_attribute_2);
15817         handle_missing_value(l_service_request_rec.external_attribute_3 ,l_old_servicerequest_rec.external_attribute_3);
15818         handle_missing_value(l_service_request_rec.external_attribute_4 ,l_old_servicerequest_rec.external_attribute_4 );
15819         handle_missing_value(l_service_request_rec.external_attribute_5 ,l_old_servicerequest_rec.external_attribute_5 );
15820         handle_missing_value(l_service_request_rec.external_attribute_6 ,l_old_servicerequest_rec.external_attribute_6 );
15821         handle_missing_value(l_service_request_rec.external_attribute_7 ,l_old_servicerequest_rec.external_attribute_7 );
15822         handle_missing_value(l_service_request_rec.external_attribute_8 ,l_old_servicerequest_rec.external_attribute_8 );
15823         handle_missing_value(l_service_request_rec.external_attribute_9 ,l_old_servicerequest_rec.external_attribute_9 );
15824         handle_missing_value(l_service_request_rec.external_attribute_10,l_old_servicerequest_rec.external_attribute_10);
15825         handle_missing_value(l_service_request_rec.external_attribute_11,l_old_servicerequest_rec.external_attribute_11);
15826         handle_missing_value(l_service_request_rec.external_attribute_12,l_old_servicerequest_rec.external_attribute_12);
15827         handle_missing_value(l_service_request_rec.external_attribute_13,l_old_servicerequest_rec.external_attribute_13);
15828         handle_missing_value(l_service_request_rec.external_attribute_14,l_old_servicerequest_rec.external_attribute_14);
15829         handle_missing_value(l_service_request_rec.external_attribute_15,l_old_servicerequest_rec.external_attribute_15);
15830     else
15831 
15832         --  context is changed. so set all g_miss_char to null except global data segments
15833         l_ff_name := 'CS_INCIDENTS_ALL_B_EXT';
15834         set_attribute_value(l_service_request_rec.external_attribute_1,l_old_servicerequest_rec.external_attribute_1,
15835                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_1');
15836 
15837         set_attribute_value(l_service_request_rec.external_attribute_2,l_old_servicerequest_rec.external_attribute_2,
15838                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_2');
15839 
15840         set_attribute_value(l_service_request_rec.external_attribute_3,l_old_servicerequest_rec.external_attribute_3,
15841                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_3');
15842 
15843         set_attribute_value(l_service_request_rec.external_attribute_4,l_old_servicerequest_rec.external_attribute_4,
15844                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_4');
15845 
15846         set_attribute_value(l_service_request_rec.external_attribute_5,l_old_servicerequest_rec.external_attribute_5,
15847                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_5');
15848 
15849         set_attribute_value(l_service_request_rec.external_attribute_6,l_old_servicerequest_rec.external_attribute_6,
15850                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_6');
15851 
15852         set_attribute_value(l_service_request_rec.external_attribute_7,l_old_servicerequest_rec.external_attribute_7,
15853                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_7');
15854 
15855         set_attribute_value(l_service_request_rec.external_attribute_8,l_old_servicerequest_rec.external_attribute_8,
15856                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_8');
15857 
15858         set_attribute_value(l_service_request_rec.external_attribute_9,l_old_servicerequest_rec.external_attribute_9,
15859                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_9');
15860 
15861         set_attribute_value(l_service_request_rec.external_attribute_10,l_old_servicerequest_rec.external_attribute_10,
15862                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_10');
15863 
15864         set_attribute_value(l_service_request_rec.external_attribute_11,l_old_servicerequest_rec.external_attribute_11,
15865                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_11');
15866 
15867         set_attribute_value(l_service_request_rec.external_attribute_12,l_old_servicerequest_rec.external_attribute_12,
15868                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_12');
15869 
15870         set_attribute_value(l_service_request_rec.external_attribute_13,l_old_servicerequest_rec.external_attribute_13,
15871                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_13');
15872 
15873         set_attribute_value(l_service_request_rec.external_attribute_14,l_old_servicerequest_rec.external_attribute_14,
15874                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_14');
15875 
15876         set_attribute_value(l_service_request_rec.external_attribute_15,l_old_servicerequest_rec.external_attribute_15,
15877                                                             l_ff_name,'EXTERNAL_ATTRIBUTE_15');
15878     end if;
15879 
15880     IF ( l_update_desc_flex_ext = FND_API.G_TRUE and
15881          p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
15882         Cs_ServiceRequest_Util.Validate_external_Desc_Flex
15883    ( p_api_name                 => l_api_name_full,
15884      p_application_short_name   => 'CS',
15885      p_ext_desc_flex_name       => 'CS_INCIDENTS_ALL_B_EXT',
15886      p_ext_desc_segment1        => l_service_request_rec.external_attribute_1,
15887      p_ext_desc_segment2        => l_service_request_rec.external_attribute_2,
15888      p_ext_desc_segment3        => l_service_request_rec.external_attribute_3,
15889      p_ext_desc_segment4        => l_service_request_rec.external_attribute_4,
15890      p_ext_desc_segment5        => l_service_request_rec.external_attribute_5,
15891      p_ext_desc_segment6        => l_service_request_rec.external_attribute_6,
15892      p_ext_desc_segment7        => l_service_request_rec.external_attribute_7,
15893      p_ext_desc_segment8        => l_service_request_rec.external_attribute_8,
15894      p_ext_desc_segment9        => l_service_request_rec.external_attribute_9,
15895      p_ext_desc_segment10       => l_service_request_rec.external_attribute_10,
15896      p_ext_desc_segment11       => l_service_request_rec.external_attribute_11,
15897      p_ext_desc_segment12       => l_service_request_rec.external_attribute_12,
15898      p_ext_desc_segment13       => l_service_request_rec.external_attribute_13,
15899      p_ext_desc_segment14       => l_service_request_rec.external_attribute_14,
15900      p_ext_desc_segment15       => l_service_request_rec.external_attribute_15,
15901      p_ext_desc_context         => l_service_request_rec.external_context,
15902      p_resp_appl_id             => p_resp_appl_id,
15903      p_resp_id                  => p_resp_id,
15904      p_return_status            => l_return_status
15905     );
15906 
15907         IF (l_return_status = FND_API.G_RET_STS_ERROR) THEN
15908           raise FND_API.G_EXC_ERROR;
15909         ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
15910           raise FND_API.G_EXC_UNEXPECTED_ERROR;
15911         END IF;
15912     END IF;
15913 
15914   /******** Bug 5216510 spusegao **********/
15915 
15916   -- Since we dont care about the org_id parameter passed to the Update
15917   -- Service Request API, we use the
15918   -- org_id stored in the table
15919   -- Use this org_id for all the validations.
15920 
15921   l_org_id := l_old_ServiceRequest_rec.org_id;
15922 
15923   -- Since Caller type is not updatable.
15924   l_service_request_rec.caller_type := l_old_ServiceRequest_rec.caller_type;
15925 
15926   -----------------------------------------------------------
15927   -- In B-B model, customer_id cannot be updated
15928   -- In B-C model, primary contact_id cannot be updated
15929   ---------------------------------------------------------------
15930   -- Check if any records are passed in the contacts table.
15931   -- If so, get the primary contact id.
15932   -- Only one record with primary flag set to Y must be passed.
15933 
15934   l_contact_index := p_contacts.FIRST;
15935 
15936   -- Flag to indicate records have been passed
15937   IF (l_contact_index IS NULL) THEN
15938     l_contacts_passed := 'N';
15939   ELSE
15940     l_contacts_passed := 'Y';
15941   END IF;
15942 
15943   IF (l_service_request_rec.caller_type = 'ORGANIZATION') OR
15944      (l_service_request_rec.caller_type = 'PERSON') THEN
15945       --Customer_id is not updatable
15946       IF (l_service_request_rec.customer_id <> FND_API.G_MISS_NUM) OR
15947           l_service_request_rec.customer_id IS NULL THEN
15948         -- Check if one passed is same as old.
15949         IF (nvl(l_service_request_rec.customer_id,-99) <> nvl(l_old_servicerequest_rec.customer_id,-99) ) THEN
15950 
15951              FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_NOT_UPDATABLE');
15952              FND_MESSAGE.Set_Token('PARAM_NAME', 'Customer_id');
15953              FND_MSG_PUB.ADD;
15954              RAISE FND_API.G_EXC_ERROR;
15955         END IF; ---customer_id <> old customer_id
15956       ELSE
15957 
15958              l_service_request_rec.customer_id  := l_old_servicerequest_rec.customer_id ;
15959 
15960              IF (l_service_request_rec.customer_number <> FND_API.G_MISS_CHAR)
15961              AND (l_service_request_rec.customer_number IS NOT NULL ) THEN
15962                    IF (nvl(l_service_request_rec.customer_number,-99) <> nvl(l_old_servicerequest_rec.customer_number,-99) ) THEN
15963 
15964                              FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_NOT_UPDATABLE');
15965                              FND_MESSAGE.Set_Token('PARAM_NAME', 'Customer_number');
15966                              FND_MSG_PUB.ADD;
15967                              RAISE FND_API.G_EXC_ERROR;
15968                     END IF; ---customer_number <> old customer_number
15969               END IF; -- customer number is passed
15970       END IF; ----G_MISS_NUM
15971   ELSE   --caller type
15972       NULL;
15973   END IF ; ----caller type
15974 
15975   --- Added for HA, the WHO columns should be derived before validating
15976   --- WHO columns
15977   --- if passed null or has G_MISS values.
15978 
15979   IF (l_service_request_rec.created_by = FND_API.G_MISS_NUM OR
15980       l_service_request_rec.created_by IS NULL ) THEN
15981       l_service_request_rec.created_by := p_last_updated_by;
15982   END IF;
15983 
15984   IF (l_service_request_rec.last_update_login = FND_API.G_MISS_NUM OR
15985       l_service_request_rec.last_update_login IS NULL ) THEN
15986       l_service_request_rec.last_update_login := p_last_update_login;
15987   END IF;
15988 
15989   --
15990   -- We first deal with some special validation rules
15991   --
15992   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
15993     --
15994     -- Validate WHO information
15995     --
15996     CS_ServiceRequest_UTIL.Validate_Who_Info
15997       ( p_api_name             => l_api_name_full,
15998         p_parameter_name_usr   => 'p_last_updated_by',
15999         p_parameter_name_login => 'p_last_update_login',
16000         p_user_id              => l_service_request_rec.last_updated_by,
16001         p_login_id             => l_service_request_rec.last_update_login,
16002         x_return_status        => l_return_status);
16003     IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
16004       RAISE FND_API.G_EXC_ERROR;
16005     END IF;
16006 
16007         -- Validate p_last_update_by information
16008 
16009      IF p_last_updated_by IS NOT NULL AND
16010         p_last_updated_by <> FND_API.G_MISS_NUM THEN
16011 
16012 
16013         CS_ServiceRequest_UTIL.Validate_Who_Info
16014           ( p_api_name             => l_api_name_full,
16015             p_parameter_name_usr   => 'p_last_updated_by',
16016             p_parameter_name_login => null,
16017             p_user_id              => p_last_updated_by,
16018             p_login_id             => null,
16019             x_return_status        => l_return_status);
16020 
16021         IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
16022           RAISE FND_API.G_EXC_ERROR;
16023         END IF;
16024      END IF ;
16025 
16026   END IF ;  -- p_validation level end if
16027 
16028     --
16029     -- Can't update the request type or owner if there is
16030     -- an active workflow.  Also, cannot close the service
16031     -- request (by setting the status) if there's an active
16032     -- workflow process in progress unless this procedure
16033     -- itself was called by a workflow process.
16034     --
16035     IF (l_old_ServiceRequest_rec.workflow_process_id IS NOT NULL) AND
16036        CS_Workflow_PKG.Is_Servereq_Item_Active
16037        ( p_request_number  => l_old_ServiceRequest_rec.incident_number,
16038          p_wf_process_id   => l_old_ServiceRequest_rec.workflow_process_id)  = 'Y'  AND
16039        ((FND_API.To_Boolean(p_called_by_workflow) = FALSE) OR
16040       (NOT (l_old_ServiceRequest_rec.workflow_process_id = p_workflow_process_id))) THEN
16041 
16042       IF (l_service_request_rec.type_id <> FND_API.G_MISS_NUM) AND
16043          (l_service_request_rec.type_id <> l_old_ServiceRequest_rec.incident_type_id) THEN
16044 
16045         IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
16046           FND_MESSAGE.Set_Name('CS', 'CS_API_SR_TYPE_READONLY');
16047           FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16048           FND_MSG_PUB.ADD;
16049         END IF;
16050         RAISE FND_API.G_EXC_ERROR;
16051       END IF;
16052 
16053       IF (l_service_request_rec.owner_id <> FND_API.G_MISS_NUM AND
16054          l_service_request_rec.owner_id <> l_old_ServiceRequest_rec.incident_owner_id) OR
16055          (l_service_request_rec.owner_id IS NULL AND
16056           l_old_ServiceRequest_rec.incident_owner_id IS NOT NULL) OR
16057          (l_service_request_rec.owner_group_id <> FND_API.G_MISS_NUM AND
16058          l_service_request_rec.owner_group_id <> l_old_ServiceRequest_rec.owner_group_id) THEN
16059 
16060         IF fnd_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
16061           FND_MESSAGE.Set_Name('CS', 'CS_API_SR_OWNER_READONLY');
16062           FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16063           FND_MSG_PUB.ADD;
16064         END IF;
16065         RAISE FND_API.G_EXC_ERROR;
16066       END IF;
16067     END IF;     -- Workflow condition
16068 
16069     CS_SERVICEREQUEST_UTIL.get_status_details
16070     ( p_status_id                  => l_old_servicerequest_rec.incident_status_id
16071     , x_close_flag                 => l_sr_related_data.old_close_flag
16072     , x_disallow_request_update    => l_sr_related_data.old_disallow_request_update
16073     , x_disallow_agent_dispatch    => l_sr_related_data.old_disallow_owner_update
16074     , x_disallow_product_update    => l_sr_related_data.old_disallow_product_update
16075     , x_pending_approval_flag      => l_sr_related_data.old_pending_approval_flag
16076     , x_intermediate_status_id     => l_sr_related_data.old_intermediate_status_id
16077     , x_approval_action_status_id  => l_sr_related_data.old_approval_action_status_id
16078     , x_rejection_action_status_id => l_sr_related_data.old_rejection_action_status_id
16079     , x_return_status              => l_return_status
16080     );
16081     l_old_close_flag  := l_sr_related_data.old_close_flag;
16082     l_closed_flag_temp := l_old_close_flag;
16083     l_disallow_request_update  := l_sr_related_data.old_disallow_request_update;
16084     IF (l_service_request_rec.status_id <> FND_API.G_MISS_NUM AND
16085         l_service_request_rec.status_id <> l_old_servicerequest_rec.incident_status_id)
16086     THEN
16087         IF (l_service_request_rec.type_id = FND_API.G_MISS_NUM) THEN
16088           l_type_id_temp := l_old_ServiceRequest_rec.incident_type_id;
16089         ELSE
16090           l_type_id_temp := l_service_request_rec.type_id;
16091         END IF;
16092 
16093         --This part of the code should just check whether the status can be
16094         --updated.Also Aborting the workflow code is based on close flag from
16095         --CS_INCIDENTS_STATUSES and abort_workflow on close flag from
16096         --CS_INCIDENT_TYPES.
16097 
16098         -- This functionality is based on the change in the SR status
16099         -- Check if we need to abort the workflow process if the service
16100         -- request is being closed. First we check if the
16101         -- abort_workflow_close_flag for the type_id passed is set to 'Y'
16102         -- then we check if the status of the SR has gone to close for the
16103         -- first time.
16104         -- Check what was the old value of close flag depending on old type id
16105         -- and old status id of SR
16106 
16107         -- Get the old value of close flag
16108 		-- added disallow_request_update, disallow_agent_dispatch, disallow_product_update to the SQL
16109       -- 3306908 - commented the date validation
16110 
16111   IF (l_service_request_rec.last_updated_by = FND_API.G_MISS_NUM OR
16112       l_service_request_rec.last_updated_by IS NULL ) THEN
16113       l_service_request_rec.last_updated_by := p_last_updated_by;
16114   END IF;
16115 
16116     CS_SERVICEREQUEST_UTIL.get_status_details
16117     ( p_status_id                  => l_service_request_rec.status_id
16118     , x_close_flag                 => l_sr_related_data.close_flag
16119     , x_disallow_request_update    => l_sr_related_data.disallow_request_update
16120     , x_disallow_agent_dispatch    => l_sr_related_data.disallow_owner_update
16121     , x_disallow_product_update    => l_sr_related_data.disallow_product_update
16122     , x_pending_approval_flag      => l_sr_related_data.pending_approval_flag
16123     , x_intermediate_status_id     => l_sr_related_data.intermediate_status_id
16124     , x_approval_action_status_id  => l_sr_related_data.approval_action_status_id
16125     , x_rejection_action_status_id => l_sr_related_data.rejection_action_status_id
16126     , x_return_status              => l_return_status
16127     );
16128     IF l_return_status <> FND_API.G_RET_STS_SUCCESS
16129     THEN
16130       l_return_status := FND_API.G_RET_STS_ERROR;
16131       CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
16132       ( p_token_an    => l_api_name_full
16133       , p_token_v     => TO_CHAR(l_service_request_rec.status_id)
16134       , p_token_p     => 'p_status_id'
16135       , p_table_name  => G_TABLE_NAME
16136       , p_column_name => 'INCIDENT_STATUS_ID'
16137       );
16138 
16139       RAISE FND_API.G_EXC_ERROR;
16140     END IF;
16141     l_new_close_flag  := l_sr_related_data.close_flag;
16142     l_closed_flag_temp := l_sr_related_data.close_flag;
16143 
16144    -- -------------------------------------------------------------
16145    --  Check if the passsed type_id has Abort Workflow Close flag set to 'Y'.
16146    --  If so, get the workflow name asociated with that type_id
16147    --  Check the close flag from the status table.
16148    -- -------------------------------------------------------------
16149 
16150       BEGIN
16151        -- Initialize the return status.
16152        l_return_status := FND_API.G_RET_STS_SUCCESS;
16153        -- Verify the type ID against the database.
16154       -- Suppose type is not updated and old type is end date and then cond on start and
16155        -- end dates will cause no dat found. old value of type id even if it is end dated
16156        -- should not cause any error.
16157           SELECT autolaunch_workflow_flag, abort_workflow_close_flag, workflow
16158           INTO   x_autolaunch_wkf_flag, x_abort_wkf_close_flag, x_wkf_process_name
16159           FROM   cs_incident_types
16160           WHERE  incident_type_id = l_type_id_temp
16161           AND    incident_subtype = G_SR_SUBTYPE
16162           ;
16163 
16164       EXCEPTION
16165            WHEN NO_DATA_FOUND THEN
16166                l_return_status := FND_API.G_RET_STS_ERROR;
16167 
16168                CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
16169                                  ( p_token_an    => l_api_name_full,
16170                                    p_token_v     => TO_CHAR(l_type_id_temp),
16171                                    p_token_p     => 'p_type_id',
16172                                    p_table_name  => G_TABLE_NAME ,
16173                                    p_column_name => 'INCIDENT_TYPE_ID' );
16174 
16175                RAISE FND_API.G_EXC_ERROR;
16176       END ;
16177 
16178     -- Fix for 11.5.7 bug 2254288 . These variables are not being set properly.
16179     -- rmanabat 03/12/02
16180     l_abort_workflow_close_flag := x_abort_wkf_close_flag;
16181     l_autolaunch_workflow_flag := x_autolaunch_wkf_flag;
16182 
16183      -- Call Abort workflow, if the status is being changed to CLOSE and the
16184      -- abort workflow on close flag is set to Y and there is an active
16185      -- workflow process in progress.
16186 
16187      IF (l_abort_workflow_close_flag = 'Y') THEN
16188         IF (l_old_close_flag = 'N' OR  l_old_close_flag IS NULL)
16189         AND (l_closed_flag_temp='Y')
16190         AND (CS_Workflow_PKG.Is_Servereq_Item_Active
16191                  (p_request_number  => l_old_ServiceRequest_rec.incident_number,
16192                   p_wf_process_id   => l_old_ServiceRequest_rec.workflow_process_id )  = 'Y')
16193         THEN
16194           CS_Workflow_PKG.Abort_Servereq_Workflow
16195              (p_request_number  => l_old_ServiceRequest_rec.incident_number,
16196               p_wf_process_id   => l_old_ServiceRequest_rec.workflow_process_id,
16197               p_user_id         => p_last_updated_by);
16198         END IF;
16199      END IF;
16200      --l_status_validated := TRUE;
16201 	 -- for bug 3640344 - pkesani
16202    ELSE
16203     l_sr_related_data.close_flag := l_sr_related_data.old_close_flag;
16204     -- since SR status is not changed all new flag will be same as old flag
16205     l_sr_related_data.pending_approval_flag := l_sr_related_data.old_pending_approval_flag;
16206    END IF ;  /* status id changed end if */
16207 
16208   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
16209      -- If this flag is set to Y, update only status and return
16210      -- if last_update_program_code is g_miss_char then it is replaced with 'UNKNOWN'
16211      -- value from old record is not used for this attribute. so the condition below too
16212      -- does not check old value rec in case of g_miss_char.
16213      IF (l_sr_related_data.old_disallow_request_update = 'Y') THEN
16214        -- if disallow request update is ON and SR is in intermediate status
16215        -- then only ERES can update service request. if updating program in
16216        -- other than ERES then raise error and exit.
16217 
16218        IF l_sr_related_data.old_pending_approval_flag = 'Y' AND
16219           NVL(l_service_requesT_rec.last_update_program_code,'UNKNOWN') <> 'ERES'
16220        THEN
16221          FND_MESSAGE.Set_Name('CS', 'CS_SR_APPROVAL_NEEDED');
16222          FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16223          FND_MSG_PUB.ADD_DETAIL
16224          ( p_associated_column1 => 'CS_INCIDENTS_ALL_B.INCIDENT_STATUS_ID'
16225          );
16226          RAISE FND_API.G_EXC_ERROR;
16227        END IF;
16228        -- if new status has pending approval flag then it means ERES update is in
16229        -- progress and do not call update_status because update_status calls
16230        -- update_servicerequest to process ERES updates
16231        IF l_sr_related_data.pending_approval_flag <> 'Y' AND
16232           NVL(l_service_requesT_rec.last_update_program_code,'UNKNOWN') <> 'ERES'
16233        THEN
16234          x_service_request_rec := l_service_request_rec;
16235          RAISE OnlyUpdStatus ;
16236        END IF;
16237      END IF;
16238 
16239     IF (l_sr_related_data.old_disallow_owner_update = 'Y') THEN
16240 
16241        -- Tell the user he cannot update owner and store old value in the field
16242       IF (NVL(l_service_request_rec.owner_id,-9) <> FND_API.G_MISS_NUM AND
16243           NVL(l_service_request_rec.owner_id,-9) <> NVL(l_old_servicerequest_rec.incident_owner_id,-9)) OR
16244          (NVL(l_service_request_rec.resource_type,'x') <> FND_API.G_MISS_CHAR AND
16245           NVL(l_service_request_rec.resource_type,'x') <> NVL(l_old_servicerequest_rec.resource_type,'x'))
16246       THEN
16247         --IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
16248           FND_MESSAGE.Set_Name('CS', 'CS_API_SR_OWNER_NOT_UPDATED');
16249           FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16250           FND_MSG_PUB.ADD_DETAIL
16251           ( p_message_type=>FND_MSG_PUB.G_INFORMATION_MSG
16252           , p_associated_column1 => 'CS_INCIDENTS_ALL_B.incident_owner_id'
16253           );
16254         --END IF;
16255       END IF;
16256       l_service_request_rec.owner_id      := l_old_ServiceRequest_rec.incident_owner_id;
16257       l_service_request_rec.resource_type := l_old_ServiceRequest_rec.resource_type;
16258 
16259     END IF;
16260 
16261 
16262     IF (l_sr_related_data.old_disallow_product_update = 'Y') THEN
16263 
16264         --Changes starts for bug 14242503. For disallow product update flag, check if any prodouct related info is changed, if so, throw a warning,
16265     --else don't throw the warning
16266     IF (l_service_request_rec.customer_product_id = FND_API.G_MISS_NUM  OR
16267         NVL(l_service_request_rec.customer_product_id,-99) =  NVL(l_old_ServiceRequest_rec.customer_product_id,-99))
16268     AND (l_service_request_rec.cp_component_id = FND_API.G_MISS_NUM  OR
16269         NVL(l_service_request_rec.cp_component_id,-99) = NVL(l_old_servicerequest_rec.cp_component_id,-99))
16270     AND (l_service_request_rec.cp_component_version_id = FND_API.G_MISS_NUM  OR
16271          NVL(l_service_request_rec.cp_component_version_id,-99) = NVL(l_old_servicerequest_rec.cp_component_version_id,-99))
16272     AND (l_service_request_rec.cp_subcomponent_id = FND_API.G_MISS_NUM OR
16273          NVL(l_service_request_rec.cp_subcomponent_id,-99) = NVL(l_old_servicerequest_rec.cp_subcomponent_id,-99))
16274     AND (l_service_request_rec.cp_subcomponent_version_id = FND_API.G_MISS_NUM OR
16275          NVL(l_service_request_rec.cp_subcomponent_version_id,-99) = NVL(l_old_servicerequest_rec.cp_subcomponent_version_id,99))
16276     AND (l_service_request_rec.cp_revision_id = FND_API.G_MISS_NUM OR
16277         NVL(l_service_request_rec.cp_revision_id ,-99) = NVL(l_old_servicerequest_rec.cp_revision_id ,-99))
16278     AND (l_service_request_rec.product_revision =  FND_API.G_MISS_CHAR OR
16279         NVL(l_service_request_rec.product_revision,'-99')= NVL(l_old_servicerequest_rec.product_revision,'-99'))
16280     AND (l_service_request_rec.component_version = FND_API.G_MISS_CHAR OR
16281         NVL(l_service_request_rec.component_version,'-99') = NVL(l_old_servicerequest_rec.component_version,'-99'))
16282     AND (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR OR
16283         NVL(l_service_request_rec.subcomponent_version,'-99') = NVL(l_old_servicerequest_rec.subcomponent_version,'-99'))
16284     AND (l_service_request_rec.original_order_number = FND_API.G_MISS_NUM OR
16285         NVL( l_service_request_rec.original_order_number,-99) = NVL(l_old_ServiceRequest_rec.original_order_number,-99))
16286     AND (l_service_request_rec.purchase_order_num = FND_API.G_MISS_CHAR OR
16287     NVL(l_service_request_rec.purchase_order_num,'99') = NVL(l_old_ServiceRequest_rec.purchase_order_num,'-99'))
16288     AND (l_service_request_rec.inv_item_revision = FND_API.G_MISS_CHAR OR
16289     NVL(l_service_request_rec.inv_item_revision,'-99') = NVL(l_old_ServiceRequest_rec.inv_item_revision,'-99'))
16290     AND (l_service_request_rec.inv_component_id = FND_API.G_MISS_NUM OR
16291         NVL(l_service_request_rec.inv_component_id,-99)= NVL(l_old_ServiceRequest_rec.inv_component_id,-99))
16292     AND (l_service_request_rec.inv_component_version = FND_API.G_MISS_CHAR OR
16293         NVL(l_service_request_rec.inv_component_version,'-99')= NVL(l_old_ServiceRequest_rec.inv_component_version,'-99'))
16294     AND (l_service_request_rec.inv_subcomponent_id = FND_API.G_MISS_NUM OR
16295         NVL(l_service_request_rec.inv_subcomponent_id,-99)  = NVL(l_old_ServiceRequest_rec.inv_subcomponent_id,-99))
16296     AND (l_service_request_rec.inv_subcomponent_version = FND_API.G_MISS_CHAR OR
16297         NVL(l_service_request_rec.inv_subcomponent_version,'-99')  = NVL(l_old_ServiceRequest_rec.inv_subcomponent_version,'-99'))
16298     AND (l_service_request_rec.inventory_item_id  = FND_API.G_MISS_NUM OR
16299        NVL(l_service_request_rec.inventory_item_id,-99) = NVL(l_old_ServiceRequest_rec.inventory_item_id,-99))
16300     AND (l_service_request_rec.current_serial_number = FND_API.G_MISS_CHAR OR
16301         NVL(l_service_request_rec.current_serial_number,'-99') = NVL(l_old_ServiceRequest_rec.current_serial_number,'-99')) THEN
16302              l_cust_product_changed := 'N';
16303      END IF;
16304 
16305       IF l_cust_product_changed = 'Y' THEN
16306         IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
16307           FND_MESSAGE.Set_Name('CS', 'CS_API_SR_PRODUCT_NOT_UPDATED');
16308           FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16309           FND_MSG_PUB.ADD;
16310     END IF;
16311      END IF;
16312      --End of changes for bug 14242503
16313 
16314       -- Tell the user he cannot update product and related fields and store
16315       -- old value in the field.Check if install_base or not
16316 	  -- Fix for bug 14242503 .Added one more if condition
16317       --IF (l_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM) THEN
16318 	 IF (l_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM OR l_service_request_rec.customer_product_id IS NULL ) THEN
16319 
16320         l_service_request_rec.customer_product_id     := l_old_ServiceRequest_rec.customer_product_id;
16321         l_service_request_rec.cp_component_id         := l_old_servicerequest_rec.cp_component_id;
16322         l_service_request_rec.cp_component_version_id := l_old_servicerequest_rec.cp_component_version_id;
16323         l_service_request_rec.cp_subcomponent_id      := l_old_servicerequest_rec.cp_subcomponent_id;
16324         l_service_request_rec.cp_subcomponent_version_id := l_old_servicerequest_rec.cp_subcomponent_version_id;
16325         l_service_request_rec.cp_revision_id          := l_old_servicerequest_rec.cp_revision_id;
16326         l_service_request_rec.product_revision        := l_old_servicerequest_rec.product_revision;
16327         l_service_request_rec.component_version       := l_old_servicerequest_rec.component_version;
16328         l_service_request_rec.subcomponent_version    := l_old_servicerequest_rec.subcomponent_version;
16329       ELSE
16330         -- Inv fields
16331         -- Below two fields will have value only if it is not installed base.
16332         l_service_request_rec.original_order_number := l_old_ServiceRequest_rec.original_order_number;
16333         l_service_request_rec.purchase_order_num    := l_old_ServiceRequest_rec.purchase_order_num;
16334         l_service_request_rec.inv_item_revision     := l_old_ServiceRequest_rec.inv_item_revision;
16335         l_service_request_rec.inv_component_id      := l_old_ServiceRequest_rec.inv_component_id;
16336         l_service_request_rec.inv_component_version := l_old_ServiceRequest_rec.inv_component_version ;
16337         l_service_request_rec.inv_subcomponent_id   := l_old_ServiceRequest_rec.inv_subcomponent_id ;
16338         l_service_request_rec.inv_subcomponent_version  :=l_old_ServiceRequest_rec.inv_subcomponent_version  ;
16339       END IF;
16340 
16341       --These are fields which will have value irrespective of Installed base or not.
16342       l_service_request_rec.inventory_item_id    := l_old_ServiceRequest_rec.inventory_item_id;
16343       l_service_request_rec.current_serial_number :=l_old_ServiceRequest_rec.current_serial_number;
16344   --Commented out below code and move the code up for bug 14242503
16345         /*
16346          IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
16347           FND_MESSAGE.Set_Name('CS', 'CS_API_SR_PRODUCT_NOT_UPDATED');
16348           FND_MESSAGE.Set_Token('API_NAME', l_api_name_full);
16349           FND_MSG_PUB.ADD;
16350          END IF; */
16351     END IF;
16352  END IF;    /* end of validation level check */
16353 
16354   --
16355   -- For each column in the table, we have a corresponding local variable.
16356   -- These local variables will be used in the actual UPDATE SQL statement.
16357   -- If a column is being updated, we need to initialize the corresponding
16358   -- local variable to the value of the parameter that was passed in; otherwise,
16359   -- the the local variable should be set to the original value in the table.
16360   --
16361   -- In addition, if the column that is being updated requires validation, then
16362   -- we need to set the corresponding field in the validation record.  For
16363   -- validation, we always store the values into the validation record, however,
16364   -- the validation routine is called depending on the value of the validation
16365   -- level parameter.
16366   --
16367   -- We also keep track of changes in the fields that are audited by setting
16368   -- the audit records when changes are detected
16369   --
16370   -- -----------------------------------------------------------------
16371   -- Check the header fields: type, status, severity, urgency, owner,
16372   -- publish flag and summary. All but summary need to be validated if
16373   -- the validation level is set.
16374   -- -----------------------------------------------------------------
16375 
16376   IF (l_service_request_rec.type_id = FND_API.G_MISS_NUM) OR
16377      (nvl(l_service_request_rec.type_id,-99) = nvl(l_old_ServiceRequest_rec.incident_type_id,-99))
16378   THEN
16379     l_service_request_rec.type_id := l_old_ServiceRequest_rec.incident_type_id;
16380     -- For audit record added by shijain
16381     x_audit_vals_rec.change_incident_type_flag := 'N';
16382     x_audit_vals_rec.old_incident_type_id      := l_old_ServiceRequest_rec.incident_type_id;
16383     x_audit_vals_rec.incident_type_id          := l_service_request_rec.type_id;
16384   ELSE
16385     l_SR_Validation_rec.validate_type := FND_API.G_TRUE;
16386     l_SR_Validation_rec.type_id := l_service_request_rec.type_id;
16387     l_SR_Validation_rec.old_type_id := l_old_ServiceRequest_rec.incident_type_id;
16388 
16389     -- Since the validation of type depends on the value of status,
16390     -- we need to also set the status_id field in the validation record.
16391     IF (l_service_request_rec.status_id = FND_API.G_MISS_NUM) OR
16392        (nvl(l_service_request_rec.status_id,-99) = nvl(l_old_ServiceRequest_rec.incident_status_id,-99))THEN
16393       l_SR_Validation_rec.status_id := l_old_ServiceRequest_rec.incident_status_id;
16394       l_SR_Validation_rec.validate_status := FND_API.G_TRUE;
16395     ELSE
16396       -- This needs to be done here, cause if both type and status change,
16397       -- then status_id will be overwritten by the old status id in the
16398       -- (status change) loop below.
16399 
16400       l_SR_Validation_rec.updated_status_id := l_service_request_rec.status_id;
16401       l_SR_Validation_rec.validate_updated_status := FND_API.G_TRUE;
16402       -- This flag is needed cause we have to assign the appropriate status id
16403       -- to the Validate_Type Procedure
16404 
16405       l_SR_Validation_rec.status_id_change :=  FND_API.G_TRUE;
16406 
16407     END IF;
16408     -- For audit record
16409     x_audit_vals_rec.CHANGE_INCIDENT_TYPE_FLAG := 'Y';
16410     x_audit_vals_rec.OLD_INCIDENT_TYPE_ID      := l_old_ServiceRequest_rec.incident_type_id;
16411     x_audit_vals_rec.INCIDENT_TYPE_ID          := l_service_request_rec.type_id;
16412   END IF;
16413 
16414   IF (l_service_request_rec.status_id = FND_API.G_MISS_NUM) OR
16415      (nvl(l_service_request_rec.status_id,-99) = nvl(l_old_ServiceRequest_rec.incident_status_id,-99)) THEN
16416      l_service_request_rec.status_id     := l_old_ServiceRequest_rec.incident_status_id;
16417      -- For audit record added by shijain
16418      x_audit_vals_rec.change_incident_status_flag := 'N';
16419      x_audit_vals_rec.old_incident_status_id      := l_old_ServiceRequest_rec.incident_status_id;
16420      x_audit_vals_rec.incident_status_id          := l_service_request_rec.status_id;
16421   ELSE
16422     --IF (l_status_validated = FALSE) THEN
16423       l_SR_Validation_rec.validate_updated_status := FND_API.G_TRUE;
16424 
16425       -- We need the old status id to validate the new status id. So, we assign
16426       -- the old status_id to the status_id attribute of the Validation Rec
16427       -- Type and the new status_id is assigned to the updated_status_id
16428       -- attribute of the Validation Rec Type
16429 
16430       l_SR_Validation_rec.updated_status_id := l_service_request_rec.status_id;
16431       l_SR_Validation_rec.status_id         := l_old_ServiceRequest_rec.incident_status_id;
16432       --
16433       -- Since the validation of status depends on the value of type,
16434       -- we need to also set the type_id field in the validation record.
16435       --
16436       l_SR_Validation_rec.type_id := l_service_request_rec.type_id;
16437     --END IF;
16438     -- For audit record
16439        x_audit_vals_rec.CHANGE_INCIDENT_STATUS_FLAG := 'Y';
16440        x_audit_vals_rec.OLD_INCIDENT_STATUS_ID      := l_old_ServiceRequest_rec.incident_status_id;
16441        x_audit_vals_rec.INCIDENT_STATUS_ID          := l_service_request_rec.status_id;
16442   END IF;
16443 
16444   IF (l_service_request_rec.severity_id = FND_API.G_MISS_NUM) OR
16445      (nvl(l_service_request_rec.severity_id,-99) = nvl(l_old_ServiceRequest_rec.incident_severity_id,-99)) THEN
16446     l_service_request_rec.severity_id     := l_old_ServiceRequest_rec.incident_severity_id;
16447     -- For audit record added by shijain
16448     x_audit_vals_rec.change_incident_severity_flag := 'N';
16449     x_audit_vals_rec.old_incident_severity_id      := l_old_ServiceRequest_rec.incident_severity_id;
16450     x_audit_vals_rec.incident_severity_id          := l_service_request_rec.severity_id;
16451   ELSE
16452     l_SR_Validation_rec.severity_id       := l_service_request_rec.severity_id;
16453     -- For audit record
16454     x_audit_vals_rec.CHANGE_INCIDENT_SEVERITY_FLAG := 'Y';
16455     x_audit_vals_rec.OLD_INCIDENT_SEVERITY_ID      := l_old_ServiceRequest_rec.incident_severity_id;
16456     x_audit_vals_rec.INCIDENT_SEVERITY_ID          := l_service_request_rec.severity_id;
16457   END IF;
16458 
16459   IF (l_service_request_rec.urgency_id = FND_API.G_MISS_NUM)
16460   OR
16461      (nvl(l_service_request_rec.urgency_id,-99) = nvl(l_old_ServiceRequest_rec.incident_urgency_id,-99))
16462   THEN
16463 
16464     l_service_request_rec.urgency_id     := l_old_ServiceRequest_rec.incident_urgency_id;
16465     -- For audit record added by shijain
16466     x_audit_vals_rec.change_incident_urgency_flag := 'N';
16467     x_audit_vals_rec.old_incident_urgency_id      := l_old_ServiceRequest_rec.incident_urgency_id;
16468     x_audit_vals_rec.incident_urgency_id          := l_service_request_rec.urgency_id;
16469   ELSE
16470     IF (l_service_request_rec.urgency_id IS NOT NULL) THEN
16471       l_SR_Validation_rec.urgency_id := l_service_request_rec.urgency_id;
16472     END IF;
16473     -- For audit record
16474     x_audit_vals_rec.CHANGE_INCIDENT_URGENCY_FLAG := 'Y';
16475     x_audit_vals_rec.OLD_INCIDENT_URGENCY_ID      := l_old_ServiceRequest_rec.incident_urgency_id;
16476     x_audit_vals_rec.INCIDENT_URGENCY_ID          := l_service_request_rec.urgency_id;
16477   END IF;
16478 -- Added NULL condition for Bug# 2181534
16479 
16480 -- commented for 2993526
16481 /*  IF (l_service_request_rec.owner_id = FND_API.G_MISS_NUM) OR
16482      (nvl(l_service_request_rec.owner_id,-99) = nvl(l_old_ServiceRequest_rec.incident_owner_id,-99))
16483   THEN
16484     l_service_request_rec.owner_id := l_old_ServiceRequest_rec.incident_owner_id;
16485     l_service_request_rec.owner    := l_old_ServiceRequest_rec.owner;
16486 
16487      -- for audit record added by shijain
16488      x_audit_vals_rec.change_incident_owner_flag := 'N';
16489      x_audit_vals_rec.old_incident_owner_id      := l_old_ServiceRequest_rec.incident_owner_id;
16490      x_audit_vals_rec.incident_owner_id          := l_service_request_rec.owner_id;
16491      x_audit_vals_rec.change_assigned_time_flag  := 'N';
16492      x_audit_vals_rec.old_owner_assigned_time    := l_old_ServiceRequest_rec.owner_assigned_time;
16493      x_audit_vals_rec.owner_assigned_time        := SYSDATE;
16494   ELSE
16495      l_SR_Validation_rec.owner_id := l_service_request_rec.owner_id;
16496      -- For audit record
16497      ---- Added for Enh# 2216664
16498      IF (l_service_request_rec.owner_id IS NOT NULL AND
16499         l_service_request_rec.owner_id <> FND_API.G_MISS_NUM) THEN
16500      -- for bug 2770831 added Begin End and Exception to handle NO_DATA_FOUND.
16501 
16502        BEGIN
16503         SELECT resource_name INTO l_service_request_rec.owner
16504         FROM jtf_rs_resource_extns_tl
16505         WHERE resource_id = l_service_request_rec.owner_id
16506         AND LANGUAGE =  USERENV('LANG');
16507        EXCEPTION
16508 	     WHEN NO_DATA_FOUND THEN
16509              l_return_status := FND_API.G_RET_STS_ERROR;
16510              CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
16511                     ( p_token_an    => l_api_name_full,
16512                       p_token_v     => TO_CHAR(l_service_request_rec.owner_id),
16513                       p_token_p     => 'p_owner_id',
16514                       p_table_name  => G_TABLE_NAME ,
16515                       p_column_name => 'INCIDENT_OWNER_ID' );
16516 
16517                RAISE FND_API.G_EXC_ERROR;
16518        END;
16519      END IF;
16520      IF (l_service_request_rec.owner_id IS NULL) THEN
16521          l_service_request_rec.owner := NULL;
16522      END IF;
16523 
16524      x_audit_vals_rec.CHANGE_INCIDENT_OWNER_FLAG := 'Y';
16525      x_audit_vals_rec.OLD_INCIDENT_OWNER_ID      := l_old_ServiceRequest_rec.incident_owner_id;
16526      x_audit_vals_rec.INCIDENT_OWNER_ID          := l_service_request_rec.owner_id;
16527     -----Added for Bug# 1874546-----jngeorge------07/18/01
16528      x_audit_vals_rec.change_RESOURCE_TYPE_FLAG  := 'Y';
16529      x_audit_vals_rec.OLD_RESOURCE_TYPE          := l_old_ServiceRequest_rec.resource_type;
16530      x_audit_vals_rec.RESOURCE_TYPE              := l_service_request_rec.resource_type;
16531      x_audit_vals_rec.change_ASSIGNED_TIME_FLAG  := 'Y';
16532      x_audit_vals_rec.OLD_OWNER_ASSIGNED_TIME    := l_old_ServiceRequest_rec.owner_assigned_time;
16533      x_audit_vals_rec.OWNER_ASSIGNED_TIME        := SYSDATE;
16534  END IF;  */
16535 
16536 --
16537 --2993526
16538 ---
16539 ---
16540  IF (l_service_request_rec.owner_id = FND_API.G_MISS_NUM) OR
16541      (nvl(l_service_request_rec.owner_id,-99) = nvl(l_old_ServiceRequest_rec.incident_owner_id,-99))
16542   THEN
16543     l_service_request_rec.owner_id := l_old_ServiceRequest_rec.incident_owner_id;
16544  ELSE
16545      l_SR_Validation_rec.owner_id := l_service_request_rec.owner_id;
16546  END IF;
16547  --
16548  -- Group Type
16549  -- if Group id passed and group type is not passed and old value is null then set group type from profile
16550  --
16551  IF (l_service_request_rec.group_type = FND_API.G_MISS_CHAR AND
16552      l_old_servicerequest_rec.group_type is null AND
16553      l_service_request_rec.owner_group_id <> FND_API.G_MISS_NUM) THEN
16554      l_service_request_rec.group_type := nvl( FND_PROFILE.value('CS_SR_DEFAULT_GROUP_TYPE'), 'RS_GROUP');
16555  END IF;
16556  IF (l_service_request_rec.group_type = FND_API.G_MISS_CHAR) OR
16557      (nvl(l_service_request_rec.group_type,'-99') = nvl(l_old_ServiceRequest_rec.group_type,'-99')) THEN
16558     l_service_request_rec.group_type := l_old_ServiceRequest_rec.group_type;
16559  ELSE
16560     l_SR_Validation_rec.group_type := l_service_request_rec.group_type;
16561  END IF;
16562  -- Owner Group ID
16563  IF (l_service_request_rec.owner_group_id = FND_API.G_MISS_NUM) OR
16564      (l_service_request_rec.owner_group_id IS NULL AND
16565       l_old_ServiceRequest_rec.owner_group_id IS NULL) OR
16566      (l_service_request_rec.owner_group_id = l_old_ServiceRequest_rec.owner_group_id) THEN
16567     l_service_request_rec.owner_group_id := l_old_ServiceRequest_rec.owner_group_id;
16568  ELSE
16569     l_SR_Validation_rec.owner_group_id := l_service_request_rec.owner_group_id;
16570     l_SR_Validation_rec.group_type := l_service_request_rec.group_type;
16571  END IF;
16572 
16573   IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) OR
16574      (nvl(l_service_request_rec.inv_platform_org_id,-99) = nvl(l_old_ServiceRequest_rec.inv_platform_org_id,-99)) THEN
16575     l_service_request_rec.inv_platform_org_id := l_old_ServiceRequest_rec.inv_platform_org_id;
16576     -- For audit record added by shijain
16577     x_audit_vals_rec.change_platform_org_id_flag := 'N';
16578     x_audit_vals_rec.old_inv_platform_org_id     := l_old_ServiceRequest_rec.inv_platform_org_id;
16579     x_audit_vals_rec.inv_platform_org_id         := l_service_request_rec.inv_platform_org_id;
16580   ELSE
16581     -- For audit record
16582     x_audit_vals_rec.change_platform_org_id_FLAG := 'Y';
16583     x_audit_vals_rec.OLD_inv_platform_org_id := l_old_ServiceRequest_rec.inv_platform_org_id;
16584     x_audit_vals_rec.inv_platform_org_id := l_service_request_rec.inv_platform_org_id;
16585   END IF;
16586 
16587   IF ((l_service_request_rec.publish_flag = FND_API.G_MISS_CHAR) OR
16588       (l_service_request_rec.publish_flag = l_old_ServiceRequest_rec.publish_flag)) THEN
16589     l_service_request_rec.publish_flag := l_old_ServiceRequest_rec.publish_flag;
16590   ELSE
16591     l_SR_Validation_rec.publish_flag := l_service_request_rec.publish_flag;
16592   END IF;
16593 
16594   IF (l_service_request_rec.summary = FND_API.G_MISS_CHAR) OR
16595      (l_service_request_rec.summary = l_old_ServiceRequest_rec.summary) THEN
16596     l_service_request_rec.summary := l_old_ServiceRequest_rec.summary;
16597   END IF;
16598 
16599   ---- Added for Enh# 1830701
16600   IF (l_service_request_rec.incident_occurred_date = FND_API.G_MISS_DATE) OR
16601      (l_service_request_rec.incident_occurred_date = l_old_ServiceRequest_rec.incident_occurred_date) THEN
16602      l_service_request_rec.incident_occurred_date := l_old_ServiceRequest_rec.incident_occurred_date;
16603   ELSE
16604     l_SR_Validation_rec.incident_occurred_date := l_service_request_rec.incident_occurred_date;
16605   END IF;
16606 
16607   IF (l_service_request_rec.incident_resolved_date = FND_API.G_MISS_DATE) OR
16608      (l_service_request_rec.incident_resolved_date = l_old_ServiceRequest_rec.incident_resolved_date) THEN
16609      l_service_request_rec.incident_resolved_date := l_old_ServiceRequest_rec.incident_resolved_date;
16610   ELSE
16611     l_SR_Validation_rec.incident_resolved_date := l_service_request_rec.incident_resolved_date;
16612   END IF;
16613 
16614 
16615   IF (l_service_request_rec.inc_responded_by_date = FND_API.G_MISS_DATE) OR
16616      (l_service_request_rec.inc_responded_by_date = l_old_ServiceRequest_rec.inc_responded_by_date) THEN
16617      l_service_request_rec.inc_responded_by_date := l_old_ServiceRequest_rec.inc_responded_by_date;
16618   ELSE
16619     l_SR_Validation_rec.inc_responded_by_date := l_service_request_rec.inc_responded_by_date;
16620   END IF;
16621 
16622   -- 12/13/2005 smisra bug 4386870
16623   -- if there is no change in incident location then country too should not change ecause it is
16624   -- derived from location
16625 
16626   IF l_service_request_rec.incident_location_id = l_old_servicerequest_rec.incident_location_id OR
16627      (l_service_request_rec.incident_location_id = FND_API.G_MISS_NUM AND
16628       l_old_servicerequest_rec.incident_location_id IS NOT NULL)
16629   THEN
16630     -- siahmed for 12.1.2 project this to make sure that the address field that will be updated
16631    -- is a one_time_address. This is doen to make so that we can use this
16632    -- global variabel in the update_sr_validation the country gets assigned
16633    -- with the old country valu which is preventing the onetime address
16634    -- to change a country once it has been assined. Using the global
16635    -- variable we will assign the value accordingly.
16636    --check if created by module = 'SR_ONETIME'
16637     IF (G_ONETIME_ADD_CNT >=1) THEN
16638        --dont do anything
16639        l_service_request_rec.incident_country := l_service_request_rec.incident_country;
16640     ELSE
16641        --there no else if and this was the original line
16642        l_service_request_rec.incident_country := l_old_ServiceRequest_rec.incident_country;
16643     END IF;
16644     --end of addition by siahmed
16645   END IF;
16646   ---- Added for Enh# 222054
16647   -- Modified for Misc ERs project of 11.5.10 --anmukher --08/29/03
16648   IF (l_service_request_rec.incident_location_id = FND_API.G_MISS_NUM) OR
16649      (l_service_request_rec.incident_location_id = l_old_ServiceRequest_rec.incident_location_id
16650      AND l_service_request_rec.incident_location_type = l_old_ServiceRequest_rec.incident_location_type) THEN
16651        l_service_request_rec.incident_location_id   := l_old_ServiceRequest_rec.incident_location_id;
16652        l_service_request_rec.incident_location_type := l_old_ServiceRequest_rec.incident_location_type;
16653   /* 12/13/05 smisra bug 4386870
16654   These is no need to copy location id and type
16655   to validation record vecause location validation is moved to vldt_sr_rec
16656   ELSE
16657     l_SR_Validation_rec.incident_location_id   := l_service_request_rec.incident_location_id;
16658     l_SR_Validation_rec.incident_location_type := l_service_request_rec.incident_location_type;
16659   ***/
16660   END IF;
16661   IF (l_service_request_rec.incident_location_id is NULL OR
16662       (l_service_request_rec.incident_location_id = FND_API.G_MISS_NUM AND
16663        l_old_servicerequest_rec.incident_location_id IS NULL )) AND
16664      l_service_request_rec.incident_country <> FND_API.G_MISS_CHAR AND
16665      l_service_request_rec.incident_country <> NVL(l_old_servicerequest_rec.incident_country,'####')
16666   THEN
16667     l_SR_Validation_rec.incident_country := l_service_request_rec.incident_country;
16668   END IF;
16669   -- Bug 3420335
16670   -- if incident_location_id is being set to Null then location_type to be set to null
16671   IF (l_service_request_rec.incident_location_id is NULL) then
16672       l_service_request_rec.incident_location_type := NULL;
16673   END IF;
16674 
16675   /*
16676   -- Added for Misc ERs project of 11.5.10 --anmukher --08/26/03
16677   IF (l_service_request_rec.incident_location_type = FND_API.G_MISS_CHAR) OR
16678      (l_service_request_rec.incident_location_type = l_old_ServiceRequest_rec.incident_location_type) THEN
16679      l_service_request_rec.incident_location_type := l_old_ServiceRequest_rec.incident_location_type;
16680   ELSE
16681     l_SR_Validation_rec.incident_location_type := l_service_request_rec.incident_location_type;
16682   END IF;
16683   */
16684 
16685   IF (l_service_request_rec.customer_site_id = FND_API.G_MISS_NUM) OR
16686      (l_service_request_rec.customer_site_id =  l_old_ServiceRequest_rec.customer_site_id) THEN
16687     l_service_request_rec.customer_site_id := l_old_ServiceRequest_rec.customer_site_id;
16688   END IF;
16689 
16690   IF (l_service_request_rec.error_code = FND_API.G_MISS_CHAR) OR
16691      (l_service_request_rec.error_code =  l_old_ServiceRequest_rec.error_code) THEN
16692     l_service_request_rec.error_code := l_old_ServiceRequest_rec.error_code;
16693   END IF;
16694 
16695   IF (l_service_request_rec.incident_address = FND_API.G_MISS_CHAR) OR
16696      (l_service_request_rec.incident_address =  l_old_ServiceRequest_rec.incident_address) THEN
16697     l_service_request_rec.incident_address := l_old_ServiceRequest_rec.incident_address;
16698   END IF;
16699 
16700   IF (l_service_request_rec.incident_city = FND_API.G_MISS_CHAR) OR
16701      (l_service_request_rec.incident_city =  l_old_ServiceRequest_rec.incident_city) THEN
16702     l_service_request_rec.incident_city := l_old_ServiceRequest_rec.incident_city;
16703   END IF;
16704 
16705   IF (l_service_request_rec.incident_state = FND_API.G_MISS_CHAR) OR
16706      (l_service_request_rec.incident_state =  l_old_ServiceRequest_rec.incident_state) THEN
16707     l_service_request_rec.incident_state := l_old_ServiceRequest_rec.incident_state;
16708   END IF;
16709 
16710   IF (l_service_request_rec.incident_country = FND_API.G_MISS_CHAR) OR
16711      (l_service_request_rec.incident_country =  l_old_ServiceRequest_rec.incident_country) THEN
16712     l_service_request_rec.incident_country := l_old_ServiceRequest_rec.incident_country;
16713   END IF;
16714 
16715   IF (l_service_request_rec.incident_province = FND_API.G_MISS_CHAR) OR
16716      (l_service_request_rec.incident_province =  l_old_ServiceRequest_rec.incident_province) THEN
16717     l_service_request_rec.incident_province := l_old_ServiceRequest_rec.incident_province;
16718   END IF;
16719 
16720   IF (l_service_request_rec.incident_postal_code = FND_API.G_MISS_CHAR) OR
16721      (l_service_request_rec.incident_postal_code =  l_old_ServiceRequest_rec.incident_postal_code) THEN
16722     l_service_request_rec.incident_postal_code := l_old_ServiceRequest_rec.incident_postal_code;
16723   END IF;
16724 
16725   IF (l_service_request_rec.incident_county = FND_API.G_MISS_CHAR) OR
16726      (l_service_request_rec.incident_county =  l_old_ServiceRequest_rec.incident_county) THEN
16727     l_service_request_rec.incident_county := l_old_ServiceRequest_rec.incident_county;
16728   END IF;
16729 
16730   IF (l_service_request_rec.resolution_summary = FND_API.G_MISS_CHAR) OR
16731      (l_service_request_rec.resolution_summary =  l_old_ServiceRequest_rec.resolution_summary) THEN
16732     l_service_request_rec.resolution_summary := l_old_ServiceRequest_rec.resolution_summary;
16733   END IF;
16734 
16735   -- Added for address fields related changes by shijain
16736   IF (l_service_request_rec.incident_point_of_interest = FND_API.G_MISS_CHAR)
16737   OR
16738      (nvl(l_service_request_rec.incident_point_of_interest,-99) = nvl(l_old_ServiceRequest_rec.incident_point_of_interest,-99))
16739   THEN
16740       l_service_request_rec.incident_point_of_interest := l_old_ServiceRequest_rec.incident_point_of_interest;
16741   END IF;
16742 
16743   IF (l_service_request_rec.incident_cross_street = FND_API.G_MISS_CHAR) OR
16744      (l_service_request_rec.incident_cross_street = l_old_ServiceRequest_rec.incident_cross_street)
16745   THEN
16746       l_service_request_rec.incident_cross_street  := l_old_ServiceRequest_rec.incident_cross_street;
16747   END IF;
16748 
16749   IF (l_service_request_rec.incident_direction_qualifier  = FND_API.G_MISS_CHAR)
16750   OR
16751      (l_service_request_rec.incident_direction_qualifier  = l_old_ServiceRequest_rec.incident_direction_qualifier)
16752   THEN
16753       l_service_request_rec.incident_direction_qualifier := l_old_ServiceRequest_rec.incident_direction_qualifier;
16754   END IF;
16755 
16756   IF (l_service_request_rec.incident_distance_qualifier   = FND_API.G_MISS_CHAR)
16757   OR
16758      (l_service_request_rec.incident_distance_qualifier   = l_old_ServiceRequest_rec.incident_distance_qualifier )
16759   THEN
16760       l_service_request_rec.incident_distance_qualifier  := l_old_ServiceRequest_rec.incident_distance_qualifier ;
16761   END IF;
16762 
16763   IF (l_service_request_rec.incident_distance_qual_uom  = FND_API.G_MISS_CHAR)
16764   OR
16765      (l_service_request_rec.incident_distance_qual_uom  = l_old_ServiceRequest_rec.incident_distance_qual_uom )
16766   THEN
16767       l_service_request_rec.incident_distance_qual_uom := l_old_ServiceRequest_rec.incident_distance_qual_uom ;
16768   END IF;
16769 
16770   IF (l_service_request_rec.incident_address2   = FND_API.G_MISS_CHAR) OR
16771      (l_service_request_rec.incident_address2   = l_old_ServiceRequest_rec.incident_address2  )
16772   THEN
16773       l_service_request_rec.incident_address2  := l_old_ServiceRequest_rec.incident_address2  ;
16774   END IF;
16775 
16776   IF (l_service_request_rec.incident_address3   = FND_API.G_MISS_CHAR) OR
16777      (l_service_request_rec.incident_address3   = l_old_ServiceRequest_rec.incident_address3  )
16778   THEN
16779       l_service_request_rec.incident_address3  := l_old_ServiceRequest_rec.incident_address3  ;
16780   END IF;
16781 
16782   IF (l_service_request_rec.incident_address4   = FND_API.G_MISS_CHAR) OR
16783      (l_service_request_rec.incident_address4   = l_old_ServiceRequest_rec.incident_address4  )
16784   THEN
16785       l_service_request_rec.incident_address4  := l_old_ServiceRequest_rec.incident_address4  ;
16786   END IF;
16787 
16788   IF (l_service_request_rec.incident_address_style   = FND_API.G_MISS_CHAR) OR
16789      (l_service_request_rec.incident_address_style   = l_old_ServiceRequest_rec.incident_address_style  )
16790   THEN
16791       l_service_request_rec.incident_address_style  := l_old_ServiceRequest_rec.incident_address_style  ;
16792   END IF;
16793 
16794   IF (l_service_request_rec.incident_addr_lines_phonetic  = FND_API.G_MISS_CHAR)
16795   OR
16796      (l_service_request_rec.incident_addr_lines_phonetic  = l_old_ServiceRequest_rec.incident_addr_lines_phonetic  )
16797   THEN
16798       l_service_request_rec.incident_addr_lines_phonetic := l_old_ServiceRequest_rec.incident_addr_lines_phonetic  ;
16799   END IF;
16800 
16801   IF (l_service_request_rec.incident_po_box_number  = FND_API.G_MISS_CHAR) OR
16802      (l_service_request_rec.incident_po_box_number  = l_old_ServiceRequest_rec.incident_po_box_number  )
16803   THEN
16804       l_service_request_rec.incident_po_box_number := l_old_ServiceRequest_rec.incident_po_box_number ;
16805   END IF;
16806 
16807  IF (l_service_request_rec.incident_house_number   = FND_API.G_MISS_CHAR) OR
16808      (l_service_request_rec.incident_house_number  = l_old_ServiceRequest_rec.incident_house_number ) THEN
16809       l_service_request_rec.incident_house_number := l_old_ServiceRequest_rec.incident_house_number ;
16810  END IF;
16811 
16812  IF (l_service_request_rec.incident_street_suffix  = FND_API.G_MISS_CHAR) OR
16813     (l_service_request_rec.incident_street_suffix  = l_old_ServiceRequest_rec.incident_street_suffix)
16814  THEN
16815      l_service_request_rec.incident_street_suffix := l_old_ServiceRequest_rec.incident_street_suffix ;
16816  END IF;
16817 
16818  IF (l_service_request_rec.incident_street  = FND_API.G_MISS_CHAR) OR
16819     (l_service_request_rec.incident_street  = l_old_ServiceRequest_rec.incident_street)
16820  THEN
16821      l_service_request_rec.incident_street := l_old_ServiceRequest_rec.incident_street;
16822  END IF;
16823 
16824  IF (l_service_request_rec.incident_street_number  = FND_API.G_MISS_CHAR) OR
16825     (l_service_request_rec.incident_street_number  = l_old_ServiceRequest_rec.incident_street_number)
16826  THEN
16827      l_service_request_rec.incident_street_number := l_old_ServiceRequest_rec.incident_street_number;
16828  END IF;
16829 
16830  IF (l_service_request_rec.incident_floor  = FND_API.G_MISS_CHAR) OR
16831     (l_service_request_rec.incident_floor  = l_old_ServiceRequest_rec.incident_floor)
16832  THEN
16833      l_service_request_rec.incident_floor := l_old_ServiceRequest_rec.incident_floor;
16834  END IF;
16835 
16836  IF (l_service_request_rec.incident_suite  = FND_API.G_MISS_CHAR) OR
16837     (l_service_request_rec.incident_suite  = l_old_ServiceRequest_rec.incident_suite) THEN
16838      l_service_request_rec.incident_suite := l_old_ServiceRequest_rec.incident_suite;
16839  END IF;
16840 
16841  IF (l_service_request_rec.incident_postal_plus4_code = FND_API.G_MISS_CHAR) OR
16842     (l_service_request_rec.incident_postal_plus4_code = l_old_ServiceRequest_rec.incident_postal_plus4_code)
16843  THEN
16844      l_service_request_rec.incident_postal_plus4_code:= l_old_ServiceRequest_rec.incident_postal_plus4_code;
16845  END IF;
16846 
16847  IF (l_service_request_rec.incident_position  = FND_API.G_MISS_CHAR) OR
16848     (l_service_request_rec.incident_position  = l_old_ServiceRequest_rec.incident_position)
16849  THEN
16850      l_service_request_rec.incident_position := l_old_ServiceRequest_rec.incident_position;
16851  END IF;
16852 
16853  IF (l_service_request_rec.incident_location_directions = FND_API.G_MISS_CHAR)
16854  OR
16855     (l_service_request_rec.incident_location_directions = l_old_ServiceRequest_rec.incident_location_directions)
16856  THEN
16857      l_service_request_rec.incident_location_directions:= l_old_ServiceRequest_rec.incident_location_directions;
16858  END IF;
16859 
16860  IF (l_service_request_rec.incident_location_description  = FND_API.G_MISS_CHAR)
16861  OR
16862     (l_service_request_rec.incident_location_description  = l_old_ServiceRequest_rec.incident_location_description)
16863  THEN
16864      l_service_request_rec.incident_location_description := l_old_ServiceRequest_rec.incident_location_description;
16865  END IF;
16866 
16867  IF (l_service_request_rec.install_site_id  = FND_API.G_MISS_NUM) OR
16868     (l_service_request_rec.install_site_id  = l_old_ServiceRequest_rec.INSTALL_SITE_ID)
16869  THEN
16870      l_service_request_rec.install_site_id := l_old_ServiceRequest_rec.INSTALL_SITE_ID;
16871  END IF;
16872 
16873   IF (l_service_request_rec.owner_assigned_flag   = FND_API.G_MISS_CHAR) OR
16874      (l_service_request_rec.owner_assigned_flag   = l_old_ServiceRequest_rec.owner_assigned_flag  )
16875   THEN
16876       l_service_request_rec.owner_assigned_flag  := l_old_ServiceRequest_rec.owner_assigned_flag  ;
16877   END IF;
16878   IF (l_service_request_rec.group_territory_id   = FND_API.G_MISS_NUM) OR
16879      (l_service_request_rec.group_territory_id   = l_old_ServiceRequest_rec.group_territory_id  )
16880   THEN
16881       l_service_request_rec.group_territory_id  := l_old_ServiceRequest_rec.group_territory_id  ;
16882   END IF;
16883 
16884  IF (l_service_request_rec.obligation_date = FND_API.G_MISS_DATE) OR
16885      (l_service_request_rec.obligation_date IS NULL AND
16886       l_old_ServiceRequest_rec.obligation_date IS NULL) OR
16887      (l_service_request_rec.obligation_date = l_old_ServiceRequest_rec.obligation_date) THEN
16888     l_service_request_rec.obligation_date := l_old_ServiceRequest_rec.obligation_date;
16889     -- For audit record added by shijain
16890     x_audit_vals_rec.change_obligation_flag := 'N';
16891     x_audit_vals_rec.old_obligation_date    := l_old_ServiceRequest_rec.obligation_date;
16892     x_audit_vals_rec.obligation_date        := l_service_request_rec.obligation_date;
16893   ELSE
16894     -- For audit record
16895     x_audit_vals_rec.change_obligation_FLAG := 'Y';
16896     x_audit_vals_rec.OLD_obligation_date    := l_old_ServiceRequest_rec.obligation_date;
16897     x_audit_vals_rec.obligation_date        := l_service_request_rec.obligation_date;
16898   END IF;
16899 
16900 
16901   IF (l_service_request_rec.inventory_item_id = FND_API.G_MISS_NUM) OR
16902      (nvl(l_service_request_rec.inventory_item_id,-99) = nvl(l_old_ServiceRequest_rec.inventory_item_id,-99))
16903   THEN
16904       l_service_request_rec.inventory_item_id := l_old_ServiceRequest_rec.inventory_item_id;
16905 
16906 	-- For bug 2907824  we need the inventory_item_id for validation of dependent fields
16907 	-- like inv_item_revision, so we set the old value from the DB to the Validation record.
16908       l_SR_Validation_rec.inventory_item_id := l_old_ServiceRequest_rec.inventory_item_id;
16909 
16910       -- For audit record added by shijain
16911       x_audit_vals_rec.change_inventory_item_flag  := 'N';
16912       x_audit_vals_rec.old_inventory_item_id       := l_old_ServiceRequest_rec.inventory_item_id ;
16913       x_audit_vals_rec.inventory_item_id           := l_service_request_rec.inventory_item_id ;
16914   ELSE
16915         -- For audit record
16916      x_audit_vals_rec.CHANGE_inventory_item_flag  := 'Y';
16917      x_audit_vals_rec.OLD_inventory_item_id       := l_old_ServiceRequest_rec.inventory_item_id ;
16918      x_audit_vals_rec.inventory_item_id           := l_service_request_rec.inventory_item_id ;
16919 
16920   END IF;
16921 
16922   -- For incident date audit record added by shijain
16923   IF (l_service_request_rec.request_date = FND_API.G_MISS_DATE) OR
16924      (l_service_request_rec.request_date IS NULL AND
16925       l_old_ServiceRequest_rec.incident_date IS NULL) OR
16926      (l_service_request_rec.request_date = l_old_ServiceRequest_rec.incident_date)
16927   THEN
16928       l_service_request_rec.request_date         := l_old_ServiceRequest_rec.incident_date;
16929       -- For audit record
16930       x_audit_vals_rec.change_incident_date_flag  := 'N';
16931       x_audit_vals_rec.old_incident_date          := l_old_ServiceRequest_rec.incident_date ;
16932       x_audit_vals_rec.incident_date              := l_service_request_rec.request_date ;
16933   ELSE
16934         -- For audit record
16935      x_audit_vals_rec.CHANGE_incident_date_flag  := 'Y';
16936      x_audit_vals_rec.OLD_incident_date          := l_old_ServiceRequest_rec.incident_date ;
16937      x_audit_vals_rec.incident_date              := l_service_request_rec.request_date ;
16938   END IF;
16939 
16940   -- 2993526
16941   -- For owner assigned time audit record added by shijain
16942 /*
16943   IF (l_service_request_rec.owner_assigned_time = FND_API.G_MISS_DATE) OR
16944      (l_service_request_rec.owner_assigned_time IS NULL AND
16945       l_old_ServiceRequest_rec.owner_assigned_time IS NULL) OR
16946      (l_service_request_rec.owner_assigned_time = l_old_ServiceRequest_rec.owner_assigned_time)
16947   THEN
16948       l_service_request_rec.owner_assigned_time   := l_old_ServiceRequest_rec.owner_assigned_time;
16949       -- For audit record
16950       x_audit_vals_rec.change_assigned_time_flag  := 'N';
16951       x_audit_vals_rec.old_owner_assigned_time    := l_old_ServiceRequest_rec.owner_assigned_time;
16952       x_audit_vals_rec.owner_assigned_time        := SYSDATE;
16953   ELSE
16954      -- For audit record
16955      x_audit_vals_rec.change_ASSIGNED_TIME_FLAG  := 'Y';
16956      x_audit_vals_rec.OLD_OWNER_ASSIGNED_TIME    := l_old_ServiceRequest_rec.owner_assigned_time;
16957      x_audit_vals_rec.OWNER_ASSIGNED_TIME        := SYSDATE;
16958 
16959   END IF; */
16960 
16961   IF (l_service_request_rec.current_serial_number = FND_API.G_MISS_CHAR) THEN
16962     l_service_request_rec.current_serial_number := l_old_ServiceRequest_rec.current_serial_number;
16963   END IF;
16964 
16965   IF (l_service_request_rec.original_order_number = FND_API.G_MISS_NUM) THEN
16966     l_service_request_rec.original_order_number := l_old_ServiceRequest_rec.original_order_number;
16967   END IF;
16968 
16969   IF (l_service_request_rec.purchase_order_num = FND_API.G_MISS_CHAR) THEN
16970     l_service_request_rec.purchase_order_num := l_old_ServiceRequest_rec.purchase_order_num;
16971   END IF;
16972 
16973   IF (l_service_request_rec.qa_collection_plan_id = FND_API.G_MISS_NUM) THEN
16974     l_service_request_rec.qa_collection_plan_id := l_old_ServiceRequest_rec.qa_collection_id;
16975   END IF;
16976 
16977   IF (l_service_request_rec.resource_subtype_id = FND_API.G_MISS_NUM) THEN
16978     l_service_request_rec.resource_subtype_id := l_old_ServiceRequest_rec.resource_subtype_id;
16979   END IF;
16980 
16981   IF (l_service_request_rec.employee_id IS NOT NULL) THEN
16982     l_service_request_rec.employee_id := NULL;
16983   END IF;
16984 
16985   IF (l_service_request_rec.cust_po_number = FND_API.G_MISS_CHAR) THEN
16986     l_service_request_rec.cust_po_number := l_old_ServiceRequest_rec.customer_po_number;
16987   END IF;
16988 
16989   IF (l_service_request_rec.cust_ticket_number = FND_API.G_MISS_CHAR) THEN
16990     l_service_request_rec.cust_ticket_number := l_old_ServiceRequest_rec.customer_ticket_number;
16991   END IF;
16992 
16993   IF (l_service_request_rec.sr_creation_channel = FND_API.G_MISS_CHAR) THEN
16994     l_service_request_rec.sr_creation_channel := l_old_ServiceRequest_rec.sr_creation_channel;
16995   END IF;
16996 
16997   IF (l_service_request_rec.time_zone_id = FND_API.G_MISS_NUM) THEN
16998     l_service_request_rec.time_zone_id := l_old_ServiceRequest_rec.time_zone_id;
16999   END IF;
17000 
17001   IF (l_service_request_rec.time_difference = FND_API.G_MISS_NUM) THEN
17002     l_service_request_rec.time_difference := l_old_ServiceRequest_rec.time_difference;
17003   END IF;
17004 
17005     IF (l_service_request_rec.contract_service_id = FND_API.G_MISS_NUM)  OR
17006        (l_service_request_rec.contract_service_id = l_old_ServiceRequest_rec.contract_service_id) THEN
17007        l_service_request_rec.contract_service_id := l_old_ServiceRequest_rec.contract_service_id;
17008        l_SR_Validation_rec.contract_service_id   := l_old_serviceRequest_rec.contract_service_id;
17009        --need to copy value to validation rec as contract id validation depends on it.
17010     ELSE
17011       l_SR_Validation_rec.contract_service_id := l_service_request_rec.contract_service_id;
17012     END IF;
17013 
17014     IF (l_service_request_rec.contract_id = FND_API.G_MISS_NUM)  OR
17015        (l_service_request_rec.contract_id = l_old_ServiceRequest_rec.contract_id) THEN
17016        l_service_request_rec.contract_id := l_old_ServiceRequest_rec.contract_id;
17017        -- need to set o/p vars since these are used in update not the l_service_request_rec
17018        x_contra_id       := l_old_ServiceRequest_rec.contract_id;
17019        x_contract_number := l_old_ServiceRequest_Rec.contract_number;
17020     ELSE
17021       l_SR_Validation_rec.contract_id := l_service_request_rec.contract_id;
17022     END IF;
17023 
17024     IF (l_service_request_rec.project_number = FND_API.G_MISS_CHAR)  OR
17025        (l_service_request_rec.project_number = l_old_ServiceRequest_rec.project_number) THEN
17026        l_service_request_rec.project_number := l_old_ServiceRequest_rec.project_number;
17027     ELSE
17028       l_SR_Validation_rec.project_number := l_service_request_rec.project_number;
17029     END IF;
17030 
17031 
17032     IF (l_service_request_rec.account_id = FND_API.G_MISS_NUM)  OR
17033        (l_service_request_rec.account_id = l_old_ServiceRequest_rec.account_id) THEN
17034        l_service_request_rec.account_id := l_old_ServiceRequest_rec.account_id;
17035           --Added this here, cause user may have passed a new customer product id
17036           --but nay have not passed a new account id. The validation rec has to be
17037           --assigned this so that it does not have the MISS NUM value.
17038           -- l_SR_Validation_rec.account_id := l_service_request_rec.account_id;
17039     ELSE
17040       l_SR_Validation_rec.account_id := l_service_request_rec.account_id;
17041     END IF;
17042 
17043     -- auditing is done after AM API Call
17044     IF (l_service_request_rec.resource_type = FND_API.G_MISS_CHAR)  OR
17045        (nvl(l_service_request_rec.resource_type,'-99') = nvl(l_old_ServiceRequest_rec.resource_type,'-99')) THEN
17046        l_service_request_rec.resource_type := l_old_ServiceRequest_rec.resource_type;
17047     ELSE
17048       l_SR_Validation_rec.resource_type := l_service_request_rec.resource_type;
17049     END IF;
17050 
17051     --For optional fields, the passed value may be FND, SAME AS OLD
17052     --or user may have passed a valid value or he may want to NULL that field.
17053 
17054     IF (l_service_request_rec.platform_id = FND_API.G_MISS_NUM) OR
17055        (nvl(l_service_request_rec.platform_id,-99) = nvl(l_old_ServiceRequest_rec.platform_id,-99)) THEN
17056 
17057        l_SR_Validation_rec.platform_id := l_old_ServiceRequest_rec.platform_id;
17058        l_service_request_rec.platform_id := l_old_ServiceRequest_rec.platform_id;
17059        -- Audit the change added by shijain
17060        x_audit_vals_rec.change_platform_id_flag := 'N';
17061        x_audit_vals_rec.old_platform_id         := l_old_ServiceRequest_rec.platform_id;
17062        x_audit_vals_rec.platform_id             := l_service_request_rec.platform_id;
17063     ELSE
17064       l_SR_Validation_rec.platform_id := l_service_request_rec.platform_id;
17065       -- Audit the change
17066       x_audit_vals_rec.change_platform_id_FLAG := 'Y';
17067       x_audit_vals_rec.OLD_platform_id := l_old_ServiceRequest_rec.platform_id;
17068       x_audit_vals_rec.platform_id := l_service_request_rec.platform_id;
17069 
17070     END IF;
17071 
17072    -- Added audit changes for platform version id added by shijain
17073    IF (l_service_request_rec.platform_version_id = FND_API.G_MISS_NUM) OR
17074       (nvl(l_service_request_rec.platform_version_id,-99) = nvl(l_old_ServiceRequest_rec.platform_version_id,-99)) THEN
17075        l_service_request_rec.platform_version_id:= l_old_ServiceRequest_rec.platform_version_id;
17076        -- Audit the change
17077        x_audit_vals_rec.change_plat_ver_id_flag := 'N';
17078        x_audit_vals_rec.old_platform_version_id := l_old_ServiceRequest_rec.platform_version_id;
17079        x_audit_vals_rec.platform_version_id     := l_service_request_rec.platform_version_id;
17080   ELSE
17081       l_SR_Validation_rec.platform_version_id := l_service_request_rec.platform_version_id;
17082       -- Audit the change
17083       x_audit_vals_rec.change_plat_ver_id_FLAG := 'Y';
17084       x_audit_vals_rec.OLD_platform_version_id := l_old_ServiceRequest_rec.platform_version_id;
17085       x_audit_vals_rec.platform_version_id     := l_service_request_rec.platform_version_id;
17086   END IF;
17087 
17088      IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) OR
17089       (nvl(l_service_request_rec.inv_platform_org_id,-99) = nvl(l_old_ServiceRequest_rec.inv_platform_org_id,-99)) THEN
17090        l_SR_Validation_rec.inv_platform_org_id:= l_old_ServiceRequest_rec.inv_platform_org_id;
17091        -- Audit the change
17092        x_audit_vals_rec.change_platform_org_id_flag := 'N';
17093        x_audit_vals_rec.old_inv_platform_org_id := l_old_ServiceRequest_rec.inv_platform_org_id;
17094        x_audit_vals_rec.inv_platform_org_id     := l_service_request_rec.inv_platform_org_id;
17095   ELSE
17096       l_SR_Validation_rec.inv_platform_org_id := l_service_request_rec.inv_platform_org_id;
17097       -- Audit the change
17098       x_audit_vals_rec.change_platform_org_id_flag := 'Y';
17099       x_audit_vals_rec.OLD_inv_platform_org_id := l_old_ServiceRequest_rec.inv_platform_org_id;
17100       x_audit_vals_rec.inv_platform_org_id     := l_service_request_rec.inv_platform_org_id;
17101   END IF;
17102 
17103   IF (l_service_request_rec.platform_version = FND_API.G_MISS_CHAR) OR
17104       (nvl(l_service_request_rec.platform_version,'-99') = nvl(l_old_ServiceRequest_rec.platform_version,'-99')) THEN
17105        l_service_request_rec.platform_version:= l_old_ServiceRequest_rec.platform_version;
17106        -- Audit the change
17107        x_audit_vals_rec.old_platform_version := l_old_ServiceRequest_rec.platform_version;
17108        x_audit_vals_rec.platform_version     := l_service_request_rec.platform_version;
17109   ELSE
17110       l_SR_Validation_rec.platform_version := l_service_request_rec.platform_version;
17111       -- Audit the change
17112       x_audit_vals_rec.OLD_platform_version := l_old_ServiceRequest_rec.platform_version;
17113       x_audit_vals_rec.platform_version     := l_service_request_rec.platform_version;
17114   END IF;
17115 
17116   -- Added audit changes for language id added by shijain
17117   IF (l_service_request_rec.language_id = FND_API.G_MISS_NUM) OR
17118      (nvl(l_service_request_rec.language_id,-99) = nvl(l_old_ServiceRequest_rec.language_id,-99))
17119   THEN
17120        l_service_request_rec.language_id:= l_old_ServiceRequest_rec.language_id;
17121        -- Audit the change
17122        x_audit_vals_rec.change_language_id_flag := 'N';
17123        x_audit_vals_rec.old_language_id := l_old_ServiceRequest_rec.language_id;
17124        x_audit_vals_rec.language_id     := l_service_request_rec.language_id;
17125   ELSE
17126       l_SR_Validation_rec.language_id := l_service_request_rec.language_id;
17127       -- Audit the change
17128       x_audit_vals_rec.change_language_id_flag := 'Y';
17129       x_audit_vals_rec.old_language_id := l_old_ServiceRequest_rec.language_id;
17130       x_audit_vals_rec.language_id     := l_service_request_rec.language_id;
17131   END IF;
17132 
17133   IF (l_service_request_rec.platform_version = FND_API.G_MISS_CHAR) THEN
17134     l_service_request_rec.platform_version := l_old_ServiceRequest_rec.platform_version;
17135   END IF;
17136 
17137   IF (l_service_request_rec.platform_version_id = FND_API.G_MISS_NUM) THEN
17138     l_service_request_rec.platform_version_id := l_old_ServiceRequest_rec.platform_version_id;
17139   END IF;
17140 
17141   IF (l_service_request_rec.inv_platform_org_id = FND_API.G_MISS_NUM) THEN
17142     l_service_request_rec.inv_platform_org_id := l_old_ServiceRequest_rec.inv_platform_org_id;
17143   END IF;
17144 
17145   IF (l_service_request_rec.db_version = FND_API.G_MISS_CHAR) THEN
17146     l_service_request_rec.db_version := l_old_ServiceRequest_rec.db_version;
17147   END IF;
17148 
17149   IF (l_service_request_rec.last_update_channel = FND_API.G_MISS_CHAR) THEN
17150     l_service_request_rec.last_update_channel := l_old_ServiceRequest_rec.last_update_channel;
17151   END IF;
17152 
17153     -- Check if Territory id has been passed to the API
17154     IF (l_service_request_rec.territory_id = FND_API.G_MISS_NUM) OR
17155        (nvl(l_service_request_rec.territory_id,-99) = nvl(l_old_ServiceRequest_rec.territory_id,-99)) THEN
17156       l_service_request_rec.territory_id := l_old_ServiceRequest_rec.territory_id;
17157       -- Audit the change added by shijain
17158       x_audit_vals_rec.change_territory_id_flag := 'N';
17159       x_audit_vals_rec.old_territory_id         := l_old_ServiceRequest_rec.territory_id;
17160       x_audit_vals_rec.territory_id             := l_service_request_rec.territory_id;
17161     ELSE
17162       l_SR_Validation_rec.territory_id := l_service_request_rec.territory_id;
17163       -- Audit the change
17164       x_audit_vals_rec.change_territory_id_FLAG := 'Y';
17165       x_audit_vals_rec.OLD_territory_id := l_old_ServiceRequest_rec.territory_id;
17166       x_audit_vals_rec.territory_id := l_service_request_rec.territory_id;
17167     END IF;
17168 
17169     IF (l_service_request_rec.cp_component_id = FND_API.G_MISS_NUM) OR
17170        (nvl(l_service_request_rec.cp_component_id,-99) = nvl(l_old_ServiceRequest_rec.cp_component_id,-99)) THEN
17171       l_service_request_rec.cp_component_id := l_old_ServiceRequest_rec.cp_component_id;
17172       -- Audit the change added by shijain
17173       x_audit_vals_rec.change_cp_component_id_flag := 'N';
17174       x_audit_vals_rec.old_cp_component_id         := l_old_ServiceRequest_rec.cp_component_id;
17175       x_audit_vals_rec.cp_component_id             := l_service_request_rec.cp_component_id;
17176       IF (l_service_request_rec.component_version = FND_API.G_MISS_CHAR) THEN
17177           l_service_request_rec.component_version := l_old_servicerequest_rec.component_version;
17178       END IF;
17179     ELSE
17180       l_SR_Validation_rec.cp_component_id := l_service_request_rec.cp_component_id;
17181       -- Audit the change
17182       x_audit_vals_rec.change_cp_compONENT_id_FLAG := 'Y';
17183       x_audit_vals_rec.OLD_cp_component_id := l_old_ServiceRequest_rec.cp_component_id;
17184       x_audit_vals_rec.cp_component_id := l_service_request_rec.cp_component_id;
17185     END IF;
17186     IF (l_service_request_rec.cp_component_id is NULL AND
17187         l_service_request_rec.component_version is NOT NULL AND
17188         l_service_request_rec.component_version <> FND_API.G_MISS_CHAR) THEN
17189         l_service_request_rec.component_version := null;
17190 	CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17191 		p_token_an	=>  l_api_name_full,
17192 		p_token_ip	=>  'p_component_version' );
17193     END IF;
17194 
17195     -- Check if Component Version id has been passed to the API
17196     IF (l_service_request_rec.cp_component_version_id = FND_API.G_MISS_NUM) OR
17197        (nvl(l_service_request_rec.cp_component_version_id,-99) = nvl(l_old_ServiceRequest_rec.cp_component_version_id,-99)) THEN
17198       l_service_request_rec.cp_component_version_id := l_old_ServiceRequest_rec.cp_component_version_id;
17199       -- Audit the change added by shijain
17200       x_audit_vals_rec.change_cp_comp_ver_id_flag  := 'N';
17201       x_audit_vals_rec.old_cp_component_version_id := l_old_ServiceRequest_rec.cp_component_version_id;
17202       x_audit_vals_rec.cp_component_version_id     := l_service_request_rec.cp_component_version_id;
17203     ELSE
17204       l_SR_Validation_rec.cp_component_version_id := l_service_request_rec.cp_component_version_id;
17205       -- Audit the change
17206       x_audit_vals_rec.CHANGE_CP_COMP_VER_ID_FLAG := 'Y';
17207       x_audit_vals_rec.OLD_cp_component_version_id := l_old_ServiceRequest_rec.cp_component_version_id;
17208       x_audit_vals_rec.cp_component_version_id := l_service_request_rec.cp_component_version_id;
17209     END IF;
17210 
17211     -- Check if SubComponent id has been passed to the API
17212     IF (l_service_request_rec.cp_subcomponent_id = FND_API.G_MISS_NUM) OR
17213        (nvl(l_service_request_rec.cp_subcomponent_id,-99) = nvl(l_old_ServiceRequest_rec.cp_subcomponent_id,-99)) THEN
17214       l_service_request_rec.cp_subcomponent_id := l_old_ServiceRequest_rec.cp_subcomponent_id;
17215       -- Audit the change added by shijain
17216       x_audit_vals_rec.change_cp_subcomponent_id_flag := 'N';
17217       x_audit_vals_rec.old_cp_subcomponent_id         := l_old_ServiceRequest_rec.cp_subcomponent_id;
17218       x_audit_vals_rec.cp_subcomponent_id             := l_service_request_rec.cp_subcomponent_id;
17219       IF (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR) THEN
17220           l_service_request_rec.subcomponent_version := l_old_servicerequest_rec.subcomponent_version;
17221       END IF;
17222     ELSE
17223       l_SR_Validation_rec.cp_subcomponent_id := l_service_request_rec.cp_subcomponent_id;
17224       -- Audit the change
17225       x_audit_vals_rec.change_cp_subcompONENT_id_FLAG := 'Y';
17226       x_audit_vals_rec.OLD_cp_subcomponent_id := l_old_ServiceRequest_rec.cp_subcomponent_id;
17227       x_audit_vals_rec.cp_subcomponent_id := l_service_request_rec.cp_subcomponent_id;
17228     END IF;
17229     IF (l_service_request_rec.cp_subcomponent_id is NULL AND
17230         l_service_request_rec.subcomponent_version is NOT NULL AND
17231         l_service_request_rec.subcomponent_version <> FND_API.G_MISS_CHAR ) THEN
17232         l_service_request_rec.subcomponent_version := null;
17233 	CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17234 		p_token_an	=>  l_api_name_full,
17235 		p_token_ip	=>  'p_subcomponent_version' );
17236     END IF;
17237 
17238     -- Check if Component Version id has been passed to the API
17239     IF (l_service_request_rec.cp_subcomponent_version_id = FND_API.G_MISS_NUM) OR
17240        (nvl(l_service_request_rec.cp_subcomponent_version_id,-99) = nvl(l_old_ServiceRequest_rec.cp_subcomponent_version_id,-99)) THEN
17241       l_service_request_rec.cp_subcomponent_version_id := l_old_ServiceRequest_rec.cp_subcomponent_version_id;
17242       -- Audit the change added by shijain
17243       x_audit_vals_rec.change_cp_subcomp_ver_id_flag  := 'N';
17244       x_audit_vals_rec.old_cp_subcomponent_version_id := l_old_ServiceRequest_rec.cp_subcomponent_version_id;
17245       x_audit_vals_rec.cp_subcomponent_version_id     := l_service_request_rec.cp_subcomponent_version_id;
17246     ELSE
17247       l_SR_Validation_rec.cp_subcomponent_version_id := l_service_request_rec.cp_subcomponent_version_id;
17248       -- Audit the change
17249       x_audit_vals_rec.CHANGE_CP_SUBCOMP_VER_ID_FLAG := 'Y';
17250       x_audit_vals_rec.OLD_cp_subcomponent_version_id := l_old_ServiceRequest_rec.cp_subcomponent_version_id;
17251       x_audit_vals_rec.cp_subcomponent_version_id := l_service_request_rec.cp_subcomponent_version_id;
17252     END IF;
17253 
17254     -- Check if CP Revision ID has been passed to the API
17255     IF (l_service_request_rec.cp_revision_id = FND_API.G_MISS_NUM) OR
17256        (nvl(l_service_request_rec.cp_revision_id,-99) = nvl(l_old_ServiceRequest_rec.cp_revision_id,-99)) THEN
17257       l_service_request_rec.cp_revision_id := l_old_ServiceRequest_rec.cp_revision_id;
17258       -- Audit the change added by shijain
17259       x_audit_vals_rec.change_cp_revision_id_flag := 'N';
17260       x_audit_vals_rec.old_cp_revision_id         := l_old_ServiceRequest_rec.cp_revision_id;
17261       x_audit_vals_rec.cp_revision_id             := l_service_request_rec.cp_revision_id;
17262     ELSE
17263       l_SR_Validation_rec.cp_revision_id := l_service_request_rec.cp_revision_id;
17264       -- Audit the change
17265       x_audit_vals_rec.change_cp_revISION_id_FLAG := 'Y';
17266       x_audit_vals_rec.OLD_cp_revision_id := l_old_ServiceRequest_rec.cp_revision_id;
17267       x_audit_vals_rec.cp_revision_id := l_service_request_rec.cp_revision_id;
17268     END IF;
17269 
17270     /*** smisra 8/16/04 3815808 this will be done inside servicerequest_cross_val procedure
17271     -- Check if Product Revision has been passed to the API
17272     IF (l_service_request_rec.product_revision = FND_API.G_MISS_CHAR) OR
17273        (nvl(l_service_request_rec.product_revision,-99) = nvl(l_old_ServiceRequest_rec.product_revision,-99)) THEN
17274       l_service_request_rec.product_revision := l_old_ServiceRequest_rec.product_revision;
17275       -- Audit the change added by shijain
17276       x_audit_vals_rec.change_product_revision_flag := 'N';
17277       x_audit_vals_rec.old_product_revision         := l_old_ServiceRequest_rec.product_revision;
17278       x_audit_vals_rec.product_revision             := l_service_request_rec.product_revision;
17279     ELSE
17280       l_SR_Validation_rec.product_revision := l_service_request_rec.product_revision;
17281       -- Audit the change
17282       x_audit_vals_rec.change_proDUCT_revISION_FLAG := 'Y';
17283       x_audit_vals_rec.OLD_product_revision := l_old_ServiceRequest_rec.product_revision;
17284       x_audit_vals_rec.product_revision := l_service_request_rec.product_revision;
17285     END IF;
17286     *****/
17287     /*** smisra 5/4/04 3566783 this will be done inside servicerequest_cross_val procedure
17288     -- Check if Component Version has been passed to the API
17289     IF (l_service_request_rec.component_version = FND_API.G_MISS_CHAR) OR
17290        (nvl(l_service_request_rec.component_version,-99) = nvl(l_old_ServiceRequest_rec.component_version,-99)) THEN
17291       l_service_request_rec.component_version := l_old_ServiceRequest_rec.component_version;
17292       -- Audit the change added by shijain
17293       x_audit_vals_rec.change_comp_ver_flag  := 'N';
17294       x_audit_vals_rec.old_component_version := l_old_ServiceRequest_rec.component_version;
17295       x_auDit_vals_rec.component_version     := l_service_request_rec.component_version;
17296     ELSE
17297       l_SR_Validation_rec.component_version := l_service_request_rec.component_version;
17298       -- Audit the change
17299       x_audit_vals_rec.CHANGE_COMP_VER_FLAG := 'Y';
17300       x_audit_vals_rec.OLD_component_version := l_old_ServiceRequest_rec.component_version;
17301       x_audit_vals_rec.component_version := l_service_request_rec.component_version;
17302     END IF;
17303 
17304     -- Check if Subcomponent Version has been passed to the API
17305     IF (l_service_request_rec.subcomponent_version = FND_API.G_MISS_CHAR) OR
17306        (nvl(l_service_request_rec.subcomponent_version,-99) = nvl(l_old_ServiceRequest_rec.subcomponent_version,-99)) THEN
17307       l_service_request_rec.subcomponent_version := l_old_ServiceRequest_rec.subcomponent_version;
17308       -- Audit the change added by shijain
17309       x_audit_vals_rec.change_subcomp_ver_flag  := 'N';
17310       x_audit_vals_rec.old_subcomponent_version := l_old_ServiceRequest_rec.subcomponent_version;
17311       x_audit_vals_rec.subcomponent_version     := l_service_request_rec.subcomponent_version;
17312     ELSE
17313       l_SR_Validation_rec.subcomponent_version := l_service_request_rec.subcomponent_version;
17314       -- Audit the change
17315       x_audit_vals_rec.CHANGE_SUBCOMP_VER_FLAG := 'Y';
17316       x_audit_vals_rec.OLD_subcomponent_version := l_old_ServiceRequest_rec.subcomponent_version;
17317       x_audit_vals_rec.subcomponent_version := l_service_request_rec.subcomponent_version;
17318     END IF;
17319     *****************************************************/
17320 
17321     -- Check if Inv Item Revision has been passed to the API
17322     IF (l_service_request_rec.inv_item_revision = FND_API.G_MISS_CHAR) OR
17323        (nvl(l_service_request_rec.inv_item_revision,-99) = nvl(l_old_ServiceRequest_rec.inv_item_revision,-99)) THEN
17324       l_service_request_rec.inv_item_revision := l_old_ServiceRequest_rec.inv_item_revision;
17325       -- Audit the change added by shijain
17326       x_audit_vals_rec.change_inv_item_revision := 'N';
17327       x_audit_vals_rec.old_inv_item_revision    := l_old_ServiceRequest_rec.inv_item_revision;
17328       x_audit_vals_rec.inv_item_revision        := l_service_request_rec.inv_item_revision;
17329     ELSE
17330       l_SR_Validation_rec.inv_item_revision := l_service_request_rec.inv_item_revision;
17331       -- Audit the change
17332       x_audit_vals_rec.CHANGE_INV_ITEM_REVISION := 'Y';
17333       x_audit_vals_rec.OLD_inv_item_revision := l_old_ServiceRequest_rec.inv_item_revision;
17334       x_audit_vals_rec.inv_item_revision := l_service_request_rec.inv_item_revision;
17335      END IF;
17336 
17337     -- inventory component and subcomponent for Bug# 2254523
17338     -- Check if INV COMPONENT ID has been passed to the API
17339     IF (l_service_request_rec.inv_component_id = FND_API.G_MISS_NUM) OR
17340        (l_service_request_rec.inv_component_id IS NULL AND
17341         l_old_ServiceRequest_rec.inv_component_id IS NULL) OR
17342        (l_service_request_rec.inv_component_id = l_old_ServiceRequest_rec.inv_component_id) THEN
17343       l_service_request_rec.inv_component_id := l_old_ServiceRequest_rec.inv_component_id;
17344       -- Audit the change added by shijain
17345       x_audit_vals_rec.change_inv_component_id := 'N';
17346       x_audit_vals_rec.old_inv_component_id    := l_old_ServiceRequest_rec.inv_component_id;
17347       x_audit_vals_rec.inv_component_id        := l_service_request_rec.inv_component_id;
17348     ELSE
17349       l_SR_Validation_rec.inv_component_id := l_service_request_rec.inv_component_id;
17350       -- Audit the change
17351       x_audit_vals_rec.CHANGE_INV_COMPONENT_ID := 'Y';
17352       x_audit_vals_rec.OLD_inv_component_id := l_old_ServiceRequest_rec.inv_component_id;
17353       x_audit_vals_rec.inv_component_id := l_service_request_rec.inv_component_id;
17354     END IF;
17355 
17356     -- Check if INV COMPONENT VERSION has been passed to the API
17357     IF (l_service_request_rec.inv_component_version = FND_API.G_MISS_CHAR) OR
17358        (l_service_request_rec.inv_component_version IS NULL AND
17359         l_old_ServiceRequest_rec.inv_component_version IS NULL) OR
17360        (l_service_request_rec.inv_component_version = l_old_ServiceRequest_rec.inv_component_version) THEN
17361       l_service_request_rec.inv_component_version := l_old_ServiceRequest_rec.inv_component_version;
17362       -- Audit the change added by shijain
17363       x_audit_vals_rec.change_inv_component_version := 'N';
17364       x_audit_vals_rec.old_inv_component_version    := l_old_ServiceRequest_rec.inv_component_version;
17365       x_audit_vals_rec.inv_component_version        := l_service_request_rec.inv_component_version;
17366     ELSE
17367       l_SR_Validation_rec.inv_component_version := l_service_request_rec.inv_component_version;
17368       -- Audit the change
17369       x_audit_vals_rec.CHANGE_INV_COMPONENT_VERSION := 'Y';
17370       x_audit_vals_rec.OLD_inv_component_version:= l_old_ServiceRequest_rec.inv_component_version;
17371       x_audit_vals_rec.inv_component_version := l_service_request_rec.inv_component_version;
17372     END IF;
17373 
17374     -- Check if INV SUB COMPONENT ID has been passed to the API
17375     IF (l_service_request_rec.inv_subcomponent_id = FND_API.G_MISS_NUM) OR
17376        (l_service_request_rec.inv_subcomponent_id IS NULL AND
17377         l_old_ServiceRequest_rec.inv_subcomponent_id IS NULL) OR
17378        (l_service_request_rec.inv_subcomponent_id = l_old_ServiceRequest_rec.inv_subcomponent_id) THEN
17379       l_service_request_rec.inv_subcomponent_id := l_old_ServiceRequest_rec.inv_subcomponent_id;
17380       -- Audit the change added by shijain
17381       x_audit_vals_rec.change_inv_subcomponent_id := 'N';
17382       x_audit_vals_rec.old_inv_subcomponent_id    := l_old_ServiceRequest_rec.inv_subcomponent_id;
17383       x_audit_vals_rec.inv_subcomponent_id        := l_service_request_rec.inv_subcomponent_id;
17384     ELSE
17385       l_SR_Validation_rec.inv_subcomponent_id := l_service_request_rec.inv_subcomponent_id;
17386       -- Audit the change
17387       x_audit_vals_rec.CHANGE_INV_SUBCOMPONENT_ID := 'Y';
17388       x_audit_vals_rec.OLD_inv_subcomponent_id := l_old_ServiceRequest_rec.inv_subcomponent_id;
17389       x_audit_vals_rec.inv_subcomponent_id := l_service_request_rec.inv_subcomponent_id;
17390     END IF;
17391 
17392     -- Check if INV SUBCOMPONENT VERSION has been passed to the API
17393     IF (l_service_request_rec.inv_subcomponent_version = FND_API.G_MISS_CHAR) OR
17394        (l_service_request_rec.inv_subcomponent_version IS NULL AND
17395         l_old_ServiceRequest_rec.inv_subcomponent_version IS NULL) OR
17396        (l_service_request_rec.inv_subcomponent_version = l_old_ServiceRequest_rec.inv_subcomponent_version) THEN
17397       l_service_request_rec.inv_subcomponent_version := l_old_ServiceRequest_rec.inv_subcomponent_version;
17398       -- Audit the change added by shijain
17399       x_audit_vals_rec.change_inv_subcomp_version := 'N';
17400       x_audit_vals_rec.old_inv_subcomponent_version:= l_old_ServiceRequest_rec.inv_subcomponent_version;
17401       x_audit_vals_rec.inv_subcomponent_version := l_service_request_rec.inv_subcomponent_version;
17402     ELSE
17403       l_SR_Validation_rec.inv_subcomponent_version := l_service_request_rec.inv_subcomponent_version;
17404       -- Audit the change
17405       x_audit_vals_rec.change_inv_subcomp_verSION := 'Y';
17406       x_audit_vals_rec.OLD_inv_subcomponent_version:= l_old_ServiceRequest_rec.inv_subcomponent_version;
17407       x_audit_vals_rec.inv_subcomponent_version := l_service_request_rec.inv_subcomponent_version;
17408     END IF;
17409 
17410   IF (l_service_request_rec.inventory_org_id = FND_API.G_MISS_NUM) OR
17411      (nvl(l_service_request_rec.inventory_org_id,-99) = nvl(l_old_ServiceRequest_rec.inv_organization_id,-99))
17412   THEN
17413        l_service_request_rec.inventory_org_id  := l_old_ServiceRequest_rec.inv_organization_id ;
17414        -- For audit record added by shijain
17415        x_audit_vals_rec.change_inv_organization_flag  := 'N';
17416        x_audit_vals_rec.old_inv_organization_id       := l_old_ServiceRequest_rec.inv_organization_id ;
17417        x_audit_vals_rec.inv_organization_id           := l_service_request_rec.inventory_org_id ;
17418   ELSE
17419        -- For audit record
17420        x_audit_vals_rec.CHANGE_inv_organization_flag  := 'Y';
17421        x_audit_vals_rec.OLD_inv_organization_id     := l_old_ServiceRequest_rec.inv_organization_id ;
17422        x_audit_vals_rec.inv_organization_id         := l_service_request_rec.inventory_org_id ;
17423   END IF;
17424 
17425   -- ----------------------------------------------------
17426   -- Added for enhancements for 11.5.6
17427   -- category_id, comm_pref_code and cust_pref_lang_id needs to be
17428   -- validated. tier,tier_version,operating_system,
17429   -- operating_system_version, database, inv_platform_org_id are not
17430   -- validated now.
17431   -- ----------------------------------------------------
17432 
17433   IF (l_service_request_rec.cust_pref_lang_id = FND_API.G_MISS_NUM) THEN
17434     l_service_request_rec.cust_pref_lang_id := l_old_ServiceRequest_rec.cust_pref_lang_id;
17435   ELSE
17436       l_SR_Validation_rec.cust_pref_lang_id := l_service_request_rec.cust_pref_lang_id;
17437   END IF;
17438 
17439   IF (l_service_request_rec.comm_pref_code = FND_API.G_MISS_CHAR) THEN
17440     l_service_request_rec.comm_pref_code := l_old_ServiceRequest_rec.comm_pref_code;
17441   ELSE
17442       l_SR_Validation_rec.comm_pref_code := l_service_request_rec.comm_pref_code;
17443   END IF;
17444 
17445   IF (l_service_request_rec.cust_pref_lang_code = FND_API.G_MISS_CHAR) THEN
17446     l_service_request_rec.cust_pref_lang_code := l_old_ServiceRequest_rec.cust_pref_lang_code;
17447   END IF;
17448 
17449   IF (l_service_request_rec.tier = FND_API.G_MISS_CHAR) THEN
17450     l_service_request_rec.tier := l_old_ServiceRequest_rec.tier;
17451   END IF;
17452 
17453   IF (l_service_request_rec.tier_version = FND_API.G_MISS_CHAR) THEN
17454     l_service_request_rec.tier_version := l_old_ServiceRequest_rec.tier_version;
17455   END IF;
17456 
17457   IF (l_service_request_rec.operating_system = FND_API.G_MISS_CHAR) THEN
17458     l_service_request_rec.operating_system := l_old_ServiceRequest_rec.operating_system;
17459   END IF;
17460 
17461   IF (l_service_request_rec.operating_system_version = FND_API.G_MISS_CHAR) THEN
17462     l_service_request_rec.operating_system_version := l_old_ServiceRequest_rec.operating_system_version;
17463   END IF;
17464 
17465   IF (l_service_request_rec.DATABASE = FND_API.G_MISS_CHAR) THEN
17466     l_service_request_rec.DATABASE := l_old_ServiceRequest_rec.DATABASE;
17467   END IF;
17468 
17469   IF (l_service_request_rec.category_id = FND_API.G_MISS_NUM) THEN
17470     l_service_request_rec.category_id := l_old_ServiceRequest_rec.category_id;
17471   ELSE
17472     l_SR_Validation_rec.category_id   := l_service_request_rec.category_id;
17473     IF (l_service_request_rec.category_id        IS NOT NULL AND
17474         l_service_request_rec.category_set_id    = FND_API.G_MISS_NUM AND
17475         l_old_servicerequest_rec.category_set_id IS NULL) THEN
17476        l_service_request_rec.category_set_id := FND_PROFILE.value('CS_SR_DEFAULT_CATEGORY_SET');
17477     END IF;
17478   END IF;
17479 
17480   IF (l_service_request_rec.category_set_id = FND_API.G_MISS_NUM) THEN
17481     l_service_request_rec.category_set_id := l_old_ServiceRequest_rec.category_set_id;
17482   ELSE
17483     l_SR_Validation_rec.category_set_id := l_service_request_rec.category_set_id;
17484   END IF;
17485 
17486   IF (l_service_request_rec.external_reference = FND_API.G_MISS_CHAR) THEN
17487     l_service_request_rec.external_reference := l_old_ServiceRequest_rec.external_reference;
17488   ELSE
17489     l_SR_Validation_rec.external_reference := l_service_request_rec.external_reference;
17490     l_SR_Validation_rec.customer_product_id := l_service_request_rec.customer_product_id;
17491   END IF;
17492 
17493   IF (l_service_request_rec.system_id = FND_API.G_MISS_NUM) THEN
17494     l_service_request_rec.system_id := l_old_ServiceRequest_rec.system_id;
17495   ELSE
17496     l_SR_Validation_rec.system_id := l_service_request_rec.system_id;
17497   END IF;
17498 
17499   -- ----------------------------------------------------
17500   -- Some other fields that might need validations:
17501   --   problem_code, expected_resolution_date,
17502   --   resolution_code, and actual resolution_date
17503   -- ----------------------------------------------------
17504   IF (l_service_request_rec.problem_code = FND_API.G_MISS_CHAR) THEN
17505     l_service_request_rec.problem_code := l_old_ServiceRequest_rec.problem_code;
17506   ELSE
17507     l_service_request_rec.problem_code := UPPER(l_service_request_rec.problem_code);
17508     IF (l_service_request_rec.problem_code IS NOT NULL) THEN
17509       l_SR_Validation_rec.problem_code := l_service_request_rec.problem_code;
17510     END IF;
17511   END IF;
17512 
17513 
17514   IF (l_service_request_rec.resolution_code = FND_API.G_MISS_CHAR) THEN
17515     l_service_request_rec.resolution_code := l_old_ServiceRequest_rec.resolution_code;
17516   ELSE
17517     l_service_request_rec.resolution_code := UPPER(l_service_request_rec.resolution_code);
17518     IF (l_service_request_rec.resolution_code IS NOT NULL) THEN
17519       l_SR_Validation_rec.resolution_code := l_service_request_rec.resolution_code;
17520     END IF;
17521   END IF;
17522 
17523 -------Fix for Bug#1697139 --jngeorge--05/21/01
17524 ------Added two more conditions for Bug# 1874528 ----jngeorge---07/18/01
17525   IF (l_service_request_rec.exp_resolution_date = FND_API.G_MISS_DATE)OR
17526      (l_service_request_rec.exp_resolution_date IS NULL AND
17527       l_old_ServiceRequest_rec.expected_resolution_date IS NULL) OR
17528      (l_service_request_rec.exp_resolution_date = l_old_ServiceRequest_rec.expected_resolution_date) THEN
17529     l_service_request_rec.exp_resolution_date := l_old_ServiceRequest_rec.expected_resolution_date;
17530     --
17531     -- For audit record added by shijain
17532     --
17533     x_audit_vals_rec.change_resolution_flag       := 'N';
17534     x_audit_vals_rec.old_expected_resolution_date := l_old_ServiceRequest_rec.expected_resolution_date;
17535     x_audit_vals_rec.expected_resolution_date     := l_service_request_rec.exp_resolution_date;
17536 
17537   ELSE
17538     IF (l_service_request_rec.exp_resolution_date IS NOT NULL) OR
17539        (l_service_request_rec.exp_resolution_date <> FND_API.G_MISS_DATE ) THEN
17540       l_SR_Validation_rec.exp_resolution_date := l_service_request_rec.exp_resolution_date;
17541     END IF;
17542     --
17543     -- For audit record
17544     --
17545     x_audit_vals_rec.change_RESOLUTION_FLAG := 'Y';
17546     x_audit_vals_rec.OLD_EXPECTED_RESOLUTION_DATE := l_old_ServiceRequest_rec.expected_resolution_date;
17547     x_audit_vals_rec.EXPECTED_RESOLUTION_DATE := l_service_request_rec.exp_resolution_date;
17548   END IF;
17549 
17550   IF (l_service_request_rec.act_resolution_date = FND_API.G_MISS_DATE) THEN
17551     l_service_request_rec.act_resolution_date := l_old_ServiceRequest_rec.actual_resolution_date;
17552   ELSE
17553     IF (l_service_request_rec.act_resolution_date IS NOT NULL) THEN
17554       l_SR_Validation_rec.act_resolution_date := l_service_request_rec.act_resolution_date;
17555     END IF;
17556   END IF;
17557 
17558   -- -----------------------------------------------------------
17559   -- Check to see if the descriptive flexfield is being updated
17560   -- -----------------------------------------------------------
17561   -- 11/25/03 smisra
17562   -- All attributes that are g_miss_char must be set to value in database
17563   -- whether flex fields are changed or not.
17564   -- So this code is moved immiediately after cursor to fetch values from database
17565   -- and if attribute value is g_miss_char, it is being set to value from database.
17566   --IF (FND_API.To_Boolean(l_update_desc_flex)) THEN
17567     --NULL;
17568   --ELSE
17569     --l_service_request_rec.request_attribute_1   := l_old_ServiceRequest_rec.incident_attribute_1;
17570     --l_service_request_rec.request_attribute_2   := l_old_ServiceRequest_rec.incident_attribute_2;
17571     --l_service_request_rec.request_attribute_3   := l_old_ServiceRequest_rec.incident_attribute_3;
17572     --l_service_request_rec.request_attribute_4   := l_old_ServiceRequest_rec.incident_attribute_4;
17573     --l_service_request_rec.request_attribute_5   := l_old_ServiceRequest_rec.incident_attribute_5;
17574     --l_service_request_rec.request_attribute_6   := l_old_ServiceRequest_rec.incident_attribute_6;
17575     --l_service_request_rec.request_attribute_7   := l_old_ServiceRequest_rec.incident_attribute_7;
17576     --l_service_request_rec.request_attribute_8   := l_old_ServiceRequest_rec.incident_attribute_8;
17577     --l_service_request_rec.request_attribute_9   := l_old_ServiceRequest_rec.incident_attribute_9;
17578     --l_service_request_rec.request_attribute_10  := l_old_ServiceRequest_rec.incident_attribute_10;
17579     --l_service_request_rec.request_attribute_11  := l_old_ServiceRequest_rec.incident_attribute_11;
17580     --l_service_request_rec.request_attribute_12  := l_old_ServiceRequest_rec.incident_attribute_12;
17581     --l_service_request_rec.request_attribute_13  := l_old_ServiceRequest_rec.incident_attribute_13;
17582     --l_service_request_rec.request_attribute_14  := l_old_ServiceRequest_rec.incident_attribute_14;
17583     --l_service_request_rec.request_attribute_15  := l_old_ServiceRequest_rec.incident_attribute_15;
17584     --l_service_request_rec.request_context       := l_old_ServiceRequest_rec.incident_context;
17585     --l_service_request_rec.external_attribute_1   := l_old_ServiceRequest_rec.external_attribute_1;
17586     --l_service_request_rec.external_attribute_2   := l_old_ServiceRequest_rec.external_attribute_2;
17587     --l_service_request_rec.external_attribute_3   := l_old_ServiceRequest_rec.external_attribute_3;
17588     --l_service_request_rec.external_attribute_4   := l_old_ServiceRequest_rec.external_attribute_4;
17589     --l_service_request_rec.external_attribute_5   := l_old_ServiceRequest_rec.external_attribute_5;
17590     --l_service_request_rec.external_attribute_6   := l_old_ServiceRequest_rec.external_attribute_6;
17591     --l_service_request_rec.external_attribute_7   := l_old_ServiceRequest_rec.external_attribute_7;
17592     --l_service_request_rec.external_attribute_8   := l_old_ServiceRequest_rec.external_attribute_8;
17593     --l_service_request_rec.external_attribute_9   := l_old_ServiceRequest_rec.external_attribute_9;
17594     --l_service_request_rec.external_attribute_10  := l_old_ServiceRequest_rec.external_attribute_10;
17595     --l_service_request_rec.external_attribute_11  := l_old_ServiceRequest_rec.external_attribute_11;
17596     --l_service_request_rec.external_attribute_12  := l_old_ServiceRequest_rec.external_attribute_12;
17597     --l_service_request_rec.external_attribute_13  := l_old_ServiceRequest_rec.external_attribute_13;
17598     --l_service_request_rec.external_attribute_14  := l_old_ServiceRequest_rec.external_attribute_14;
17599     --l_service_request_rec.external_attribute_15  := l_old_ServiceRequest_rec.external_attribute_15;
17600     --l_service_request_rec.external_context       := l_old_ServiceRequest_rec.external_context;
17601   --END IF;
17602 
17603  /* IF (l_service_request_rec.verify_cp_flag = FND_API.G_MISS_CHAR) THEN
17604     --
17605     -- We don't actually store a flag in the table to indicate
17606     -- if Installed Base mode is used.  We could tell this by
17607     -- checking to see if customer_product_id is NULL or not
17608     --
17609     IF (l_old_ServiceRequest_rec.customer_product_id IS NULL) THEN
17610       l_service_request_rec.verify_cp_flag := 'N';
17611     ELSE
17612       l_service_request_rec.verify_cp_flag := 'Y';
17613     END IF;
17614 	--	 2757488
17615   ELSIF (l_service_request_rec.verify_cp_flag NOT IN ('Y','N'))  THEN
17616   		CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
17617                             ( p_token_an    => l_api_name_full,
17618                               p_token_v     => l_service_request_rec.verify_cp_flag,
17619                               p_token_p     => 'verify_cp_flag',
17620                               p_table_name  => G_TABLE_NAME ,
17621                               p_column_name => '');
17622 		RAISE FND_API.G_EXC_ERROR;
17623   END IF; */
17624 
17625 
17626    -- For bug 3333340
17627    p_passed_value := l_service_request_rec.verify_cp_flag;
17628    IF (l_service_request_rec.verify_cp_flag <> FND_API.G_MISS_CHAR
17629        AND l_service_request_rec.verify_cp_flag IS NOT NULL) THEN
17630 
17631       IF (l_service_request_rec.verify_cp_flag NOT IN ('Y','N'))  THEN
17632   		CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
17633                             ( p_token_an    => l_api_name_full,
17634                               p_token_v     => l_service_request_rec.verify_cp_flag,
17635                               p_token_p     => 'verify_cp_flag',
17636                               p_table_name  => G_TABLE_NAME ,
17637                               p_column_name => '');
17638 		RAISE FND_API.G_EXC_ERROR;
17639       END IF;
17640   END IF;
17641 
17642   IF (l_service_request_rec.customer_product_id <> FND_API.G_MISS_NUM AND
17643       l_service_request_rec.customer_product_id IS NOT NULL) THEN
17644       l_service_request_rec.verify_cp_flag := 'Y';
17645   ELSIF ( l_service_request_rec.customer_product_id IS NULL) THEN
17646       l_service_request_rec.verify_cp_flag := 'N';
17647   ELSE
17648       IF (l_old_ServiceRequest_rec.customer_product_id IS NOT NULL) THEN
17649            l_service_request_rec.verify_cp_flag := 'Y';
17650       ELSE
17651            l_service_request_rec.verify_cp_flag := 'N';
17652       END IF;
17653   END IF;
17654 
17655   if ( p_passed_value <> FND_API.G_MISS_CHAR) then
17656          if ( p_passed_value <> l_service_request_rec.verify_cp_flag) then
17657 	     CS_ServiceRequest_UTIL.Add_Cp_Flag_Ignored_Msg (p_token_an   => l_api_name_full,
17658 					                     p_token_ip   => p_passed_value,
17659 						             p_token_pv   => l_service_request_rec.verify_cp_flag);
17660 	 end if;
17661   end if;
17662 
17663 
17664 
17665   l_SR_Validation_rec.caller_type := l_service_request_rec.caller_type;
17666 ----**********************
17667   IF (l_service_request_rec.customer_id = FND_API.G_MISS_NUM) THEN
17668     IF (l_service_request_rec.customer_number = FND_API.G_MISS_CHAR) THEN
17669         l_service_request_rec.customer_id := l_old_ServiceRequest_rec.customer_id;
17670            --Since we are not going to store the customer number in the base table
17671            --l_service_request_rec.customer_number := l_old_ServiceRequest_rec.customer_number;
17672     ELSE
17673       BEGIN
17674         SELECT party_id INTO l_service_request_rec.customer_id
17675         FROM hz_parties
17676         WHERE party_number = l_service_request_rec.customer_number;
17677       EXCEPTION
17678         WHEN OTHERS THEN
17679 
17680           CS_ServiceRequest_UTIL.Add_Invalid_Argument_Msg
17681                             ( p_token_an    => l_api_name_full,
17682                               p_token_v     => l_service_request_rec.customer_number,
17683                               p_token_p     => 'p_customer_number',
17684                               p_table_name  => G_TABLE_NAME ,
17685                               p_column_name => 'CUSTOMER_NUMBER');
17686 
17687           RAISE FND_API.G_EXC_ERROR;
17688       END;
17689     END IF;
17690   ELSIF (l_service_request_rec.customer_id IS NOT NULL) THEN
17691     --Added by shramana for bug 13686788
17692 	IF l_service_request_rec.customer_id <> l_old_ServiceRequest_rec.customer_id THEN
17693 		l_SR_Validation_rec.validate_customer := FND_API.G_TRUE;
17694 	END IF;
17695     l_SR_Validation_rec.customer_id := l_service_request_rec.customer_id;
17696   END IF;
17697 
17698   IF (l_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM) OR
17699      (NVL(l_service_request_rec.bill_to_site_id, -99)
17700                             = NVL(l_old_ServiceRequest_rec.bill_to_site_id, -99))  THEN
17701       l_service_request_rec.bill_to_site_id := l_old_ServiceRequest_rec.bill_to_site_id;
17702   ELSE
17703       l_SR_Validation_rec.validate_bill_to_site := FND_API.G_TRUE;
17704       l_SR_Validation_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id;
17705       l_SR_Validation_rec.bill_to_site_id := l_service_request_rec.bill_to_site_id;
17706   END IF;
17707 
17708   IF (l_service_request_rec.bill_to_site_use_id = FND_API.G_MISS_NUM) OR
17709      (NVL(l_service_request_rec.bill_to_site_use_id, -99) =
17710                           NVL(l_old_ServiceRequest_rec.bill_to_site_use_id, -99))  THEN
17711       l_service_request_rec.bill_to_site_use_id := l_old_ServiceRequest_rec.bill_to_site_use_id;
17712   ELSE
17713       l_SR_Validation_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id;
17714       l_SR_Validation_rec.bill_to_site_use_id := l_service_request_rec.bill_to_site_use_id;
17715   END IF;
17716 
17717   IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM) OR
17718      (NVL(l_service_request_rec.bill_to_party_id, -99) =
17719                      NVL(l_old_ServiceRequest_rec.bill_to_party_id, -99))  THEN
17720       l_service_request_rec.bill_to_party_id := l_old_ServiceRequest_rec.bill_to_party_id;
17721   ELSE
17722       l_SR_Validation_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id;
17723   END IF;
17724 
17725   --Passed value is FND or same as old(which may be null)
17726   IF (l_service_request_rec.bill_to_contact_id = FND_API.G_MISS_NUM) OR
17727      (NVL(l_service_request_rec.bill_to_contact_id, -99) = NVL(l_old_ServiceRequest_rec.bill_to_contact_id, -99))  THEN
17728     l_service_request_rec.bill_to_contact_id := l_old_ServiceRequest_rec.bill_to_contact_id;
17729     -- For audit record added by shijain
17730     x_audit_vals_rec.change_bill_to_flag    := 'N';
17731     x_audit_vals_rec.old_bill_to_contact_id := l_old_ServiceRequest_rec.bill_to_contact_id;
17732     x_audit_vals_rec.bill_to_contact_id     := l_service_request_rec.bill_to_contact_id;
17733   ELSIF (l_service_request_rec.bill_to_contact_id IS NOT NULL) THEN
17734     l_SR_Validation_rec.bill_to_contact_id := l_service_request_rec.bill_to_contact_id;
17735     l_SR_Validation_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id;
17736   END IF;
17737 
17738   IF (NVL(l_service_request_rec.bill_to_contact_id, -99) <> NVL(l_old_ServiceRequest_rec.bill_to_contact_id, -99)) THEN
17739     -- For audit record
17740     x_audit_vals_rec.change_bill_to_FLAG := 'Y';
17741     x_audit_vals_rec.OLD_bill_to_contact_id := l_old_ServiceRequest_rec.bill_to_contact_id;
17742     x_audit_vals_rec.bill_to_contact_id := l_service_request_rec.bill_to_contact_id;
17743   --ELSE
17744     --l_new_vals_rec.bill_to_contact_id := l_service_request_rec.bill_to_contact_id;
17745   END IF;
17746 
17747   IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM) OR
17748      (NVL(l_service_request_rec.ship_to_party_id, -99) = NVL(l_old_ServiceRequest_rec.ship_to_party_id, -99))  THEN
17749       l_service_request_rec.ship_to_party_id := l_old_ServiceRequest_rec.ship_to_party_id;
17750   ELSIF (l_service_request_rec.ship_to_party_id IS NOT NULL) THEN
17751       l_SR_Validation_rec.ship_to_party_id := l_service_request_rec.ship_to_party_id;
17752   END IF;
17753 
17754   IF (l_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM) OR
17755      (NVL(l_service_request_rec.ship_to_site_id, -99) =
17756                       NVL(l_old_ServiceRequest_rec.ship_to_site_id, -99))  THEN
17757       l_service_request_rec.ship_to_site_id := l_old_ServiceRequest_rec.ship_to_site_id;
17758   ELSE
17759       l_SR_Validation_rec.validate_ship_to_site := FND_API.G_TRUE;
17760       l_SR_Validation_rec.ship_to_party_id := l_service_request_rec.ship_to_party_id;
17761       l_SR_Validation_rec.ship_to_site_id := l_service_request_rec.ship_to_site_id;
17762   END IF;
17763 
17764   IF (l_service_request_rec.ship_to_site_use_id = FND_API.G_MISS_NUM) OR
17765      (NVL(l_service_request_rec.ship_to_site_use_id, -99) =
17766                            NVL(l_old_ServiceRequest_rec.ship_to_site_use_id, -99))  THEN
17767       l_service_request_rec.ship_to_site_use_id := l_old_ServiceRequest_rec.ship_to_site_use_id;
17768   ELSE
17769       l_SR_Validation_rec.ship_to_party_id := l_service_request_rec.ship_to_party_id;
17770       l_SR_Validation_rec.ship_to_site_use_id := l_service_request_rec.ship_to_site_use_id;
17771   END IF;
17772 
17773   IF (l_service_request_rec.ship_to_contact_id = FND_API.G_MISS_NUM) OR
17774         (NVL(l_service_request_rec.ship_to_contact_id, -99) = NVL(l_old_ServiceRequest_rec.ship_to_contact_id, -99))THEN
17775       l_service_request_rec.ship_to_contact_id := l_old_ServiceRequest_rec.ship_to_contact_id;
17776     -- For audit record added by shijain
17777     x_audit_vals_rec.change_ship_to_flag    := 'N';
17778     x_audit_vals_rec.old_ship_to_contact_id := l_old_ServiceRequest_rec.ship_to_contact_id;
17779     x_audit_vals_rec.ship_to_contact_id     := l_service_request_rec.ship_to_contact_id;
17780   ELSIF (l_service_request_rec.ship_to_contact_id IS NOT NULL) THEN
17781     l_SR_Validation_rec.ship_to_contact_id := l_service_request_rec.ship_to_contact_id;
17782     l_SR_Validation_rec.ship_to_party_id   := l_service_request_rec.ship_to_party_id;
17783   END IF;
17784 
17785   IF (NVL(l_service_request_rec.ship_to_contact_id, -99) <> NVL(l_old_ServiceRequest_rec.ship_to_contact_id, -99)) THEN
17786     -- For audit record
17787     x_audit_vals_rec.change_ship_to_FLAG := 'Y';
17788     x_audit_vals_rec.OLD_ship_to_contact_id := l_old_ServiceRequest_rec.ship_to_contact_id;
17789     x_audit_vals_rec.ship_to_contact_id := l_service_request_rec.ship_to_contact_id;
17790   --ELSE
17791    -- l_new_vals_rec.ship_to_contact_id := l_service_request_rec.ship_to_contact_id;
17792   END IF;
17793 
17794   IF (l_service_request_rec.install_site_id = FND_API.G_MISS_NUM) OR
17795      (nvl(l_service_request_rec.install_site_id, -99) =
17796                                  nvl(l_old_ServiceRequest_rec.install_site_id, -99) ) THEN
17797       l_service_request_rec.install_site_id := l_old_ServiceRequest_rec.install_site_id;
17798   ELSE
17799       l_SR_Validation_rec.validate_install_site := FND_API.G_TRUE;
17800       l_SR_Validation_rec.install_site_id := l_service_request_rec.install_site_id;
17801   END IF;
17802 
17803   IF (l_service_request_rec.install_site_use_id = FND_API.G_MISS_NUM) OR
17804      (nvl(l_service_request_rec.install_site_use_id, -99) =
17805                                  nvl(l_old_ServiceRequest_rec.install_site_use_id, -99) ) THEN
17806       l_service_request_rec.install_site_use_id := l_old_ServiceRequest_rec.install_site_use_id;
17807   ELSE
17808       l_SR_Validation_rec.validate_install_site := FND_API.G_TRUE;
17809       l_SR_Validation_rec.install_site_use_id := l_service_request_rec.install_site_use_id;
17810   END IF;
17811 
17812   ---Put this fix because audit was erroring out from CC to SR.
17813 
17814   IF (l_service_request_rec.verify_cp_flag = 'Y') THEN
17815     IF (l_service_request_rec.customer_product_id = FND_API.G_MISS_NUM) OR
17816           (NVL(l_service_request_rec.customer_product_id,-99)
17817             = NVL(l_old_ServiceRequest_rec.customer_product_id,-99)) THEN
17818       l_service_request_rec.customer_product_id := l_old_ServiceRequest_rec.customer_product_id;
17819       -- For audit record added by shijain
17820       x_audit_vals_rec.change_customer_product_FLAG := 'N';
17821       x_audit_vals_rec.OLD_customer_product_id      := l_old_ServiceRequest_rec.customer_product_id;
17822       x_audit_vals_rec.customer_product_id          := l_service_request_rec.customer_product_id;
17823 
17824     ELSE
17825       IF (l_service_request_rec.customer_product_id IS NOT NULL) THEN
17826         l_SR_Validation_rec.customer_product_id := l_service_request_rec.customer_product_id;
17827         -- For audit record
17828         x_audit_vals_rec.change_customer_product_FLAG := 'N';
17829         x_audit_vals_rec.OLD_customer_product_id := l_old_ServiceRequest_rec.customer_product_id;
17830         x_audit_vals_rec.customer_product_id := l_service_request_rec.customer_product_id;
17831       END IF;
17832     END IF;
17833  -- END IF;
17834 
17835     l_service_request_rec.original_order_number := NULL;
17836     l_service_request_rec.purchase_order_num := NULL;
17837 
17838   ELSE
17839 
17840     -- for bug 3333340
17841        if (l_service_request_rec.cp_component_id <> FND_API.G_MISS_NUM AND
17842 	    l_service_request_rec.cp_component_id IS NOT NULL) then
17843 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17844 		p_token_an	=>  l_api_name_full,
17845 		p_token_ip	=>  'p_cp_component_id' );
17846 
17847 		l_service_request_rec.cp_component_id := NULL;
17848 	end if;
17849 
17850         if (l_service_request_rec.cp_component_version_id <> FND_API.G_MISS_NUM AND
17851 	    l_service_request_rec.cp_component_version_id IS NOT NULL) then
17852 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17853 		p_token_an	=>  l_api_name_full,
17854 		p_token_ip	=>  'p_cp_component_version_id' );
17855 
17856 		l_service_request_rec.cp_component_version_id := NULL;
17857 	end if;
17858 
17859 	if (l_service_request_rec.cp_subcomponent_id <> FND_API.G_MISS_NUM AND
17860 	    l_service_request_rec.cp_subcomponent_id IS NOT NULL) then
17861 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17862 		p_token_an	=>  l_api_name_full,
17863 		p_token_ip	=>  'p_cp_subcomponent_id' );
17864 
17865 		l_service_request_rec.cp_subcomponent_id := NULL;
17866 	end if;
17867 
17868 	if (l_service_request_rec.cp_subcomponent_version_id <> FND_API.G_MISS_NUM AND
17869 	    l_service_request_rec.cp_subcomponent_version_id IS NOT NULL) then
17870 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17871 		p_token_an	=>  l_api_name_full,
17872 		p_token_ip	=>  'p_cp_subcomponent_version_id' );
17873 
17874 		l_service_request_rec.cp_subcomponent_version_id := NULL;
17875 	end if;
17876 
17877 	if (l_service_request_rec.cp_revision_id  <> FND_API.G_MISS_NUM AND
17878 	    l_service_request_rec.cp_revision_id  IS NOT NULL) then
17879 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17880 		p_token_an	=>  l_api_name_full,
17881 		p_token_ip	=>  'p_cp_revision_id' );
17882 
17883 		l_service_request_rec.cp_revision_id := NULL;
17884 	end if;
17885 -- Fix for bug 9398013 Sharanya. Checking for validation level also
17886 	if (l_service_request_rec.product_revision  <> FND_API.G_MISS_CHAR AND
17887 	    l_service_request_rec.product_revision  IS NOT NULL AND
17888 	    (p_validation_level > FND_API.G_VALID_LEVEL_NONE)) then
17889 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17890 		p_token_an	=>  l_api_name_full,
17891 		p_token_ip	=>  'p_product_revision' );
17892 
17893 		l_service_request_rec.product_revision := NULL;
17894 	end if;
17895 
17896 	if (l_service_request_rec.component_version <> FND_API.G_MISS_CHAR AND
17897 	    l_service_request_rec.component_version IS NOT NULL) then
17898 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17899 		p_token_an	=>  l_api_name_full,
17900 		p_token_ip	=>  'p_component_version' );
17901 
17902 		l_service_request_rec.component_version := NULL;
17903 	end if;
17904 
17905 	if (l_service_request_rec.subcomponent_version <> FND_API.G_MISS_CHAR AND
17906 	    l_service_request_rec.subcomponent_version IS NOT NULL) then
17907 	        CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg(
17908 		p_token_an	=>  l_api_name_full,
17909 		p_token_ip	=>  'p_subcomponent_version' );
17910 
17911 		l_service_request_rec.subcomponent_version := NULL;
17912 	end if;
17913 
17914     -- Verify CP is 'N'
17915     -- This step id done so that  l_service_request_rec.customer_product_id does not have MISS NUM value
17916     -- Added to take care of a situation where verify_cp is passed as 'N' by the caller
17917     -- This means that the customer_product_id and the related fields should be null
17918     l_service_request_rec.customer_product_id  := NULL;
17919     x_audit_vals_rec.customer_product_id       := NULL ;
17920     ---l_service_request_rec.account_id        := NULL;
17921     l_service_request_rec.cp_component_id      := NULL;
17922     l_service_request_rec.cp_component_version_id := NULL;
17923     l_service_request_rec.cp_subcomponent_id   := NULL;
17924     l_service_request_rec.cp_subcomponent_version_id := NULL;
17925     l_service_request_rec.cp_revision_id       := NULL;
17926     l_service_request_rec.product_revision     := NULL;
17927     l_service_request_rec.component_version    := NULL;
17928     l_service_request_rec.subcomponent_version := NULL;
17929 
17930 
17931 
17932 --- fix for bug# 1657370 --jngeorge --05/22/01
17933     --l_service_request_rec.current_serial_number := NULL;
17934 --- commenting the above line 'coz it clears the current_serial_number
17935 --- during an update for a non-IB .Fix for Bug# 1902127.
17936 
17937 -- added a condition to check if the new inventory_item_id is same
17938 -- as old value. Fix for Bug#1854325 -- jngeorge
17939 
17940     IF (l_service_request_rec.inventory_item_id = FND_API.G_MISS_NUM) OR
17941        (l_service_request_rec.inventory_item_id =l_old_ServiceRequest_rec.inventory_item_id) THEN
17942       l_service_request_rec.inventory_item_id := l_old_ServiceRequest_rec.inventory_item_id;
17943     ELSE
17944       IF (l_service_request_rec.inventory_item_id IS NOT NULL) THEN
17945         l_SR_Validation_rec.inventory_item_id := l_service_request_rec.inventory_item_id;
17946       END IF;
17947     END IF;
17948 
17949     IF (l_service_request_rec.original_order_number = FND_API.G_MISS_NUM) THEN
17950       l_service_request_rec.original_order_number := l_old_ServiceRequest_rec.original_order_number;
17951     END IF;
17952 
17953     IF (l_service_request_rec.purchase_order_num = FND_API.G_MISS_CHAR) THEN
17954       l_service_request_rec.purchase_order_num := l_old_ServiceRequest_rec.purchase_order_num;
17955     END IF;
17956 
17957   END IF;
17958 
17959 -- added a condition to check if the new inventory_item_id is same
17960 -- as old value. Fix for Bug#1854325 -- jngeorge
17961   IF (l_service_request_rec.inventory_item_id = FND_API.G_MISS_NUM) OR
17962        (l_service_request_rec.inventory_item_id =l_old_ServiceRequest_rec.inventory_item_id) THEN
17963         l_service_request_rec.inventory_item_id := l_old_ServiceRequest_rec.inventory_item_id;
17964   ELSE
17965         IF (l_service_request_rec.inventory_item_id IS NOT NULL) THEN
17966            l_SR_Validation_rec.inventory_item_id := l_service_request_rec.inventory_item_id;
17967     END IF;
17968   END IF;
17969 
17970   IF (NVL(l_service_request_rec.customer_product_id, -99) <> NVL(l_old_ServiceRequest_rec.customer_product_id, -99)) THEN
17971     -- For audit record
17972     x_audit_vals_rec.change_customer_product_FLAG := 'Y';
17973     x_audit_vals_rec.OLD_customer_product_id := l_old_ServiceRequest_rec.customer_product_id;
17974     x_audit_vals_rec.customer_product_id := l_service_request_rec.customer_product_id;
17975   END IF;
17976 
17977   IF (l_service_request_rec.current_serial_number = FND_API.G_MISS_CHAR) THEN
17978     l_service_request_rec.current_serial_number := l_old_ServiceRequest_rec.current_serial_number;
17979   ELSE
17980     IF (l_service_request_rec.current_serial_number IS NOT NULL) THEN
17981       l_SR_Validation_rec.current_serial_number := l_service_request_rec.current_serial_number;
17982     END IF;
17983   END IF;
17984 
17985    --Assign the inventory org id retrived from the table to the validation record
17986    l_SR_Validation_rec.inventory_org_id := l_service_request_rec.inventory_org_id;
17987 
17988    -- Added for ER# 2433831 -- Bill To Account and Ship to Account
17989    IF (l_service_request_rec.bill_to_account_id = FND_API.G_MISS_NUM) THEN
17990       l_service_request_rec.bill_to_account_id := l_old_ServiceRequest_rec.bill_to_account_id ;
17991    ELSE
17992       IF (l_service_request_rec.bill_to_account_id IS NOT NULL) THEN
17993           l_SR_Validation_rec.bill_to_account_id := l_service_request_rec.bill_to_account_id ;
17994           l_SR_Validation_rec.bill_to_party_id := l_service_request_rec.bill_to_party_id ;
17995       END IF;
17996    END IF ;
17997 
17998    IF (l_service_request_rec.ship_to_account_id = FND_API.G_MISS_NUM) THEN
17999       l_service_request_rec.ship_to_account_id := l_old_ServiceRequest_rec.ship_to_account_id ;
18000    ELSE
18001       IF (l_service_request_rec.ship_to_account_id IS NOT NULL) THEN
18002           l_SR_Validation_rec.ship_to_account_id := l_service_request_rec.ship_to_account_id ;
18003           l_SR_Validation_rec.ship_to_party_id := l_service_request_rec.ship_to_party_id ;
18004       END IF;
18005    END IF ;
18006 
18007    -- Added for ER# 2463321 -- Non-Promary customer contacts (Phone and Email).
18008    IF (l_service_request_rec.customer_phone_id = FND_API.G_MISS_NUM) THEN
18009       l_service_request_rec.customer_phone_id := l_old_ServiceRequest_rec.customer_phone_id ;
18010    ELSE
18011       IF (l_service_request_rec.customer_phone_id IS NOT NULL) THEN
18012           l_SR_Validation_rec.customer_phone_id := l_service_request_rec.customer_phone_id ;
18013       END IF;
18014    END IF ;
18015 
18016    IF (l_service_request_rec.customer_email_id = FND_API.G_MISS_NUM) THEN
18017       l_service_request_rec.customer_email_id := l_old_ServiceRequest_rec.customer_email_id ;
18018    ELSE
18019       IF (l_service_request_rec.customer_email_id IS NOT NULL) THEN
18020           l_SR_Validation_rec.customer_email_id := l_service_request_rec.customer_email_id ;
18021       END IF;
18022    END IF ;
18023 
18024   -- for cmro_eam
18025    IF (l_service_request_rec.owning_dept_id = FND_API.G_MISS_NUM) THEN
18026        l_service_request_rec.owning_dept_id := l_old_ServiceRequest_rec.owning_department_id ;
18027    ELSE
18028        IF (l_service_request_rec.owning_dept_id IS NOT NULL) THEN
18029        l_SR_Validation_rec.owning_dept_id := l_service_request_rec.owning_dept_id ;
18030        END IF;
18031    END IF;
18032 
18033    -- end of cmro_eam
18034 
18035    -- For bug 3635269
18036    IF (l_service_request_rec.sr_creation_channel = FND_API.G_MISS_CHAR) THEN
18037        l_service_request_rec.sr_creation_channel := l_old_ServiceRequest_rec.sr_creation_channel ;
18038    ELSE
18039        IF (l_service_request_rec.sr_creation_channel IS NOT NULL) THEN
18040        l_SR_Validation_rec.sr_creation_channel := l_service_request_rec.sr_creation_channel ;
18041        END IF;
18042    END IF;
18043 
18044     --15995804. Add price_list_header_id
18045   IF (l_service_request_rec.price_list_header_id = FND_API.G_MISS_NUM) OR
18046      (NVL(l_service_request_rec.price_list_header_id, -99) =
18047                            NVL(l_old_ServiceRequest_rec.price_list_header_id, -99))  THEN
18048       l_service_request_rec.price_list_header_id := l_old_ServiceRequest_rec.price_list_header_id;
18049   ELSE
18050       l_SR_Validation_rec.price_list_header_id := l_service_request_rec.price_list_header_id;
18051   END IF;
18052 
18053   --
18054   -- Call the validation procedure if the validation level is
18055   -- properly set
18056   --
18057   IF (p_validation_level > FND_API.G_VALID_LEVEL_NONE) THEN
18058     Validate_ServiceRequest_Record(
18059        p_api_name               => l_api_name_full,
18060        p_service_request_rec    => l_SR_Validation_rec,
18061        p_request_date           => l_old_ServiceRequest_rec.incident_date,
18062        p_org_id                 => l_org_id,
18063        p_resp_appl_id           => p_resp_appl_id,
18064        p_resp_id                => p_resp_id,
18065        p_user_id                => p_last_updated_by,
18066        p_operation              => l_operation,
18067        p_close_flag             => l_close_flag,
18068        p_disallow_request_update=> l_disallow_request_update,
18069        p_disallow_owner_update  => l_disallow_owner_update,
18070        p_disallow_product_update=> l_disallow_product_update,
18071        p_employee_name          => l_employee_name,
18072        p_inventory_item_id      => l_cp_inventory_item_id,
18073        p_contract_id            => l_contra_id,
18074        p_contract_number        => l_contract_number,
18075        x_bill_to_site_id        => l_bill_to_site_id,
18076        x_ship_to_site_id        => l_ship_to_site_id,
18077        x_bill_to_site_use_id    => l_bill_to_site_use_id,
18078        x_ship_to_site_use_id    => l_ship_to_site_use_id,
18079        x_return_status          => l_return_status,
18080        x_group_name             => l_group_name,
18081        x_owner_name             => l_owner_name,
18082        x_product_revision       => l_dummy0,
18083        x_component_version      => l_dummy1,
18084        x_subcomponent_version   => l_dummy2,
18085        --for cmro_eam
18086        p_cmro_flag              => p_cmro_flag,
18087        p_maintenance_flag       => p_maintenance_flag,
18088 	   p_sr_mode                => 'UPDATE'
18089       );
18090 
18091     IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18092       RAISE FND_API.G_EXC_ERROR;
18093     END IF;
18094     IF (l_contra_id is NOT NULL) THEN
18095        x_contra_id := l_contra_id;
18096     END IF;
18097     IF (l_contra_id is NOT NULL) THEN
18098        x_contract_number := l_contract_number;
18099     END IF;
18100 
18101     -- For bug 3340433
18102     /* Commenting the assignments as the validations are not called from
18103     validate_servicerequest_record because of the update mode */
18104 
18105     /*
18106 
18107     IF (l_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM) OR
18108        (NVL(l_service_request_rec.ship_to_site_id, -99)
18109                            = NVL(l_old_ServiceRequest_rec.ship_to_site_id, -99))
18110     THEN
18111       IF l_ship_to_site_id IS NULL OR
18112          l_ship_to_site_id =l_old_ServiceRequest_rec.ship_to_site_id
18113       THEN
18114             l_service_request_rec.ship_to_site_id :=
18115                               l_old_ServiceRequest_rec.ship_to_site_id;
18116       ELSE
18117             l_service_request_rec.ship_to_site_id := l_ship_to_site_id;
18118       END IF;
18119     END IF;
18120 
18121     IF (l_service_request_rec.ship_to_site_use_id = FND_API.G_MISS_NUM) OR
18122        (NVL(l_service_request_rec.ship_to_site_use_id, -99)
18123                        = NVL(l_old_ServiceRequest_rec.ship_to_site_use_id, -99))
18124     THEN
18125       IF l_ship_to_site_use_id IS NULL OR
18126          l_ship_to_site_use_id =l_old_ServiceRequest_rec.ship_to_site_use_id
18127       THEN
18128             l_service_request_rec.ship_to_site_use_id :=
18129                               l_old_ServiceRequest_rec.ship_to_site_use_id;
18130       ELSE
18131             l_service_request_rec.ship_to_site_use_id := l_ship_to_site_use_id;
18132       END IF;
18133     END IF;
18134 
18135     IF (l_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM) OR
18136        (NVL(l_service_request_rec.bill_to_site_id, -99)
18137                            = NVL(l_old_ServiceRequest_rec.bill_to_site_id, -99))
18138     THEN
18139       IF l_bill_to_site_id IS NULL OR
18140          l_bill_to_site_id =l_old_ServiceRequest_rec.bill_to_site_id
18141       THEN
18142             l_service_request_rec.bill_to_site_id :=
18143                               l_old_ServiceRequest_rec.bill_to_site_id;
18144       ELSE
18145             l_service_request_rec.bill_to_site_id := l_bill_to_site_id;
18146       END IF;
18147     END IF;
18148 
18149     IF (l_service_request_rec.bill_to_site_use_id = FND_API.G_MISS_NUM) OR
18150        (NVL(l_service_request_rec.bill_to_site_use_id, -99)
18151                        = NVL(l_old_ServiceRequest_rec.bill_to_site_use_id, -99))
18152     THEN
18153       IF l_bill_to_site_use_id IS NULL OR
18154          l_bill_to_site_use_id =l_old_ServiceRequest_rec.bill_to_site_use_id
18155       THEN
18156             l_service_request_rec.bill_to_site_use_id :=
18157                               l_old_ServiceRequest_rec.bill_to_site_use_id;
18158       ELSE
18159             l_service_request_rec.bill_to_site_use_id := l_bill_to_site_use_id;
18160       END IF;
18161     END IF;
18162 
18163     --
18164     -- Need to store the inventory_item_id from the CP if CP is
18165     -- used
18166     --
18167     -- Added a condition because inventory_item_id becomes null
18168     -- Fix for Bug# 1854325.-- jngeorge
18169     -- If customer_product_id is specified then the inventory item id
18170     -- specified in the record type is always overwritten by the
18171     -- inventory item id value in the
18172     -- CS_CUSTOMER_PRODUCTS_ALL for that customer_product_id
18173 
18174 
18175 
18176     IF (l_service_request_rec.customer_product_id IS NOT NULL) AND
18177        (l_service_request_rec.inventory_item_id <> l_old_ServiceRequest_rec.inventory_item_id) THEN
18178       l_service_request_rec.inventory_item_id := l_cp_inventory_item_id;
18179 
18180     END IF; */
18181 
18182     --added this code on dec 8th 2000
18183     IF  l_status_validated = TRUE  THEN
18184          l_close_flag := l_closed_flag_temp ;
18185     END IF;
18186 
18187     -- For bug 3464004
18188     -- Close date was nullified when the closed SR is updated with summary
18189     -- or urgency
18190     -- The validate_status and validate_updated_status is not called when the
18191     -- status is not updated so the close_flag is null
18192 
18193     if ( l_service_request_rec.status_id = FND_API.G_MISS_NUM) then
18194 
18195       l_temp_close_flag := get_status_flag(l_old_ServiceRequest_rec.incident_status_id);
18196       if (l_temp_close_flag = 'C') then
18197             l_close_flag := 'Y';
18198       else
18199             l_close_flag := 'N';
18200       end if;
18201     else
18202       -- for bug 3520943 - to get the close date
18203       l_temp_close_flag := get_status_flag(l_service_request_rec.status_id);
18204 
18205       if (l_temp_close_flag = 'C') then
18206             l_close_flag := 'Y';
18207       else
18208             l_close_flag := 'N';
18209       end if;
18210 
18211     end if;
18212 
18213     --
18214     -- We can only verify the close_date after calling the validation
18215     -- procedure because we need to get the closed_flag first
18216     --
18217     IF (l_close_flag = 'Y') THEN
18218         -- Added it for Ehn. 2655115
18219         -- Commented out for bug #3050727, since this is now redundant after the bug-fix --anmukher --09/15/03
18220         -- l_service_request_rec.status_flag := 'C';
18221 
18222       IF ((l_service_request_rec.closed_date = FND_API.G_MISS_DATE) OR
18223            (l_service_request_rec.closed_date IS NULL)) THEN
18224         IF (l_old_ServiceRequest_rec.close_date IS NULL) THEN
18225           l_service_request_rec.closed_date := SYSDATE;
18226         ELSE
18227           l_service_request_rec.closed_date := l_old_ServiceRequest_rec.close_date;
18228         END IF;
18229       ELSIF (l_service_request_rec.closed_date IS NOT NULL) THEN
18230 
18231         CS_ServiceRequest_UTIL.Validate_Closed_Date
18232           ( p_api_name       => l_api_name_full,
18233             p_parameter_name => 'p_closed_date',
18234             p_closed_date    => l_service_request_rec.closed_date,
18235             p_request_date   => l_old_ServiceRequest_rec.incident_date,
18236             x_return_status  => l_return_status
18237           );
18238         IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
18239           RAISE FND_API.G_EXC_ERROR;
18240         END IF;
18241       END IF;
18242     ELSE
18243       -- Added it for Ehn. 2655115
18244       -- Commented out for bug #3050727, since this is now redundant after the bug-fix --anmukher --09/15/03
18245       -- l_service_request_rec.status_flag:= 'O';
18246 
18247       IF (l_service_request_rec.closed_date <> FND_API.G_MISS_DATE) THEN
18248 
18249         CS_ServiceRequest_UTIL.Add_Param_Ignored_Msg
18250                           ( p_token_an     =>  l_api_name_full,
18251                             p_token_ip     =>  'p_closed_date',
18252                             p_table_name   =>  G_TABLE_NAME,
18253                             p_column_name  =>  'CLOSED_DATE' );
18254       END IF;
18255       l_service_request_rec.closed_date := NULL;
18256     END IF;
18257   END IF;   /* Validation Level */
18258 
18259 -- for the bug 3050727
18260 -- Commented out the IF-END IF since the assignment should be done anyway --anmukher --09/15/03
18261   -- IF (p_validation_level = FND_API.G_VALID_LEVEL_NONE) THEN
18262 	l_service_request_rec.status_flag := get_status_flag(l_service_request_rec.status_id);
18263   -- END IF;
18264 
18265   /* Bug 2624341 close date should be audited if the status is changed,
18266      i.e. if the status is changed from closed to open the the close_date
18267      should be nullfied, in the audit table, so moved this code after
18268      checking the close_flag and setting the close_date based on the
18269      close_flag. Change done by shijain*/
18270 
18271   IF (l_service_request_rec.closed_date = FND_API.G_MISS_DATE) OR
18272      (l_service_request_rec.closed_date IS NULL AND
18273       l_old_ServiceRequest_rec.close_date IS NULL) OR
18274      (l_service_request_rec.closed_date = l_old_ServiceRequest_rec.close_date)
18275   THEN
18276     l_service_request_rec.closed_date := l_old_ServiceRequest_rec.close_date;
18277     IF  (x_audit_vals_rec.change_incident_status_flag = 'Y')
18278     AND (l_closed_flag_temp = 'N' OR l_closed_flag_temp IS NULL)
18279     THEN
18280         l_service_request_rec.closed_date := NULL;
18281     END IF;
18282     -- For audit record added by shijain
18283     x_audit_vals_rec.change_close_date_flag := 'N';
18284     x_audit_vals_rec.old_close_date         := l_old_ServiceRequest_rec.close_date;
18285     x_audit_vals_rec.close_date             := l_service_request_rec.closed_date;
18286   ELSE
18287     -- For audit record
18288     x_audit_vals_rec.change_close_date_FLAG := 'Y';
18289     x_audit_vals_rec.OLD_close_date         := l_old_ServiceRequest_rec.close_date;
18290     x_audit_vals_rec.close_date             := l_service_request_rec.closed_date;
18291   END IF;
18292 
18293  /* Enh. 2624341 status flag should be audited based on the close_flag,
18294     if the close flag='Y' then the status_flag should be C else O, so
18295     we are checking the status flag after we get the close flag in
18296     validate_service_request procedure.Change done by shijain*/
18297 
18298  IF (l_service_request_rec.status_flag = FND_API.G_MISS_CHAR) OR
18299     ( l_service_request_rec.status_flag = l_old_ServiceRequest_rec.status_flag )
18300  THEN
18301     l_service_request_rec.status_flag  := l_old_ServiceRequest_rec.status_flag;
18302     -- For audit record added by shijain
18303     x_audit_vals_rec.change_status_flag  := 'N';
18304     x_audit_vals_rec.old_status_flag     := l_old_ServiceRequest_rec.status_flag ;
18305     x_audit_vals_rec.status_flag         := l_service_request_rec.status_flag;
18306  ELSE
18307     -- For audit record
18308     x_audit_vals_rec.CHANGE_status_flag  := 'Y';
18309     x_audit_vals_rec.OLD_status_flag     := l_old_ServiceRequest_rec.status_flag ;
18310     x_audit_vals_rec.status_flag         := l_service_request_rec.status_flag;
18311  END IF;
18312 
18313 -- for cmro_eam
18314 IF (l_service_request_rec.owning_dept_id = FND_API.G_MISS_NUM OR
18315     l_service_request_rec.owning_dept_id = l_old_ServiceRequest_rec.owning_department_id) THEN
18316     l_service_request_rec.owning_dept_id := l_old_ServiceRequest_rec.owning_department_id;
18317 END IF;
18318 
18319 -- end for cmro_eam
18320 ---------------------------------------------------
18321   -- Before the actual update, see if the all the fields have their old values or null values
18322   --(otherwise they will have the MISS_NUM constants)
18323   IF (l_service_request_rec.customer_id = FND_API.G_MISS_NUM OR
18324       l_service_request_rec.customer_id = l_old_ServiceRequest_rec.customer_id) THEN
18325       l_service_request_rec.customer_id := l_old_ServiceRequest_rec.customer_id;
18326   END IF;
18327 
18328   IF (l_service_request_rec.bill_to_site_id = FND_API.G_MISS_NUM OR
18329       l_service_request_rec.bill_to_site_id = l_old_ServiceRequest_rec.bill_to_site_id) THEN
18330       l_service_request_rec.bill_to_site_id := l_old_ServiceRequest_rec.bill_to_site_id ;
18331   END IF;
18332 
18333   IF (l_service_request_rec.bill_to_site_use_id = FND_API.G_MISS_NUM OR
18334       l_service_request_rec.bill_to_site_use_id = l_old_ServiceRequest_rec.bill_to_site_use_id) THEN
18335       l_service_request_rec.bill_to_site_use_id := l_old_ServiceRequest_rec.bill_to_site_use_id ;
18336   END IF;
18337 
18338   IF (l_service_request_rec.bill_to_party_id = FND_API.G_MISS_NUM OR
18339       l_service_request_rec.bill_to_party_id = l_old_ServiceRequest_rec.bill_to_party_id) THEN
18340       l_service_request_rec.bill_to_party_id := l_old_ServiceRequest_rec.bill_to_party_id ;
18341   END IF;
18342 
18343   IF (l_service_request_rec.ship_to_site_id = FND_API.G_MISS_NUM OR
18344       l_service_request_rec.ship_to_site_id = l_old_ServiceRequest_rec.ship_to_site_id) THEN
18345       l_service_request_rec.ship_to_site_id := l_old_ServiceRequest_rec.ship_to_site_id ;
18346   END IF;
18347 
18348   IF (l_service_request_rec.ship_to_site_use_id = FND_API.G_MISS_NUM OR
18349       l_service_request_rec.ship_to_site_use_id = l_old_ServiceRequest_rec.ship_to_site_use_id) THEN
18350       l_service_request_rec.ship_to_site_use_id := l_old_ServiceRequest_rec.ship_to_site_use_id ;
18351   END IF;
18352 
18353   IF (l_service_request_rec.ship_to_party_id = FND_API.G_MISS_NUM OR
18354       l_service_request_rec.ship_to_party_id = l_old_ServiceRequest_rec.ship_to_party_id) THEN
18355       l_service_request_rec.ship_to_party_id := l_old_ServiceRequest_rec.ship_to_party_id ;
18356   END IF;
18357 
18358   IF (l_service_request_rec.install_site_id = FND_API.G_MISS_NUM OR
18359       nvl(l_service_request_rec.install_site_id,-99) = nvl(l_old_ServiceRequest_rec.install_site_id,-99)
18360      )
18361   AND (l_service_request_rec.install_site_use_id <> FND_API.G_MISS_NUM OR
18362        nvl(l_service_request_rec.install_site_use_id,-99) <> nvl(l_old_ServiceRequest_rec.install_site_use_id,-99))
18363  THEN
18364 	  l_service_request_rec.install_site_use_id := l_service_request_rec.install_site_use_id;
18365       l_service_request_rec.install_site_id := l_service_request_rec.install_site_use_id;
18366   END IF;
18367 
18368   IF (l_service_request_rec.install_site_use_id = FND_API.G_MISS_NUM OR
18369       nvl(l_service_request_rec.install_site_use_id,-99) = nvl(l_old_ServiceRequest_rec.install_site_use_id,-99)
18370      )
18371   AND (l_service_request_rec.install_site_id <> FND_API.G_MISS_NUM OR
18372        nvl(l_service_request_rec.install_site_id,-99) <> nvl(l_old_ServiceRequest_rec.install_site_id,-99))
18373  THEN
18374       l_service_request_rec.install_site_id := l_service_request_rec.install_site_id;
18375       l_service_request_rec.install_site_use_id := l_service_request_rec.install_site_id;
18376   END IF;
18377 
18378   IF (l_service_request_rec.bill_to_contact_id = FND_API.G_MISS_NUM OR
18379       l_service_request_rec.bill_to_contact_id = l_old_ServiceRequest_rec.bill_to_contact_id) THEN
18380       l_service_request_rec.bill_to_contact_id := l_old_ServiceRequest_rec.bill_to_contact_id;
18381   END IF;
18382 
18383   IF (l_service_request_rec.ship_to_contact_id = FND_API.G_MISS_NUM OR
18384       l_service_request_rec.ship_to_contact_id = l_old_ServiceRequest_rec.ship_to_contact_id) THEN
18385       l_service_request_rec.ship_to_contact_id := l_old_ServiceRequest_rec.ship_to_contact_id;
18386   END IF;
18387 
18388    -- Added for ER# 2320056 -- Coverage Type
18389    IF (l_service_request_rec.coverage_type = FND_API.G_MISS_CHAR) THEN
18390        l_service_request_rec.coverage_type := l_old_ServiceRequest_rec.coverage_type  ;
18391    END IF ;
18392 
18393 -- If the contract service id is null then coverage type should be null
18394 -- Added this check for 1159 by shijain dec6th 2002
18395    IF (l_service_request_rec.contract_service_id = FND_API.G_MISS_NUM)
18396    OR (l_service_request_rec.contract_service_id IS NULL)  THEN
18397            l_service_request_rec.coverage_type  := NULL;
18398    END IF;
18399 
18400 
18401    IF (l_service_request_rec.program_id = FND_API.G_MISS_NUM) THEN
18402        l_service_request_rec.program_id := l_old_ServiceRequest_rec.program_id  ;
18403    END IF ;
18404 
18405    IF (l_service_request_rec.program_application_id = FND_API.G_MISS_NUM) THEN
18406        l_service_request_rec.program_application_id := l_old_ServiceRequest_rec.program_application_id  ;
18407    END IF ;
18408 
18409    IF (l_service_request_rec.conc_request_id = FND_API.G_MISS_NUM) THEN
18410        l_service_request_rec.conc_request_id := l_old_ServiceRequest_rec.request_id  ;
18411    END IF ;
18412 
18413    IF (l_service_request_rec.program_login_id = FND_API.G_MISS_NUM) THEN
18414        l_service_request_rec.program_login_id := l_old_ServiceRequest_rec.program_login_id  ;
18415    END IF ;
18416 
18417   --- Added for HA, the WHO columns should be derived before inserting
18418   --- if passed null or has G_MISS values.
18419   IF (l_service_request_rec.last_update_date = FND_API.G_MISS_DATE OR
18420       l_service_request_rec.last_update_date IS NULL ) THEN
18421       l_service_request_rec.last_update_date := SYSDATE;
18422   END IF;
18423 
18424   IF (l_service_request_rec.last_updated_by = FND_API.G_MISS_NUM OR
18425       l_service_request_rec.last_updated_by IS NULL ) THEN
18426       l_service_request_rec.last_updated_by := p_last_updated_by;
18427   END IF;
18428 
18429   IF (l_service_request_rec.creation_date = FND_API.G_MISS_DATE OR
18430       l_service_request_rec.creation_date IS NULL ) THEN
18431       l_service_request_rec.creation_date := SYSDATE;
18432   END IF;
18433 
18434   IF (l_service_request_rec.created_by = FND_API.G_MISS_NUM OR
18435       l_service_request_rec.created_by IS NULL ) THEN
18436       l_service_request_rec.created_by := p_last_updated_by;
18437   END IF;
18438 
18439   IF (l_service_request_rec.last_update_login = FND_API.G_MISS_NUM OR
18440       l_service_request_rec.last_update_login IS NULL ) THEN
18441       l_service_request_rec.last_update_login := p_last_update_login;
18442   END IF;
18443 
18444   IF (l_service_request_rec.maint_organization_id = FND_API.G_MISS_NUM) THEN
18445     l_service_request_rec.maint_organization_id := l_old_ServiceRequest_rec.maint_organization_id  ;
18446   END IF ;
18447 
18448   IF (l_service_request_rec.site_id = FND_API.G_MISS_NUM) THEN
18449     l_service_request_rec.site_id := l_old_ServiceRequest_rec.site_id  ;
18450   END IF ;
18451 
18452    --15995804. Add price_list_header_id and SLA dates
18453   IF (l_service_request_rec.price_list_header_id = FND_API.G_MISS_NUM OR
18454       l_service_request_rec.price_list_header_id = l_old_ServiceRequest_rec.price_list_header_id) THEN
18455       l_service_request_rec.price_list_header_id := l_old_ServiceRequest_rec.price_list_header_id ;
18456   END IF;
18457   IF (l_service_request_rec.sla_date_1 = FND_API.G_MISS_DATE ) THEN
18458       l_service_request_rec.sla_date_1 := l_old_ServiceRequest_rec.sla_date_1;
18459   END IF;
18460   IF (l_service_request_rec.sla_date_2 = FND_API.G_MISS_DATE ) THEN
18461       l_service_request_rec.sla_date_2 := l_old_ServiceRequest_rec.sla_date_2;
18462   END IF;
18463   IF (l_service_request_rec.sla_date_3 = FND_API.G_MISS_DATE ) THEN
18464       l_service_request_rec.sla_date_3 := l_old_ServiceRequest_rec.sla_date_3;
18465   END IF;
18466   IF (l_service_request_rec.sla_date_4 = FND_API.G_MISS_DATE ) THEN
18467       l_service_request_rec.sla_date_4 := l_old_ServiceRequest_rec.sla_date_4;
18468   END IF;
18469   IF (l_service_request_rec.sla_date_5 = FND_API.G_MISS_DATE ) THEN
18470       l_service_request_rec.sla_date_5 := l_old_ServiceRequest_rec.sla_date_5;
18471   END IF;
18472   IF (l_service_request_rec.sla_date_6 = FND_API.G_MISS_DATE ) THEN
18473       l_service_request_rec.sla_date_6 := l_old_ServiceRequest_rec.sla_date_6;
18474   END IF;
18475   IF (l_service_request_rec.sla_duration_1 = FND_API.G_MISS_NUM OR
18476       l_service_request_rec.sla_duration_1 = l_old_ServiceRequest_rec.sla_duration_1) THEN
18477       l_service_request_rec.sla_duration_1 := l_old_ServiceRequest_rec.sla_duration_1 ;
18478   END IF;
18479   IF (l_service_request_rec.sla_duration_2 = FND_API.G_MISS_NUM OR
18480       l_service_request_rec.sla_duration_2 = l_old_ServiceRequest_rec.sla_duration_2) THEN
18481       l_service_request_rec.sla_duration_2 := l_old_ServiceRequest_rec.sla_duration_2 ;
18482   END IF;
18483 
18484    --15995804. End Add price_list_header_id and SLA dates
18485 
18486 
18487 ---------------------------------------------------
18488 ----Added for Enhancements 11.5.6
18489     IF (l_service_request_rec.owner_group_id IS NOT NULL AND
18490         l_service_request_rec.owner_id IS NOT NULL) OR
18491        (l_service_request_rec.owner_group_id IS NOT NULL AND
18492            l_service_request_rec.group_type = 'RS_TEAM') THEN
18493          l_service_request_rec.owner_assigned_flag := 'Y';
18494     ELSIF (l_service_request_rec.owner_group_id IS NULL) THEN
18495          l_service_request_rec.owner_assigned_flag := 'N';
18496     END IF;
18497 --*************************************************
18498 
18499 --Added code to fix Bug# 1948054
18500 IF (p_validation_level = FND_API.G_VALID_LEVEL_NONE) THEN
18501     --
18502     -- Validate contract service id
18503     --
18504     IF (l_service_request_rec.contract_service_id <> FND_API.G_MISS_NUM AND
18505         l_service_request_rec.contract_service_id IS NOT NULL) THEN
18506 
18507         CS_ServiceRequest_UTIL.Validate_Contract_Service_Id(
18508           p_api_name         => l_api_name,
18509           p_parameter_name   => 'p_contract_service_id',
18510           p_contract_service_id => l_service_request_rec.contract_service_id,
18511           x_contract_id      =>x_contra_id,
18512           x_contract_number  =>x_contract_number,
18513           x_return_status    => l_return_status);
18514 
18515       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18516          x_return_status := FND_API.G_RET_STS_ERROR;
18517         RETURN;
18518       END IF;
18519           END IF;
18520 
18521     -- Validate contract id
18522     --
18523     IF (p_service_request_rec.contract_id <> FND_API.G_MISS_NUM) AND
18524         (p_service_request_rec.contract_id IS NOT NULL) AND
18525         (p_service_request_rec.contract_service_id IS NULL OR
18526          p_service_request_rec.contract_service_id = FND_API.G_MISS_NUM) THEN
18527 
18528         CS_ServiceRequest_UTIL.Validate_Contract_Id(
18529           p_api_name         => l_api_name,
18530           p_parameter_name   => 'p_contract_id',
18531           p_contract_id => l_service_request_rec.contract_id,
18532                 x_contract_number  => x_contract_number,
18533           x_return_status    => l_return_status);
18534 
18535       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18536          x_return_status := FND_API.G_RET_STS_ERROR;
18537         RETURN;
18538       END IF;
18539       x_contra_id := l_service_request_rec.contract_id;
18540 
18541     END IF;
18542 
18543  END IF;   --- p validation_level
18544 
18545    ---- Added this code because the form is clearing the group,
18546    ---- when group_type is not entered.
18547 
18548     IF (l_service_request_rec.owner_group_id IS NOT NULL AND
18549         l_service_request_rec.group_type IS NULL) THEN
18550          l_service_request_rec.owner_group_id := NULL;
18551     END IF;
18552 
18553   -- Added this code for source changes for 11.5.9 by shijain dated oct 11 2002
18554   -- this code is to check if the last_update_program_code is passed and is not
18555   -- null as this is a mandatory parameter.
18556 
18557   IF (l_service_request_rec.last_update_program_code = FND_API.G_MISS_CHAR  OR
18558       l_service_request_rec.last_update_program_code  IS NULL) THEN
18559 
18560       /*Commented this code for backward compatibility, that if someone
18561         passes a last update program code as NULL or G_MISS_CHAR, we are supporting
18562         it now and defaulting it to UNKNOWN
18563         CS_ServiceRequest_UTIL.Add_Null_Parameter_Msg
18564                         ( p_token_an     => l_api_name_full,
18565                           p_token_np     => 'SR Last Update Program Code',
18566                           p_table_name   => G_TABLE_NAME ,
18567                           p_column_name  => 'LAST_UPDATE_PROGRAM_CODE');
18568 
18569        RAISE FND_API.G_EXC_ERROR;
18570        */
18571        l_service_request_rec.last_update_program_code:='UNKNOWN';
18572   END IF;
18573 
18574     --
18575     -- Validate last update program code 10/11/02 shijain
18576     --
18577 
18578     IF (l_service_request_rec.last_update_program_code <> FND_API.G_MISS_CHAR) AND
18579         (l_service_request_rec.last_update_program_code IS NOT NULL) THEN
18580 
18581         CS_ServiceRequest_UTIL.Validate_source_program_code(
18582           p_api_name             => l_api_name,
18583           p_parameter_name       => 'p_last_update_program_code',
18584           p_source_program_code  => l_service_request_rec.last_update_program_code,
18585           x_return_status        => l_return_status);
18586 
18587       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18588          x_return_status := FND_API.G_RET_STS_ERROR;
18589         RETURN;
18590       END IF;
18591    END IF;
18592 
18593 -- Added for address by shijain 05 dec 2002
18594       IF (l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER <> FND_API.G_MISS_CHAR) AND
18595         (l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER IS NOT NULL) THEN
18596 
18597         CS_ServiceRequest_UTIL.Validate_INC_DIRECTION_QUAL(
18598           p_api_name             => l_api_name,
18599           p_parameter_name       => 'p_INC_DIRECTION_QUAL',
18600           p_INC_DIRECTION_QUAL  => l_service_request_rec.INCIDENT_DIRECTION_QUALIFIER,
18601           x_return_status        => l_return_status);
18602 
18603       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18604          x_return_status := FND_API.G_RET_STS_ERROR;
18605         RETURN;
18606       END IF;
18607    END IF;
18608 
18609 -- Added for address by shijain 05 dec 2002
18610     IF (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM <> FND_API.G_MISS_CHAR) AND
18611         (l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM IS NOT NULL) THEN
18612 
18613 
18614         CS_ServiceRequest_UTIL.Validate_INC_DIST_QUAL_UOM(
18615           p_api_name             => l_api_name,
18616           p_parameter_name       => 'p_INC_DIST_QUAL_UOM',
18617           p_INC_DIST_QUAL_UOM  => l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM,
18618           x_return_status        => l_return_status);
18619 
18620       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
18621          x_return_status := FND_API.G_RET_STS_ERROR;
18622         RETURN;
18623       END IF;
18624    END IF;
18625 
18626   x_audit_vals_rec.OLD_INCIDENT_NUMBER		:= l_old_ServiceRequest_rec.INCIDENT_NUMBER;
18627   x_audit_vals_rec.INCIDENT_NUMBER		:= l_old_ServiceRequest_rec.INCIDENT_NUMBER;
18628 
18629   x_audit_vals_rec.OLD_CUSTOMER_ID		:= l_old_ServiceRequest_rec.CUSTOMER_ID;
18630   IF (nvl(l_service_request_rec.CUSTOMER_ID,-99) <> FND_API.G_MISS_NUM) AND
18631     (nvl(l_service_request_rec.CUSTOMER_ID,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_ID,-99)) THEN
18632     x_audit_vals_rec.CUSTOMER_ID		:= l_service_request_rec.CUSTOMER_ID;
18633   ELSE
18634     x_audit_vals_rec.CUSTOMER_ID		:= l_old_ServiceRequest_rec.CUSTOMER_ID;
18635   END IF;
18636 
18637   x_audit_vals_rec.OLD_BILL_TO_SITE_USE_ID	:= l_old_ServiceRequest_rec.BILL_TO_SITE_USE_ID;
18638   IF (nvl(l_service_request_rec.BILL_TO_SITE_USE_ID,-99) <> FND_API.G_MISS_NUM) AND
18639     (nvl(l_service_request_rec.BILL_TO_SITE_USE_ID,-99) <> nvl(l_old_ServiceRequest_rec.BILL_TO_SITE_USE_ID,-99)) THEN
18640     x_audit_vals_rec.BILL_TO_SITE_USE_ID	:= l_service_request_rec.BILL_TO_SITE_USE_ID;
18641   ELSE
18642     x_audit_vals_rec.BILL_TO_SITE_USE_ID	:= l_old_ServiceRequest_rec.BILL_TO_SITE_USE_ID;
18643   END IF;
18644 
18645   x_audit_vals_rec.OLD_EMPLOYEE_ID		:= l_old_ServiceRequest_rec.EMPLOYEE_ID;
18646   IF (nvl(l_service_request_rec.EMPLOYEE_ID,-99) <> FND_API.G_MISS_NUM) AND
18647     (nvl(l_service_request_rec.EMPLOYEE_ID,-99) <> nvl(l_old_ServiceRequest_rec.EMPLOYEE_ID,-99)) THEN
18648     x_audit_vals_rec.EMPLOYEE_ID		:= l_service_request_rec.EMPLOYEE_ID;
18649   ELSE
18650     x_audit_vals_rec.EMPLOYEE_ID		:= l_old_ServiceRequest_rec.EMPLOYEE_ID;
18651   END IF;
18652 
18653   x_audit_vals_rec.OLD_SHIP_TO_SITE_USE_ID	:= l_old_ServiceRequest_rec.SHIP_TO_SITE_USE_ID;
18654   IF (nvl(l_service_request_rec.SHIP_TO_SITE_USE_ID,-99) <> FND_API.G_MISS_NUM) AND
18655     (nvl(l_service_request_rec.SHIP_TO_SITE_USE_ID,-99) <> nvl(l_old_ServiceRequest_rec.SHIP_TO_SITE_USE_ID,-99)) THEN
18656     x_audit_vals_rec.SHIP_TO_SITE_USE_ID	:= l_service_request_rec.SHIP_TO_SITE_USE_ID;
18657   ELSE
18658     x_audit_vals_rec.SHIP_TO_SITE_USE_ID	:= l_old_ServiceRequest_rec.SHIP_TO_SITE_USE_ID;
18659   END IF;
18660 
18661   x_audit_vals_rec.OLD_PROBLEM_CODE		:= l_old_ServiceRequest_rec.PROBLEM_CODE;
18662   IF (nvl(l_service_request_rec.PROBLEM_CODE,-99) <> FND_API.G_MISS_CHAR) AND
18663     (nvl(l_service_request_rec.PROBLEM_CODE,-99) <> nvl(l_old_ServiceRequest_rec.PROBLEM_CODE,-99)) THEN
18664     x_audit_vals_rec.PROBLEM_CODE		:= l_service_request_rec.PROBLEM_CODE;
18665   ELSE
18666     x_audit_vals_rec.PROBLEM_CODE		:= l_old_ServiceRequest_rec.PROBLEM_CODE;
18667   END IF;
18668 
18669   x_audit_vals_rec.OLD_ACTUAL_RESOLUTION_DATE	:= l_old_ServiceRequest_rec.ACTUAL_RESOLUTION_DATE;
18670   IF (nvl(l_service_request_rec.ACT_RESOLUTION_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
18671     (nvl(l_service_request_rec.ACT_RESOLUTION_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
18672         nvl(l_old_ServiceRequest_rec.ACTUAL_RESOLUTION_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
18673     x_audit_vals_rec.ACTUAL_RESOLUTION_DATE	:= l_service_request_rec.ACT_RESOLUTION_DATE;
18674   ELSE
18675     x_audit_vals_rec.ACTUAL_RESOLUTION_DATE	:= l_old_ServiceRequest_rec.ACTUAL_RESOLUTION_DATE;
18676   END IF;
18677 
18678   x_audit_vals_rec.OLD_INSTALL_SITE_USE_ID	:= l_old_ServiceRequest_rec.INSTALL_SITE_USE_ID;
18679   IF (nvl(l_service_request_rec.INSTALL_SITE_USE_ID,-99) <> FND_API.G_MISS_NUM) AND
18680     (nvl(l_service_request_rec.INSTALL_SITE_USE_ID,-99) <> nvl(l_old_ServiceRequest_rec.INSTALL_SITE_USE_ID,-99)) THEN
18681     x_audit_vals_rec.INSTALL_SITE_USE_ID	:= l_service_request_rec.INSTALL_SITE_USE_ID;
18682   ELSE
18683     x_audit_vals_rec.INSTALL_SITE_USE_ID	:= l_old_ServiceRequest_rec.INSTALL_SITE_USE_ID;
18684   END IF;
18685 
18686   x_audit_vals_rec.OLD_CURRENT_SERIAL_NUMBER	:= l_old_ServiceRequest_rec.CURRENT_SERIAL_NUMBER;
18687   IF (nvl(l_service_request_rec.CURRENT_SERIAL_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
18688     (nvl(l_service_request_rec.CURRENT_SERIAL_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.CURRENT_SERIAL_NUMBER,-99)) THEN
18689     x_audit_vals_rec.CURRENT_SERIAL_NUMBER	:= l_service_request_rec.CURRENT_SERIAL_NUMBER;
18690   ELSE
18691     x_audit_vals_rec.CURRENT_SERIAL_NUMBER	:= l_old_ServiceRequest_rec.CURRENT_SERIAL_NUMBER;
18692   END IF;
18693 
18694   x_audit_vals_rec.OLD_SYSTEM_ID		:= l_old_ServiceRequest_rec.SYSTEM_ID;
18695   IF (nvl(l_service_request_rec.SYSTEM_ID,-99) <> FND_API.G_MISS_NUM) AND
18696     (nvl(l_service_request_rec.SYSTEM_ID,-99) <> nvl(l_old_ServiceRequest_rec.SYSTEM_ID,-99)) THEN
18697     x_audit_vals_rec.SYSTEM_ID			:= l_service_request_rec.SYSTEM_ID;
18698   ELSE
18699     x_audit_vals_rec.SYSTEM_ID			:= l_old_ServiceRequest_rec.SYSTEM_ID;
18700   END IF;
18701 
18702   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_1	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_1;
18703   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_1,-99) <> FND_API.G_MISS_CHAR) AND
18704     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_1,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_1,-99)) THEN
18705     x_audit_vals_rec.INCIDENT_ATTRIBUTE_1	:= l_service_request_rec.REQUEST_ATTRIBUTE_1;
18706   ELSE
18707     x_audit_vals_rec.INCIDENT_ATTRIBUTE_1	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_1;
18708   END IF;
18709 
18710 
18711   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_2	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_2;
18712   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_2,-99) <> FND_API.G_MISS_CHAR) AND
18713     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_2,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_2,-99)) THEN
18714     x_audit_vals_rec.INCIDENT_ATTRIBUTE_2	:= l_service_request_rec.REQUEST_ATTRIBUTE_2;
18715   ELSE
18716     x_audit_vals_rec.INCIDENT_ATTRIBUTE_2	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_2;
18717   END IF;
18718 
18719   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_3	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_3;
18720   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_3,-99) <> FND_API.G_MISS_CHAR) AND
18721     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_3,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_3,-99)) THEN
18722     x_audit_vals_rec.INCIDENT_ATTRIBUTE_3	:= l_service_request_rec.REQUEST_ATTRIBUTE_3;
18723   ELSE
18724     x_audit_vals_rec.INCIDENT_ATTRIBUTE_3	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_3;
18725   END IF;
18726 
18727   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_4	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_4;
18728   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_4,-99) <> FND_API.G_MISS_CHAR) AND
18729     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_4,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_4,-99)) THEN
18730     x_audit_vals_rec.INCIDENT_ATTRIBUTE_4	:= l_service_request_rec.REQUEST_ATTRIBUTE_4;
18731   ELSE
18732     x_audit_vals_rec.INCIDENT_ATTRIBUTE_4	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_4;
18733   END IF;
18734 
18735   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_5	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_5;
18736   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_5,-99) <> FND_API.G_MISS_CHAR) AND
18737     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_5,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_5,-99)) THEN
18738     x_audit_vals_rec.INCIDENT_ATTRIBUTE_5	:= l_service_request_rec.REQUEST_ATTRIBUTE_5;
18739   ELSE
18740     x_audit_vals_rec.INCIDENT_ATTRIBUTE_5	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_5;
18741   END IF;
18742 
18743   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_6	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_6;
18744   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_6,-99) <> FND_API.G_MISS_CHAR) AND
18745     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_6,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_6,-99)) THEN
18746     x_audit_vals_rec.INCIDENT_ATTRIBUTE_6	:= l_service_request_rec.REQUEST_ATTRIBUTE_6;
18747   ELSE
18748     x_audit_vals_rec.INCIDENT_ATTRIBUTE_6	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_6;
18749   END IF;
18750 
18751   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_7	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_7;
18752   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_7,-99) <> FND_API.G_MISS_CHAR) AND
18753     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_7,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_7,-99)) THEN
18754     x_audit_vals_rec.INCIDENT_ATTRIBUTE_7	:= l_service_request_rec.REQUEST_ATTRIBUTE_7;
18755   ELSE
18756     x_audit_vals_rec.INCIDENT_ATTRIBUTE_7	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_7;
18757   END IF;
18758 
18759   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_8	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_8;
18760   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_8,-99) <> FND_API.G_MISS_CHAR) AND
18761     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_8,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_8,-99)) THEN
18762     x_audit_vals_rec.INCIDENT_ATTRIBUTE_8	:= l_service_request_rec.REQUEST_ATTRIBUTE_8;
18763   ELSE
18764     x_audit_vals_rec.INCIDENT_ATTRIBUTE_8	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_8;
18765   END IF;
18766 
18767   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_9	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_9;
18768   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_9,-99) <> FND_API.G_MISS_CHAR) AND
18769     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_9,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_9,-99)) THEN
18770     x_audit_vals_rec.INCIDENT_ATTRIBUTE_9	:= l_service_request_rec.REQUEST_ATTRIBUTE_9;
18771   ELSE
18772     x_audit_vals_rec.INCIDENT_ATTRIBUTE_9	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_9;
18773   END IF;
18774 
18775   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_10	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_10;
18776   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_10,-99) <> FND_API.G_MISS_CHAR) AND
18777     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_10,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_10,-99)) THEN
18778     x_audit_vals_rec.INCIDENT_ATTRIBUTE_10	:= l_service_request_rec.REQUEST_ATTRIBUTE_10;
18779   ELSE
18780     x_audit_vals_rec.INCIDENT_ATTRIBUTE_10	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_10;
18781   END IF;
18782 
18783   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_11	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_11;
18784   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_11,-99) <> FND_API.G_MISS_CHAR) AND
18785     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_11,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_11,-99)) THEN
18786     x_audit_vals_rec.INCIDENT_ATTRIBUTE_11	:= l_service_request_rec.REQUEST_ATTRIBUTE_11;
18787   ELSE
18788     x_audit_vals_rec.INCIDENT_ATTRIBUTE_11	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_11;
18789   END IF;
18790 
18791   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_12	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_12;
18792   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_12,-99) <> FND_API.G_MISS_CHAR) AND
18793     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_12,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_12,-99)) THEN
18794     x_audit_vals_rec.INCIDENT_ATTRIBUTE_12	:= l_service_request_rec.REQUEST_ATTRIBUTE_12;
18795   ELSE
18796     x_audit_vals_rec.INCIDENT_ATTRIBUTE_12	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_12;
18797   END IF;
18798 
18799   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_13	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_13;
18800   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_13,-99) <> FND_API.G_MISS_CHAR) AND
18801     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_13,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_13,-99)) THEN
18802     x_audit_vals_rec.INCIDENT_ATTRIBUTE_13	:= l_service_request_rec.REQUEST_ATTRIBUTE_13;
18803   ELSE
18804     x_audit_vals_rec.INCIDENT_ATTRIBUTE_13	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_13;
18805   END IF;
18806 
18807   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_14	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_14;
18808   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_14,-99) <> FND_API.G_MISS_CHAR) AND
18809     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_14,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_14,-99)) THEN
18810     x_audit_vals_rec.INCIDENT_ATTRIBUTE_14	:= l_service_request_rec.REQUEST_ATTRIBUTE_14;
18811   ELSE
18812     x_audit_vals_rec.INCIDENT_ATTRIBUTE_14	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_14;
18813   END IF;
18814 
18815   x_audit_vals_rec.OLD_INCIDENT_ATTRIBUTE_15	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_15;
18816   IF (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_15,-99) <> FND_API.G_MISS_CHAR) AND
18817     (nvl(l_service_request_rec.REQUEST_ATTRIBUTE_15,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_15,-99)) THEN
18818     x_audit_vals_rec.INCIDENT_ATTRIBUTE_15	:= l_service_request_rec.REQUEST_ATTRIBUTE_15;
18819   ELSE
18820     x_audit_vals_rec.INCIDENT_ATTRIBUTE_15	:= l_old_ServiceRequest_rec.INCIDENT_ATTRIBUTE_15;
18821   END IF;
18822 
18823   x_audit_vals_rec.OLD_INCIDENT_CONTEXT		:= l_old_ServiceRequest_rec.INCIDENT_CONTEXT;
18824   IF (nvl(l_service_request_rec.REQUEST_CONTEXT,-99) <> FND_API.G_MISS_CHAR) AND
18825     (nvl(l_service_request_rec.REQUEST_CONTEXT,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_CONTEXT,-99)) THEN
18826     x_audit_vals_rec.INCIDENT_CONTEXT		:= l_service_request_rec.REQUEST_CONTEXT;
18827   ELSE
18828     x_audit_vals_rec.INCIDENT_CONTEXT		:= l_old_ServiceRequest_rec.INCIDENT_CONTEXT;
18829   END IF;
18830 
18831   x_audit_vals_rec.OLD_RESOLUTION_CODE		:= l_old_ServiceRequest_rec.RESOLUTION_CODE;
18832   IF (nvl(l_service_request_rec.RESOLUTION_CODE,-99) <> FND_API.G_MISS_CHAR) AND
18833     (nvl(l_service_request_rec.RESOLUTION_CODE,-99) <> nvl(l_old_ServiceRequest_rec.RESOLUTION_CODE,-99)) THEN
18834     x_audit_vals_rec.RESOLUTION_CODE		:= l_service_request_rec.RESOLUTION_CODE;
18835   ELSE
18836     x_audit_vals_rec.RESOLUTION_CODE		:= l_old_ServiceRequest_rec.RESOLUTION_CODE;
18837   END IF;
18838 
18839   x_audit_vals_rec.OLD_ORIGINAL_ORDER_NUMBER	:= l_old_ServiceRequest_rec.ORIGINAL_ORDER_NUMBER;
18840   IF (nvl(l_service_request_rec.ORIGINAL_ORDER_NUMBER,-99) <> FND_API.G_MISS_NUM) AND
18841     (nvl(l_service_request_rec.ORIGINAL_ORDER_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.ORIGINAL_ORDER_NUMBER,-99)) THEN
18842     x_audit_vals_rec.ORIGINAL_ORDER_NUMBER	:= l_service_request_rec.ORIGINAL_ORDER_NUMBER;
18843   ELSE
18844     x_audit_vals_rec.ORIGINAL_ORDER_NUMBER	:= l_old_ServiceRequest_rec.ORIGINAL_ORDER_NUMBER;
18845   END IF;
18846 
18847   /* Could not populate this column as no equivalent column was found in l_service_request_rec */
18848   /*
18849   IF (nvl(l_service_request_rec.,-99) <> FND_API.G_MISS_NUM) AND
18850     (nvl(l_service_request_rec. ,-99)) THEN
18851     x_audit_vals_rec.ORG_ID			:= l_service_request_rec.;
18852   END IF;
18853   */
18854 
18855   x_audit_vals_rec.OLD_PURCHASE_ORDER_NUMBER	:= l_old_ServiceRequest_rec.PURCHASE_ORDER_NUM;
18856   IF (nvl(l_service_request_rec.PURCHASE_ORDER_NUM,-99) <> FND_API.G_MISS_CHAR) AND
18857     (nvl(l_service_request_rec.PURCHASE_ORDER_NUM,-99) <> nvl(l_old_ServiceRequest_rec.PURCHASE_ORDER_NUM,-99)) THEN
18858     x_audit_vals_rec.PURCHASE_ORDER_NUMBER	:= l_service_request_rec.PURCHASE_ORDER_NUM;
18859   ELSE
18860     x_audit_vals_rec.PURCHASE_ORDER_NUMBER	:= l_old_ServiceRequest_rec.PURCHASE_ORDER_NUM;
18861   END IF;
18862 
18863   x_audit_vals_rec.OLD_PUBLISH_FLAG		:= l_old_ServiceRequest_rec.PUBLISH_FLAG;
18864   IF (nvl(l_service_request_rec.PUBLISH_FLAG,-99) <> FND_API.G_MISS_CHAR) AND
18865     (nvl(l_service_request_rec.PUBLISH_FLAG,-99) <> nvl(l_old_ServiceRequest_rec.PUBLISH_FLAG,-99)) THEN
18866     x_audit_vals_rec.PUBLISH_FLAG		:= l_service_request_rec.PUBLISH_FLAG;
18867   ELSE
18868     x_audit_vals_rec.PUBLISH_FLAG		:= l_old_ServiceRequest_rec.PUBLISH_FLAG;
18869   END IF;
18870 
18871   x_audit_vals_rec.OLD_QA_COLLECTION_ID		:= l_old_ServiceRequest_rec.QA_COLLECTION_ID;
18872   IF (nvl(l_service_request_rec.QA_COLLECTION_PLAN_ID,-99) <> FND_API.G_MISS_NUM) AND
18873     (nvl(l_service_request_rec.QA_COLLECTION_PLAN_ID,-99) <> nvl(l_old_ServiceRequest_rec.QA_COLLECTION_ID,-99)) THEN
18874     x_audit_vals_rec.QA_COLLECTION_ID		:= l_service_request_rec.QA_COLLECTION_PLAN_ID;
18875   ELSE
18876     x_audit_vals_rec.QA_COLLECTION_ID		:= l_old_ServiceRequest_rec.QA_COLLECTION_ID;
18877   END IF;
18878 
18879   x_audit_vals_rec.OLD_CONTRACT_ID		:= l_old_ServiceRequest_rec.CONTRACT_ID;
18880   IF (nvl(l_service_request_rec.CONTRACT_ID,-99) <> FND_API.G_MISS_NUM) AND
18881     (nvl(l_service_request_rec.CONTRACT_ID,-99) <> nvl(l_old_ServiceRequest_rec.CONTRACT_ID,-99)) THEN
18882     x_audit_vals_rec.CONTRACT_ID		:= l_service_request_rec.CONTRACT_ID;
18883   ELSE
18884     x_audit_vals_rec.CONTRACT_ID		:= l_old_ServiceRequest_rec.CONTRACT_ID;
18885   END IF;
18886 
18887   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
18888   /*
18889   IF (nvl(l_service_request_rec.,-99) <> FND_API.G_MISS_CHAR) AND
18890     (nvl(l_service_request_rec. ,-99)) THEN
18891     x_audit_vals_rec.CONTRACT_NUMBER		:= l_service_request_rec.;
18892   END IF;
18893   */
18894 
18895   x_audit_vals_rec.OLD_CONTRACT_SERVICE_ID	:= l_old_ServiceRequest_rec.CONTRACT_SERVICE_ID;
18896   IF (nvl(l_service_request_rec.CONTRACT_SERVICE_ID,-99) <> FND_API.G_MISS_NUM) AND
18897     (nvl(l_service_request_rec.CONTRACT_SERVICE_ID,-99) <> nvl(l_old_ServiceRequest_rec.CONTRACT_SERVICE_ID,-99)) THEN
18898     x_audit_vals_rec.CONTRACT_SERVICE_ID	:= l_service_request_rec.CONTRACT_SERVICE_ID;
18899   ELSE
18900     x_audit_vals_rec.CONTRACT_SERVICE_ID	:= l_old_ServiceRequest_rec.CONTRACT_SERVICE_ID;
18901   END IF;
18902 
18903   x_audit_vals_rec.OLD_TIME_ZONE_ID		:= l_old_ServiceRequest_rec.TIME_ZONE_ID;
18904   IF (nvl(l_service_request_rec.TIME_ZONE_ID,-99) <> FND_API.G_MISS_NUM) AND
18905     (nvl(l_service_request_rec.TIME_ZONE_ID,-99) <> nvl(l_old_ServiceRequest_rec.TIME_ZONE_ID,-99)) THEN
18906     x_audit_vals_rec.TIME_ZONE_ID		:= l_service_request_rec.TIME_ZONE_ID;
18907   ELSE
18908     x_audit_vals_rec.TIME_ZONE_ID		:= l_old_ServiceRequest_rec.TIME_ZONE_ID;
18909   END IF;
18910 
18911   x_audit_vals_rec.OLD_ACCOUNT_ID		:= l_old_ServiceRequest_rec.ACCOUNT_ID;
18912   IF (nvl(l_service_request_rec.ACCOUNT_ID,-99) <> FND_API.G_MISS_NUM) AND
18913     (nvl(l_service_request_rec.ACCOUNT_ID,-99) <> nvl(l_old_ServiceRequest_rec.ACCOUNT_ID,-99)) THEN
18914     x_audit_vals_rec.ACCOUNT_ID			:= l_service_request_rec.ACCOUNT_ID;
18915   ELSE
18916     x_audit_vals_rec.ACCOUNT_ID			:= l_old_ServiceRequest_rec.ACCOUNT_ID;
18917   END IF;
18918 
18919   x_audit_vals_rec.OLD_TIME_DIFFERENCE		:= l_old_ServiceRequest_rec.TIME_DIFFERENCE;
18920   IF (nvl(l_service_request_rec.TIME_DIFFERENCE,-99) <> FND_API.G_MISS_NUM) AND
18921     (nvl(l_service_request_rec.TIME_DIFFERENCE,-99) <> nvl(l_old_ServiceRequest_rec.TIME_DIFFERENCE,-99)) THEN
18922     x_audit_vals_rec.TIME_DIFFERENCE		:= l_service_request_rec.TIME_DIFFERENCE;
18923   ELSE
18924     x_audit_vals_rec.TIME_DIFFERENCE		:= l_old_ServiceRequest_rec.TIME_DIFFERENCE;
18925   END IF;
18926 
18927   x_audit_vals_rec.OLD_CUSTOMER_PO_NUMBER	:= l_old_ServiceRequest_rec.CUSTOMER_PO_NUMBER;
18928   IF (nvl(l_service_request_rec.CUST_PO_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
18929     (nvl(l_service_request_rec.CUST_PO_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_PO_NUMBER,-99)) THEN
18930     x_audit_vals_rec.CUSTOMER_PO_NUMBER		:= l_service_request_rec.CUST_PO_NUMBER;
18931   ELSE
18932     x_audit_vals_rec.CUSTOMER_PO_NUMBER		:= l_old_ServiceRequest_rec.CUSTOMER_PO_NUMBER;
18933   END IF;
18934 
18935   x_audit_vals_rec.OLD_CUSTOMER_TICKET_NUMBER	:= l_old_ServiceRequest_rec.CUSTOMER_TICKET_NUMBER;
18936   IF (nvl(l_service_request_rec.CUST_TICKET_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
18937     (nvl(l_service_request_rec.CUST_TICKET_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_TICKET_NUMBER,-99)) THEN
18938     x_audit_vals_rec.CUSTOMER_TICKET_NUMBER	:= l_service_request_rec.CUST_TICKET_NUMBER;
18939   ELSE
18940     x_audit_vals_rec.CUSTOMER_TICKET_NUMBER	:= l_old_ServiceRequest_rec.CUSTOMER_TICKET_NUMBER;
18941   END IF;
18942 
18943   x_audit_vals_rec.OLD_CUSTOMER_SITE_ID		:= l_old_ServiceRequest_rec.CUSTOMER_SITE_ID;
18944   IF (nvl(l_service_request_rec.CUSTOMER_SITE_ID,-99) <> FND_API.G_MISS_NUM) AND
18945     (nvl(l_service_request_rec.CUSTOMER_SITE_ID,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_SITE_ID,-99)) THEN
18946     x_audit_vals_rec.CUSTOMER_SITE_ID		:= l_service_request_rec.CUSTOMER_SITE_ID;
18947   ELSE
18948     x_audit_vals_rec.CUSTOMER_SITE_ID		:= l_old_ServiceRequest_rec.CUSTOMER_SITE_ID;
18949   END IF;
18950 
18951   x_audit_vals_rec.OLD_CALLER_TYPE		:= l_old_ServiceRequest_rec.CALLER_TYPE;
18952   IF (nvl(l_service_request_rec.CALLER_TYPE,-99) <> FND_API.G_MISS_CHAR) AND
18953     (nvl(l_service_request_rec.CALLER_TYPE,-99) <> nvl(l_old_ServiceRequest_rec.CALLER_TYPE,-99)) THEN
18954     x_audit_vals_rec.CALLER_TYPE		:= l_service_request_rec.CALLER_TYPE;
18955   ELSE
18956     x_audit_vals_rec.CALLER_TYPE		:= l_old_ServiceRequest_rec.CALLER_TYPE;
18957   END IF;
18958 
18959   x_audit_vals_rec.OLD_PROJECT_NUMBER		:= l_old_ServiceRequest_rec.PROJECT_NUMBER;
18960   IF (nvl(l_service_request_rec.PROJECT_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
18961     (nvl(l_service_request_rec.PROJECT_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.PROJECT_NUMBER,-99)) THEN
18962     x_audit_vals_rec.PROJECT_NUMBER		:= l_service_request_rec.PROJECT_NUMBER;
18963   ELSE
18964     x_audit_vals_rec.PROJECT_NUMBER		:= l_old_ServiceRequest_rec.PROJECT_NUMBER;
18965   END IF;
18966 
18967   x_audit_vals_rec.OLD_PLATFORM_VERSION		:= l_old_ServiceRequest_rec.PLATFORM_VERSION;
18968   IF (nvl(l_service_request_rec.PLATFORM_VERSION,-99) <> FND_API.G_MISS_CHAR) AND
18969     (nvl(l_service_request_rec.PLATFORM_VERSION,-99) <> nvl(l_old_ServiceRequest_rec.PLATFORM_VERSION,-99)) THEN
18970     x_audit_vals_rec.PLATFORM_VERSION		:= l_service_request_rec.PLATFORM_VERSION;
18971   ELSE
18972     x_audit_vals_rec.PLATFORM_VERSION		:= l_old_ServiceRequest_rec.PLATFORM_VERSION;
18973   END IF;
18974 
18975   x_audit_vals_rec.OLD_PLATFORM_VERSION_ID      := l_old_ServiceRequest_rec.PLATFORM_VERSION_ID;
18976   IF (nvl(l_service_request_rec.PLATFORM_VERSION_ID,-99) <> FND_API.G_MISS_NUM) AND
18977     (nvl(l_service_request_rec.PLATFORM_VERSION_ID,-99) <> nvl(l_old_ServiceRequest_rec.PLATFORM_VERSION_ID,-99)) THEN
18978     x_audit_vals_rec.PLATFORM_VERSION_ID           := l_service_request_rec.PLATFORM_VERSION_ID;
18979   ELSE
18980     x_audit_vals_rec.PLATFORM_VERSION_ID           := l_old_ServiceRequest_rec.PLATFORM_VERSION_ID;
18981   END IF;
18982 
18983   x_audit_vals_rec.OLD_inv_platform_org_id      := l_old_ServiceRequest_rec.inv_platform_org_id;
18984   IF (nvl(l_service_request_rec.inv_platform_org_id,-99) <> FND_API.G_MISS_NUM) AND
18985       nvl(l_service_request_rec.inv_platform_org_id,-99) <> nvl(l_old_ServiceRequest_rec.inv_platform_org_id,-99)
18986      THEN
18987      x_audit_vals_rec.inv_platform_org_id          := l_service_request_rec.inv_platform_org_id;
18988   ELSE
18989      x_audit_vals_rec.inv_platform_org_id          := l_old_ServiceRequest_rec.inv_platform_org_id;
18990   END IF;
18991 
18992   x_audit_vals_rec.OLD_DB_VERSION		:= l_old_ServiceRequest_rec.DB_VERSION;
18993   IF (nvl(l_service_request_rec.DB_VERSION,-99) <> FND_API.G_MISS_CHAR) AND
18994     (nvl(l_service_request_rec.DB_VERSION,-99) <> nvl(l_old_ServiceRequest_rec.DB_VERSION,-99)) THEN
18995     x_audit_vals_rec.DB_VERSION			:= l_service_request_rec.DB_VERSION;
18996   ELSE
18997     x_audit_vals_rec.DB_VERSION			:= l_old_ServiceRequest_rec.DB_VERSION;
18998   END IF;
18999 
19000   x_audit_vals_rec.OLD_CUST_PREF_LANG_ID	:= l_old_ServiceRequest_rec.CUST_PREF_LANG_ID;
19001   IF (nvl(l_service_request_rec.CUST_PREF_LANG_ID,-99) <> FND_API.G_MISS_NUM) AND
19002     (nvl(l_service_request_rec.CUST_PREF_LANG_ID,-99) <> nvl(l_old_ServiceRequest_rec.CUST_PREF_LANG_ID,-99)) THEN
19003     x_audit_vals_rec.CUST_PREF_LANG_ID		:= l_service_request_rec.CUST_PREF_LANG_ID;
19004   ELSE
19005     x_audit_vals_rec.CUST_PREF_LANG_ID		:= l_old_ServiceRequest_rec.CUST_PREF_LANG_ID;
19006   END IF;
19007 
19008   x_audit_vals_rec.OLD_TIER			:= l_old_ServiceRequest_rec.TIER;
19009   IF (nvl(l_service_request_rec.TIER,-99) <> FND_API.G_MISS_CHAR) AND
19010     (nvl(l_service_request_rec.TIER,-99) <> nvl(l_old_ServiceRequest_rec.TIER,-99)) THEN
19011     x_audit_vals_rec.TIER			:= l_service_request_rec.TIER;
19012   ELSE
19013     x_audit_vals_rec.TIER			:= l_old_ServiceRequest_rec.TIER;
19014   END IF;
19015 
19016   x_audit_vals_rec.OLD_CATEGORY_ID		:= l_old_ServiceRequest_rec.CATEGORY_ID;
19017   IF (nvl(l_service_request_rec.CATEGORY_ID,-99) <> FND_API.G_MISS_NUM) AND
19018     (nvl(l_service_request_rec.CATEGORY_ID,-99) <> nvl(l_old_ServiceRequest_rec.CATEGORY_ID,-99)) THEN
19019     x_audit_vals_rec.CATEGORY_ID		:= l_service_request_rec.CATEGORY_ID;
19020   ELSE
19021     x_audit_vals_rec.CATEGORY_ID		:= l_old_ServiceRequest_rec.CATEGORY_ID;
19022   END IF;
19023 
19024   x_audit_vals_rec.OLD_OPERATING_SYSTEM		:= l_old_ServiceRequest_rec.OPERATING_SYSTEM;
19025   IF (nvl(l_service_request_rec.OPERATING_SYSTEM,-99) <> FND_API.G_MISS_CHAR) AND
19026     (nvl(l_service_request_rec.OPERATING_SYSTEM,-99) <> nvl(l_old_ServiceRequest_rec.OPERATING_SYSTEM,-99)) THEN
19027     x_audit_vals_rec.OPERATING_SYSTEM		:= l_service_request_rec.OPERATING_SYSTEM;
19028   ELSE
19029     x_audit_vals_rec.OPERATING_SYSTEM		:= l_old_ServiceRequest_rec.OPERATING_SYSTEM;
19030   END IF;
19031 
19032   x_audit_vals_rec.OLD_OPERATING_SYSTEM_VERSION	:= l_old_ServiceRequest_rec.OPERATING_SYSTEM_VERSION;
19033   IF (nvl(l_service_request_rec.OPERATING_SYSTEM_VERSION,-99) <> FND_API.G_MISS_CHAR) AND
19034     (nvl(l_service_request_rec.OPERATING_SYSTEM_VERSION,-99) <> nvl(l_old_ServiceRequest_rec.OPERATING_SYSTEM_VERSION,-99)) THEN
19035     x_audit_vals_rec.OPERATING_SYSTEM_VERSION	:= l_service_request_rec.OPERATING_SYSTEM_VERSION;
19036   ELSE
19037     x_audit_vals_rec.OPERATING_SYSTEM_VERSION	:= l_old_ServiceRequest_rec.OPERATING_SYSTEM_VERSION;
19038   END IF;
19039 
19040 
19041   x_audit_vals_rec.OLD_DATABASE			:= l_old_ServiceRequest_rec.DATABASE;
19042   IF (nvl(l_service_request_rec.DATABASE,-99) <> FND_API.G_MISS_CHAR) AND
19043     (nvl(l_service_request_rec.DATABASE,-99) <> nvl(l_old_ServiceRequest_rec.DATABASE,-99)) THEN
19044     x_audit_vals_rec.DATABASE			:= l_service_request_rec.DATABASE;
19045   ELSE
19046     x_audit_vals_rec.DATABASE			:= l_old_ServiceRequest_rec.DATABASE;
19047   END IF;
19048 
19049   x_audit_vals_rec.OLD_GROUP_TERRITORY_ID	:= l_old_ServiceRequest_rec.GROUP_TERRITORY_ID;
19050   IF (nvl(l_service_request_rec.GROUP_TERRITORY_ID,-99) <> FND_API.G_MISS_NUM) AND
19051     (nvl(l_service_request_rec.GROUP_TERRITORY_ID,-99) <> nvl(l_old_ServiceRequest_rec.GROUP_TERRITORY_ID,-99)) THEN
19052     x_audit_vals_rec.GROUP_TERRITORY_ID		:= l_service_request_rec.GROUP_TERRITORY_ID;
19053   ELSE
19054     x_audit_vals_rec.GROUP_TERRITORY_ID		:= l_old_ServiceRequest_rec.GROUP_TERRITORY_ID;
19055   END IF;
19056     IF (l_service_request_rec.territory_id = FND_API.G_MISS_NUM) OR
19057        (nvl(l_service_request_rec.territory_id,-99) = nvl(l_old_ServiceRequest_rec.territory_id,-99)) THEN
19058       x_audit_vals_rec.change_territory_id_flag := 'N';
19059       x_audit_vals_rec.old_territory_id         := l_old_ServiceRequest_rec.territory_id;
19060       x_audit_vals_rec.territory_id             := l_old_ServiceRequest_rec.territory_id;
19061     ELSE
19062       x_audit_vals_rec.change_territory_id_FLAG := 'Y';
19063       x_audit_vals_rec.OLD_territory_id := l_old_ServiceRequest_rec.territory_id;
19064       x_audit_vals_rec.territory_id := l_service_request_rec.territory_id;
19065     END IF;
19066 
19067   x_audit_vals_rec.OLD_COMM_PREF_CODE	:= l_old_ServiceRequest_rec.COMM_PREF_CODE;
19068   IF (nvl(l_service_request_rec.COMM_PREF_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19069     (nvl(l_service_request_rec.COMM_PREF_CODE,-99) <> nvl(l_old_ServiceRequest_rec.COMM_PREF_CODE,-99)) THEN
19070     x_audit_vals_rec.COMM_PREF_CODE		:= l_service_request_rec.COMM_PREF_CODE;
19071   ELSE
19072     x_audit_vals_rec.COMM_PREF_CODE		:= l_old_ServiceRequest_rec.COMM_PREF_CODE;
19073   END IF;
19074 
19075   x_audit_vals_rec.OLD_LAST_UPDATE_CHANNEL	:= l_old_ServiceRequest_rec.LAST_UPDATE_CHANNEL;
19076   IF (nvl(l_service_request_rec.LAST_UPDATE_CHANNEL,-99) <> FND_API.G_MISS_CHAR) AND
19077     (nvl(l_service_request_rec.LAST_UPDATE_CHANNEL,-99) <> nvl(l_old_ServiceRequest_rec.LAST_UPDATE_CHANNEL,-99)) THEN
19078     x_audit_vals_rec.LAST_UPDATE_CHANNEL	:= l_service_request_rec.LAST_UPDATE_CHANNEL;
19079   ELSE
19080     x_audit_vals_rec.LAST_UPDATE_CHANNEL	:= l_old_ServiceRequest_rec.LAST_UPDATE_CHANNEL;
19081   END IF;
19082 
19083   x_audit_vals_rec.OLD_CUST_PREF_LANG_CODE	:= l_old_ServiceRequest_rec.CUST_PREF_LANG_CODE;
19084   IF (nvl(l_service_request_rec.CUST_PREF_LANG_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19085     (nvl(l_service_request_rec.CUST_PREF_LANG_CODE,-99) <> nvl(l_old_ServiceRequest_rec.CUST_PREF_LANG_CODE,-99)) THEN
19086     x_audit_vals_rec.CUST_PREF_LANG_CODE	:= l_service_request_rec.CUST_PREF_LANG_CODE;
19087   ELSE
19088     x_audit_vals_rec.CUST_PREF_LANG_CODE	:= l_old_ServiceRequest_rec.CUST_PREF_LANG_CODE;
19089   END IF;
19090 
19091   x_audit_vals_rec.OLD_ERROR_CODE		:= l_old_ServiceRequest_rec.ERROR_CODE;
19092   IF (nvl(l_service_request_rec.ERROR_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19093     (nvl(l_service_request_rec.ERROR_CODE,-99) <> nvl(l_old_ServiceRequest_rec.ERROR_CODE,-99)) THEN
19094     x_audit_vals_rec.ERROR_CODE			:= l_service_request_rec.ERROR_CODE;
19095   ELSE
19096     x_audit_vals_rec.ERROR_CODE			:= l_old_ServiceRequest_rec.ERROR_CODE;
19097   END IF;
19098 
19099   x_audit_vals_rec.OLD_CATEGORY_SET_ID		:= l_old_ServiceRequest_rec.CATEGORY_SET_ID;
19100   IF (nvl(l_service_request_rec.CATEGORY_SET_ID,-99) <> FND_API.G_MISS_NUM) AND
19101     (nvl(l_service_request_rec.CATEGORY_SET_ID,-99) <> nvl(l_old_ServiceRequest_rec.CATEGORY_SET_ID,-99)) THEN
19102     x_audit_vals_rec.CATEGORY_SET_ID		:= l_service_request_rec.CATEGORY_SET_ID;
19103   ELSE
19104     x_audit_vals_rec.CATEGORY_SET_ID		:= l_old_ServiceRequest_rec.CATEGORY_SET_ID;
19105   END IF;
19106 
19107   x_audit_vals_rec.OLD_EXTERNAL_REFERENCE	:= l_old_ServiceRequest_rec.EXTERNAL_REFERENCE;
19108   IF (nvl(l_service_request_rec.EXTERNAL_REFERENCE,-99) <> FND_API.G_MISS_CHAR) AND
19109     (nvl(l_service_request_rec.EXTERNAL_REFERENCE,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_REFERENCE,-99)) THEN
19110     x_audit_vals_rec.EXTERNAL_REFERENCE		:= l_service_request_rec.EXTERNAL_REFERENCE;
19111   ELSE
19112     x_audit_vals_rec.EXTERNAL_REFERENCE		:= l_old_ServiceRequest_rec.EXTERNAL_REFERENCE;
19113   END IF;
19114 
19115   x_audit_vals_rec.OLD_INCIDENT_OCCURRED_DATE	:= l_old_ServiceRequest_rec.INCIDENT_OCCURRED_DATE;
19116   IF (nvl(l_service_request_rec.INCIDENT_OCCURRED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19117     (nvl(l_service_request_rec.INCIDENT_OCCURRED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19118         nvl(l_old_ServiceRequest_rec.INCIDENT_OCCURRED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19119     x_audit_vals_rec.INCIDENT_OCCURRED_DATE	:= l_service_request_rec.INCIDENT_OCCURRED_DATE;
19120   ELSE
19121     x_audit_vals_rec.INCIDENT_OCCURRED_DATE	:= l_old_ServiceRequest_rec.INCIDENT_OCCURRED_DATE;
19122   END IF;
19123 
19124  /*Bug 3666722 smisra. incident resolved date and incident responded by date could set
19125    if incident status has responded and/or resolved flag set to Y. so copy to audit should
19126    done after these dates are set depending on new status.
19127    moved this code after call to update_sr_validation procedure.
19128  */
19129  --x_audit_vals_rec.OLD_INCIDENT_RESOLVED_DATE	:= l_old_ServiceRequest_rec.INCIDENT_RESOLVED_DATE;
19130  --IF (nvl(l_service_request_rec.INCIDENT_RESOLVED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19131  --  (nvl(l_service_request_rec.INCIDENT_RESOLVED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19132  --      nvl(l_old_ServiceRequest_rec.INCIDENT_RESOLVED_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19133  --  x_audit_vals_rec.INCIDENT_RESOLVED_DATE	:= l_service_request_rec.INCIDENT_RESOLVED_DATE;
19134  --ELSE
19135  --  x_audit_vals_rec.INCIDENT_RESOLVED_DATE	:= l_old_ServiceRequest_rec.INCIDENT_RESOLVED_DATE;
19136  --END IF;
19137  --
19138  --x_audit_vals_rec.OLD_INC_RESPONDED_BY_DATE	:= l_old_ServiceRequest_rec.INC_RESPONDED_BY_DATE;
19139  --IF (nvl(l_service_request_rec.INC_RESPONDED_BY_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19140  --  (nvl(l_service_request_rec.INC_RESPONDED_BY_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19141  --      nvl(l_old_ServiceRequest_rec.INC_RESPONDED_BY_DATE,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19142  --  x_audit_vals_rec.INC_RESPONDED_BY_DATE	:= l_service_request_rec.INC_RESPONDED_BY_DATE;
19143  --ELSE
19144  --  x_audit_vals_rec.INC_RESPONDED_BY_DATE	:= l_old_ServiceRequest_rec.INC_RESPONDED_BY_DATE;
19145  --END IF;
19146 
19147   /* 12/13/05 smisra moved to update_service_request procedure just before call to
19148      create audit record
19149   x_audit_vals_rec.OLD_INCIDENT_LOCATION_ID	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_ID;
19150   IF (nvl(l_service_request_rec.INCIDENT_LOCATION_ID,-99) <> FND_API.G_MISS_NUM) AND
19151     (nvl(l_service_request_rec.INCIDENT_LOCATION_ID,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_LOCATION_ID,-99)) THEN
19152     x_audit_vals_rec.INCIDENT_LOCATION_ID	:= l_service_request_rec.INCIDENT_LOCATION_ID;
19153   ELSE
19154     x_audit_vals_rec.INCIDENT_LOCATION_ID	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_ID;
19155   END IF;
19156   */
19157 
19158   x_audit_vals_rec.OLD_INCIDENT_ADDRESS		:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS;
19159   IF (nvl(l_service_request_rec.INCIDENT_ADDRESS,-99) <> FND_API.G_MISS_CHAR) AND
19160     (nvl(l_service_request_rec.INCIDENT_ADDRESS,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDRESS,-99)) THEN
19161     x_audit_vals_rec.INCIDENT_ADDRESS		:= l_service_request_rec.INCIDENT_ADDRESS;
19162   ELSE
19163     x_audit_vals_rec.INCIDENT_ADDRESS		:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS;
19164   END IF;
19165 
19166   x_audit_vals_rec.OLD_INCIDENT_CITY		:= l_old_ServiceRequest_rec.INCIDENT_CITY;
19167   IF (nvl(l_service_request_rec.INCIDENT_CITY,-99) <> FND_API.G_MISS_CHAR) AND
19168     (nvl(l_service_request_rec.INCIDENT_CITY,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_CITY,-99)) THEN
19169     x_audit_vals_rec.INCIDENT_CITY		:= l_service_request_rec.INCIDENT_CITY;
19170   ELSE
19171     x_audit_vals_rec.INCIDENT_CITY		:= l_old_ServiceRequest_rec.INCIDENT_CITY;
19172   END IF;
19173 
19174   x_audit_vals_rec.OLD_INCIDENT_STATE		:= l_old_ServiceRequest_rec.INCIDENT_STATE;
19175   IF (nvl(l_service_request_rec.INCIDENT_STATE,-99) <> FND_API.G_MISS_CHAR) AND
19176     (nvl(l_service_request_rec.INCIDENT_STATE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_STATE,-99)) THEN
19177     x_audit_vals_rec.INCIDENT_STATE		:= l_service_request_rec.INCIDENT_STATE;
19178   ELSE
19179     x_audit_vals_rec.INCIDENT_STATE		:= l_old_ServiceRequest_rec.INCIDENT_STATE;
19180   END IF;
19181 
19182   /* 12/13/05 smisra moved to update_service_request procedure just before call to
19183      create audit record
19184   x_audit_vals_rec.OLD_INCIDENT_COUNTRY		:= l_old_ServiceRequest_rec.INCIDENT_COUNTRY;
19185   IF (nvl(l_service_request_rec.INCIDENT_COUNTRY,-99) <> FND_API.G_MISS_CHAR) AND
19186     (nvl(l_service_request_rec.INCIDENT_COUNTRY,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_COUNTRY,-99)) THEN
19187     x_audit_vals_rec.INCIDENT_COUNTRY		:= l_service_request_rec.INCIDENT_COUNTRY;
19188   ELSE
19189     x_audit_vals_rec.INCIDENT_COUNTRY		:= l_old_ServiceRequest_rec.INCIDENT_COUNTRY;
19190   END IF;
19191   */
19192 
19193   x_audit_vals_rec.OLD_INCIDENT_PROVINCE	:= l_old_ServiceRequest_rec.INCIDENT_PROVINCE;
19194   IF (nvl(l_service_request_rec.INCIDENT_PROVINCE,-99) <> FND_API.G_MISS_CHAR) AND
19195     (nvl(l_service_request_rec.INCIDENT_PROVINCE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_PROVINCE,-99)) THEN
19196     x_audit_vals_rec.INCIDENT_PROVINCE		:= l_service_request_rec.INCIDENT_PROVINCE;
19197   ELSE
19198     x_audit_vals_rec.INCIDENT_PROVINCE		:= l_old_ServiceRequest_rec.INCIDENT_PROVINCE;
19199   END IF;
19200 
19201   x_audit_vals_rec.OLD_INCIDENT_POSTAL_CODE	:= l_old_ServiceRequest_rec.INCIDENT_POSTAL_CODE;
19202   IF (nvl(l_service_request_rec.INCIDENT_POSTAL_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19203     (nvl(l_service_request_rec.INCIDENT_POSTAL_CODE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_POSTAL_CODE,-99)) THEN
19204     x_audit_vals_rec.INCIDENT_POSTAL_CODE	:= l_service_request_rec.INCIDENT_POSTAL_CODE;
19205   ELSE
19206     x_audit_vals_rec.INCIDENT_POSTAL_CODE	:= l_old_ServiceRequest_rec.INCIDENT_POSTAL_CODE;
19207   END IF;
19208 
19209   x_audit_vals_rec.OLD_INCIDENT_COUNTY		:= l_old_ServiceRequest_rec.INCIDENT_COUNTY;
19210   IF (nvl(l_service_request_rec.INCIDENT_COUNTY,-99) <> FND_API.G_MISS_CHAR) AND
19211     (nvl(l_service_request_rec.INCIDENT_COUNTY,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_COUNTY,-99)) THEN
19212     x_audit_vals_rec.INCIDENT_COUNTY		:= l_service_request_rec.INCIDENT_COUNTY;
19213   ELSE
19214     x_audit_vals_rec.INCIDENT_COUNTY		:= l_old_ServiceRequest_rec.INCIDENT_COUNTY;
19215   END IF;
19216 
19217   x_audit_vals_rec.OLD_SR_CREATION_CHANNEL	:= l_old_ServiceRequest_rec.SR_CREATION_CHANNEL;
19218   IF (nvl(l_service_request_rec.SR_CREATION_CHANNEL,-99) <> FND_API.G_MISS_CHAR) AND
19219     (nvl(l_service_request_rec.SR_CREATION_CHANNEL,-99) <> nvl(l_old_ServiceRequest_rec.SR_CREATION_CHANNEL,-99)) THEN
19220     x_audit_vals_rec.SR_CREATION_CHANNEL	:= l_service_request_rec.SR_CREATION_CHANNEL;
19221   ELSE
19222     x_audit_vals_rec.SR_CREATION_CHANNEL	:= l_old_ServiceRequest_rec.SR_CREATION_CHANNEL;
19223   END IF;
19224 
19225   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
19226   /*
19227   IF (nvl(l_service_request_rec.,-99) <> FND_API.G_MISS_NUM) AND
19228     (nvl(l_service_request_rec. ,-99)) THEN
19229     x_audit_vals_rec.DEF_DEFECT_ID		:= l_service_request_rec.;
19230   END IF;
19231   */
19232 
19233   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
19234   /*
19235   IF (nvl(l_service_request_rec.,-99) <> FND_API.G_MISS_NUM) AND
19236     (nvl(l_service_request_rec. ,-99)) THEN
19237     x_audit_vals_rec.DEF_DEFECT_ID2		:= l_service_request_rec.;
19238   END IF;
19239   */
19240 
19241   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_1	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_1;
19242   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_1,-99) <> FND_API.G_MISS_CHAR) AND
19243     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_1,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_1,-99)) THEN
19244     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_1	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_1;
19245   ELSE
19246     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_1	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_1;
19247   END IF;
19248 
19249   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_2	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_2;
19250   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_2,-99) <> FND_API.G_MISS_CHAR) AND
19251     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_2,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_2,-99)) THEN
19252     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_2	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_2;
19253   ELSE
19254     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_2	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_2;
19255   END IF;
19256 
19257   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_3	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_3;
19258   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_3,-99) <> FND_API.G_MISS_CHAR) AND
19259     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_3,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_3,-99)) THEN
19260     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_3	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_3;
19261   ELSE
19262     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_3	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_3;
19263   END IF;
19264 
19265   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_4	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_4;
19266   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_4,-99) <> FND_API.G_MISS_CHAR) AND
19267     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_4,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_4,-99)) THEN
19268     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_4	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_4;
19269   ELSE
19270     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_4	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_4;
19271   END IF;
19272 
19273   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_5	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_5;
19274   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_5,-99) <> FND_API.G_MISS_CHAR) AND
19275     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_5,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_5,-99)) THEN
19276     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_5	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_5;
19277   ELSE
19278     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_5	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_5;
19279   END IF;
19280 
19281   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_6	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_6;
19282   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_6,-99) <> FND_API.G_MISS_CHAR) AND
19283     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_6,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_6,-99)) THEN
19284     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_6	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_6;
19285   ELSE
19286     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_6	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_6;
19287   END IF;
19288 
19289   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_7	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_7;
19290   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_7,-99) <> FND_API.G_MISS_CHAR) AND
19291     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_7,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_7,-99)) THEN
19292     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_7	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_7;
19293   ELSE
19294     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_7	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_7;
19295   END IF;
19296 
19297   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_8	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_8;
19298   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_8,-99) <> FND_API.G_MISS_CHAR) AND
19299     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_8,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_8,-99)) THEN
19300     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_8	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_8;
19301   ELSE
19302     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_8	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_8;
19303   END IF;
19304 
19305   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_9	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_9;
19306   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_9,-99) <> FND_API.G_MISS_CHAR) AND
19307     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_9,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_9,-99)) THEN
19308     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_9	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_9;
19309   ELSE
19310     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_9	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_9;
19311   END IF;
19312 
19313   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_10	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_10;
19314   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_10,-99) <> FND_API.G_MISS_CHAR) AND
19315     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_10,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_10,-99)) THEN
19316     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_10	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_10;
19317   ELSE
19318     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_10	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_10;
19319   END IF;
19320 
19321   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_11	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_11;
19322   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_11,-99) <> FND_API.G_MISS_CHAR) AND
19323     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_11,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_11,-99)) THEN
19324     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_11	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_11;
19325   ELSE
19326     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_11	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_11;
19327   END IF;
19328 
19329   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_12	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_12;
19330   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_12,-99) <> FND_API.G_MISS_CHAR) AND
19331     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_12,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_12,-99)) THEN
19332     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_12	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_12;
19333   ELSE
19334     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_12	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_12;
19335   END IF;
19336 
19337   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_13	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_13;
19338   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_13,-99) <> FND_API.G_MISS_CHAR) AND
19339     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_13,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_13,-99)) THEN
19340     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_13	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_13;
19341   ELSE
19342     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_13	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_13;
19343   END IF;
19344 
19345   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_14	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_14;
19346   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_14,-99) <> FND_API.G_MISS_CHAR) AND
19347     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_14,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_14,-99)) THEN
19348     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_14	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_14;
19349   ELSE
19350     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_14	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_14;
19351   END IF;
19352 
19353   x_audit_vals_rec.OLD_EXTERNAL_ATTRIBUTE_15	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_15;
19354   IF (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_15,-99) <> FND_API.G_MISS_CHAR) AND
19355     (nvl(l_service_request_rec.EXTERNAL_ATTRIBUTE_15,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_15,-99)) THEN
19356     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_15	:= l_service_request_rec.EXTERNAL_ATTRIBUTE_15;
19357   ELSE
19358     x_audit_vals_rec.EXTERNAL_ATTRIBUTE_15	:= l_old_ServiceRequest_rec.EXTERNAL_ATTRIBUTE_15;
19359   END IF;
19360 
19361   x_audit_vals_rec.OLD_EXTERNAL_CONTEXT		:= l_old_ServiceRequest_rec.EXTERNAL_CONTEXT;
19362   IF (nvl(l_service_request_rec.EXTERNAL_CONTEXT,-99) <> FND_API.G_MISS_CHAR) AND
19363     (nvl(l_service_request_rec.EXTERNAL_CONTEXT,-99) <> nvl(l_old_ServiceRequest_rec.EXTERNAL_CONTEXT,-99)) THEN
19364     x_audit_vals_rec.EXTERNAL_CONTEXT		:= l_service_request_rec.EXTERNAL_CONTEXT;
19365   ELSE
19366     x_audit_vals_rec.EXTERNAL_CONTEXT		:= l_old_ServiceRequest_rec.EXTERNAL_CONTEXT;
19367   END IF;
19368 
19369   x_audit_vals_rec.OLD_LAST_UPDATE_PROGRAM_CODE	:= l_old_ServiceRequest_rec.LAST_UPDATE_PROGRAM_CODE;
19370   IF (nvl(l_service_request_rec.LAST_UPDATE_PROGRAM_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19371     (nvl(l_service_request_rec.LAST_UPDATE_PROGRAM_CODE,-99) <> nvl(l_old_ServiceRequest_rec.LAST_UPDATE_PROGRAM_CODE,-99)) THEN
19372     x_audit_vals_rec.LAST_UPDATE_PROGRAM_CODE	:= l_service_request_rec.LAST_UPDATE_PROGRAM_CODE;
19373   ELSE
19374     x_audit_vals_rec.LAST_UPDATE_PROGRAM_CODE	:= l_old_ServiceRequest_rec.LAST_UPDATE_PROGRAM_CODE;
19375   END IF;
19376 
19377   x_audit_vals_rec.OLD_CREATION_PROGRAM_CODE := l_old_ServiceRequest_rec.CREATION_PROGRAM_CODE;
19378   IF (nvl(l_service_request_rec.CREATION_PROGRAM_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19379     (nvl(l_service_request_rec.CREATION_PROGRAM_CODE,-99) <> nvl(l_old_ServiceRequest_rec.CREATION_PROGRAM_CODE,-99)) THEN
19380     x_audit_vals_rec.CREATION_PROGRAM_CODE	:= l_service_request_rec.CREATION_PROGRAM_CODE;
19381   ELSE
19382     x_audit_vals_rec.CREATION_PROGRAM_CODE	:= l_old_ServiceRequest_rec.CREATION_PROGRAM_CODE;
19383   END IF;
19384 
19385   x_audit_vals_rec.OLD_COVERAGE_TYPE		:= l_old_ServiceRequest_rec.COVERAGE_TYPE;
19386   IF (nvl(l_service_request_rec.COVERAGE_TYPE,-99) <> FND_API.G_MISS_CHAR) AND
19387     (nvl(l_service_request_rec.COVERAGE_TYPE,-99) <> nvl(l_old_ServiceRequest_rec.COVERAGE_TYPE,-99)) THEN
19388     x_audit_vals_rec.COVERAGE_TYPE		:= l_service_request_rec.COVERAGE_TYPE;
19389   ELSE
19390     x_audit_vals_rec.COVERAGE_TYPE		:= l_old_ServiceRequest_rec.COVERAGE_TYPE;
19391   END IF;
19392 
19393   x_audit_vals_rec.OLD_BILL_TO_ACCOUNT_ID	:= l_old_ServiceRequest_rec.BILL_TO_ACCOUNT_ID;
19394   IF (nvl(l_service_request_rec.BILL_TO_ACCOUNT_ID,-99) <> FND_API.G_MISS_NUM) AND
19395     (nvl(l_service_request_rec.BILL_TO_ACCOUNT_ID,-99) <> nvl(l_old_ServiceRequest_rec.BILL_TO_ACCOUNT_ID,-99)) THEN
19396     x_audit_vals_rec.BILL_TO_ACCOUNT_ID		:= l_service_request_rec.BILL_TO_ACCOUNT_ID;
19397   ELSE
19398     x_audit_vals_rec.BILL_TO_ACCOUNT_ID		:= l_old_ServiceRequest_rec.BILL_TO_ACCOUNT_ID;
19399   END IF;
19400 
19401   x_audit_vals_rec.OLD_SHIP_TO_ACCOUNT_ID	:= l_old_ServiceRequest_rec.SHIP_TO_ACCOUNT_ID;
19402   IF (nvl(l_service_request_rec.SHIP_TO_ACCOUNT_ID,-99) <> FND_API.G_MISS_NUM) AND
19403     (nvl(l_service_request_rec.SHIP_TO_ACCOUNT_ID,-99) <> nvl(l_old_ServiceRequest_rec.SHIP_TO_ACCOUNT_ID,-99)) THEN
19404     x_audit_vals_rec.SHIP_TO_ACCOUNT_ID		:= l_service_request_rec.SHIP_TO_ACCOUNT_ID;
19405   ELSE
19406     x_audit_vals_rec.SHIP_TO_ACCOUNT_ID		:= l_old_ServiceRequest_rec.SHIP_TO_ACCOUNT_ID;
19407   END IF;
19408 
19409   x_audit_vals_rec.OLD_CUSTOMER_EMAIL_ID	:= l_old_ServiceRequest_rec.CUSTOMER_EMAIL_ID;
19410   IF (nvl(l_service_request_rec.CUSTOMER_EMAIL_ID,-99) <> FND_API.G_MISS_NUM) AND
19411     (nvl(l_service_request_rec.CUSTOMER_EMAIL_ID,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_EMAIL_ID,-99)) THEN
19412     x_audit_vals_rec.CUSTOMER_EMAIL_ID		:= l_service_request_rec.CUSTOMER_EMAIL_ID;
19413   ELSE
19414     x_audit_vals_rec.CUSTOMER_EMAIL_ID		:= l_old_ServiceRequest_rec.CUSTOMER_EMAIL_ID;
19415   END IF;
19416 
19417   x_audit_vals_rec.OLD_CUSTOMER_PHONE_ID	:= l_old_ServiceRequest_rec.CUSTOMER_PHONE_ID;
19418   IF (nvl(l_service_request_rec.CUSTOMER_PHONE_ID,-99) <> FND_API.G_MISS_NUM) AND
19419     (nvl(l_service_request_rec.CUSTOMER_PHONE_ID,-99) <> nvl(l_old_ServiceRequest_rec.CUSTOMER_PHONE_ID,-99)) THEN
19420     x_audit_vals_rec.CUSTOMER_PHONE_ID		:= l_service_request_rec.CUSTOMER_PHONE_ID;
19421   ELSE
19422     x_audit_vals_rec.CUSTOMER_PHONE_ID		:= l_old_ServiceRequest_rec.CUSTOMER_PHONE_ID;
19423   END IF;
19424 
19425   x_audit_vals_rec.OLD_BILL_TO_PARTY_ID		:= l_old_ServiceRequest_rec.BILL_TO_PARTY_ID;
19426   IF (nvl(l_service_request_rec.BILL_TO_PARTY_ID,-99) <> FND_API.G_MISS_NUM) AND
19427     (nvl(l_service_request_rec.BILL_TO_PARTY_ID,-99) <> nvl(l_old_ServiceRequest_rec.BILL_TO_PARTY_ID,-99)) THEN
19428     x_audit_vals_rec.BILL_TO_PARTY_ID		:= l_service_request_rec.BILL_TO_PARTY_ID;
19429   ELSE
19430     x_audit_vals_rec.BILL_TO_PARTY_ID		:= l_old_ServiceRequest_rec.BILL_TO_PARTY_ID;
19431   END IF;
19432 
19433   x_audit_vals_rec.OLD_SHIP_TO_PARTY_ID		:= l_old_ServiceRequest_rec.SHIP_TO_PARTY_ID;
19434   IF (nvl(l_service_request_rec.SHIP_TO_PARTY_ID,-99) <> FND_API.G_MISS_NUM) AND
19435     (nvl(l_service_request_rec.SHIP_TO_PARTY_ID,-99) <> nvl(l_old_ServiceRequest_rec.SHIP_TO_PARTY_ID,-99)) THEN
19436     x_audit_vals_rec.SHIP_TO_PARTY_ID		:= l_service_request_rec.SHIP_TO_PARTY_ID;
19437   ELSE
19438     x_audit_vals_rec.SHIP_TO_PARTY_ID		:= l_old_ServiceRequest_rec.SHIP_TO_PARTY_ID;
19439   END IF;
19440 
19441   x_audit_vals_rec.OLD_BILL_TO_SITE_ID		:= l_old_ServiceRequest_rec.BILL_TO_SITE_ID;
19442   IF (nvl(l_service_request_rec.BILL_TO_SITE_ID,-99) <> FND_API.G_MISS_NUM) AND
19443     (nvl(l_service_request_rec.BILL_TO_SITE_ID,-99) <> nvl(l_old_ServiceRequest_rec.BILL_TO_SITE_ID,-99)) THEN
19444     x_audit_vals_rec.BILL_TO_SITE_ID		:= l_service_request_rec.BILL_TO_SITE_ID;
19445   ELSE
19446     x_audit_vals_rec.BILL_TO_SITE_ID		:= l_old_ServiceRequest_rec.BILL_TO_SITE_ID;
19447   END IF;
19448 
19449   x_audit_vals_rec.OLD_SHIP_TO_SITE_ID		:= l_old_ServiceRequest_rec.SHIP_TO_SITE_ID;
19450   IF (nvl(l_service_request_rec.SHIP_TO_SITE_ID,-99) <> FND_API.G_MISS_NUM) AND
19451     (nvl(l_service_request_rec.SHIP_TO_SITE_ID,-99) <> nvl(l_old_ServiceRequest_rec.SHIP_TO_SITE_ID,-99)) THEN
19452     x_audit_vals_rec.SHIP_TO_SITE_ID		:= l_service_request_rec.SHIP_TO_SITE_ID;
19453   ELSE
19454     x_audit_vals_rec.SHIP_TO_SITE_ID		:= l_old_ServiceRequest_rec.SHIP_TO_SITE_ID;
19455   END IF;
19456 
19457   x_audit_vals_rec.OLD_PROGRAM_LOGIN_ID		:= l_old_ServiceRequest_rec.PROGRAM_LOGIN_ID;
19458   IF (nvl(l_service_request_rec.PROGRAM_LOGIN_ID,-99) <> FND_API.G_MISS_NUM) AND
19459     (nvl(l_service_request_rec.PROGRAM_LOGIN_ID,-99) <> nvl(l_old_ServiceRequest_rec.PROGRAM_LOGIN_ID,-99)) THEN
19460     x_audit_vals_rec.PROGRAM_LOGIN_ID		:= l_service_request_rec.PROGRAM_LOGIN_ID;
19461   ELSE
19462     x_audit_vals_rec.PROGRAM_LOGIN_ID		:= l_old_ServiceRequest_rec.PROGRAM_LOGIN_ID;
19463   END IF;
19464 
19465   x_audit_vals_rec.OLD_INCIDENT_POINT_OF_INTEREST := l_old_ServiceRequest_rec.INCIDENT_POINT_OF_INTEREST;
19466   IF (nvl(l_service_request_rec.INCIDENT_POINT_OF_INTEREST,-99) <> FND_API.G_MISS_CHAR) AND
19467     (nvl(l_service_request_rec.INCIDENT_POINT_OF_INTEREST,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_POINT_OF_INTEREST,-99)) THEN
19468     x_audit_vals_rec.INCIDENT_POINT_OF_INTEREST	:= l_service_request_rec.INCIDENT_POINT_OF_INTEREST;
19469   ELSE
19470     x_audit_vals_rec.INCIDENT_POINT_OF_INTEREST	:= l_old_ServiceRequest_rec.INCIDENT_POINT_OF_INTEREST;
19471   END IF;
19472 
19473   x_audit_vals_rec.OLD_INCIDENT_CROSS_STREET	 := l_old_ServiceRequest_rec.INCIDENT_CROSS_STREET;
19474   IF (nvl(l_service_request_rec.INCIDENT_CROSS_STREET,-99) <> FND_API.G_MISS_CHAR) AND
19475     (nvl(l_service_request_rec.INCIDENT_CROSS_STREET,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_CROSS_STREET,-99)) THEN
19476     x_audit_vals_rec.INCIDENT_CROSS_STREET	:= l_service_request_rec.INCIDENT_CROSS_STREET;
19477   ELSE
19478     x_audit_vals_rec.INCIDENT_CROSS_STREET	:= l_old_ServiceRequest_rec.INCIDENT_CROSS_STREET;
19479   END IF;
19480 
19481   x_audit_vals_rec.OLD_INCIDENT_DIRECTION_QUALIF := l_old_ServiceRequest_rec.INCIDENT_DIRECTION_QUALIFIER;
19482   IF (nvl(l_service_request_rec.incident_direction_qualifier,-99) <> FND_API.G_MISS_CHAR) AND
19483     (nvl(l_service_request_rec.incident_direction_qualifier,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_DIRECTION_QUALIFIER,-99)) THEN
19484     x_audit_vals_rec.INCIDENT_DIRECTION_QUALIF	:= l_service_request_rec.incident_direction_qualifier;
19485   ELSE
19486     x_audit_vals_rec.INCIDENT_DIRECTION_QUALIF	:= l_old_ServiceRequest_rec.INCIDENT_DIRECTION_QUALIFIER;
19487   END IF;
19488 
19489   x_audit_vals_rec.OLD_INCIDENT_DISTANCE_QUALIF	:= l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUALIFIER;
19490   IF (nvl(l_service_request_rec.incident_distance_qualifier,-99) <> FND_API.G_MISS_CHAR) AND
19491     (nvl(l_service_request_rec.incident_distance_qualifier,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUALIFIER,-99)) THEN
19492     x_audit_vals_rec.INCIDENT_DISTANCE_QUALIF	:= l_service_request_rec.incident_distance_qualifier;
19493   ELSE
19494     x_audit_vals_rec.INCIDENT_DISTANCE_QUALIF	:= l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUALIFIER;
19495   END IF;
19496 
19497   x_audit_vals_rec.OLD_INCIDENT_DISTANCE_QUAL_UOM := l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUAL_UOM;
19498   IF (nvl(l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM,-99) <> FND_API.G_MISS_CHAR) AND
19499     (nvl(l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUAL_UOM,-99)) THEN
19500     x_audit_vals_rec.INCIDENT_DISTANCE_QUAL_UOM	:= l_service_request_rec.INCIDENT_DISTANCE_QUAL_UOM;
19501   ELSE
19502     x_audit_vals_rec.INCIDENT_DISTANCE_QUAL_UOM	:= l_old_ServiceRequest_rec.INCIDENT_DISTANCE_QUAL_UOM;
19503   END IF;
19504 
19505   x_audit_vals_rec.OLD_INCIDENT_ADDRESS2	:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS2;
19506   IF (nvl(l_service_request_rec.INCIDENT_ADDRESS2,-99) <> FND_API.G_MISS_CHAR) AND
19507     (nvl(l_service_request_rec.INCIDENT_ADDRESS2,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDRESS2,-99)) THEN
19508     x_audit_vals_rec.INCIDENT_ADDRESS2		:= l_service_request_rec.INCIDENT_ADDRESS2;
19509   ELSE
19510     x_audit_vals_rec.INCIDENT_ADDRESS2		:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS2;
19511   END IF;
19512 
19513   x_audit_vals_rec.OLD_INCIDENT_ADDRESS3	:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS3;
19514   IF (nvl(l_service_request_rec.INCIDENT_ADDRESS3,-99) <> FND_API.G_MISS_CHAR) AND
19515     (nvl(l_service_request_rec.INCIDENT_ADDRESS3,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDRESS3,-99)) THEN
19516     x_audit_vals_rec.INCIDENT_ADDRESS3		:= l_service_request_rec.INCIDENT_ADDRESS3;
19517   ELSE
19518     x_audit_vals_rec.INCIDENT_ADDRESS3		:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS3;
19519   END IF;
19520 
19521   x_audit_vals_rec.OLD_INCIDENT_ADDRESS4	:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS4;
19522   IF (nvl(l_service_request_rec.INCIDENT_ADDRESS4,-99) <> FND_API.G_MISS_CHAR) AND
19523     (nvl(l_service_request_rec.INCIDENT_ADDRESS4,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDRESS4,-99)) THEN
19524     x_audit_vals_rec.INCIDENT_ADDRESS4		:= l_service_request_rec.INCIDENT_ADDRESS4;
19525   ELSE
19526     x_audit_vals_rec.INCIDENT_ADDRESS4		:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS4;
19527   END IF;
19528 
19529   x_audit_vals_rec.OLD_INCIDENT_ADDRESS_STYLE	:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS_STYLE;
19530   IF (nvl(l_service_request_rec.INCIDENT_ADDRESS_STYLE,-99) <> FND_API.G_MISS_CHAR) AND
19531     (nvl(l_service_request_rec.INCIDENT_ADDRESS_STYLE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDRESS_STYLE,-99)) THEN
19532     x_audit_vals_rec.INCIDENT_ADDRESS_STYLE	:= l_service_request_rec.INCIDENT_ADDRESS_STYLE;
19533   ELSE
19534     x_audit_vals_rec.INCIDENT_ADDRESS_STYLE	:= l_old_ServiceRequest_rec.INCIDENT_ADDRESS_STYLE;
19535   END IF;
19536 
19537   x_audit_vals_rec.OLD_INCIDENT_ADDR_LNS_PHONETIC := l_old_ServiceRequest_rec.INCIDENT_ADDR_LINES_PHONETIC;
19538   IF (nvl(l_service_request_rec.incident_addr_lines_phonetic,-99) <> FND_API.G_MISS_CHAR) AND
19539     (nvl(l_service_request_rec.incident_addr_lines_phonetic,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_ADDR_LINES_PHONETIC,-99)) THEN
19540     x_audit_vals_rec.INCIDENT_ADDR_LNS_PHONETIC	:= l_service_request_rec.incident_addr_lines_phonetic;
19541   ELSE
19542     x_audit_vals_rec.INCIDENT_ADDR_LNS_PHONETIC	:= l_old_ServiceRequest_rec.INCIDENT_ADDR_LINES_PHONETIC;
19543   END IF;
19544 
19545   x_audit_vals_rec.OLD_INCIDENT_PO_BOX_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_PO_BOX_NUMBER;
19546   IF (nvl(l_service_request_rec.INCIDENT_PO_BOX_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
19547     (nvl(l_service_request_rec.INCIDENT_PO_BOX_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_PO_BOX_NUMBER,-99)) THEN
19548     x_audit_vals_rec.INCIDENT_PO_BOX_NUMBER	:= l_service_request_rec.INCIDENT_PO_BOX_NUMBER;
19549   ELSE
19550     x_audit_vals_rec.INCIDENT_PO_BOX_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_PO_BOX_NUMBER;
19551   END IF;
19552 
19553   x_audit_vals_rec.OLD_INCIDENT_HOUSE_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_HOUSE_NUMBER;
19554   IF (nvl(l_service_request_rec.INCIDENT_HOUSE_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
19555     (nvl(l_service_request_rec.INCIDENT_HOUSE_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_HOUSE_NUMBER,-99)) THEN
19556     x_audit_vals_rec.INCIDENT_HOUSE_NUMBER	:= l_service_request_rec.INCIDENT_HOUSE_NUMBER;
19557   ELSE
19558     x_audit_vals_rec.INCIDENT_HOUSE_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_HOUSE_NUMBER;
19559   END IF;
19560 
19561   x_audit_vals_rec.OLD_INCIDENT_STREET_SUFFIX	:= l_old_ServiceRequest_rec.INCIDENT_STREET_SUFFIX;
19562   IF (nvl(l_service_request_rec.INCIDENT_STREET_SUFFIX,-99) <> FND_API.G_MISS_CHAR) AND
19563     (nvl(l_service_request_rec.INCIDENT_STREET_SUFFIX,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_STREET_SUFFIX,-99)) THEN
19564     x_audit_vals_rec.INCIDENT_STREET_SUFFIX	:= l_service_request_rec.INCIDENT_STREET_SUFFIX;
19565   ELSE
19566     x_audit_vals_rec.INCIDENT_STREET_SUFFIX	:= l_old_ServiceRequest_rec.INCIDENT_STREET_SUFFIX;
19567   END IF;
19568 
19569   x_audit_vals_rec.OLD_INCIDENT_STREET		:= l_old_ServiceRequest_rec.INCIDENT_STREET;
19570   IF (nvl(l_service_request_rec.INCIDENT_STREET,-99) <> FND_API.G_MISS_CHAR) AND
19571     (nvl(l_service_request_rec.INCIDENT_STREET,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_STREET,-99)) THEN
19572     x_audit_vals_rec.INCIDENT_STREET		:= l_service_request_rec.INCIDENT_STREET;
19573   ELSE
19574     x_audit_vals_rec.INCIDENT_STREET		:= l_old_ServiceRequest_rec.INCIDENT_STREET;
19575   END IF;
19576 
19577   x_audit_vals_rec.OLD_INCIDENT_STREET_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_STREET_NUMBER;
19578   IF (nvl(l_service_request_rec.INCIDENT_STREET_NUMBER,-99) <> FND_API.G_MISS_CHAR) AND
19579     (nvl(l_service_request_rec.INCIDENT_STREET_NUMBER,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_STREET_NUMBER,-99)) THEN
19580     x_audit_vals_rec.INCIDENT_STREET_NUMBER	:= l_service_request_rec.INCIDENT_STREET_NUMBER;
19581   ELSE
19582     x_audit_vals_rec.INCIDENT_STREET_NUMBER	:= l_old_ServiceRequest_rec.INCIDENT_STREET_NUMBER;
19583   END IF;
19584 
19585   x_audit_vals_rec.OLD_INCIDENT_FLOOR		:= l_old_ServiceRequest_rec.INCIDENT_FLOOR;
19586   IF (nvl(l_service_request_rec.INCIDENT_FLOOR,-99) <> FND_API.G_MISS_CHAR) AND
19587     (nvl(l_service_request_rec.INCIDENT_FLOOR,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_FLOOR,-99)) THEN
19588     x_audit_vals_rec.INCIDENT_FLOOR		:= l_service_request_rec.INCIDENT_FLOOR;
19589   ELSE
19590     x_audit_vals_rec.INCIDENT_FLOOR		:= l_old_ServiceRequest_rec.INCIDENT_FLOOR;
19591   END IF;
19592 
19593   x_audit_vals_rec.OLD_INCIDENT_SUITE		:= l_old_ServiceRequest_rec.INCIDENT_SUITE;
19594   IF (nvl(l_service_request_rec.INCIDENT_SUITE,-99) <> FND_API.G_MISS_CHAR) AND
19595     (nvl(l_service_request_rec.INCIDENT_SUITE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_SUITE,-99)) THEN
19596     x_audit_vals_rec.INCIDENT_SUITE		:= l_service_request_rec.INCIDENT_SUITE;
19597   ELSE
19598     x_audit_vals_rec.INCIDENT_SUITE		:= l_old_ServiceRequest_rec.INCIDENT_SUITE;
19599   END IF;
19600 
19601   x_audit_vals_rec.OLD_INCIDENT_POSTAL_PLUS4_CODE := l_old_ServiceRequest_rec.INCIDENT_POSTAL_PLUS4_CODE;
19602   IF (nvl(l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE,-99) <> FND_API.G_MISS_CHAR) AND
19603     (nvl(l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_POSTAL_PLUS4_CODE,-99)) THEN
19604     x_audit_vals_rec.INCIDENT_POSTAL_PLUS4_CODE	:= l_service_request_rec.INCIDENT_POSTAL_PLUS4_CODE;
19605   ELSE
19606     x_audit_vals_rec.INCIDENT_POSTAL_PLUS4_CODE	:= l_old_ServiceRequest_rec.INCIDENT_POSTAL_PLUS4_CODE;
19607   END IF;
19608 
19609   x_audit_vals_rec.OLD_INCIDENT_POSITION	:= l_old_ServiceRequest_rec.INCIDENT_POSITION;
19610   IF (nvl(l_service_request_rec.INCIDENT_POSITION,-99) <> FND_API.G_MISS_CHAR) AND
19611     (nvl(l_service_request_rec.INCIDENT_POSITION,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_POSITION,-99)) THEN
19612     x_audit_vals_rec.INCIDENT_POSITION		:= l_service_request_rec.INCIDENT_POSITION;
19613   ELSE
19614     x_audit_vals_rec.INCIDENT_POSITION		:= l_old_ServiceRequest_rec.INCIDENT_POSITION;
19615   END IF;
19616 
19617   x_audit_vals_rec.OLD_INCIDENT_LOC_DIRECTIONS	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_DIRECTIONS;
19618   IF (nvl(l_service_request_rec.incident_location_directions,-99) <> FND_API.G_MISS_CHAR) AND
19619     (nvl(l_service_request_rec.incident_location_directions,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_LOCATION_DIRECTIONS,-99)) THEN
19620     x_audit_vals_rec.INCIDENT_LOC_DIRECTIONS	:= l_service_request_rec.incident_location_directions;
19621   ELSE
19622     x_audit_vals_rec.INCIDENT_LOC_DIRECTIONS	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_DIRECTIONS;
19623   END IF;
19624 
19625   x_audit_vals_rec.OLD_INCIDENT_LOC_DESCRIPTION	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_DESCRIPTION;
19626   IF (nvl(l_service_request_rec.incident_location_description,-99) <> FND_API.G_MISS_CHAR) AND
19627     (nvl(l_service_request_rec.incident_location_description,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_LOCATION_DESCRIPTION,-99)) THEN
19628     x_audit_vals_rec.INCIDENT_LOC_DESCRIPTION	:= l_service_request_rec.incident_location_description;
19629   END IF;
19630 
19631   x_audit_vals_rec.OLD_INSTALL_SITE_ID		:= l_old_ServiceRequest_rec.INSTALL_SITE_ID;
19632   IF (nvl(l_service_request_rec.INSTALL_SITE_ID,-99) <> FND_API.G_MISS_NUM) AND
19633     (nvl(l_service_request_rec.INSTALL_SITE_ID,-99) <> nvl(l_old_ServiceRequest_rec.INSTALL_SITE_ID,-99)) THEN
19634     x_audit_vals_rec.INSTALL_SITE_ID		:= l_service_request_rec.INSTALL_SITE_ID;
19635   ELSE
19636     x_audit_vals_rec.INSTALL_SITE_ID		:= l_old_ServiceRequest_rec.INSTALL_SITE_ID;
19637   END IF;
19638 
19639   x_audit_vals_rec.OLD_TIER_VERSION		:= l_old_ServiceRequest_rec.TIER_VERSION;
19640   IF (nvl(l_service_request_rec.TIER_VERSION,-99) <> FND_API.G_MISS_CHAR) AND
19641     (nvl(l_service_request_rec.TIER_VERSION,-99) <> nvl(l_old_ServiceRequest_rec.TIER_VERSION,-99)) THEN
19642     x_audit_vals_rec.TIER_VERSION		:= l_service_request_rec.TIER_VERSION;
19643   ELSE
19644     x_audit_vals_rec.TIER_VERSION		:= l_old_ServiceRequest_rec.TIER_VERSION;
19645   END IF;
19646 
19647   -- anmukher --09/12/03
19648 
19649   x_audit_vals_rec.OLD_INC_OBJECT_VERSION_NUMBER := l_old_ServiceRequest_rec.OBJECT_VERSION_NUMBER;
19650   x_audit_vals_rec.INC_OBJECT_VERSION_NUMBER	 := l_old_ServiceRequest_rec.OBJECT_VERSION_NUMBER + 1;
19651 
19652   x_audit_vals_rec.OLD_INC_REQUEST_ID		:= l_old_ServiceRequest_rec.REQUEST_ID;
19653   IF (nvl(l_service_request_rec.conc_request_id,-99) <> FND_API.G_MISS_NUM) AND
19654     (nvl(l_service_request_rec.conc_request_id,-99) <> nvl(l_old_ServiceRequest_rec.REQUEST_ID,-99)) THEN
19655     x_audit_vals_rec.INC_REQUEST_ID		:= l_service_request_rec.conc_request_id;
19656   ELSE
19657     x_audit_vals_rec.INC_REQUEST_ID		:= l_old_ServiceRequest_rec.REQUEST_ID;
19658   END IF;
19659 
19660   x_audit_vals_rec.OLD_INC_PROGRAM_APPLICATION_ID := l_old_ServiceRequest_rec.PROGRAM_APPLICATION_ID;
19661   IF (nvl(l_service_request_rec.program_application_id,-99) <> FND_API.G_MISS_NUM) AND
19662     (nvl(l_service_request_rec.program_application_id,-99) <> nvl(l_old_ServiceRequest_rec.PROGRAM_APPLICATION_ID,-99)) THEN
19663     x_audit_vals_rec.INC_PROGRAM_APPLICATION_ID	:= l_service_request_rec.program_application_id;
19664   ELSE
19665     x_audit_vals_rec.INC_PROGRAM_APPLICATION_ID	:= l_old_ServiceRequest_rec.PROGRAM_APPLICATION_ID;
19666   END IF;
19667 
19668   x_audit_vals_rec.OLD_INC_PROGRAM_ID		:= l_old_ServiceRequest_rec.PROGRAM_ID;
19669   IF (nvl(l_service_request_rec.program_id,-99) <> FND_API.G_MISS_NUM) AND
19670     (nvl(l_service_request_rec.program_id,-99) <> nvl(l_old_ServiceRequest_rec.PROGRAM_ID,-99)) THEN
19671     x_audit_vals_rec.INC_PROGRAM_ID		:= l_service_request_rec.program_id;
19672   ELSE
19673     x_audit_vals_rec.INC_PROGRAM_ID		:= l_old_ServiceRequest_rec.PROGRAM_ID;
19674   END IF;
19675 
19676    --15995804. audit  price_list_header_id and SLA
19677   x_audit_vals_rec.OLD_PRICE_LIST_HEADER_ID := l_old_ServiceRequest_rec.PRICE_LIST_HEADER_ID;
19678   IF (nvl(l_service_request_rec.PRICE_LIST_HEADER_ID,-99) <> FND_API.G_MISS_NUM) AND
19679     (nvl(l_service_request_rec.PRICE_LIST_HEADER_ID,-99) <> nvl(l_old_ServiceRequest_rec.PRICE_LIST_HEADER_ID,-99)) THEN
19680     x_audit_vals_rec.PRICE_LIST_HEADER_ID	:= l_service_request_rec.PRICE_LIST_HEADER_ID;
19681   ELSE
19682     x_audit_vals_rec.PRICE_LIST_HEADER_ID	:= l_old_ServiceRequest_rec.PRICE_LIST_HEADER_ID;
19683   END IF;
19684   x_audit_vals_rec.OLD_SLA_DATE_1	:= l_old_ServiceRequest_rec.SLA_DATE_1;
19685   IF (nvl(l_service_request_rec.SLA_DATE_1,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19686     (nvl(l_service_request_rec.SLA_DATE_1,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19687         nvl(l_old_ServiceRequest_rec.SLA_DATE_1,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19688     x_audit_vals_rec.CHANGE_SLA_DATE_1_FLAG := 'Y';
19689     x_audit_vals_rec.SLA_DATE_1	:= l_service_request_rec.SLA_DATE_1;
19690   ELSE
19691     x_audit_vals_rec.CHANGE_SLA_DATE_1_FLAG := 'N';
19692     x_audit_vals_rec.SLA_DATE_1	:= l_old_ServiceRequest_rec.SLA_DATE_1;
19693   END IF;
19694   x_audit_vals_rec.OLD_SLA_DATE_2	:= l_old_ServiceRequest_rec.SLA_DATE_2;
19695   IF (nvl(l_service_request_rec.SLA_DATE_2,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19696     (nvl(l_service_request_rec.SLA_DATE_2,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19697         nvl(l_old_ServiceRequest_rec.SLA_DATE_2,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19698     x_audit_vals_rec.CHANGE_SLA_DATE_2_FLAG := 'Y';
19699     x_audit_vals_rec.SLA_DATE_2	:= l_service_request_rec.SLA_DATE_2;
19700   ELSE
19701     x_audit_vals_rec.CHANGE_SLA_DATE_2_FLAG := 'N';
19702     x_audit_vals_rec.SLA_DATE_2	:= l_old_ServiceRequest_rec.SLA_DATE_2;
19703   END IF;
19704   x_audit_vals_rec.OLD_SLA_DATE_3	:= l_old_ServiceRequest_rec.SLA_DATE_3;
19705   IF (nvl(l_service_request_rec.SLA_DATE_3,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19706     (nvl(l_service_request_rec.SLA_DATE_3,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19707         nvl(l_old_ServiceRequest_rec.SLA_DATE_3,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19708     x_audit_vals_rec.CHANGE_SLA_DATE_3_FLAG := 'Y';
19709     x_audit_vals_rec.SLA_DATE_3	:= l_service_request_rec.SLA_DATE_3;
19710   ELSE
19711     x_audit_vals_rec.CHANGE_SLA_DATE_3_FLAG := 'N';
19712     x_audit_vals_rec.SLA_DATE_3	:= l_old_ServiceRequest_rec.SLA_DATE_3;
19713   END IF;
19714   x_audit_vals_rec.OLD_SLA_DATE_4	:= l_old_ServiceRequest_rec.SLA_DATE_4;
19715   IF (nvl(l_service_request_rec.SLA_DATE_4,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19716     (nvl(l_service_request_rec.SLA_DATE_4,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19717         nvl(l_old_ServiceRequest_rec.SLA_DATE_4,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19718     x_audit_vals_rec.CHANGE_SLA_DATE_4_FLAG := 'Y';
19719     x_audit_vals_rec.SLA_DATE_4	:= l_service_request_rec.SLA_DATE_4;
19720   ELSE
19721     x_audit_vals_rec.CHANGE_SLA_DATE_4_FLAG := 'N';
19722     x_audit_vals_rec.SLA_DATE_4	:= l_old_ServiceRequest_rec.SLA_DATE_4;
19723   END IF;
19724   x_audit_vals_rec.OLD_SLA_DATE_5	:= l_old_ServiceRequest_rec.SLA_DATE_5;
19725   IF (nvl(l_service_request_rec.SLA_DATE_5,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19726     (nvl(l_service_request_rec.SLA_DATE_5,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19727         nvl(l_old_ServiceRequest_rec.SLA_DATE_5,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19728      x_audit_vals_rec.CHANGE_SLA_DATE_5_FLAG := 'Y';
19729     x_audit_vals_rec.SLA_DATE_5	:= l_service_request_rec.SLA_DATE_5;
19730   ELSE
19731      x_audit_vals_rec.CHANGE_SLA_DATE_5_FLAG := 'N';
19732     x_audit_vals_rec.SLA_DATE_5	:= l_old_ServiceRequest_rec.SLA_DATE_5;
19733   END IF;
19734   x_audit_vals_rec.OLD_SLA_DATE_6	:= l_old_ServiceRequest_rec.SLA_DATE_6;
19735   IF (nvl(l_service_request_rec.SLA_DATE_6,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19736     (nvl(l_service_request_rec.SLA_DATE_6,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <>
19737         nvl(l_old_ServiceRequest_rec.SLA_DATE_6,TO_DATE('09-09-0999', 'DD-MM-YYYY'))) THEN
19738     x_audit_vals_rec.CHANGE_SLA_DATE_6_FLAG := 'Y';
19739     x_audit_vals_rec.SLA_DATE_6	:= l_service_request_rec.SLA_DATE_6;
19740   ELSE
19741     x_audit_vals_rec.CHANGE_SLA_DATE_6_FLAG := 'N';
19742     x_audit_vals_rec.SLA_DATE_6	:= l_old_ServiceRequest_rec.SLA_DATE_6;
19743   END IF;
19744   x_audit_vals_rec.OLD_SLA_DURATION_1 := l_old_ServiceRequest_rec.SLA_DURATION_1;
19745   IF (nvl(l_service_request_rec.SLA_DURATION_1,-99) <> FND_API.G_MISS_NUM) AND
19746     (nvl(l_service_request_rec.SLA_DURATION_1,-99) <> nvl(l_old_ServiceRequest_rec.SLA_DURATION_1,-99)) THEN
19747     x_audit_vals_rec.CHANGE_SLA_DURATION_1_FLAG := 'Y';
19748     x_audit_vals_rec.SLA_DURATION_1	:= l_service_request_rec.SLA_DURATION_1;
19749   ELSE
19750     x_audit_vals_rec.CHANGE_SLA_DURATION_1_FLAG := 'N';
19751     x_audit_vals_rec.SLA_DURATION_1	:= l_old_ServiceRequest_rec.SLA_DURATION_1;
19752   END IF;
19753   x_audit_vals_rec.OLD_SLA_DURATION_2 := l_old_ServiceRequest_rec.SLA_DURATION_2;
19754   IF (nvl(l_service_request_rec.SLA_DURATION_2,-99) <> FND_API.G_MISS_NUM) AND
19755     (nvl(l_service_request_rec.SLA_DURATION_2,-99) <> nvl(l_old_ServiceRequest_rec.SLA_DURATION_2,-99)) THEN
19756     x_audit_vals_rec.CHANGE_SLA_DURATION_2_FLAG := 'Y';
19757     x_audit_vals_rec.SLA_DURATION_2	:= l_service_request_rec.SLA_DURATION_2;
19758   ELSE
19759     x_audit_vals_rec.CHANGE_SLA_DURATION_2_FLAG := 'N';
19760     x_audit_vals_rec.SLA_DURATION_2	:= l_old_ServiceRequest_rec.SLA_DURATION_2;
19761   END IF;
19762 
19763    --15995804. End audit  price_list_header_id and SLA
19764 
19765   /* Cannot populate this column as there is no equivalent column in l_service_request_rec */
19766   /*
19767   IF (nvl(l_service_request_rec. ,TO_DATE('09-09-0999', 'DD-MM-YYYY')) <> FND_API.G_MISS_DATE) AND
19768     (l_service_request_rec. ) THEN
19769     x_audit_vals_rec.INC_PROGRAM_UPDATE_DATE	:= l_service_request_rec.;
19770   END IF;
19771   */
19772 
19773   x_audit_vals_rec.OLD_OWNING_DEPARTMENT_ID	:= l_old_ServiceRequest_rec.OWNING_DEPARTMENT_ID;
19774   IF (nvl(l_service_request_rec.owning_dept_id,-99) <> FND_API.G_MISS_NUM) AND
19775     (nvl(l_service_request_rec.owning_dept_id,-99) <> nvl(l_old_ServiceRequest_rec.OWNING_DEPARTMENT_ID,-99)) THEN
19776     x_audit_vals_rec.OWNING_DEPARTMENT_ID	:= l_service_request_rec.owning_dept_id;
19777   ELSE
19778     x_audit_vals_rec.OWNING_DEPARTMENT_ID	:= l_old_ServiceRequest_rec.OWNING_DEPARTMENT_ID;
19779   END IF;
19780 
19781   /* 12/13/05 smisra moved to update_service_request procedure just before call to
19782      create audit record
19783   x_audit_vals_rec.OLD_INCIDENT_LOCATION_TYPE	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_TYPE;
19784   IF (nvl(l_service_request_rec.incident_location_type,-99) <> FND_API.G_MISS_CHAR) AND
19785     (nvl(l_service_request_rec.incident_location_type,-99) <> nvl(l_old_ServiceRequest_rec.INCIDENT_LOCATION_TYPE,-99)) THEN
19786     x_audit_vals_rec.INCIDENT_LOCATION_TYPE	:= l_service_request_rec.incident_location_type;
19787   ELSE
19788     x_audit_vals_rec.INCIDENT_LOCATION_TYPE	:= l_old_ServiceRequest_rec.INCIDENT_LOCATION_TYPE;
19789   END IF;
19790   ****/
19791 
19792 
19793   -- Assigning org_id values for auditing  spusegao 09/22/03
19794      x_audit_vals_rec.org_id     := l_old_ServiceRequest_rec.org_id ;
19795      x_audit_vals_rec.old_org_id := l_old_ServiceRequest_rec.org_id ;
19796 
19797 /* Credit Card 9358401 */
19798    IF p_validation_level > FND_API.G_VALID_LEVEL_NONE THEN
19799      IF l_service_request_rec.instrument_payment_use_id = FND_API.G_MISS_NUM
19800 	THEN
19801         l_service_request_rec.instrument_payment_use_id :=
19802 	                      l_old_ServiceRequest_rec.instrument_payment_use_id;
19803      END IF;
19804 
19805      IF l_service_request_rec.instrument_payment_use_id IS not NULL THEN
19806          CS_ServiceRequest_UTIL.validate_credit_card(
19807           p_api_name             => l_api_name,
19808           p_parameter_name       => 'P_INSTRUMENT_PAYMENT_USE_ID',
19809           p_instrument_payment_use_id  =>
19810 		                   l_service_request_rec.instrument_payment_use_id,
19811           p_bill_to_acct_id      => l_service_request_rec.bill_to_account_id,
19812 		p_called_from          => 'U',
19813           x_return_status        => l_return_status);
19814 
19815           IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
19816             /* Ignoring the value but SR needs to be created*/
19817             l_service_request_rec.instrument_payment_use_id := NULL;
19818           END IF;
19819      END IF;
19820 
19821      --14004721 . Additional SLA dates
19822     IF (l_service_request_rec.sla_date_1 = FND_API.G_MISS_DATE)
19823     THEN
19824         l_service_request_rec.sla_date_1 := l_old_ServiceRequest_rec.sla_date_1;
19825     END IF;
19826     IF (l_service_request_rec.sla_date_2 = FND_API.G_MISS_DATE)
19827     THEN
19828         l_service_request_rec.sla_date_2 := l_old_ServiceRequest_rec.sla_date_2;
19829     END IF;
19830     IF (l_service_request_rec.sla_date_3 = FND_API.G_MISS_DATE)
19831     THEN
19832         l_service_request_rec.sla_date_3 := l_old_ServiceRequest_rec.sla_date_3;
19833     END IF;
19834     IF (l_service_request_rec.sla_date_4 = FND_API.G_MISS_DATE)
19835     THEN
19836         l_service_request_rec.sla_date_4 := l_old_ServiceRequest_rec.sla_date_4;
19837     END IF;
19838     IF (l_service_request_rec.sla_date_5 = FND_API.G_MISS_DATE)
19839     THEN
19840         l_service_request_rec.sla_date_5 := l_old_ServiceRequest_rec.sla_date_5;
19841     END IF;
19842     IF (l_service_request_rec.sla_date_6 = FND_API.G_MISS_DATE)
19843     THEN
19844         l_service_request_rec.sla_date_6 := l_old_ServiceRequest_rec.sla_date_6;
19845     END IF;
19846     IF (l_service_request_rec.sla_duration_1 = FND_API.G_MISS_NUM)
19847     THEN
19848         l_service_request_rec.sla_duration_1 := l_old_ServiceRequest_rec.sla_duration_1;
19849     END IF;
19850     IF (l_service_request_rec.sla_duration_2 = FND_API.G_MISS_NUM)
19851     THEN
19852         l_service_request_rec.sla_duration_2 := l_old_ServiceRequest_rec.sla_duration_2;
19853     END IF;
19854     --End of changes for 14004721 . Additional SLA dates. shramana
19855 
19856    END IF; /*p_validation level*/
19857 /* Credit Card 9358401 */
19858 CLOSE l_ServiceRequest_csr;
19859 
19860 --- Assinging the values to x_service_request_rec
19861  x_service_request_rec := l_service_request_rec;
19862 
19863 EXCEPTION
19864   WHEN FND_API.G_EXC_ERROR THEN
19865     ROLLBACK TO Update_ServiceRequest_PVT;
19866     IF (l_ServiceRequest_csr%ISOPEN) THEN
19867       CLOSE l_ServiceRequest_csr;
19868     END IF;
19869     x_return_status := FND_API.G_RET_STS_ERROR;
19870     FND_MSG_PUB.Count_And_Get
19871       ( p_count => x_msg_count,
19872         p_data  => x_msg_data
19873       );
19874 
19875   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
19876     ROLLBACK TO Update_ServiceRequest_PVT;
19877     IF (l_ServiceRequest_csr%ISOPEN) THEN
19878       CLOSE l_ServiceRequest_csr;
19879     END IF;
19880     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
19881     FND_MSG_PUB.Count_And_Get
19882       ( p_count => x_msg_count,
19883         p_data  => x_msg_data
19884       );
19885 
19886   WHEN OnlyUpdStatus THEN
19887     IF (l_ServiceRequest_csr%ISOPEN) THEN
19888       CLOSE l_ServiceRequest_csr;
19889     END IF;
19890     x_return_status := 'R';
19891     FND_MSG_PUB.Count_And_Get
19892       ( p_count => x_msg_count,
19893         p_data  => x_msg_data
19894       );
19895 
19896   WHEN OTHERS THEN
19897     ROLLBACK TO Update_ServiceRequest_PVT;
19898     IF (l_ServiceRequest_csr%ISOPEN) THEN
19899       CLOSE l_ServiceRequest_csr;
19900     END IF;
19901     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
19902     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
19903       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
19904     END IF;
19905     FND_MSG_PUB.Count_And_Get
19906       ( p_count => x_msg_count,
19907         p_data  => x_msg_data
19908       );
19909 END Update_SR_Validation;
19910 
19911 PROCEDURE initialize_rec(
19912   p_sr_record                   IN OUT NOCOPY service_request_rec_type
19913 ) AS
19914 BEGIN
19915   p_sr_record.request_date               := FND_API.G_MISS_DATE;
19916   p_sr_record.type_id                    := FND_API.G_MISS_NUM;
19917   p_sr_record.status_id                  := FND_API.G_MISS_NUM;
19918   p_sr_record.severity_id                := FND_API.G_MISS_NUM;
19919   p_sr_record.urgency_id                 := FND_API.G_MISS_NUM;
19920   p_sr_record.closed_date                := FND_API.G_MISS_DATE;
19921   p_sr_record.owner_id                   := FND_API.G_MISS_NUM;
19922   p_sr_record.owner_group_id             := FND_API.G_MISS_NUM;
19923   p_sr_record.publish_flag               := FND_API.G_MISS_CHAR;
19924   p_sr_record.summary                    := FND_API.G_MISS_CHAR;
19925   p_sr_record.caller_type                := FND_API.G_MISS_CHAR;
19926   p_sr_record.customer_id                := FND_API.G_MISS_NUM;
19927   p_sr_record.customer_number            := FND_API.G_MISS_CHAR;
19928   p_sr_record.employee_id                := FND_API.G_MISS_NUM;
19929   p_sr_record.verify_cp_flag             := FND_API.G_MISS_CHAR;
19930   p_sr_record.customer_product_id        := FND_API.G_MISS_NUM;
19931   p_sr_record.platform_id                := FND_API.G_MISS_NUM;
19932   p_sr_record.platform_version		 := FND_API.G_MISS_CHAR;
19933   p_sr_record.db_version		 := FND_API.G_MISS_CHAR;
19934   p_sr_record.platform_version_id        := FND_API.G_MISS_NUM;
19935   p_sr_record.cp_component_id               := FND_API.G_MISS_NUM;
19936   p_sr_record.cp_component_version_id       := FND_API.G_MISS_NUM;
19937   p_sr_record.cp_subcomponent_id            := FND_API.G_MISS_NUM;
19938   p_sr_record.cp_subcomponent_version_id    := FND_API.G_MISS_NUM;
19939   p_sr_record.language_id                := FND_API.G_MISS_NUM;
19940   p_sr_record.LANGUAGE                   := FND_API.G_MISS_CHAR;
19941   p_sr_record.inventory_item_id          := FND_API.G_MISS_NUM;
19942   p_sr_record.inventory_org_id           := FND_API.G_MISS_NUM;
19943   p_sr_record.current_serial_number      := FND_API.G_MISS_CHAR;
19944   p_sr_record.original_order_number      := FND_API.G_MISS_NUM;
19945   p_sr_record.purchase_order_num         := FND_API.G_MISS_CHAR;
19946   p_sr_record.problem_code               := FND_API.G_MISS_CHAR;
19947   p_sr_record.exp_resolution_date        := FND_API.G_MISS_DATE;
19948   p_sr_record.install_site_use_id        := FND_API.G_MISS_NUM;
19949   p_sr_record.request_attribute_1        := FND_API.G_MISS_CHAR;
19950   p_sr_record.request_attribute_2        := FND_API.G_MISS_CHAR;
19951   p_sr_record.request_attribute_3        := FND_API.G_MISS_CHAR;
19952   p_sr_record.request_attribute_4        := FND_API.G_MISS_CHAR;
19953   p_sr_record.request_attribute_5        := FND_API.G_MISS_CHAR;
19954   p_sr_record.request_attribute_6        := FND_API.G_MISS_CHAR;
19955   p_sr_record.request_attribute_7        := FND_API.G_MISS_CHAR;
19956   p_sr_record.request_attribute_8        := FND_API.G_MISS_CHAR;
19957   p_sr_record.request_attribute_9        := FND_API.G_MISS_CHAR;
19958   p_sr_record.request_attribute_10       := FND_API.G_MISS_CHAR;
19959   p_sr_record.request_attribute_11       := FND_API.G_MISS_CHAR;
19960   p_sr_record.request_attribute_12       := FND_API.G_MISS_CHAR;
19961   p_sr_record.request_attribute_13       := FND_API.G_MISS_CHAR;
19962   p_sr_record.request_attribute_14       := FND_API.G_MISS_CHAR;
19963   p_sr_record.request_attribute_15       := FND_API.G_MISS_CHAR;
19964   p_sr_record.request_context            := FND_API.G_MISS_CHAR;
19965   p_sr_record.external_attribute_1       := FND_API.G_MISS_CHAR;
19966   p_sr_record.external_attribute_2       := FND_API.G_MISS_CHAR;
19967   p_sr_record.external_attribute_3       := FND_API.G_MISS_CHAR;
19968   p_sr_record.external_attribute_4       := FND_API.G_MISS_CHAR;
19969   p_sr_record.external_attribute_5       := FND_API.G_MISS_CHAR;
19970   p_sr_record.external_attribute_6       := FND_API.G_MISS_CHAR;
19971   p_sr_record.external_attribute_7       := FND_API.G_MISS_CHAR;
19972   p_sr_record.external_attribute_8       := FND_API.G_MISS_CHAR;
19973   p_sr_record.external_attribute_9       := FND_API.G_MISS_CHAR;
19974   p_sr_record.external_attribute_10      := FND_API.G_MISS_CHAR;
19975   p_sr_record.external_attribute_11      := FND_API.G_MISS_CHAR;
19976   p_sr_record.external_attribute_12      := FND_API.G_MISS_CHAR;
19977   p_sr_record.external_attribute_13      := FND_API.G_MISS_CHAR;
19978   p_sr_record.external_attribute_14      := FND_API.G_MISS_CHAR;
19979   p_sr_record.external_attribute_15      := FND_API.G_MISS_CHAR;
19980   p_sr_record.external_context           := FND_API.G_MISS_CHAR;
19981   p_sr_record.bill_to_site_use_id        := FND_API.G_MISS_NUM;
19982   p_sr_record.bill_to_contact_id         := FND_API.G_MISS_NUM;
19983   p_sr_record.ship_to_site_use_id        := FND_API.G_MISS_NUM;
19984   p_sr_record.ship_to_contact_id         := FND_API.G_MISS_NUM;
19985   p_sr_record.resolution_code            := FND_API.G_MISS_CHAR;
19986   p_sr_record.act_resolution_date        := FND_API.G_MISS_DATE;
19987   p_sr_record.public_comment_flag        := FND_API.G_MISS_CHAR;
19988   p_sr_record.parent_interaction_id      := FND_API.G_MISS_NUM;
19989   p_sr_record.contract_service_id        := FND_API.G_MISS_NUM;
19990   p_sr_record.contract_id                := FND_API.G_MISS_NUM;
19991   p_sr_record.project_number             := FND_API.G_MISS_CHAR;
19992   p_sr_record.qa_collection_plan_id      := FND_API.G_MISS_NUM;
19993   p_sr_record.account_id                 := FND_API.G_MISS_NUM;
19994   p_sr_record.resource_type              := FND_API.G_MISS_CHAR;
19995   p_sr_record.resource_subtype_id        := FND_API.G_MISS_NUM;
19996   p_sr_record.cust_po_number             := FND_API.G_MISS_CHAR;
19997   p_sr_record.cust_ticket_number         := FND_API.G_MISS_CHAR;
19998   p_sr_record.sr_creation_channel        := FND_API.G_MISS_CHAR;
19999   p_sr_record.obligation_date            := FND_API.G_MISS_DATE;
20000   p_sr_record.time_zone_id               := FND_API.G_MISS_NUM;
20001   p_sr_record.time_difference            := FND_API.G_MISS_NUM;
20002   p_sr_record.site_id                    := FND_API.G_MISS_NUM;
20003   p_sr_record.customer_site_id           := FND_API.G_MISS_NUM;
20004   p_sr_record.territory_id               := FND_API.G_MISS_NUM;
20005   p_sr_record.initialize_flag            := G_INITIALIZED;
20006   p_sr_record.cp_revision_id             := FND_API.G_MISS_NUM;
20007   p_sr_record.inv_item_revision          := FND_API.G_MISS_CHAR;
20008   p_sr_record.inv_component_id           := FND_API.G_MISS_NUM;
20009   p_sr_record.inv_component_version      := FND_API.G_MISS_CHAR;
20010   p_sr_record.inv_subcomponent_id        := FND_API.G_MISS_NUM;
20011   p_sr_record.inv_subcomponent_version   := FND_API.G_MISS_CHAR;
20012   p_sr_record.tier                       := FND_API.G_MISS_CHAR;
20013   p_sr_record.tier_version               := FND_API.G_MISS_CHAR;
20014   p_sr_record.operating_system           := FND_API.G_MISS_CHAR;
20015   p_sr_record.operating_system           := FND_API.G_MISS_CHAR;
20016   p_sr_record.DATABASE                   := FND_API.G_MISS_CHAR;
20017   p_sr_record.cust_pref_lang_id          := FND_API.G_MISS_NUM;
20018   p_sr_record.category_id                := FND_API.G_MISS_NUM;
20019   p_sr_record.group_type                 := FND_API.G_MISS_CHAR;
20020   p_sr_record.group_territory_id         := FND_API.G_MISS_NUM;
20021   p_sr_record.inv_platform_org_id        := FND_API.G_MISS_NUM;
20022   p_sr_record.component_version          := FND_API.G_MISS_CHAR;
20023   p_sr_record.subcomponent_version       := FND_API.G_MISS_CHAR;
20024   p_sr_record.product_revision           := FND_API.G_MISS_CHAR;
20025   p_sr_record.comm_pref_code             := FND_API.G_MISS_CHAR;
20026   p_sr_record.cust_pref_lang_code        := FND_API.G_MISS_CHAR;
20027   p_sr_record.category_set_id            := FND_API.G_MISS_NUM;
20028   p_sr_record.external_reference         := FND_API.G_MISS_CHAR;
20029   p_sr_record.system_id                  := FND_API.G_MISS_NUM;
20030 -- Added for HA
20031   p_sr_record.last_update_date           := FND_API.G_MISS_DATE;
20032   p_sr_record.last_updated_by            := FND_API.G_MISS_NUM;
20033   p_sr_record.creation_date              := FND_API.G_MISS_DATE;
20034   p_sr_record.created_by                 := FND_API.G_MISS_NUM;
20035   p_sr_record.last_update_login          := FND_API.G_MISS_NUM;
20036   p_sr_record.owner_assigned_flag        := FND_API.G_MISS_CHAR;
20037   p_sr_record.owner_assigned_time        := FND_API.G_MISS_DATE;
20038   p_sr_record.error_code                 := FND_API.G_MISS_CHAR;
20039   p_sr_record.incident_occurred_date     := FND_API.G_MISS_DATE;
20040   p_sr_record.incident_resolved_date     := FND_API.G_MISS_DATE;
20041   p_sr_record.inc_responded_by_date      := FND_API.G_MISS_DATE;
20042   p_sr_record.incident_location_id       := FND_API.G_MISS_NUM;
20043   p_sr_record.incident_address           := FND_API.G_MISS_CHAR;
20044   p_sr_record.incident_city              := FND_API.G_MISS_CHAR;
20045   p_sr_record.incident_state             := FND_API.G_MISS_CHAR;
20046   p_sr_record.incident_country           := FND_API.G_MISS_CHAR;
20047   p_sr_record.incident_province          := FND_API.G_MISS_CHAR;
20048   p_sr_record.incident_postal_code       := FND_API.G_MISS_CHAR;
20049   p_sr_record.incident_county            := FND_API.G_MISS_CHAR;
20050   p_sr_record.resolution_summary         := FND_API.G_MISS_CHAR;
20051   p_sr_record.owner                      := FND_API.G_MISS_CHAR;
20052   p_sr_record.group_owner                := FND_API.G_MISS_CHAR;
20053   -- Added for ER# 2320056
20054   p_sr_record.coverage_type              := FND_API.G_MISS_CHAR;
20055   --  Added for ER# 2433831
20056   p_sr_record.bill_to_account_id         := FND_API.G_MISS_NUM;
20057   p_sr_record.ship_to_account_id         := FND_API.G_MISS_NUM;
20058   --  Added for ER# 2463321
20059   p_sr_record.customer_phone_id   	 := FND_API.G_MISS_NUM;
20060   p_sr_record.customer_email_id   	 := FND_API.G_MISS_NUM;
20061   -- Added these parameters for 11.5.9 source changes
20062   p_sr_record.creation_program_code      := FND_API.G_MISS_CHAR;
20063   p_sr_record.last_update_program_code   := FND_API.G_MISS_CHAR;
20064   -- Bill_to_party, ship_to_party
20065   p_sr_record.bill_to_party_id           := FND_API.G_MISS_NUM;
20066   p_sr_record.ship_to_party_id           := FND_API.G_MISS_NUM;
20067   -- Conc request related fields
20068   p_sr_record.program_id                 := FND_API.G_MISS_NUM;
20069   p_sr_record.program_application_id     := FND_API.G_MISS_NUM;
20070   p_sr_record.conc_request_id            := FND_API.G_MISS_NUM;
20071   p_sr_record.program_login_id           := FND_API.G_MISS_NUM;
20072   -- Bill_to_site, ship_to_site
20073   p_sr_record.bill_to_site_id   	 := FND_API.G_MISS_NUM;
20074   p_sr_record.ship_to_site_id   	 := FND_API.G_MISS_NUM;
20075    -- Added to initialize the address columns by shijain dec 4th 2002
20076   p_sr_record.incident_point_of_interest   := FND_API.G_MISS_CHAR;
20077   p_sr_record.incident_cross_street        := FND_API.G_MISS_CHAR;
20078   p_sr_record.incident_direction_qualifier := FND_API.G_MISS_CHAR;
20079   p_sr_record.incident_distance_qualifier  := FND_API.G_MISS_CHAR;
20080   p_sr_record.incident_distance_qual_uom   := FND_API.G_MISS_CHAR;
20081   p_sr_record.incident_address2            := FND_API.G_MISS_CHAR;
20082   p_sr_record.incident_address3            := FND_API.G_MISS_CHAR;
20083   p_sr_record.incident_address4            := FND_API.G_MISS_CHAR;
20084   p_sr_record.incident_address_style       := FND_API.G_MISS_CHAR;
20085   p_sr_record.incident_addr_lines_phonetic := FND_API.G_MISS_CHAR;
20086   p_sr_record.incident_po_box_number       := FND_API.G_MISS_CHAR;
20087   p_sr_record.incident_house_number        := FND_API.G_MISS_CHAR;
20088   p_sr_record.incident_street_suffix       := FND_API.G_MISS_CHAR;
20089   p_sr_record.incident_street              := FND_API.G_MISS_CHAR;
20090   p_sr_record.incident_street_number       := FND_API.G_MISS_CHAR;
20091   p_sr_record.incident_floor               := FND_API.G_MISS_CHAR;
20092   p_sr_record.incident_suite               := FND_API.G_MISS_CHAR;
20093   p_sr_record.incident_postal_plus4_code   := FND_API.G_MISS_CHAR;
20094   p_sr_record.incident_position            := FND_API.G_MISS_CHAR;
20095   p_sr_record.incident_location_directions := FND_API.G_MISS_CHAR;
20096   p_sr_record.incident_location_description:= FND_API.G_MISS_CHAR;
20097   p_sr_record.install_site_id              := FND_API.G_MISS_NUM;
20098   -- Added to initialize the columns added for CMRO-EAM project (11.5.10) by anmukher aug 12 2003
20099   p_sr_record.owning_dept_id		   := FND_API.G_MISS_NUM;
20100   p_sr_record.old_type_CMRO_flag           := FND_API.G_MISS_CHAR;
20101   p_sr_record.new_type_CMRO_flag           := FND_API.G_MISS_CHAR;
20102   p_sr_record.old_type_maintenance_flag    := FND_API.G_MISS_CHAR;
20103   p_sr_record.new_type_maintenance_flag    := FND_API.G_MISS_CHAR;
20104   -- Added to initialize the column incident_location_type for MISC ERs Project (11.5.10) --anmukher --08/26/03
20105   p_sr_record.incident_location_type	   := FND_API.G_MISS_CHAR;
20106   p_sr_record.maint_organization_id        := FND_API.G_MISS_NUM;
20107   /* Credit Card 9358401 */
20108   p_sr_record.instrument_payment_use_id          := FND_API.G_MISS_NUM;
20109    --project related attributes 12.2+
20110   p_sr_record.project_id     	             := FND_API.G_MISS_NUM;
20111   p_sr_record.project_task_id                := FND_API.G_MISS_NUM;
20112   p_sr_record.expenditure_org_id                   := FND_API.G_MISS_NUM;
20113   --14004721 . Additional SLA dates
20114   p_sr_record.sla_date_1		   := FND_API.G_MISS_DATE;
20115   p_sr_record.sla_date_2		   := FND_API.G_MISS_DATE;
20116   p_sr_record.sla_date_3		   := FND_API.G_MISS_DATE;
20117   p_sr_record.sla_date_4		   := FND_API.G_MISS_DATE;
20118   p_sr_record.sla_date_5		   := FND_API.G_MISS_DATE;
20119   p_sr_record.sla_date_6		   := FND_API.G_MISS_DATE;
20120   p_sr_record.sla_duration_1		   := FND_API.G_MISS_NUM;
20121   p_sr_record.sla_duration_2		   := FND_API.G_MISS_NUM;
20122    --15995804. Add price_list_header_id
20123   p_sr_record.price_list_header_id	   := FND_API.G_MISS_NUM;
20124 END initialize_rec;
20125 
20126 ---- Procedure to initialize the audit record.
20127 -- -----------------------------------------------------------------------------
20128 -- Modification History
20129 -- Date     Name      Desc
20130 -- -------- --------- ----------------------------------------------------------
20131 -- 07/21/05 smisra    Added miant organization and old maint organization id col
20132 -- -----------------------------------------------------------------------------
20133 PROCEDURE initialize_audit_rec(
20134   p_sr_audit_record         IN OUT NOCOPY sr_audit_rec_type
20135 ) AS
20136 BEGIN
20137   p_sr_audit_record.INCIDENT_STATUS_ID              := NULL;
20138   p_sr_audit_record.OLD_INCIDENT_STATUS_ID          := NULL;
20139   p_sr_audit_record.CHANGE_INCIDENT_STATUS_FLAG     := NULL;
20140   p_sr_audit_record.INCIDENT_TYPE_ID                := NULL;
20141   p_sr_audit_record.OLD_INCIDENT_TYPE_ID            := NULL;
20142   p_sr_audit_record.CHANGE_INCIDENT_TYPE_FLAG       := NULL;
20143   p_sr_audit_record.INCIDENT_URGENCY_ID             := NULL;
20144   p_sr_audit_record.OLD_INCIDENT_URGENCY_ID         := NULL;
20145   p_sr_audit_record.CHANGE_INCIDENT_URGENCY_FLAG    := NULL;
20146   p_sr_audit_record.INCIDENT_SEVERITY_ID            := NULL;
20147   p_sr_audit_record.OLD_INCIDENT_SEVERITY_ID        := NULL;
20148   p_sr_audit_record.CHANGE_INCIDENT_SEVERITY_FLAG   := NULL;
20149   p_sr_audit_record.RESPONSIBLE_GROUP_ID            := NULL;
20150   p_sr_audit_record.OLD_RESPONSIBLE_GROUP_ID        := NULL;
20151   p_sr_audit_record.CHANGE_RESPONSIBLE_GROUP_FLAG   := NULL;
20152   p_sr_audit_record.INCIDENT_OWNER_ID               := NULL;
20153   p_sr_audit_record.OLD_INCIDENT_OWNER_ID           := NULL;
20154   p_sr_audit_record.CHANGE_INCIDENT_OWNER_FLAG      := NULL;
20155   p_sr_audit_record.CREATE_MANUAL_ACTION            := NULL;
20156   p_sr_audit_record.ACTION_ID                       := NULL;
20157   p_sr_audit_record.EXPECTED_RESOLUTION_DATE        := NULL;
20158   p_sr_audit_record.OLD_EXPECTED_RESOLUTION_DATE    := NULL;
20159   p_sr_audit_record.CHANGE_RESOLUTION_FLAG          := NULL;
20160   p_sr_audit_record.NEW_WORKFLOW_FLAG               := NULL;
20161   p_sr_audit_record.WORKFLOW_PROCESS_NAME           := NULL;
20162   p_sr_audit_record.WORKFLOW_PROCESS_ITEMKEY        := NULL;
20163   p_sr_audit_record.GROUP_ID                        := NULL;
20164   p_sr_audit_record.OLD_GROUP_ID                    := NULL;
20165   p_sr_audit_record.CHANGE_GROUP_FLAG               := NULL;
20166   p_sr_audit_record.OBLIGATION_DATE                 := NULL;
20167   p_sr_audit_record.OLD_OBLIGATION_DATE             := NULL;
20168   p_sr_audit_record.CHANGE_OBLIGATION_FLAG          := NULL;
20169   p_sr_audit_record.SITE_ID                         := NULL;
20170   p_sr_audit_record.OLD_SITE_ID                     := NULL;
20171   p_sr_audit_record.CHANGE_SITE_FLAG                := NULL;
20172   p_sr_audit_record.BILL_TO_CONTACT_ID              := NULL;
20173   p_sr_audit_record.OLD_BILL_TO_CONTACT_ID          := NULL;
20174   p_sr_audit_record.CHANGE_BILL_TO_FLAG             := NULL;
20175   p_sr_audit_record.SHIP_TO_CONTACT_ID              := NULL;
20176   p_sr_audit_record.OLD_SHIP_TO_CONTACT_ID          := NULL;
20177   p_sr_audit_record.CHANGE_SHIP_TO_FLAG             := NULL;
20178   p_sr_audit_record.INCIDENT_DATE                   := NULL;
20179   p_sr_audit_record.OLD_INCIDENT_DATE               := NULL;
20180   p_sr_audit_record.CHANGE_INCIDENT_DATE_FLAG       := NULL;
20181   p_sr_audit_record.CLOSE_DATE                      := NULL;
20182   p_sr_audit_record.OLD_CLOSE_DATE                  := NULL;
20183   p_sr_audit_record.CHANGE_CLOSE_DATE_FLAG          := NULL;
20184   p_sr_audit_record.CUSTOMER_PRODUCT_ID             := NULL;
20185   p_sr_audit_record.OLD_CUSTOMER_PRODUCT_ID         := NULL;
20186   p_sr_audit_record.CHANGE_CUSTOMER_PRODUCT_FLAG    := NULL;
20187   p_sr_audit_record.PLATFORM_ID                     := NULL;
20188   p_sr_audit_record.OLD_PLATFORM_ID                 := NULL;
20189   p_sr_audit_record.CHANGE_PLATFORM_ID_FLAG         := NULL;
20190   p_sr_audit_record.PLATFORM_VERSION_ID             := NULL;
20191   p_sr_audit_record.OLD_PLATFORM_VERSION_ID         := NULL;
20192   p_sr_audit_record.CHANGE_PLAT_VER_ID_FLAG         := NULL;
20193   p_sr_audit_record.CP_COMPONENT_ID                 := NULL;
20194   p_sr_audit_record.OLD_CP_COMPONENT_ID             := NULL;
20195   p_sr_audit_record.CHANGE_CP_COMPONENT_ID_FLAG     := NULL;
20196   p_sr_audit_record.CP_COMPONENT_VERSION_ID         := NULL;
20197   p_sr_audit_record.OLD_CP_COMPONENT_VERSION_ID     := NULL;
20198   p_sr_audit_record.CHANGE_CP_COMP_VER_ID_FLAG      := NULL;
20199   p_sr_audit_record.CP_SUBCOMPONENT_ID              := NULL;
20200   p_sr_audit_record.OLD_CP_SUBCOMPONENT_ID          := NULL;
20201   p_sr_audit_record.CHANGE_CP_SUBCOMPONENT_ID_FLAG  := NULL;
20202   p_sr_audit_record.CP_SUBCOMPONENT_VERSION_ID      := NULL;
20203   p_sr_audit_record.OLD_CP_SUBCOMPONENT_VERSION_ID  := NULL;
20204   p_sr_audit_record.CHANGE_CP_SUBCOMP_VER_ID_FLAG   := NULL;
20205   p_sr_audit_record.LANGUAGE_ID                     := NULL;
20206   p_sr_audit_record.OLD_LANGUAGE_ID                 := NULL;
20207   p_sr_audit_record.CHANGE_LANGUAGE_ID_FLAG         := NULL;
20208   p_sr_audit_record.TERRITORY_ID                    := NULL;
20209   p_sr_audit_record.OLD_TERRITORY_ID                := NULL;
20210   p_sr_audit_record.CHANGE_TERRITORY_ID_FLAG        := NULL;
20211   p_sr_audit_record.CP_REVISION_ID                  := NULL;
20212   p_sr_audit_record.OLD_CP_REVISION_ID              := NULL;
20213   p_sr_audit_record.CHANGE_CP_REVISION_ID_FLAG      := NULL;
20214   p_sr_audit_record.INV_ITEM_REVISION               := NULL;
20215   p_sr_audit_record.OLD_INV_ITEM_REVISION           := NULL;
20216   p_sr_audit_record.CHANGE_INV_ITEM_REVISION        := NULL;
20217   p_sr_audit_record.INV_COMPONENT_ID                := NULL;
20218   p_sr_audit_record.OLD_INV_COMPONENT_ID            := NULL;
20219   p_sr_audit_record.CHANGE_INV_COMPONENT_ID         := NULL;
20220   p_sr_audit_record.INV_COMPONENT_VERSION           := NULL;
20221   p_sr_audit_record.OLD_INV_COMPONENT_VERSION       := NULL;
20222   p_sr_audit_record.CHANGE_INV_COMPONENT_VERSION    := NULL;
20223   p_sr_audit_record.INV_SUBCOMPONENT_ID             := NULL;
20224   p_sr_audit_record.OLD_INV_SUBCOMPONENT_ID         := NULL;
20225   p_sr_audit_record.CHANGE_INV_SUBCOMPONENT_ID      := NULL;
20226   p_sr_audit_record.INV_SUBCOMPONENT_VERSION        := NULL;
20227   p_sr_audit_record.OLD_INV_SUBCOMPONENT_VERSION    := NULL;
20228   p_sr_audit_record.CHANGE_INV_SUBCOMP_VERSION      := NULL;
20229   p_sr_audit_record.RESOURCE_TYPE                   := NULL;
20230   p_sr_audit_record.OLD_RESOURCE_TYPE               := NULL;
20231   p_sr_audit_record.CHANGE_RESOURCE_TYPE_FLAG       := NULL;
20232   p_sr_audit_record.SECURITY_GROUP_ID               := NULL;
20233   p_sr_audit_record.UPGRADED_STATUS_FLAG            := NULL;
20234   p_sr_audit_record.OLD_GROUP_TYPE                  := NULL;
20235   p_sr_audit_record.GROUP_TYPE                      := NULL;
20236   p_sr_audit_record.CHANGE_GROUP_TYPE_FLAG          := NULL;
20237   p_sr_audit_record.OLD_OWNER_ASSIGNED_TIME         := NULL;
20238   p_sr_audit_record.OWNER_ASSIGNED_TIME             := NULL;
20239   p_sr_audit_record.CHANGE_ASSIGNED_TIME_FLAG       := NULL;
20240   p_sr_audit_record.INV_PLATFORM_ORG_ID             := NULL;
20241   p_sr_audit_record.OLD_INV_PLATFORM_ORG_ID         := NULL;
20242   p_sr_audit_record.CHANGE_PLATFORM_ORG_ID_FLAG     := NULL;
20243   p_sr_audit_record.COMPONENT_VERSION               := NULL;
20244   p_sr_audit_record.OLD_COMPONENT_VERSION           := NULL;
20245   p_sr_audit_record.CHANGE_COMP_VER_FLAG            := NULL;
20246   p_sr_audit_record.SUBCOMPONENT_VERSION            := NULL;
20247   p_sr_audit_record.OLD_SUBCOMPONENT_VERSION        := NULL;
20248   p_sr_audit_record.CHANGE_SUBCOMP_VER_FLAG         := NULL;
20249   p_sr_audit_record.PRODUCT_REVISION                := NULL;
20250   p_sr_audit_record.OLD_PRODUCT_REVISION            := NULL;
20251   p_sr_audit_record.CHANGE_PRODUCT_REVISION_FLAG    := NULL;
20252   p_sr_audit_record.STATUS_FLAG                     := NULL;
20253   p_sr_audit_record.OLD_STATUS_FLAG                 := NULL;
20254   p_sr_audit_record.CHANGE_STATUS_FLAG              := NULL;
20255   p_sr_audit_record.INVENTORY_ITEM_ID               := NULL;
20256   p_sr_audit_record.OLD_INVENTORY_ITEM_ID           := NULL;
20257   p_sr_audit_record.CHANGE_INVENTORY_ITEM_FLAG      := NULL;
20258   p_sr_audit_record.INV_ORGANIZATION_ID             := NULL;
20259   p_sr_audit_record.OLD_INV_ORGANIZATION_ID         := NULL;
20260   p_sr_audit_record.CHANGE_INV_ORGANIZATION_FLAG    := NULL;
20261   --p_sr_audit_record.PRIMARY_CONTACT_ID              := NULL;
20262   --p_sr_audit_record.CHANGE_PRIMARY_CONTACT_FLAG     := NULL;
20263   --p_sr_audit_record.OLD_PRIMARY_CONTACT_ID          := NULL;
20264 
20265   --Added for Auditing project of 11.5.10 --anmukher --09/09/03
20266 
20267   p_sr_audit_record.UPGRADE_FLAG_FOR_CREATE                  := NULL;
20268 p_sr_audit_record.OLD_INCIDENT_NUMBER                      := NULL;
20269 p_sr_audit_record.INCIDENT_NUMBER                          := NULL;
20270 p_sr_audit_record.OLD_CUSTOMER_ID                          := NULL;
20271 p_sr_audit_record.CUSTOMER_ID                              := NULL;
20272 p_sr_audit_record.OLD_BILL_TO_SITE_USE_ID                  := NULL;
20273 p_sr_audit_record.BILL_TO_SITE_USE_ID                      := NULL;
20274 p_sr_audit_record.OLD_EMPLOYEE_ID                          := NULL;
20275 p_sr_audit_record.EMPLOYEE_ID                              := NULL;
20276 p_sr_audit_record.OLD_SHIP_TO_SITE_USE_ID                  := NULL;
20277 p_sr_audit_record.SHIP_TO_SITE_USE_ID                      := NULL;
20278 p_sr_audit_record.OLD_PROBLEM_CODE                         := NULL;
20279 p_sr_audit_record.PROBLEM_CODE                             := NULL;
20280 p_sr_audit_record.OLD_ACTUAL_RESOLUTION_DATE               := NULL;
20281 p_sr_audit_record.ACTUAL_RESOLUTION_DATE                   := NULL;
20282 p_sr_audit_record.OLD_INSTALL_SITE_USE_ID                  := NULL;
20283 p_sr_audit_record.INSTALL_SITE_USE_ID                      := NULL;
20284 p_sr_audit_record.OLD_CURRENT_SERIAL_NUMBER                := NULL;
20285 p_sr_audit_record.CURRENT_SERIAL_NUMBER                    := NULL;
20286 p_sr_audit_record.OLD_SYSTEM_ID                            := NULL;
20287 p_sr_audit_record.SYSTEM_ID                                := NULL;
20288 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_1                 := NULL;
20289 p_sr_audit_record.INCIDENT_ATTRIBUTE_1                     := NULL;
20290 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_2                 := NULL;
20291 p_sr_audit_record.INCIDENT_ATTRIBUTE_2                     := NULL;
20292 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_3                 := NULL;
20293 p_sr_audit_record.INCIDENT_ATTRIBUTE_3                     := NULL;
20294 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_4                 := NULL;
20295 p_sr_audit_record.INCIDENT_ATTRIBUTE_4                     := NULL;
20296 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_5                 := NULL;
20297 p_sr_audit_record.INCIDENT_ATTRIBUTE_5                     := NULL;
20298 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_6                 := NULL;
20299 p_sr_audit_record.INCIDENT_ATTRIBUTE_6                     := NULL;
20300 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_7                 := NULL;
20301 p_sr_audit_record.INCIDENT_ATTRIBUTE_7                     := NULL;
20302 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_8                 := NULL;
20303 p_sr_audit_record.INCIDENT_ATTRIBUTE_8                     := NULL;
20304 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_9                 := NULL;
20305 p_sr_audit_record.INCIDENT_ATTRIBUTE_9                     := NULL;
20306 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_10                := NULL;
20307 p_sr_audit_record.INCIDENT_ATTRIBUTE_10                    := NULL;
20308 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_11                := NULL;
20309 p_sr_audit_record.INCIDENT_ATTRIBUTE_11                    := NULL;
20310 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_12                := NULL;
20311 p_sr_audit_record.INCIDENT_ATTRIBUTE_12                    := NULL;
20312 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_13                := NULL;
20313 p_sr_audit_record.INCIDENT_ATTRIBUTE_13                    := NULL;
20314 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_14                := NULL;
20315 p_sr_audit_record.INCIDENT_ATTRIBUTE_14                    := NULL;
20316 p_sr_audit_record.OLD_INCIDENT_ATTRIBUTE_15                := NULL;
20317 p_sr_audit_record.INCIDENT_ATTRIBUTE_15                    := NULL;
20318 p_sr_audit_record.OLD_INCIDENT_CONTEXT                     := NULL;
20319 p_sr_audit_record.INCIDENT_CONTEXT                         := NULL;
20320 p_sr_audit_record.OLD_RESOLUTION_CODE                      := NULL;
20321 p_sr_audit_record.RESOLUTION_CODE                          := NULL;
20322 p_sr_audit_record.OLD_ORIGINAL_ORDER_NUMBER                := NULL;
20323 p_sr_audit_record.ORIGINAL_ORDER_NUMBER                    := NULL;
20324 p_sr_audit_record.OLD_ORG_ID                               := NULL;
20325 p_sr_audit_record.ORG_ID                                   := NULL;
20326 p_sr_audit_record.OLD_PURCHASE_ORDER_NUMBER                := NULL;
20327 p_sr_audit_record.PURCHASE_ORDER_NUMBER                    := NULL;
20328 p_sr_audit_record.OLD_PUBLISH_FLAG                         := NULL;
20329 p_sr_audit_record.PUBLISH_FLAG                             := NULL;
20330 p_sr_audit_record.OLD_QA_COLLECTION_ID                     := NULL;
20331 p_sr_audit_record.QA_COLLECTION_ID                         := NULL;
20332 p_sr_audit_record.OLD_CONTRACT_ID                          := NULL;
20333 p_sr_audit_record.CONTRACT_ID                              := NULL;
20334 p_sr_audit_record.OLD_CONTRACT_NUMBER                      := NULL;
20335 p_sr_audit_record.CONTRACT_NUMBER                          := NULL;
20336 p_sr_audit_record.OLD_CONTRACT_SERVICE_ID                  := NULL;
20337 p_sr_audit_record.CONTRACT_SERVICE_ID                      := NULL;
20338 p_sr_audit_record.OLD_TIME_ZONE_ID                         := NULL;
20339 p_sr_audit_record.TIME_ZONE_ID                             := NULL;
20340 p_sr_audit_record.OLD_ACCOUNT_ID                           := NULL;
20341 p_sr_audit_record.ACCOUNT_ID                               := NULL;
20342 p_sr_audit_record.OLD_TIME_DIFFERENCE                      := NULL;
20343 p_sr_audit_record.TIME_DIFFERENCE                          := NULL;
20344 p_sr_audit_record.OLD_CUSTOMER_PO_NUMBER                   := NULL;
20345 p_sr_audit_record.CUSTOMER_PO_NUMBER                       := NULL;
20346 p_sr_audit_record.OLD_CUSTOMER_TICKET_NUMBER               := NULL;
20347 p_sr_audit_record.CUSTOMER_TICKET_NUMBER                   := NULL;
20348 p_sr_audit_record.OLD_CUSTOMER_SITE_ID                     := NULL;
20349 p_sr_audit_record.CUSTOMER_SITE_ID                         := NULL;
20350 p_sr_audit_record.OLD_CALLER_TYPE                          := NULL;
20351 p_sr_audit_record.CALLER_TYPE                              := NULL;
20352 p_sr_audit_record.OLD_SECURITY_GROUP_ID                    := NULL;
20353 p_sr_audit_record.OLD_ORIG_SYSTEM_REFERENCE                := NULL;
20354 p_sr_audit_record.ORIG_SYSTEM_REFERENCE                    := NULL;
20355 p_sr_audit_record.OLD_ORIG_SYSTEM_REFERENCE_ID             := NULL;
20356 p_sr_audit_record.ORIG_SYSTEM_REFERENCE_ID                 := NULL;
20357 p_sr_audit_record.REQUEST_ID                           := NULL;
20358 p_sr_audit_record.PROGRAM_APPLICATION_ID               := NULL;
20359 p_sr_audit_record.PROGRAM_ID                           := NULL;
20360 p_sr_audit_record.PROGRAM_UPDATE_DATE                  := NULL;
20361 p_sr_audit_record.OLD_PROJECT_NUMBER                       := NULL;
20362 p_sr_audit_record.PROJECT_NUMBER                           := NULL;
20363 p_sr_audit_record.OLD_PLATFORM_VERSION                     := NULL;
20364 p_sr_audit_record.PLATFORM_VERSION                         := NULL;
20365 p_sr_audit_record.OLD_DB_VERSION                           := NULL;
20366 p_sr_audit_record.DB_VERSION                               := NULL;
20367 p_sr_audit_record.OLD_CUST_PREF_LANG_ID                    := NULL;
20368 p_sr_audit_record.CUST_PREF_LANG_ID                        := NULL;
20369 p_sr_audit_record.OLD_TIER                                 := NULL;
20370 p_sr_audit_record.TIER                                     := NULL;
20371 p_sr_audit_record.OLD_CATEGORY_ID                          := NULL;
20372 p_sr_audit_record.CATEGORY_ID                              := NULL;
20373 p_sr_audit_record.OLD_OPERATING_SYSTEM                     := NULL;
20374 p_sr_audit_record.OPERATING_SYSTEM                         := NULL;
20375 p_sr_audit_record.OLD_OPERATING_SYSTEM_VERSION             := NULL;
20376 p_sr_audit_record.OPERATING_SYSTEM_VERSION                 := NULL;
20377 p_sr_audit_record.OLD_DATABASE                             := NULL;
20378 p_sr_audit_record.DATABASE                                 := NULL;
20379 p_sr_audit_record.OLD_GROUP_TERRITORY_ID                   := NULL;
20380 p_sr_audit_record.GROUP_TERRITORY_ID                       := NULL;
20381 p_sr_audit_record.OLD_COMM_PREF_CODE                       := NULL;
20382 p_sr_audit_record.COMM_PREF_CODE                           := NULL;
20383 p_sr_audit_record.OLD_LAST_UPDATE_CHANNEL                  := NULL;
20384 p_sr_audit_record.LAST_UPDATE_CHANNEL                      := NULL;
20385 p_sr_audit_record.OLD_CUST_PREF_LANG_CODE                  := NULL;
20386 p_sr_audit_record.CUST_PREF_LANG_CODE                      := NULL;
20387 p_sr_audit_record.OLD_ERROR_CODE                           := NULL;
20388 p_sr_audit_record.ERROR_CODE                               := NULL;
20389 p_sr_audit_record.OLD_CATEGORY_SET_ID                      := NULL;
20390 p_sr_audit_record.CATEGORY_SET_ID                          := NULL;
20391 p_sr_audit_record.OLD_EXTERNAL_REFERENCE                   := NULL;
20392 p_sr_audit_record.EXTERNAL_REFERENCE                       := NULL;
20393 p_sr_audit_record.OLD_INCIDENT_OCCURRED_DATE               := NULL;
20394 p_sr_audit_record.INCIDENT_OCCURRED_DATE                   := NULL;
20395 p_sr_audit_record.OLD_INCIDENT_RESOLVED_DATE               := NULL;
20396 p_sr_audit_record.INCIDENT_RESOLVED_DATE                   := NULL;
20397 p_sr_audit_record.OLD_INC_RESPONDED_BY_DATE                := NULL;
20398 p_sr_audit_record.INC_RESPONDED_BY_DATE                    := NULL;
20399 p_sr_audit_record.OLD_INCIDENT_LOCATION_ID                 := NULL;
20400 p_sr_audit_record.INCIDENT_LOCATION_ID                     := NULL;
20401 p_sr_audit_record.OLD_INCIDENT_ADDRESS                     := NULL;
20402 p_sr_audit_record.INCIDENT_ADDRESS                         := NULL;
20403 p_sr_audit_record.OLD_INCIDENT_CITY                        := NULL;
20404 p_sr_audit_record.INCIDENT_CITY                            := NULL;
20405 p_sr_audit_record.OLD_INCIDENT_STATE                       := NULL;
20406 p_sr_audit_record.INCIDENT_STATE                           := NULL;
20407 p_sr_audit_record.OLD_INCIDENT_COUNTRY                     := NULL;
20408 p_sr_audit_record.INCIDENT_COUNTRY                         := NULL;
20409 p_sr_audit_record.OLD_INCIDENT_PROVINCE                    := NULL;
20410 p_sr_audit_record.INCIDENT_PROVINCE                        := NULL;
20411 p_sr_audit_record.OLD_INCIDENT_POSTAL_CODE                 := NULL;
20412 p_sr_audit_record.INCIDENT_POSTAL_CODE                     := NULL;
20413 p_sr_audit_record.OLD_INCIDENT_COUNTY                      := NULL;
20414 p_sr_audit_record.INCIDENT_COUNTY                          := NULL;
20415 p_sr_audit_record.OLD_SR_CREATION_CHANNEL                  := NULL;
20416 p_sr_audit_record.SR_CREATION_CHANNEL                      := NULL;
20417 p_sr_audit_record.OLD_DEF_DEFECT_ID                        := NULL;
20418 p_sr_audit_record.DEF_DEFECT_ID                            := NULL;
20419 p_sr_audit_record.OLD_DEF_DEFECT_ID2                       := NULL;
20420 p_sr_audit_record.DEF_DEFECT_ID2                           := NULL;
20421 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_1                 := NULL;
20422 p_sr_audit_record.EXTERNAL_ATTRIBUTE_1                     := NULL;
20423 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_2                 := NULL;
20424 p_sr_audit_record.EXTERNAL_ATTRIBUTE_2                     := NULL;
20425 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_3                 := NULL;
20426 p_sr_audit_record.EXTERNAL_ATTRIBUTE_3                     := NULL;
20427 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_4                 := NULL;
20428 p_sr_audit_record.EXTERNAL_ATTRIBUTE_4                     := NULL;
20429 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_5                 := NULL;
20430 p_sr_audit_record.EXTERNAL_ATTRIBUTE_5                     := NULL;
20431 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_6                 := NULL;
20432 p_sr_audit_record.EXTERNAL_ATTRIBUTE_6                     := NULL;
20433 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_7                 := NULL;
20434 p_sr_audit_record.EXTERNAL_ATTRIBUTE_7                     := NULL;
20435 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_8                 := NULL;
20436 p_sr_audit_record.EXTERNAL_ATTRIBUTE_8                     := NULL;
20437 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_9                 := NULL;
20438 p_sr_audit_record.EXTERNAL_ATTRIBUTE_9                     := NULL;
20439 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_10                := NULL;
20440 p_sr_audit_record.EXTERNAL_ATTRIBUTE_10                    := NULL;
20441 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_11                := NULL;
20442 p_sr_audit_record.EXTERNAL_ATTRIBUTE_11                    := NULL;
20443 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_12                := NULL;
20444 p_sr_audit_record.EXTERNAL_ATTRIBUTE_12                    := NULL;
20445 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_13                := NULL;
20446 p_sr_audit_record.EXTERNAL_ATTRIBUTE_13                    := NULL;
20447 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_14                := NULL;
20448 p_sr_audit_record.EXTERNAL_ATTRIBUTE_14                    := NULL;
20449 p_sr_audit_record.OLD_EXTERNAL_ATTRIBUTE_15                := NULL;
20450 p_sr_audit_record.EXTERNAL_ATTRIBUTE_15                    := NULL;
20451 p_sr_audit_record.OLD_EXTERNAL_CONTEXT                     := NULL;
20452 p_sr_audit_record.EXTERNAL_CONTEXT                         := NULL;
20453 p_sr_audit_record.OLD_LAST_UPDATE_PROGRAM_CODE             := NULL;
20454 p_sr_audit_record.LAST_UPDATE_PROGRAM_CODE                 := NULL;
20455 p_sr_audit_record.OLD_CREATION_PROGRAM_CODE                := NULL;
20456 p_sr_audit_record.CREATION_PROGRAM_CODE                    := NULL;
20457 p_sr_audit_record.OLD_COVERAGE_TYPE                        := NULL;
20458 p_sr_audit_record.COVERAGE_TYPE                            := NULL;
20459 p_sr_audit_record.OLD_BILL_TO_ACCOUNT_ID                   := NULL;
20460 p_sr_audit_record.BILL_TO_ACCOUNT_ID                       := NULL;
20461 p_sr_audit_record.OLD_SHIP_TO_ACCOUNT_ID                   := NULL;
20462 p_sr_audit_record.SHIP_TO_ACCOUNT_ID                       := NULL;
20463 p_sr_audit_record.OLD_CUSTOMER_EMAIL_ID                    := NULL;
20464 p_sr_audit_record.CUSTOMER_EMAIL_ID                        := NULL;
20465 p_sr_audit_record.OLD_CUSTOMER_PHONE_ID                    := NULL;
20466 p_sr_audit_record.CUSTOMER_PHONE_ID                        := NULL;
20467 p_sr_audit_record.OLD_BILL_TO_PARTY_ID                     := NULL;
20468 p_sr_audit_record.BILL_TO_PARTY_ID                         := NULL;
20469 p_sr_audit_record.OLD_SHIP_TO_PARTY_ID                     := NULL;
20470 p_sr_audit_record.SHIP_TO_PARTY_ID                         := NULL;
20471 p_sr_audit_record.OLD_BILL_TO_SITE_ID                      := NULL;
20472 p_sr_audit_record.BILL_TO_SITE_ID                          := NULL;
20473 p_sr_audit_record.OLD_SHIP_TO_SITE_ID                      := NULL;
20474 p_sr_audit_record.SHIP_TO_SITE_ID                          := NULL;
20475 p_sr_audit_record.OLD_PROGRAM_LOGIN_ID                     := NULL;
20476 p_sr_audit_record.PROGRAM_LOGIN_ID                         := NULL;
20477 p_sr_audit_record.OLD_INCIDENT_POINT_OF_INTEREST           := NULL;
20478 p_sr_audit_record.INCIDENT_POINT_OF_INTEREST               := NULL;
20479 p_sr_audit_record.OLD_INCIDENT_CROSS_STREET                := NULL;
20480 p_sr_audit_record.INCIDENT_CROSS_STREET                    := NULL;
20481 p_sr_audit_record.OLD_INCIDENT_DIRECTION_QUALIF            := NULL;
20482 p_sr_audit_record.INCIDENT_DIRECTION_QUALIF                := NULL;
20483 p_sr_audit_record.OLD_INCIDENT_DISTANCE_QUALIF             := NULL;
20484 p_sr_audit_record.INCIDENT_DISTANCE_QUALIF                 := NULL;
20485 p_sr_audit_record.OLD_INCIDENT_DISTANCE_QUAL_UOM           := NULL;
20486 p_sr_audit_record.INCIDENT_DISTANCE_QUAL_UOM               := NULL;
20487 p_sr_audit_record.OLD_INCIDENT_ADDRESS2                    := NULL;
20488 p_sr_audit_record.INCIDENT_ADDRESS2                        := NULL;
20489 p_sr_audit_record.OLD_INCIDENT_ADDRESS3                    := NULL;
20490 p_sr_audit_record.INCIDENT_ADDRESS3                        := NULL;
20491 p_sr_audit_record.OLD_INCIDENT_ADDRESS4                    := NULL;
20492 p_sr_audit_record.INCIDENT_ADDRESS4                        := NULL;
20493 p_sr_audit_record.OLD_INCIDENT_ADDRESS_STYLE               := NULL;
20494 p_sr_audit_record.INCIDENT_ADDRESS_STYLE                   := NULL;
20495 p_sr_audit_record.OLD_INCIDENT_ADDR_LNS_PHONETIC           := NULL;
20496 p_sr_audit_record.INCIDENT_ADDR_LNS_PHONETIC               := NULL;
20497 p_sr_audit_record.OLD_INCIDENT_PO_BOX_NUMBER               := NULL;
20498 p_sr_audit_record.INCIDENT_PO_BOX_NUMBER                   := NULL;
20499 p_sr_audit_record.OLD_INCIDENT_HOUSE_NUMBER                := NULL;
20500 p_sr_audit_record.INCIDENT_HOUSE_NUMBER                    := NULL;
20501 p_sr_audit_record.OLD_INCIDENT_STREET_SUFFIX               := NULL;
20502 p_sr_audit_record.INCIDENT_STREET_SUFFIX                   := NULL;
20503 p_sr_audit_record.OLD_INCIDENT_STREET                      := NULL;
20504 p_sr_audit_record.INCIDENT_STREET                          := NULL;
20505 p_sr_audit_record.OLD_INCIDENT_STREET_NUMBER               := NULL;
20506 p_sr_audit_record.INCIDENT_STREET_NUMBER                   := NULL;
20507 p_sr_audit_record.OLD_INCIDENT_FLOOR                       := NULL;
20508 p_sr_audit_record.INCIDENT_FLOOR                           := NULL;
20509 p_sr_audit_record.OLD_INCIDENT_SUITE                       := NULL;
20510 p_sr_audit_record.INCIDENT_SUITE                           := NULL;
20511 p_sr_audit_record.OLD_INCIDENT_POSTAL_PLUS4_CODE           := NULL;
20512 p_sr_audit_record.INCIDENT_POSTAL_PLUS4_CODE               := NULL;
20513 p_sr_audit_record.OLD_INCIDENT_POSITION                    := NULL;
20514 p_sr_audit_record.INCIDENT_POSITION                        := NULL;
20515 p_sr_audit_record.OLD_INCIDENT_LOC_DIRECTIONS              := NULL;
20516 p_sr_audit_record.INCIDENT_LOC_DIRECTIONS                  := NULL;
20517 p_sr_audit_record.OLD_INCIDENT_LOC_DESCRIPTION             := NULL;
20518 p_sr_audit_record.INCIDENT_LOC_DESCRIPTION                 := NULL;
20519 p_sr_audit_record.OLD_INSTALL_SITE_ID                      := NULL;
20520 p_sr_audit_record.INSTALL_SITE_ID                          := NULL;
20521 p_sr_audit_record.INCIDENT_LAST_MODIFIED_DATE              := NULL;
20522 p_sr_audit_record.UPDATED_ENTITY_CODE                      := NULL;
20523 p_sr_audit_record.UPDATED_ENTITY_ID                        := NULL;
20524 p_sr_audit_record.ENTITY_ACTIVITY_CODE                     := NULL;
20525 p_sr_audit_record.OLD_TIER_VERSION                         := NULL;
20526 p_sr_audit_record.TIER_VERSION                             := NULL;
20527 -- anmukher --09/12/03
20528 p_sr_audit_record.OLD_INC_OBJECT_VERSION_NUMBER            := NULL;
20529 p_sr_audit_record.INC_OBJECT_VERSION_NUMBER                := NULL;
20530 p_sr_audit_record.OLD_INC_REQUEST_ID                       := NULL;
20531 p_sr_audit_record.INC_REQUEST_ID                           := NULL;
20532 p_sr_audit_record.OLD_INC_PROGRAM_APPLICATION_ID           := NULL;
20533 p_sr_audit_record.INC_PROGRAM_APPLICATION_ID               := NULL;
20534 p_sr_audit_record.OLD_INC_PROGRAM_ID                       := NULL;
20535 p_sr_audit_record.INC_PROGRAM_ID                           := NULL;
20536 p_sr_audit_record.OLD_INC_PROGRAM_UPDATE_DATE              := NULL;
20537 p_sr_audit_record.INC_PROGRAM_UPDATE_DATE                  := NULL;
20538 p_sr_audit_record.OLD_OWNING_DEPARTMENT_ID                 := NULL;
20539 p_sr_audit_record.OWNING_DEPARTMENT_ID                     := NULL;
20540 p_sr_audit_record.OLD_INCIDENT_LOCATION_TYPE               := NULL;
20541 p_sr_audit_record.INCIDENT_LOCATION_TYPE                   := NULL;
20542 p_sr_audit_record.OLD_UNASSIGNED_INDICATOR                 := NULL;
20543 p_sr_audit_record.UNASSIGNED_INDICATOR                     := NULL;
20544 p_sr_audit_record.maint_organization_id                    := NULL;
20545 p_sr_audit_record.old_maint_organization_id                := NULL;
20546 
20547  --15995804  Audit price list header id and sla info
20548 p_sr_audit_record.old_price_list_header_id                 := NULL;
20549 p_sr_audit_record.price_list_header_id                     := NULL;
20550 p_sr_audit_record.old_sla_date_1                           := NULL;
20551 p_sr_audit_record.sla_date_1                               := NULL;
20552 p_sr_audit_record.old_sla_date_2                           := NULL;
20553 p_sr_audit_record.sla_date_2                               := NULL;
20554 p_sr_audit_record.old_sla_date_3                           := NULL;
20555 p_sr_audit_record.sla_date_3                               := NULL;
20556 p_sr_audit_record.old_sla_date_4                           := NULL;
20557 p_sr_audit_record.sla_date_4                               := NULL;
20558 p_sr_audit_record.old_sla_date_5                           := NULL;
20559 p_sr_audit_record.sla_date_5                               := NULL;
20560 p_sr_audit_record.old_sla_date_6                           := NULL;
20561 p_sr_audit_record.sla_date_6                               := NULL;
20562 p_sr_audit_record.old_sla_duration_1                       := NULL;
20563 p_sr_audit_record.sla_duration_1                           := NULL;
20564 p_sr_audit_record.old_sla_duration_2                       := NULL;
20565 p_sr_audit_record.sla_duration_2                           := NULL;
20566  --15995804  end Audit price list header id and sla info
20567 END initialize_audit_rec;
20568 
20569 --Procedure to support MLS
20570 PROCEDURE ADD_LANGUAGE
20571 IS
20572 BEGIN
20573   DELETE FROM CS_INCIDENTS_ALL_TL T
20574   WHERE NOT EXISTS
20575   (SELECT NULL
20576    FROM CS_INCIDENTS_ALL_B B
20577    WHERE B.INCIDENT_ID = T.INCIDENT_ID
20578   );
20579 
20580   UPDATE CS_INCIDENTS_ALL_TL T SET (
20581   SUMMARY,
20582   RESOLUTION_SUMMARY
20583   --SR_CREATION_CHANNEL
20584 	 ) = (SELECT
20585   B.SUMMARY,
20586   B.RESOLUTION_SUMMARY
20587   --B.SR_CREATION_CHANNEL
20588   FROM CS_INCIDENTS_ALL_TL B
20589   WHERE B.INCIDENT_ID = T.INCIDENT_ID
20590   AND B.LANGUAGE = T.SOURCE_LANG)
20591   WHERE (
20592    T.INCIDENT_ID,
20593    T.LANGUAGE
20594   ) IN (SELECT
20595    SUBT.INCIDENT_ID,
20596    SUBT.LANGUAGE
20597    FROM CS_INCIDENTS_ALL_TL SUBB, CS_INCIDENTS_ALL_TL SUBT
20598    WHERE SUBB.INCIDENT_ID = SUBT.INCIDENT_ID
20599    AND SUBB.LANGUAGE = SUBT.SOURCE_LANG
20600    AND (SUBB.SUMMARY <> SUBT.SUMMARY
20601    OR SUBB.RESOLUTION_SUMMARY <> SUBT.RESOLUTION_SUMMARY
20602    OR (SUBB.RESOLUTION_SUMMARY IS NULL AND SUBT.RESOLUTION_SUMMARY IS NOT NULL)
20603    OR (SUBB.RESOLUTION_SUMMARY IS NOT NULL AND SUBT.RESOLUTION_SUMMARY IS  NULL)
20604    --or SUBB.SR_CREATION_CHANNEL <> SUBT.SR_CREATION_CHANNEL
20605    --or (SUBB.SR_CREATION_CHANNEL is null and SUBT.SR_CREATION_CHANNEL is not null)
20606    --or (SUBB.SR_CREATION_CHANNEL is not null and SUBT.SR_CREATION_CHANNEL is null)
20607    ));
20608 
20609     INSERT INTO CS_INCIDENTS_ALL_TL (
20610     INCIDENT_ID,
20611     SUMMARY,
20612     RESOLUTION_SUMMARY,
20613     LAST_UPDATE_DATE,
20614     LAST_UPDATED_BY,
20615     CREATION_DATE,
20616     CREATED_BY,
20617     LAST_UPDATE_LOGIN,
20618     --SR_CREATION_CHANNEL,
20619     LANGUAGE,
20620     SOURCE_LANG
20621  ) SELECT
20622     B.INCIDENT_ID,
20623     B.SUMMARY,
20624     B.RESOLUTION_SUMMARY,
20625     B.LAST_UPDATE_DATE,
20626     B.LAST_UPDATED_BY,
20627     B.CREATION_DATE,
20628     B.CREATED_BY,
20629     B.LAST_UPDATE_LOGIN,
20630     --B.SR_CREATION_CHANNEL,
20631     L.LANGUAGE_CODE,
20632     B.SOURCE_LANG
20633     FROM CS_INCIDENTS_ALL_TL B, FND_LANGUAGES L
20634     WHERE L.INSTALLED_FLAG IN ('I', 'B')
20635     AND B.LANGUAGE = USERENV('LANG')
20636     AND NOT EXISTS
20637 	 (SELECT NULL
20638 	  FROM CS_INCIDENTS_ALL_TL T
20639        WHERE T.INCIDENT_ID = B.INCIDENT_ID
20640        AND T.LANGUAGE = L.LANGUAGE_CODE);
20641 
20642    -- This is for the incident_audit_table
20643   DELETE FROM CS_INCIDENTS_AUDIT_TL T
20644   WHERE NOT EXISTS
20645     (SELECT NULL
20646     FROM CS_INCIDENTS_AUDIT_B B
20647     WHERE B.INCIDENT_AUDIT_ID = T.INCIDENT_AUDIT_ID
20648     );
20649 
20650   UPDATE CS_INCIDENTS_AUDIT_TL T SET (
20651       CHANGE_DESCRIPTION
20652     ) = (SELECT
20653       B.CHANGE_DESCRIPTION
20654     FROM CS_INCIDENTS_AUDIT_TL B
20655     WHERE B.INCIDENT_AUDIT_ID = T.INCIDENT_AUDIT_ID
20656     AND B.LANGUAGE = T.SOURCE_LANG)
20657   WHERE (
20658       T.INCIDENT_AUDIT_ID,
20659       T.LANGUAGE
20660   ) IN (SELECT
20661     SUBT.INCIDENT_AUDIT_ID,
20662     SUBT.LANGUAGE
20663     FROM CS_INCIDENTS_AUDIT_TL SUBB, CS_INCIDENTS_AUDIT_TL SUBT
20664     WHERE SUBB.INCIDENT_AUDIT_ID = SUBT.INCIDENT_AUDIT_ID
20665     AND SUBB.LANGUAGE = SUBT.SOURCE_LANG
20666     AND (SUBB.CHANGE_DESCRIPTION <> SUBT.CHANGE_DESCRIPTION
20667     OR (SUBB.CHANGE_DESCRIPTION IS NULL AND SUBT.CHANGE_DESCRIPTION IS NOT NULL)
20668     OR (SUBB.CHANGE_DESCRIPTION IS NOT NULL AND SUBT.CHANGE_DESCRIPTION IS NULL)
20669   ));
20670 
20671   INSERT INTO CS_INCIDENTS_AUDIT_TL (
20672     INCIDENT_AUDIT_ID,
20673     INCIDENT_ID,
20674     LAST_UPDATE_DATE,
20675     LAST_UPDATED_BY,
20676     CREATION_DATE,
20677     CREATED_BY,
20678     LAST_UPDATE_LOGIN,
20679     CHANGE_DESCRIPTION,
20680     LANGUAGE,
20681     SOURCE_LANG
20682   ) SELECT
20683     B.INCIDENT_AUDIT_ID,
20684     B.INCIDENT_ID,
20685     B.LAST_UPDATE_DATE,
20686     B.LAST_UPDATED_BY,
20687     B.CREATION_DATE,
20688     B.CREATED_BY,
20689     B.LAST_UPDATE_LOGIN,
20690     B.CHANGE_DESCRIPTION,
20691     L.LANGUAGE_CODE,
20692     B.SOURCE_LANG
20693   FROM CS_INCIDENTS_AUDIT_TL B, FND_LANGUAGES L
20694   WHERE L.INSTALLED_FLAG IN ('I', 'B')
20695   AND B.LANGUAGE = USERENV('LANG')
20696   AND NOT EXISTS
20697     (SELECT NULL
20698     FROM CS_INCIDENTS_AUDIT_TL T
20699     WHERE T.INCIDENT_AUDIT_ID = B.INCIDENT_AUDIT_ID
20700     AND T.LANGUAGE = L.LANGUAGE_CODE);
20701 
20702 
20703 END ADD_LANGUAGE;
20704 
20705 
20706 -- Procedure Lock Row
20707 -- This is called by the Service Request form to lock a record
20708 PROCEDURE LOCK_ROW(
20709 			    X_INCIDENT_ID		NUMBER,
20710 			    X_OBJECT_VERSION_NUMBER	NUMBER
20711 			    )
20712 IS
20713   CURSOR C IS
20714 	SELECT OBJECT_VERSION_NUMBER
20715 	FROM   CS_INCIDENTS_ALL_B
20716 	WHERE  INCIDENT_ID = X_INCIDENT_ID
20717 	FOR UPDATE OF INCIDENT_ID NOWAIT;
20718 
20719   RECINFO C%ROWTYPE;
20720 BEGIN
20721   OPEN C;
20722   FETCH C INTO RECINFO;
20723   IF (C%NOTFOUND) THEN
20724     CLOSE C;
20725     FND_MESSAGE.SET_NAME('FND', 'FORM_RECORD_DELETED');
20726     FND_MSG_PUB.ADD;
20727     APP_EXCEPTION.RAISE_EXCEPTION;
20728   END IF;
20729   CLOSE C;
20730 
20731   IF (RECINFO.OBJECT_VERSION_NUMBER = X_OBJECT_VERSION_NUMBER) THEN
20732     NULL;
20733   ELSE
20734     FND_MESSAGE.SET_NAME('FND', 'FORM_RECORD_CHANGED');
20735     FND_MSG_PUB.ADD;
20736     APP_EXCEPTION.RAISE_EXCEPTION;
20737   END IF;
20738 
20739 END LOCK_ROW;
20740 
20741    FUNCTION Get_API_Revision RETURN NUMBER IS
20742    BEGIN
20743        RETURN G_API_REVISION;
20744    END Get_API_Revision;
20745 
20746 
20747 /** Following 3 functions are added for UWQ -SR integration for
20748     pop-messages in service request form
20749 **/
20750 
20751  FUNCTION Get_Importance_Level(P_Severity_Id IN NUMBER)
20752  RETURN NUMBER IS
20753      CURSOR c_imp_csr IS
20754      SELECT importance_level
20755      FROM   cs_incident_severities_b
20756      WHERE  incident_severity_id = p_severity_id;
20757      l_imp_level  NUMBER;
20758    BEGIN
20759      OPEN  c_imp_csr;
20760      FETCH c_imp_csr INTO l_imp_level;
20761      CLOSE c_imp_csr;
20762 
20763      RETURN(l_imp_level);
20764    END Get_Importance_Level;
20765 
20766    FUNCTION Get_Old_Importance_level(p_incident_id IN NUMBER)
20767    RETURN NUMBER IS
20768      CURSOR c_imp_old_csr IS
20769      SELECT importance_level
20770      FROM cs_incident_severities_b
20771      WHERE incident_severity_id =( SELECT incident_severity_id
20772                                    FROM CS_INCIDENTS_ALL_B
20773                                    WHERE incident_id = p_incident_id);
20774     l_old_imp_level  NUMBER;
20775    BEGIN
20776      OPEN c_imp_old_csr;
20777      FETCH c_imp_old_csr INTO l_old_imp_level;
20778      CLOSE c_imp_old_csr;
20779      RETURN(l_old_imp_level);
20780    END Get_Old_Importance_level;
20781 
20782   FUNCTION Get_Owner_id(p_incident_id IN NUMBER)
20783     RETURN NUMBER IS
20784      CURSOR c_owner_id IS
20785      SELECT incident_owner_id
20786      FROM cs_incidents_all_b
20787      WHERE incident_id = p_incident_id;
20788      l_owner_id  NUMBER;
20789    BEGIN
20790      OPEN c_owner_id;
20791      FETCH c_owner_id INTO l_owner_id;
20792      CLOSE c_owner_id;
20793 
20794      RETURN(l_owner_id);
20795    END Get_Owner_id;
20796 
20797    FUNCTION Get_Title(P_Object_Code IN VARCHAR2)
20798    RETURN VARCHAR2 IS
20799      CURSOR c_title_csr IS
20800      SELECT description
20801      FROM   jtf_objects_vl
20802      WHERE  object_code=P_Object_Code;
20803      --Fixed bug#2802393, changed length from 30 to 80
20804      l_title VARCHAR2(80);
20805    BEGIN
20806      OPEN  c_title_csr;
20807      FETCH c_title_csr INTO l_title;
20808      CLOSE c_title_csr;
20809 
20810      RETURN(l_title);
20811    END Get_Title;
20812 
20813    FUNCTION Get_Message(p_message_code IN VARCHAR2)
20814    RETURN VARCHAR2 IS
20815      CURSOR c_uwq_message IS
20816      SELECT message_text
20817      FROM fnd_new_messages
20818      WHERE  application_id = 170
20819      AND    message_name = p_message_code
20820      AND    language_code = USERENV('LANG');
20821      --Fixed bug#2802393, changed length from 80 to 2000
20822      l_uwq_message VARCHAR2(2000);
20823    BEGIN
20824      OPEN c_uwq_message;
20825      FETCH c_uwq_message INTO l_uwq_message;
20826      CLOSE c_uwq_message;
20827 
20828      RETURN(l_uwq_message);
20829    END Get_Message;
20830 
20831 /* Added for enh.2655115, procedure to get the value of status_flag for
20832    inserting into cs_incidents_all_b table. If the closed flag is Y then
20833    the status is closed, else its open.created by shijain dated nov 27th 2002*/
20834 
20835    FUNCTION GET_STATUS_FLAG( p_incident_status_id IN  NUMBER)
20836    RETURN VARCHAR2 IS
20837      CURSOR get_close_flag IS
20838      SELECT close_flag
20839      FROM   cs_incident_statuses_b
20840      WHERE  incident_status_id = p_incident_status_id;
20841 
20842      l_closed_flag VARCHAR2(1);
20843      l_status_flag VARCHAR2(1):='O';
20844    BEGIN
20845      OPEN get_close_flag;
20846      FETCH get_close_flag INTO l_closed_flag;
20847      CLOSE get_close_flag;
20848 
20849      IF l_closed_flag = 'Y' THEN
20850         l_status_flag:= 'C';
20851      ELSE
20852         l_status_flag:= 'O';
20853      END IF;
20854      RETURN(l_status_flag);
20855 
20856    END GET_STATUS_FLAG;
20857 
20858 
20859 
20860 
20861 /* Added for enh.2690787, procedure to get the value of primary_contact_id for
20862    inserting into cs_incidents_all_b table based on the incident_id and the
20863    primary flag from the cs_hz_sr_contact_points table by shijain
20864 
20865 FUNCTION GET_PRIMARY_CONTACT( p_incident_id IN  NUMBER)
20866 RETURN NUMBER IS
20867 
20868      CURSOR get_primary_contact IS
20869      SELECT sr_contact_point_id
20870      FROM   cs_hz_sr_contact_points
20871      WHERE  incident_id = p_incident_id
20872      AND    primary_flag = 'Y';
20873 
20874      l_primary_contact NUMBER;
20875 
20876 BEGIN
20877      OPEN get_primary_contact;
20878      FETCH get_primary_contact INTO l_primary_contact;
20879      CLOSE get_primary_contact;
20880 
20881      RETURN(l_primary_contact);
20882 
20883 END GET_PRIMARY_CONTACT;
20884 */
20885 
20886 /* This is a overloaded procedure for create service request which is mainly
20887    created for making the changes for 1159 backward compatiable. This does not
20888    contain the following parameters:-
20889    x_individual_owner, x_group_owner, x_individual_type and p_auto_assign.
20890    and will call the above procedure with all these parameters and version
20891    as 3.0*/
20892 
20893 PROCEDURE Create_ServiceRequest(
20894     p_api_version            IN    NUMBER,
20895     p_init_msg_list          IN    VARCHAR2 DEFAULT fnd_api.g_false,
20896     p_commit                 IN    VARCHAR2 DEFAULT fnd_api.g_false,
20897     p_validation_level       IN    NUMBER   DEFAULT fnd_api.g_valid_level_full,
20898     x_return_status          OUT   NOCOPY VARCHAR2,
20899     x_msg_count              OUT   NOCOPY NUMBER,
20900     x_msg_data               OUT   NOCOPY VARCHAR2,
20901     p_resp_appl_id           IN    NUMBER   DEFAULT NULL,
20902     p_resp_id                IN    NUMBER   DEFAULT NULL,
20903     p_user_id                IN    NUMBER,
20904     p_login_id               IN    NUMBER   DEFAULT NULL,
20905     p_org_id                 IN    NUMBER   DEFAULT NULL,
20906     p_request_id             IN    NUMBER   DEFAULT NULL,
20907     p_request_number         IN    VARCHAR2 DEFAULT NULL,
20908     p_invocation_mode        IN    VARCHAR2 := 'NORMAL' ,
20909     p_service_request_rec    IN    SERVICE_REQUEST_REC_TYPE,
20910     p_notes                  IN    NOTES_TABLE,
20911     p_contacts               IN    CONTACTS_TABLE,
20912     p_default_contract_sla_ind IN  VARCHAR2 Default 'N',
20913     x_request_id             OUT   NOCOPY NUMBER,
20914     x_request_number         OUT   NOCOPY VARCHAR2,
20915     x_interaction_id         OUT   NOCOPY NUMBER,
20916     x_workflow_process_id    OUT   NOCOPY NUMBER
20917 ) IS
20918      l_api_name             CONSTANT VARCHAR2(30)    := 'Create_ServiceRequest';
20919      l_api_version          CONSTANT NUMBER          := 2.0;
20920      l_api_name_full        CONSTANT VARCHAR2(61)    := G_PKG_NAME||'.'||l_api_name;
20921      l_return_status        VARCHAR2(1);
20922      l_individual_owner     NUMBER;
20923      l_group_owner          NUMBER;
20924      l_individual_type      VARCHAR2(30);
20925 
20926 
20927 BEGIN
20928   -- Standard start of API savepoint
20929   SAVEPOINT Create_ServiceRequest_PVT;
20930 
20931  IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
20932                                      G_PKG_NAME) THEN
20933     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20934  END IF;
20935 
20936   -- Initialize API return status to success
20937   x_return_status := FND_API.G_RET_STS_SUCCESS;
20938 
20939   CS_ServiceRequest_PVT.Create_ServiceRequest
20940     ( p_api_version                  => 3.0,
20941       p_init_msg_list                => p_init_msg_list,
20942       p_commit                       => p_commit,
20943       p_validation_level             => p_validation_level,
20944       x_return_status                => x_return_status,
20945       x_msg_count                    => x_msg_count,
20946       x_msg_data                     => x_msg_data,
20947       p_resp_appl_id                 => p_resp_appl_id,
20948       p_resp_id                      => p_resp_id,
20949       p_user_id                      => p_user_id,
20950       p_login_id                     => p_login_id,
20951       p_org_id                       => p_org_id,
20952       p_request_id                   => p_request_id,
20953       p_request_number               => p_request_number,
20954       p_invocation_mode              => p_invocation_mode,
20955       p_service_request_rec          => p_service_request_rec,
20956       p_notes                        => p_notes,
20957       p_contacts                     => p_contacts,
20958       p_auto_assign                  => 'N',
20959       p_default_contract_sla_ind     => p_default_contract_sla_ind,
20960       x_request_id                   => x_request_id,
20961       x_request_number               => x_request_number,
20962       x_interaction_id               => x_interaction_id,
20963       x_workflow_process_id          => x_workflow_process_id,
20964       x_individual_owner             => l_individual_owner,
20965       x_group_owner                  => l_group_owner,
20966       x_individual_type              => l_individual_type
20967     );
20968 
20969   IF (l_return_status = FND_API.G_RET_STS_ERROR) THEN
20970     RAISE FND_API.G_EXC_ERROR;
20971   ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
20972     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
20973   END IF;
20974 
20975 EXCEPTION
20976   WHEN FND_API.G_EXC_ERROR THEN
20977     ROLLBACK TO Create_ServiceRequest_PVT;
20978     x_return_status := FND_API.G_RET_STS_ERROR;
20979     FND_MSG_PUB.Count_And_Get
20980       ( p_count => x_msg_count,
20981         p_data  => x_msg_data
20982       );
20983   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
20984     ROLLBACK TO Create_ServiceRequest_PVT;
20985     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
20986     FND_MSG_PUB.Count_And_Get
20987       ( p_count => x_msg_count,
20988         p_data  => x_msg_data
20989       );
20990   WHEN OTHERS THEN
20991     ROLLBACK TO Create_ServiceRequest_PVT;
20992     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
20993     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
20994       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
20995     END IF;
20996     FND_MSG_PUB.Count_And_Get
20997       ( p_count => x_msg_count,
20998         p_data  => x_msg_data
20999       );
21000 
21001 END Create_ServiceRequest;
21002 --
21003 PROCEDURE handle_missing_value(x_new_value in out nocopy varchar2,
21004                                p_old_value in            varchar2) is
21005 BEGIN
21006   -- if new value is g_miss_char then it should be set to value from database
21007   -- in case of new value being null, if condition will fail and new value will remain
21008   -- set to null
21009   IF (x_new_value = FND_API.G_MISS_CHAR) then
21010       x_new_value := p_old_value;
21011   END IF;
21012 END;
21013 -- -----------------------------------------------------------------------------
21014 -- Modification History:
21015 -- Date     Name     Desc
21016 -- -------- -------- -----------------------------------------------------------
21017 -- 12/23/05 smisra   Bug 4868997
21018 --                   Added a condition of application_id column of both tables.
21019 --                   Value of application id should be 170
21020 -- -----------------------------------------------------------------------------
21021 PROCEDURE set_attribute_value(x_attr_val     in out nocopy varchar2,
21022                               p_attr_val_old in            varchar2,
21023                               p_ff_name      in            varchar2,
21024                               p_attr_col     in            varchar2) is
21025   p_app_id  NUMBER;
21026   CURSOR c_global_attr is
21027    select 1
21028      from fnd_descr_flex_column_usages a,
21029           fnd_descr_flex_contexts b
21030    where a.descriptive_flexfield_name = p_ff_name
21031      and b.descriptive_flexfield_name = p_ff_name
21032      and a.application_column_name = p_attr_col
21033      and a.descriptive_flex_context_code = b.descriptive_flex_context_code
21034      AND a.application_id = p_app_id
21035      AND b.application_id = p_app_id
21036      and B.global_flag = 'Y';
21037   l_dummy number;
21038 BEGIN
21039 
21040   p_app_id := 170;
21041   if (x_attr_val = FND_API.G_MISS_CHAR) then
21042      open c_global_attr;
21043      fetch c_global_attr into l_dummy;
21044      if c_global_attr%found then
21045         x_attr_val := p_attr_val_old;
21046      else
21047         x_attr_val := null;
21048      end if;
21049      close c_global_attr;
21050   end if;
21051 END set_attribute_value;
21052 ------------------------
21053 
21054 --------------------------------------------------------------------------------
21055 --  Procedure Name            :   DELETE_SERVICEREQUEST
21056 --
21057 --  Parameters (other than standard ones)
21058 --  IN
21059 --      p_purge_set_id                  :   Id that helps identify a set of SRs
21060 --                                          that were purged in a single batch
21061 --      p_processing_set_id             :   Id that helps the API in identifying
21062 --                                          the set of SRs for which the child
21063 --                                          objects have to be deleted.
21064 --      p_purge_source_with_open_task   :   Indicates whether the SRs containing
21065 --                                          OPEN non field service tasks should
21066 --                                          be purged or not
21067 --      p_audit_required                :   Indicates if audit information has
21068 --                                          to be generated after purging the
21069 --                                          service requests
21070 --
21071 --  Description
21072 --      This API physically removes the SRs and all its child objects after
21073 --      performing validations wherever required. This is a wrapper which
21074 --      delegates the work to another helper API named
21075 --      cs_sr_delete_util.delete_servicerequest
21076 --
21077 --  HISTORY
21078 --
21079 ----------------+------------+--------------------------------------------------
21080 --  DATE        | UPDATED BY | Change Description
21081 ----------------+------------+--------------------------------------------------
21082 --  2-Aug-2005  | varnaray   | Created
21083 --              |            |
21084 ----------------+------------+--------------------------------------------------
21085 /*#
21086  * This API physically removes the SRs and all its child objects after
21087  * performing validations wherever required. This is a wrapper which delegates
21088  * the work to another helper API named
21089  * cs_sr_delete_util.delete_servicerequest
21090  * @param p_purge_set_id Id that helps identify a set of SRs that were purged
21091  * in a single batch
21092  * @param p_processing_set_id Id that helps the API in identifying the set of
21093  * SRs for which the child
21094  * objects have to be deleted.
21095  * @param p_purge_source_with_open_task Indicates whether the SRs containing
21096  * OPEN non field service
21097  * tasks should be purged or not
21098  * @param p_audit_required Indicates if audit information has to be generated
21099  * after purging the
21100  * service requests
21101  * @rep:scope Internal
21102  * @rep:product CS
21103  * @rep:displayname Delete Service Requests
21104  */
21105 PROCEDURE Delete_ServiceRequest
21106 (
21107   p_api_version_number            IN  NUMBER := 1.0
21108 , p_init_msg_list                 IN  VARCHAR2 := FND_API.G_FALSE
21109 , p_commit                        IN  VARCHAR2 := FND_API.G_FALSE
21110 , p_validation_level              IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL
21111 , p_processing_set_id             IN  NUMBER
21112 , p_purge_set_id                  IN  NUMBER
21113 , p_purge_source_with_open_task   IN  VARCHAR2
21114 , p_audit_required                IN  VARCHAR2
21115 , x_return_status                 OUT NOCOPY  VARCHAR2
21116 , x_msg_count                     OUT NOCOPY  NUMBER
21117 , x_msg_data                      OUT NOCOPY  VARCHAR2
21118 )
21119 IS
21120 --------------------------------------------------------------------------------
21121 L_API_VERSION   CONSTANT NUMBER        := 1.0;
21122 L_API_NAME      CONSTANT VARCHAR2(30)  := 'DELETE_SERVICEREQUEST';
21123 L_API_NAME_FULL CONSTANT VARCHAR2(61)  := G_PKG_NAME || '.' || L_API_NAME;
21124 L_LOG_MODULE    CONSTANT VARCHAR2(255) := 'cs.plsql.' || L_API_NAME_FULL || '.';
21125 
21126 x_msg_index_out NUMBER;
21127 
21128 BEGIN
21129   x_return_status := FND_API.G_RET_STS_SUCCESS;
21130 
21131   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
21132   THEN
21133     FND_LOG.String
21134     (
21135       FND_LOG.level_procedure
21136     , L_LOG_MODULE || 'start'
21137     , 'Inside ' || L_API_NAME_FULL || ', called with parameters below:'
21138     );
21139     FND_LOG.String
21140     (
21141       FND_LOG.level_procedure
21142     , L_LOG_MODULE || 'param 1'
21143     , 'p_api_version_number:' || p_api_version_number
21144     );
21145     FND_LOG.String
21146     (
21147       FND_LOG.level_procedure
21148     , L_LOG_MODULE || 'param 2'
21149     , 'p_init_msg_list:' || p_init_msg_list
21150     );
21151     FND_LOG.String
21152     (
21153       FND_LOG.level_procedure
21154     , L_LOG_MODULE || 'param 3'
21155     , 'p_commit:' || p_commit
21156     );
21157     FND_LOG.String
21158     (
21159       FND_LOG.level_procedure
21160     , L_LOG_MODULE || 'param 4'
21161     , 'p_validation_level:' || p_validation_level
21162     );
21163     FND_LOG.String
21164     (
21165       FND_LOG.level_procedure
21166     , L_LOG_MODULE || 'param 5'
21167     , 'p_purge_source_with_open_task:' || p_purge_source_with_open_task
21168     );
21169     FND_LOG.String
21170     (
21171       FND_LOG.level_procedure
21172     , L_LOG_MODULE || 'param 6'
21173     , 'p_processing_set_id:' || p_processing_set_id
21174     );
21175     FND_LOG.String
21176     (
21177       FND_LOG.level_procedure
21178     , L_LOG_MODULE || 'param 7'
21179     , 'p_purge_set_id:' || p_purge_set_id
21180     );
21181     FND_LOG.String
21182     (
21183       FND_LOG.level_procedure
21184     , L_LOG_MODULE || 'param 8'
21185     , 'p_audit_required:' || p_audit_required
21186     );
21187   END IF ;
21188 
21189   IF NOT FND_API.Compatible_API_Call
21190   (
21191     L_API_VERSION
21192   , p_api_version_number
21193   , L_API_NAME
21194   , G_PKG_NAME
21195   )
21196   THEN
21197     FND_MSG_PUB.Count_And_Get
21198     (
21199       p_count => x_msg_count
21200     , p_data  => x_msg_data
21201     );
21202     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21203   END IF ;
21204 
21205   IF FND_API.to_Boolean(p_init_msg_list)
21206   THEN
21207     FND_MSG_PUB.initialize;
21208   END IF ;
21209 
21210   ------------------------------------------------------------------------------
21211   -- Parameter Validations:
21212   ------------------------------------------------------------------------------
21213 
21214   IF p_processing_set_id IS NULL
21215   THEN
21216     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
21217     THEN
21218       FND_LOG.String
21219       (
21220         FND_LOG.level_unexpected
21221       , L_LOG_MODULE || 'proc_set_id_invalid'
21222       , 'p_processing_set_id should not be NULL.'
21223       );
21224     END IF ;
21225 
21226     FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_VALUE_ERROR');
21227     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
21228     FND_MESSAGE.Set_Token('PARAM', 'p_processing_set_id');
21229     FND_MESSAGE.Set_Token('CURRVAL', NVL(to_char(p_processing_set_id),'NULL'));
21230     FND_MSG_PUB.ADD;
21231 
21232     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21233   END IF;
21234 
21235   ---
21236 
21237   IF  p_purge_source_with_open_task IS NULL
21238   OR  NVL(p_purge_source_with_open_task, 'X') NOT IN ('Y', 'N')
21239   THEN
21240     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
21241     THEN
21242       FND_LOG.String
21243       (
21244         FND_LOG.level_unexpected
21245       , L_LOG_MODULE || 'p_purge_source_with_open_task_invalid'
21246       , 'p_purge_source_with_open_task value is invalid.'
21247       );
21248     END IF ;
21249 
21250     FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_VALUE_ERROR');
21251     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
21252     FND_MESSAGE.Set_Token('PARAM', 'p_purge_source_with_open_task');
21253     FND_MESSAGE.Set_Token
21254     (
21255       'CURRVAL'
21256     , NVL(p_purge_source_with_open_task, 'NULL')
21257     );
21258     FND_MSG_PUB.ADD;
21259 
21260     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21261   END IF;
21262 
21263   ---
21264 
21265   IF  p_audit_required IS NULL
21266   OR  NVL(p_audit_required, 'X') NOT IN ('Y', 'N')
21267   THEN
21268     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
21269     THEN
21270       FND_LOG.String
21271       (
21272         FND_LOG.level_unexpected
21273       , L_LOG_MODULE || 'audit_required_invalid'
21274       , 'p_audit_required value is invalid.'
21275       );
21276     END IF ;
21277 
21278     FND_MESSAGE.Set_Name('CS', 'CS_SR_PARAM_VALUE_ERROR');
21279     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
21280     FND_MESSAGE.Set_Token('PARAM', 'p_audit_required');
21281     FND_MESSAGE.Set_Token('CURRVAL', NVL(p_audit_required, 'NULL'));
21282     FND_MSG_PUB.ADD;
21283 
21284     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
21285   END IF;
21286 
21287   ------------------------------------------------------------------------------
21288   -- Actual Logic starts below:
21289   ------------------------------------------------------------------------------
21290 
21291   IF p_validation_level = FND_API.G_VALID_LEVEL_FULL
21292   THEN
21293     IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
21294     THEN
21295       FND_LOG.String
21296       (
21297         FND_LOG.level_statement
21298       , L_LOG_MODULE || 'purge_valid_start'
21299       , 'calling the SR delete validation API '
21300         || 'cs_sr_delete_util.delete_sr_validations'
21301       );
21302     END IF;
21303 
21304     -- The following procedure call performs validations on child objects
21305     -- and marks the purge_status in the global temp table. This status
21306     -- is used by the delete_servicerequest call to identify the SRs that
21307     -- can be actually purged.
21308 
21309     --Fix for bug 13619985
21310     CS_SR_DELETE_UTIL.Delete_Sr_Validations
21311     (
21312       p_api_version_number          => 1.0
21313     , p_init_msg_list               => FND_API.G_FALSE
21314     , p_commit                      => FND_API.G_FALSE
21315     , p_object_type                 => 'SR'
21316     , p_processing_set_id           => p_processing_set_id
21317     , p_purge_source_with_open_task => p_purge_source_with_open_task
21318     , x_return_status               => x_return_status
21319     , x_msg_count                   => x_msg_count
21320     , x_msg_data                    => x_msg_data
21321     );
21322 
21323     IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
21324     THEN
21325       FND_LOG.String
21326       (
21327         FND_LOG.level_statement
21328       , L_LOG_MODULE || 'purge_valid_end'
21329       , 'returned from the SR delete validation API with status '
21330         || x_return_status
21331       );
21332     END IF;
21333   END IF;
21334 
21335   IF x_return_status = FND_API.G_RET_STS_SUCCESS
21336   THEN
21337     IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
21338     THEN
21339       FND_LOG.String
21340       (
21341         FND_LOG.level_statement
21342       , L_LOG_MODULE || 'purge_start'
21343       , 'calling the SR delete helper API '
21344         || 'cs_sr_delete_util.delete_servicerequest'
21345       );
21346     END IF;
21347 
21348     -- This call refers to the SRs in the global temp table with purge_status
21349     -- null and calls other child object delete APIs to delete the child objects
21350     -- of SRs and also deletes the SRs from the base and TL tables.
21351 
21352     --Fix for bug 13619985 - shramana
21353     CS_SR_DELETE_UTIL.Delete_ServiceRequest
21354     (
21355       p_api_version_number => 1.0
21356     , p_init_msg_list      => FND_API.G_FALSE
21357     , p_commit             => FND_API.G_FALSE
21358     , p_processing_set_id  => p_processing_set_id
21359     , p_object_type        => 'SR'
21360     , p_purge_set_id       => p_purge_set_id
21361     , p_audit_required     => p_audit_required
21362     , x_return_status      => x_return_status
21363     , x_msg_count          => x_msg_count
21364     , x_msg_data           => x_msg_data
21365     );
21366 
21367     IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
21368     THEN
21369       FND_LOG.String
21370       (
21371         FND_LOG.level_statement
21372       , L_LOG_MODULE || 'purge_end'
21373       , 'returned from the SR delete helper API with status ' || x_return_status
21374       );
21375     END IF;
21376 
21377     IF  p_commit = FND_API.G_TRUE
21378     AND x_return_status = FND_API.G_RET_STS_SUCCESS
21379     THEN
21380       COMMIT;
21381 
21382       IF FND_LOG.level_statement >= FND_LOG.g_current_runtime_level
21383       THEN
21384         FND_LOG.String
21385         (
21386           FND_LOG.level_statement
21387         , L_LOG_MODULE || 'commit'
21388         , 'Performed a COMMIT.'
21389         );
21390       END IF;
21391     END IF;
21392   END IF;
21393 
21394   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
21395   THEN
21396     FND_LOG.String
21397     (
21398       FND_LOG.level_procedure
21399     , L_LOG_MODULE || 'end'
21400     , 'Completed work in ' || L_API_NAME_FULL || ' with return status '
21401       || x_return_status
21402     );
21403   END IF;
21404 EXCEPTION
21405   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
21406     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
21407 
21408     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
21409     THEN
21410       FND_LOG.String
21411       (
21412         FND_LOG.level_unexpected
21413       , L_LOG_MODULE || 'unexpected_error'
21414       , 'Inside WHEN FND_API.G_EXC_UNEXPECTED_ERROR of ' || L_API_NAME_FULL
21415       );
21416 
21417       x_msg_count := FND_MSG_PUB.Count_Msg;
21418 
21419       IF x_msg_count > 0
21420       THEN
21421         FOR
21422           i IN 1..x_msg_count
21423         LOOP
21424           FND_MSG_PUB.Get
21425           (
21426             p_msg_index     => i
21427           , p_encoded       => 'F'
21428           , p_data          => x_msg_data
21429           , p_msg_index_out => x_msg_index_out
21430           );
21431           FND_LOG.String
21432           (
21433             FND_LOG.level_unexpected
21434           , L_LOG_MODULE || 'unexpected_error'
21435           , 'Error encountered is : ' || x_msg_data || ' [Index:'
21436             || x_msg_index_out || ']'
21437           );
21438         END LOOP;
21439       END IF ;
21440     END IF ;
21441 
21442 	WHEN OTHERS THEN
21443     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
21444     FND_MESSAGE.Set_Name('CS', 'CS_SR_DEL_API_FAIL');
21445     FND_MESSAGE.Set_Token('API_NAME', L_API_NAME_FULL);
21446     FND_MESSAGE.Set_Token('ERROR', SQLERRM);
21447     FND_MSG_PUB.ADD;
21448 
21449     FND_MSG_PUB.Count_And_Get
21450     (
21451       p_count => x_msg_count
21452     , p_data  => x_msg_data
21453     );
21454 
21455     IF FND_LOG.level_unexpected >= FND_LOG.g_current_runtime_level
21456     THEN
21457       FND_LOG.String
21458       (
21459         FND_LOG.level_unexpected
21460       , L_LOG_MODULE || 'when_others'
21461       , 'Inside WHEN OTHERS of ' || L_API_NAME_FULL || '. Oracle Error was:'
21462       );
21463       FND_LOG.String
21464       (
21465         FND_LOG.level_unexpected
21466       , L_LOG_MODULE || 'when_others'
21467       , SQLERRM
21468       );
21469     END IF ;
21470 END Delete_ServiceRequest;
21471 -- -----------------------------------------------------------------------------
21472 -- Procedure Name : process_sr_ext_attrs
21473 -- Parameters     : For in out parameter, please look at procedure
21474 --                  process_sr_ext_attrs in file csvextb.pls
21475 -- IN             :
21476 -- OUT            :
21477 --
21478 -- Description    : This is a wrapper for procedure
21479 --                  cs_servicerequest_pvt.process_sr_ext_attrs
21480 --
21481 -- Modification History:
21482 -- Date     Name     Desc
21483 -- -------- -------- -----------------------------------------------------------
21484 -- 08/23/05 smisra   Created
21485 -- -----------------------------------------------------------------------------
21486 PROCEDURE process_sr_ext_attrs
21487 ( p_api_version         IN         NUMBER
21488 , p_init_msg_list       IN         VARCHAR2 DEFAULT NULL
21489 , p_commit              IN         VARCHAR2 DEFAULT NULL
21490 , p_incident_id         IN         NUMBER
21491 , p_ext_attr_grp_tbl    IN         CS_ServiceRequest_PUB.EXT_ATTR_GRP_TBL_TYPE
21492 , p_ext_attr_tbl        IN         CS_ServiceRequest_PUB.EXT_ATTR_TBL_TYPE
21493 , p_modified_by         IN         NUMBER   DEFAULT NULL
21494 , p_modified_on         IN         DATE     DEFAULT NULL
21495 , x_failed_row_id_list  OUT NOCOPY VARCHAR2
21496 , x_return_status       OUT NOCOPY VARCHAR2
21497 , x_errorcode           OUT NOCOPY NUMBER
21498 , x_msg_count           OUT NOCOPY NUMBER
21499 , x_msg_data            OUT NOCOPY VARCHAR2
21500 ) IS
21501 BEGIN
21502   CS_SR_EXTATTRIBUTES_PVT.process_sr_ext_attrs
21503   ( p_api_version         => p_api_version
21504   , p_init_msg_list       => p_init_msg_list
21505   , p_commit              => p_commit
21506   , p_incident_id         => p_incident_id
21507   , p_ext_attr_grp_tbl    => p_ext_attr_grp_tbl
21508   , p_ext_attr_tbl        => p_ext_attr_tbl
21509   , p_modified_by         => p_modified_by
21510   , p_modified_on         => p_modified_on
21511   , x_failed_row_id_list  => x_failed_row_id_list
21512   , x_return_status       => x_return_status
21513   , x_errorcode           => x_errorcode
21514   , x_msg_count           => x_msg_count
21515   , x_msg_data            => x_msg_data
21516   );
21517 END process_sr_ext_attrs;
21518 
21519 -- -----------------------------------------------------------------------------
21520 -- Procedure Name : Log_SR_PVT_Parameters
21521 -- Parameters     :
21522 -- IN             :
21523 -- OUT            :
21524 --
21525 -- Description    : Procedure to LOG the in parameters of PVT SR procedures
21526 --                  service request rec and notes, contacts tables are covered.
21527 --
21528 -- Modification History:
21529 -- Date     Name     Desc
21530 -- -------- -------- -----------------------------------------------------------
21531 -- 09/06/05 pkesani   Created
21532 -- -----------------------------------------------------------------------------
21533 
21534 PROCEDURE Log_SR_PVT_Parameters
21535 ( p_service_request_rec   	  IN         service_request_rec_type
21536 ,p_notes                 	  IN         notes_table
21537 ,p_contacts              	  IN         contacts_table
21538 )
21539 IS
21540   l_api_name	       CONSTANT	VARCHAR2(30)	:= 'Create_ServiceRequest';
21541   l_api_name_full      CONSTANT	VARCHAR2(61)	:= G_PKG_NAME||'.'||l_api_name;
21542   l_log_module         CONSTANT VARCHAR2(255)   := 'cs.plsql.' || l_api_name_full || '.';
21543   l_note_index                  BINARY_INTEGER;
21544   l_contact_index               BINARY_INTEGER;
21545 BEGIN
21546 
21547   IF FND_LOG.level_procedure >= FND_LOG.g_current_runtime_level
21548   THEN
21549 --- service_request_rec_type parameters --
21550     FND_LOG.String
21551     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21552     , 'request_date	:' || p_service_request_rec.request_date
21553     );
21554     FND_LOG.String
21555     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21556     , 'type_id	:' || p_service_request_rec.type_id
21557     );
21558     FND_LOG.String
21559     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21560     , 'status_id   	:' || p_service_request_rec.status_id
21561     );
21562     FND_LOG.String
21563     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21564     , 'severity_id 	:' || p_service_request_rec.severity_id
21565     );
21566     FND_LOG.String
21567     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21568     , 'urgency_id  	:' || p_service_request_rec.urgency_id
21569     );
21570     FND_LOG.String
21571     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21572     , 'closed_date 	:' || p_service_request_rec.closed_date
21573     );
21574     FND_LOG.String
21575     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21576     , 'owner_id    	:' || p_service_request_rec.owner_id
21577     );
21578     FND_LOG.String
21579     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21580     , 'owner_group_id   	:' || p_service_request_rec.owner_group_id
21581     );
21582     FND_LOG.String
21583     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21584     , 'publish_flag	:' || p_service_request_rec.publish_flag
21585     );
21586     FND_LOG.String
21587     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21588     , 'summary	:' || p_service_request_rec.summary
21589     );
21590     FND_LOG.String
21591     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21592     , 'caller_type 	:' || p_service_request_rec.caller_type
21593     );
21594     FND_LOG.String
21595     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21596     , 'customer_id 	:' || p_service_request_rec.customer_id
21597     );
21598     FND_LOG.String
21599     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21600     , 'customer_number  	:' || p_service_request_rec.customer_number
21601     );
21602     FND_LOG.String
21603     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21604     , 'employee_id 	:' || p_service_request_rec.employee_id
21605     );
21606     FND_LOG.String
21607     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21608     , 'verify_cp_flag   	:' || p_service_request_rec.verify_cp_flag
21609     );
21610     FND_LOG.String
21611     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21612     , 'customer_product_id   	:' || p_service_request_rec.customer_product_id
21613     );
21614     FND_LOG.String
21615     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21616     , 'platform_id 	:' || p_service_request_rec.platform_id
21617     );
21618     FND_LOG.String
21619     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21620     , 'platform_version	:' || p_service_request_rec.platform_version
21621     );
21622     FND_LOG.String
21623     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21624     , 'db_version	:' || p_service_request_rec.db_version
21625     );
21626     FND_LOG.String
21627     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21628     , 'platform_version_id   	:' || p_service_request_rec.platform_version_id
21629     );
21630     FND_LOG.String
21631     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21632     , 'cp_component_id  	:' || p_service_request_rec.cp_component_id
21633     );
21634     FND_LOG.String
21635     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21636     , 'cp_component_version_id    	:' || p_service_request_rec.cp_component_version_id
21637     );
21638     FND_LOG.String
21639     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21640     , 'cp_subcomponent_id    	:' || p_service_request_rec.cp_subcomponent_id
21641     );
21642     FND_LOG.String
21643     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21644     , 'cp_subcomponent_version_id 	:' || p_service_request_rec.cp_subcomponent_version_id
21645     );
21646     FND_LOG.String
21647     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21648     , 'language_id 	:' || p_service_request_rec.language_id
21649     );
21650     FND_LOG.String
21651     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21652     , 'language    	:' || p_service_request_rec.language
21653     );
21654     FND_LOG.String
21655     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21656     , 'inventory_item_id	:' || p_service_request_rec.inventory_item_id
21657     );
21658     FND_LOG.String
21659     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21660     , 'inventory_org_id 	:' || p_service_request_rec.inventory_org_id
21661     );
21662     FND_LOG.String
21663     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21664     , 'current_serial_number 	:' || p_service_request_rec.current_serial_number
21665     );
21666     FND_LOG.String
21667     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21668     , 'original_order_number 	:' || p_service_request_rec.original_order_number
21669     );
21670     FND_LOG.String
21671     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21672     , 'purchase_order_num    	:' || p_service_request_rec.purchase_order_num
21673     );
21674     FND_LOG.String
21675     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21676     , 'problem_code	:' || p_service_request_rec.problem_code
21677     );
21678     FND_LOG.String
21679     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21680     , 'exp_resolution_date   	:' || p_service_request_rec.exp_resolution_date
21681     );
21682     FND_LOG.String
21683     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21684     , 'install_site_use_id   	:' || p_service_request_rec.install_site_use_id
21685     );
21686     FND_LOG.String
21687     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21688     , 'request_attribute_1   	:' || p_service_request_rec.request_attribute_1
21689     );
21690     FND_LOG.String
21691     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21692     , 'request_attribute_2   	:' || p_service_request_rec.request_attribute_2
21693     );
21694     FND_LOG.String
21695     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21696     , 'request_attribute_3   	:' || p_service_request_rec.request_attribute_3
21697     );
21698     FND_LOG.String
21699     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21700     , 'request_attribute_4   	:' || p_service_request_rec.request_attribute_4
21701     );
21702     FND_LOG.String
21703     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21704     , 'request_attribute_5   	:' || p_service_request_rec.request_attribute_5
21705     );
21706     FND_LOG.String
21707     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21708     , 'request_attribute_6   	:' || p_service_request_rec.request_attribute_6
21709     );
21710     FND_LOG.String
21711     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21712     , 'request_attribute_7   	:' || p_service_request_rec.request_attribute_7
21713     );
21714     FND_LOG.String
21715     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21716     , 'request_attribute_8   	:' || p_service_request_rec.request_attribute_8
21717     );
21718     FND_LOG.String
21719     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21720     , 'request_attribute_9   	:' || p_service_request_rec.request_attribute_9
21721     );
21722     FND_LOG.String
21723     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21724     , 'request_attribute_10  	:' || p_service_request_rec.request_attribute_10
21725     );
21726     FND_LOG.String
21727     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21728     , 'request_attribute_11  	:' || p_service_request_rec.request_attribute_11
21729     );
21730     FND_LOG.String
21731     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21732     , 'request_attribute_12  	:' || p_service_request_rec.request_attribute_12
21733     );
21734     FND_LOG.String
21735     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21736     , 'request_attribute_13  	:' || p_service_request_rec.request_attribute_13
21737     );
21738     FND_LOG.String
21739     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21740     , 'request_attribute_14  	:' || p_service_request_rec.request_attribute_14
21741     );
21742     FND_LOG.String
21743     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21744     , 'request_attribute_15  	:' || p_service_request_rec.request_attribute_15
21745     );
21746     FND_LOG.String
21747     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21748     , 'request_context  	:' || p_service_request_rec.request_context
21749     );
21750     FND_LOG.String
21751     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21752     , 'external_attribute_1  	:' || p_service_request_rec.external_attribute_1
21753     );
21754     FND_LOG.String
21755     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21756     , 'external_attribute_2  	:' || p_service_request_rec.external_attribute_2
21757     );
21758     FND_LOG.String
21759     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21760     , 'external_attribute_3  	:' || p_service_request_rec.external_attribute_3
21761     );
21762     FND_LOG.String
21763     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21764     , 'external_attribute_4  	:' || p_service_request_rec.external_attribute_4
21765     );
21766     FND_LOG.String
21767     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21768     , 'external_attribute_5  	:' || p_service_request_rec.external_attribute_5
21769     );
21770     FND_LOG.String
21771     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21772     , 'external_attribute_6  	:' || p_service_request_rec.external_attribute_6
21773     );
21774     FND_LOG.String
21775     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21776     , 'external_attribute_7  	:' || p_service_request_rec.external_attribute_7
21777     );
21778     FND_LOG.String
21779     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21780     , 'external_attribute_8  	:' || p_service_request_rec.external_attribute_8
21781     );
21782     FND_LOG.String
21783     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21784     , 'external_attribute_9  	:' || p_service_request_rec.external_attribute_9
21785     );
21786     FND_LOG.String
21787     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21788     , 'external_attribute_10 	:' || p_service_request_rec.external_attribute_10
21789     );
21790     FND_LOG.String
21791     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21792     , 'external_attribute_11 	:' || p_service_request_rec.external_attribute_11
21793     );
21794     FND_LOG.String
21795     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21796     , 'external_attribute_12 	:' || p_service_request_rec.external_attribute_12
21797     );
21798     FND_LOG.String
21799     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21800     , 'external_attribute_13 	:' || p_service_request_rec.external_attribute_13
21801     );
21802     FND_LOG.String
21803     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21804     , 'external_attribute_14 	:' || p_service_request_rec.external_attribute_14
21805     );
21806     FND_LOG.String
21807     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21808     , 'external_attribute_15 	:' || p_service_request_rec.external_attribute_15
21809     );
21810     FND_LOG.String
21811     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21812     , 'external_context 	:' || p_service_request_rec.external_context
21813     );
21814     FND_LOG.String
21815     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21816     , 'bill_to_site_use_id   	:' || p_service_request_rec.bill_to_site_use_id
21817     );
21818     FND_LOG.String
21819     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21820     , 'bill_to_contact_id    	:' || p_service_request_rec.bill_to_contact_id
21821     );
21822     FND_LOG.String
21823     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21824     , 'ship_to_site_use_id   	:' || p_service_request_rec.ship_to_site_use_id
21825     );
21826     FND_LOG.String
21827     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21828     , 'ship_to_contact_id    	:' || p_service_request_rec.ship_to_contact_id
21829     );
21830     FND_LOG.String
21831     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21832     , 'resolution_code  	:' || p_service_request_rec.resolution_code
21833     );
21834     FND_LOG.String
21835     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21836     , 'act_resolution_date   	:' || p_service_request_rec.act_resolution_date
21837     );
21838     FND_LOG.String
21839     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21840     , 'public_comment_flag   	:' || p_service_request_rec.public_comment_flag
21841     );
21842     FND_LOG.String
21843     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21844     , 'parent_interaction_id 	:' || p_service_request_rec.parent_interaction_id
21845     );
21846     FND_LOG.String
21847     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21848     , 'contract_service_id   	:' || p_service_request_rec.contract_service_id
21849     );
21850     FND_LOG.String
21851     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21852     , 'contract_id 	:' || p_service_request_rec.contract_id
21853     );
21854     FND_LOG.String
21855     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21856     , 'project_number   	:' || p_service_request_rec.project_number
21857     );
21858     FND_LOG.String
21859     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21860     , 'qa_collection_plan_id 	:' || p_service_request_rec.qa_collection_plan_id
21861     );
21862     FND_LOG.String
21863     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21864     , 'account_id  	:' || p_service_request_rec.account_id
21865     );
21866     FND_LOG.String
21867     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21868     , 'resource_type    	:' || p_service_request_rec.resource_type
21869     );
21870     FND_LOG.String
21871     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21872     , 'resource_subtype_id   	:' || p_service_request_rec.resource_subtype_id
21873     );
21874     FND_LOG.String
21875     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21876     , 'cust_po_number   	:' || p_service_request_rec.cust_po_number
21877     );
21878     FND_LOG.String
21879     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21880     , 'cust_ticket_number	:' || p_service_request_rec.cust_ticket_number
21881     );
21882     FND_LOG.String
21883     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21884     , 'sr_creation_channel   	:' || p_service_request_rec.sr_creation_channel
21885     );
21886     FND_LOG.String
21887     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21888     , 'obligation_date  	:' || p_service_request_rec.obligation_date
21889     );
21890     FND_LOG.String
21891     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21892     , 'time_zone_id	:' || p_service_request_rec.time_zone_id
21893     );
21894     FND_LOG.String
21895     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21896     , 'time_difference  	:' || p_service_request_rec.time_difference
21897     );
21898     FND_LOG.String
21899     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21900     , 'site_id	:' || p_service_request_rec.site_id
21901     );
21902     FND_LOG.String
21903     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21904     , 'customer_site_id 	:' || p_service_request_rec.customer_site_id
21905     );
21906     FND_LOG.String
21907     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21908     , 'territory_id	:' || p_service_request_rec.territory_id
21909     );
21910     FND_LOG.String
21911     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21912     , 'initialize_flag  	:' || p_service_request_rec.initialize_flag
21913     );
21914     FND_LOG.String
21915     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21916     , 'cp_revision_id   	:' || p_service_request_rec.cp_revision_id
21917     );
21918     FND_LOG.String
21919     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21920     , 'inv_item_revision	:' || p_service_request_rec.inv_item_revision
21921     );
21922     FND_LOG.String
21923     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21924     , 'inv_component_id	:' || p_service_request_rec.inv_component_id
21925     );
21926     FND_LOG.String
21927     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21928     , 'inv_component_version 	:' || p_service_request_rec.inv_component_version
21929     );
21930     FND_LOG.String
21931     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21932     , 'inv_subcomponent_id   	:' || p_service_request_rec.inv_subcomponent_id
21933     );
21934     FND_LOG.String
21935     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21936     , 'inv_subcomponent_version   	:' || p_service_request_rec.inv_subcomponent_version
21937     );
21938     FND_LOG.String
21939     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21940     , 'tier   	:' || p_service_request_rec.tier
21941     );
21942     FND_LOG.String
21943     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21944     , 'tier_version	:' || p_service_request_rec.tier_version
21945     );
21946     FND_LOG.String
21947     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21948     , 'operating_system 	:' || p_service_request_rec.operating_system
21949     );
21950     FND_LOG.String
21951     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21952     , 'operating_system_version   	:' || p_service_request_rec.operating_system_version
21953     );
21954     FND_LOG.String
21955     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21956     , 'database    	:' || p_service_request_rec.database
21957     );
21958     FND_LOG.String
21959     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21960     , 'cust_pref_lang_id	:' || p_service_request_rec.cust_pref_lang_id
21961     );
21962     FND_LOG.String
21963     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21964     , 'category_id 	:' || p_service_request_rec.category_id
21965     );
21966     FND_LOG.String
21967     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21968     , 'group_type  	:' || p_service_request_rec.group_type
21969     );
21970     FND_LOG.String
21971     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21972     , 'group_territory_id    	:' || p_service_request_rec.group_territory_id
21973     );
21974     FND_LOG.String
21975     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21976     , 'inv_platform_org_id   	:' || p_service_request_rec.inv_platform_org_id
21977     );
21978     FND_LOG.String
21979     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21980     , 'product_revision 	:' || p_service_request_rec.product_revision
21981     );
21982     FND_LOG.String
21983     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21984     , 'component_version	:' || p_service_request_rec.component_version
21985     );
21986     FND_LOG.String
21987     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21988     , 'subcomponent_version  	:' || p_service_request_rec.subcomponent_version
21989     );
21990     FND_LOG.String
21991     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21992     , 'comm_pref_code   	:' || p_service_request_rec.comm_pref_code
21993     );
21994     FND_LOG.String
21995     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
21996     , 'last_update_date 	:' || p_service_request_rec.last_update_date
21997     );
21998     FND_LOG.String
21999     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22000     , 'last_updated_by  	:' || p_service_request_rec.last_updated_by
22001     );
22002     FND_LOG.String
22003     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22004     , 'creation_date    	:' || p_service_request_rec.creation_date
22005     );
22006     FND_LOG.String
22007     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22008     , 'created_by  	:' || p_service_request_rec.created_by
22009     );
22010     FND_LOG.String
22011     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22012     , 'last_update_login	:' || p_service_request_rec.last_update_login
22013     );
22014     FND_LOG.String
22015     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22016     , 'owner_assigned_time   	:' || p_service_request_rec.owner_assigned_time
22017     );
22018     FND_LOG.String
22019     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22020     , 'owner_assigned_flag   	:' || p_service_request_rec.owner_assigned_flag
22021     );
22022     FND_LOG.String
22023     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22024     , 'last_update_channel   	:' || p_service_request_rec.last_update_channel
22025     );
22026     FND_LOG.String
22027     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22028     , 'cust_pref_lang_code   	:' || p_service_request_rec.cust_pref_lang_code
22029     );
22030     FND_LOG.String
22031     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22032     , 'load_balance	:' || p_service_request_rec.load_balance
22033     );
22034     FND_LOG.String
22035     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22036     , 'assign_owner	:' || p_service_request_rec.assign_owner
22037     );
22038     FND_LOG.String
22039     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22040     , 'category_set_id  	:' || p_service_request_rec.category_set_id
22041     );
22042     FND_LOG.String
22043     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22044     , 'external_reference    	:' || p_service_request_rec.external_reference
22045     );
22046     FND_LOG.String
22047     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22048     , 'system_id   	:' || p_service_request_rec.system_id
22049     );
22050     FND_LOG.String
22051     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22052     , 'error_code  	:' || p_service_request_rec.error_code
22053     );
22054     FND_LOG.String
22055     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22056     , 'incident_occurred_date	:' || p_service_request_rec.incident_occurred_date
22057     );
22058     FND_LOG.String
22059     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22060     , 'incident_resolved_date	:' || p_service_request_rec.incident_resolved_date
22061     );
22062     FND_LOG.String
22063     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22064     , 'inc_responded_by_date 	:' || p_service_request_rec.inc_responded_by_date
22065     );
22066     FND_LOG.String
22067     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22068     , 'resolution_summary    	:' || p_service_request_rec.resolution_summary
22069     );
22070     FND_LOG.String
22071     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22072     , 'incident_location_id  	:' || p_service_request_rec.incident_location_id
22073     );
22074     FND_LOG.String
22075     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22076     , 'incident_address 	:' || p_service_request_rec.incident_address
22077     );
22078     FND_LOG.String
22079     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22080     , 'incident_city    	:' || p_service_request_rec.incident_city
22081     );
22082     FND_LOG.String
22083     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22084     , 'incident_state   	:' || p_service_request_rec.incident_state
22085     );
22086     FND_LOG.String
22087     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22088     , 'incident_country 	:' || p_service_request_rec.incident_country
22089     );
22090     FND_LOG.String
22091     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22092     , 'incident_province	:' || p_service_request_rec.incident_province
22093     );
22094     FND_LOG.String
22095     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22096     , 'incident_postal_code  	:' || p_service_request_rec.incident_postal_code
22097     );
22098     FND_LOG.String
22099     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22100     , 'incident_county  	:' || p_service_request_rec.incident_county
22101     );
22102     FND_LOG.String
22103     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22104     , 'owner  	:' || p_service_request_rec.owner
22105     );
22106     FND_LOG.String
22107     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22108     , 'group_owner 	:' || p_service_request_rec.group_owner
22109     );
22110     FND_LOG.String
22111     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22112     , 'cc_number   	:' || p_service_request_rec.cc_number
22113     );
22114     FND_LOG.String
22115     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22116     , 'cc_expiration_date    	:' || p_service_request_rec.cc_expiration_date
22117     );
22118     FND_LOG.String
22119     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22120     , 'cc_type_code	:' || p_service_request_rec.cc_type_code
22121     );
22122     FND_LOG.String
22123     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22124     , 'cc_first_name    	:' || p_service_request_rec.cc_first_name
22125     );
22126     FND_LOG.String
22127     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22128     , 'cc_last_name	:' || p_service_request_rec.cc_last_name
22129     );
22130     FND_LOG.String
22131     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22132     , 'cc_middle_name   	:' || p_service_request_rec.cc_middle_name
22133     );
22134     FND_LOG.String
22135     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22136     , 'cc_id   	:' || p_service_request_rec.cc_id
22137     );
22138     FND_LOG.String
22139     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22140     , 'coverage_type    	:' || p_service_request_rec.coverage_type
22141     );
22142     FND_LOG.String
22143     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22144     , 'bill_to_account_id    	:' || p_service_request_rec.bill_to_account_id
22145     );
22146     FND_LOG.String
22147     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22148     , 'ship_to_account_id    	:' || p_service_request_rec.ship_to_account_id
22149     );
22150     FND_LOG.String
22151     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22152     , 'customer_phone_id   	:' || p_service_request_rec.customer_phone_id
22153     );
22154     FND_LOG.String
22155     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22156     , 'customer_email_id   	:' || p_service_request_rec.customer_email_id
22157     );
22158     FND_LOG.String
22159     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22160     , 'creation_program_code 	:' || p_service_request_rec.creation_program_code
22161     );
22162     FND_LOG.String
22163     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22164     , 'last_update_program_code   	:' || p_service_request_rec.last_update_program_code
22165     );
22166     FND_LOG.String
22167     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22168     , 'bill_to_party_id 	:' || p_service_request_rec.bill_to_party_id
22169     );
22170     FND_LOG.String
22171     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22172     , 'ship_to_party_id 	:' || p_service_request_rec.ship_to_party_id
22173     );
22174     FND_LOG.String
22175     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22176     , 'program_id  	:' || p_service_request_rec.program_id
22177     );
22178     FND_LOG.String
22179     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22180     , 'program_application_id	:' || p_service_request_rec.program_application_id
22181     );
22182     FND_LOG.String
22183     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22184     , 'conc_request_id  	:' || p_service_request_rec.conc_request_id
22185     );
22186     FND_LOG.String
22187     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22188     , 'program_login_id 	:' || p_service_request_rec.program_login_id
22189     );
22190     FND_LOG.String
22191     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22192     , 'bill_to_site_id  	:' || p_service_request_rec.bill_to_site_id
22193     );
22194     FND_LOG.String
22195     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22196     , 'ship_to_site_id  	:' || p_service_request_rec.ship_to_site_id
22197     );
22198     FND_LOG.String
22199     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22200     , 'incident_point_of_interest 	:' || p_service_request_rec.incident_point_of_interest
22201     );
22202     FND_LOG.String
22203     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22204     , 'incident_cross_street 	:' || p_service_request_rec.incident_cross_street
22205     );
22206     FND_LOG.String
22207     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22208     , 'incident_direction_qualifier    	:' || p_service_request_rec.incident_direction_qualifier
22209     );
22210     FND_LOG.String
22211     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22212     , 'incident_distance_qualifier	:' || p_service_request_rec.incident_distance_qualifier
22213     );
22214     FND_LOG.String
22215     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22216     , 'incident_distance_qual_uom 	:' || p_service_request_rec.incident_distance_qual_uom
22217     );
22218     FND_LOG.String
22219     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22220     , 'incident_address2	:' || p_service_request_rec.incident_address2
22221     );
22222     FND_LOG.String
22223     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22224     , 'incident_address3 	:' || p_service_request_rec.incident_address3
22225     );
22226     FND_LOG.String
22227     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22228     , 'incident_address4	:' || p_service_request_rec.incident_address4
22229     );
22230     FND_LOG.String
22231     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22232     , 'incident_address_style 	:' || p_service_request_rec.incident_address_style
22233     );
22234     FND_LOG.String
22235     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22236     , 'incident_addr_lines_phonetic    	:' || p_service_request_rec.incident_addr_lines_phonetic
22237     );
22238     FND_LOG.String
22239     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22240     , 'incident_po_box_number	:' || p_service_request_rec.incident_po_box_number
22241     );
22242     FND_LOG.String
22243     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22244     , 'incident_house_number  	:' || p_service_request_rec.incident_house_number
22245     );
22246     FND_LOG.String
22247     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22248     , 'incident_street_suffix	:' || p_service_request_rec.incident_street_suffix
22249     );
22250     FND_LOG.String
22251     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22252     , 'incident_street   	:' || p_service_request_rec.incident_street
22253     );
22254     FND_LOG.String
22255     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22256     , 'incident_street_number	:' || p_service_request_rec.incident_street_number
22257     );
22258     FND_LOG.String
22259     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22260     , 'incident_floor   	:' || p_service_request_rec.incident_floor
22261     );
22262     FND_LOG.String
22263     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22264     , 'incident_suite   	:' || p_service_request_rec.incident_suite
22265     );
22266     FND_LOG.String
22267     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22268     , 'incident_postal_plus4_code 	:' || p_service_request_rec.incident_postal_plus4_code
22269     );
22270     FND_LOG.String
22271     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22272     , 'incident_position	:' || p_service_request_rec.incident_position
22273     );
22274     FND_LOG.String
22275     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22276     , 'incident_location_directions    	:' || p_service_request_rec.incident_location_directions
22277     );
22278     FND_LOG.String
22279     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22280     , 'incident_location_description   	:' || p_service_request_rec.incident_location_description
22281     );
22282     FND_LOG.String
22283     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22284     , 'install_site_id  	:' || p_service_request_rec.install_site_id
22285     );
22286     FND_LOG.String
22287     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22288     , 'status_flag 	:' || p_service_request_rec.status_flag
22289     );
22290     FND_LOG.String
22291     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22292     , 'primary_contact_id    	:' || p_service_request_rec.primary_contact_id
22293     );
22294     FND_LOG.String
22295     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22296     , 'old_type_maintenance_flag	:' || p_service_request_rec.old_type_maintenance_flag
22297     );
22298     FND_LOG.String
22299     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22300     , 'new_type_maintenance_flag	:' || p_service_request_rec.new_type_maintenance_flag
22301     );
22302     FND_LOG.String
22303     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22304     , 'old_type_CMRO_flag	:' || p_service_request_rec.old_type_CMRO_flag
22305     );
22306     FND_LOG.String
22307     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22308     , 'new_type_CMRO_flag	:' || p_service_request_rec.new_type_CMRO_flag
22309     );
22310     FND_LOG.String
22311     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22312     , 'item_serial_number	:' || p_service_request_rec.item_serial_number
22313     );
22314     FND_LOG.String
22315     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22316     , 'owning_dept_id	:' || p_service_request_rec.owning_dept_id
22317     );
22318     FND_LOG.String
22319     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22320     , 'incident_location_type	:' || p_service_request_rec.incident_location_type
22321     );
22322     FND_LOG.String
22323     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22324     , 'org_id    	:' || p_service_request_rec.org_id
22325     );
22326     FND_LOG.String
22327     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22328     , 'maint_organization_id    	:' || p_service_request_rec.maint_organization_id
22329     );
22330     /* Credit Card 9358401 */
22331     FND_LOG.String
22332     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22333     , 'instrument_payment_use_id    	:' ||
22334                              p_service_request_rec.instrument_payment_use_id
22335     );
22336 
22337     --12.2+ logging for project_id and project_task_id project integration siahmed
22338      FND_LOG.String
22339     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22340     , 'project_id    	:' || p_service_request_rec.project_id
22341     );
22342  FND_LOG.String
22343     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22344     , 'project_task_id    	:' || p_service_request_rec.project_task_id
22345     );
22346     FND_LOG.String
22347     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22348     , 'expenditure_org_id    	:' || p_service_request_rec.expenditure_org_id
22349     );
22350 
22351 
22352 
22353    --end of addition for 12.2+ siahmed
22354 
22355    --14004721 . Additional SLA dates
22356     FND_LOG.String
22357     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22358     , 'sla_date_1    	:' ||
22359                              p_service_request_rec.sla_date_1
22360     );
22361     FND_LOG.String
22362     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22363     , 'sla_date_2    	:' ||
22364                              p_service_request_rec.sla_date_2
22365     );
22366     FND_LOG.String
22367     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22368     , 'sla_date_3    	:' ||
22369                              p_service_request_rec.sla_date_3
22370     );
22371     FND_LOG.String
22372     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22373     , 'sla_date_4    	:' ||
22374                              p_service_request_rec.sla_date_4
22375     );
22376     FND_LOG.String
22377     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22378     , 'sla_date_5    	:' ||
22379                              p_service_request_rec.sla_date_5
22380     );
22381     FND_LOG.String
22382     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22383     , 'sla_date_6    	:' ||
22384                              p_service_request_rec.sla_date_6
22385     );
22386     FND_LOG.String
22387     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22388     , 'sla_duration_1    	:' ||
22389                              p_service_request_rec.sla_duration_1
22390     );
22391     FND_LOG.String
22392     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22393     , 'sla_duration_2    	:' ||
22394                              p_service_request_rec.sla_duration_2
22395     );
22396 
22397     --15995804. Add price_list_header_id
22398     FND_LOG.String
22399     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22400     , 'price_list_header_id    :' ||
22401 			      p_service_request_rec.price_list_header_id
22402     );
22403 
22404 
22405   -- For Notes
22406   l_note_index := p_notes.FIRST;
22407   WHILE l_note_index IS NOT NULL LOOP
22408     FND_LOG.String
22409     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22410     , 'note                  	:' ||p_notes(l_note_index).note
22411     );
22412     FND_LOG.String
22413     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22414     , 'note_detail                  	:' ||p_notes(l_note_index).note_detail
22415     );
22416     FND_LOG.String
22417     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22418     , 'note_type                  	:' ||p_notes(l_note_index).note_type
22419     );
22420     FND_LOG.String
22421     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22422     , 'note_context_type_01            	:' ||p_notes(l_note_index).note_context_type_01
22423     );
22424     FND_LOG.String
22425     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22426     , 'note_context_type_id_01         	:' ||p_notes(l_note_index).note_context_type_id_01
22427     );
22428     FND_LOG.String
22429     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22430     , 'note_context_type_02            	:' ||p_notes(l_note_index).note_context_type_02
22431     );
22432     FND_LOG.String
22433     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22434     , 'note_context_type_id_02      	:' ||p_notes(l_note_index).note_context_type_id_02
22435     );
22436     FND_LOG.String
22437     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22438     , 'note_context_type_03       	:' ||p_notes(l_note_index).note_context_type_03
22439     );
22440     FND_LOG.String
22441     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22442     , 'note_context_type_id_03         	:' ||p_notes(l_note_index).note_context_type_id_03
22443     );
22444 
22445     l_note_index := p_notes.NEXT(l_note_index);
22446   END LOOP;
22447 
22448   -- For Contacts
22449   l_contact_index := p_contacts.FIRST;
22450   WHILE l_contact_index IS NOT NULL LOOP
22451     FND_LOG.String
22452     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22453     , 'sr_contact_point_id             	:' ||  p_contacts(l_contact_index).sr_contact_point_id
22454     );
22455     FND_LOG.String
22456     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22457     , 'party_id                  	:' ||  p_contacts(l_contact_index).party_id
22458     );
22459     FND_LOG.String
22460     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22461     , 'contact_point_id                	:' ||  p_contacts(l_contact_index).contact_point_id
22462     );
22463     FND_LOG.String
22464     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22465     , 'contact_point_type       	:' ||  p_contacts(l_contact_index).contact_point_type
22466     );
22467     FND_LOG.String
22468     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22469     , 'primary_flag                  	:' ||  p_contacts(l_contact_index).primary_flag
22470     );
22471     FND_LOG.String
22472     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22473     , 'contact_type                  	:' ||  p_contacts(l_contact_index).contact_type
22474     );
22475     FND_LOG.String
22476     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22477     , 'party_role_code                 	:' ||  P_contacts(l_contact_index).party_role_code
22478     );
22479     FND_LOG.String
22480     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22481     , 'start_date_active        	:' ||  P_contacts(l_contact_index).start_date_active
22482     );
22483     FND_LOG.String
22484     ( FND_LOG.level_procedure , L_LOG_MODULE || ''
22485     , 'end_date_active                 	:' ||  P_contacts(l_contact_index).end_date_active
22486     );
22487 
22488     l_contact_index := p_contacts.NEXT(l_contact_index);
22489   END LOOP;
22490 
22491   END IF ;
22492 
22493 END Log_SR_PVT_Parameters;
22494 
22495 ----------------------------------------------------------------------------------------------
22496 --CREATED BY SIAHMED FOR 12.1.2 PROJECT siahmed
22497 --this procdure will called during onetime address creation.
22498 --this basically allows creation of one-time addresses and party sites as TCA locations via service
22499 --request API that will be used by all EBS CRM service applications
22500 PROCEDURE create_onetime_address
22501 (    p_service_req_rec   IN  service_request_rec_type,
22502      x_msg_count         OUT NOCOPY  NUMBER,
22503      x_msg_data          OUT NOCOPY  VARCHAR2,
22504      x_return_status     OUT NOCOPY  VARCHAR2,
22505      x_location_id       OUT NOCOPY  NUMBER)
22506 Is
22507    l_service_req_rec  service_request_rec_type DEFAULT p_service_req_rec;
22508 
22509    l_location_rec      HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
22510    l_location_id       NUMBER;
22511    l_loc_id            NUMBER;
22512    l_created_by_module VARCHAR2(150);
22513    l_application_id    NUMBER;
22514    l_init_msg_list     VARCHAR2(10);
22515    l_do_addr_val       VARCHAR2(10);
22516    l_addr_val_status   VARCHAR2(200);
22517    l_addr_warn_msg     VARCHAR2(2000);
22518    -- party site related variables
22519    l_party_site_rec      HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
22520    l_party_site_id       NUMBER;
22521    l_party_site_number   VARCHAR2(2000);
22522    -- common attributes for all return types
22523    l_return_status       VARCHAR2(1);
22524    l_msg_count           NUMBER;
22525    l_msg_data            VARCHAR2(2000);
22526 
22527 
22528 
22529 BEGIN
22530    l_created_by_module                := 'SR_ONETIME';
22531 
22532    -- prepare the location_rec with the values that has been passed in the service_request_rec_type
22533    l_location_rec.address1            := l_service_req_rec.incident_address;
22534    l_location_rec.address2            := l_service_req_rec.incident_address2;
22535    l_location_rec.address3            := l_service_req_rec.incident_address3;
22536    l_location_rec.address4            := l_service_req_rec.incident_address4;
22537    l_location_rec.city                := l_service_req_rec.incident_city;
22538    l_location_rec.state               := l_service_req_rec.incident_state;
22539    l_location_rec.postal_code         := l_service_req_rec.incident_postal_code;
22540    l_location_rec.county              := l_service_req_rec.incident_county;
22541    l_location_rec.province            := l_service_req_rec.incident_province;
22542    l_location_rec.country             := l_service_req_rec.incident_country;
22543    l_location_rec.created_by_module   := l_created_by_module;
22544    l_location_rec.postal_plus4_code   := l_service_req_rec.incident_postal_plus4_code;
22545    l_location_rec.address_lines_phonetic := l_service_req_rec.incident_addr_lines_phonetic;
22546 
22547    --save point to be rolled back if one time address creation fails during location or site creation.
22548    SAVEPOINT create_onetime_address;
22549 
22550    IF (fnd_profile.value('CS_SR_VALIDATE_ONE_TIME_ADDRESS_AGAINST_TCA_GEOGRAPHY') = 'Y') THEN
22551 	l_do_addr_val := 'Y';
22552    else
22553 	l_do_addr_val := 'N';
22554    END IF;
22555 
22556    HZ_LOCATION_V2PUB.create_location (
22557      p_init_msg_list     => FND_API.G_FALSE,
22558      p_location_rec      => l_location_rec,
22559      p_do_addr_val       => l_do_addr_val,
22560      x_location_id       => l_location_id,
22561      x_addr_val_status   => l_addr_val_status,
22562      x_addr_warn_msg     => l_addr_warn_msg,
22563      x_return_status     => l_return_status,
22564      x_msg_count         => l_msg_count,
22565      x_msg_data          => l_msg_data
22566      );
22567 
22568 
22569 
22570      --if location has been created successfully then create party_site
22571      --if party_site creation fails then roll back all the way to create_onetime_address;
22572      If l_return_status = FND_API.G_RET_STS_SUCCESS Then
22573           -- populating the msg_count and msg_data to capture warning during
22574           -- location creation.
22575           x_msg_count     := l_msg_count;
22576           x_msg_data      := l_msg_data;
22577 
22578 	  --party_site initialization
22579           l_party_site_rec.party_id          := l_service_req_rec.customer_id;
22580           l_party_site_rec.location_id       := l_location_id;
22581           l_party_site_rec.party_site_number := l_service_req_rec.site_number;
22582           l_party_site_rec.party_site_name   := l_service_req_rec.site_name;
22583           l_party_site_rec.addressee	     := l_service_req_rec.addressee;
22584           l_party_site_rec.created_by_module := l_created_by_module;
22585 	  l_party_site_rec.identifying_address_flag := 'N';
22586 	  l_party_site_rec.status := 'I';
22587 
22588           -- Create the party site
22589           HZ_PARTY_SITE_V2PUB.CREATE_PARTY_SITE(
22590             p_init_msg_list      => l_init_msg_list,
22591             p_party_site_rec     => l_party_site_rec,
22592             x_party_site_id      => l_party_site_id,
22593             x_party_site_number  => l_party_site_number,
22594             x_return_status      => l_return_status,
22595             x_msg_count          => l_msg_count,
22596             x_msg_data           => l_msg_data
22597 	    );
22598 
22599 
22600 	 If l_return_status = FND_API.G_RET_STS_SUCCESS Then
22601 	    -- if location creation and party_site creation is both successful then pass the location_id
22602                 x_location_id   := l_party_site_id;
22603 
22604                 x_return_status := l_return_status;
22605 
22606                 -- taking the following msg log out as we dont care much for
22607                 -- party site creation messages. Will move this 2 lines up
22608                 -- to log any warning msg during location creation as we might
22609                 -- get warning during location verification.
22610                 --      x_msg_count     := l_msg_count;
22611                 --      x_msg_data      := l_msg_data;
22612 
22613          elsif l_return_status <> FND_API.G_RET_STS_SUCCESS Then
22614 		x_return_status := l_return_status;
22615                 x_msg_count     := l_msg_count;
22616 	       	x_msg_data      := l_msg_data;
22617 
22618 		ROLLBACK to create_onetime_address;
22619 		--raise exception here
22620          END IF;
22621 
22622 
22623      --if location creation is not successful roll back and raise exception
22624      elsif  l_return_status <> FND_API.G_RET_STS_SUCCESS Then
22625      	  x_return_status := l_return_status;
22626           x_msg_count     := l_msg_count;
22627 	  x_msg_data      := l_msg_data || l_addr_warn_msg ;
22628 
22629           ROLLBACK TO create_onetime_address;
22630 	  -- raise exception here
22631      END IF;
22632 EXCEPTION
22633   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
22634     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
22635     x_msg_data := l_msg_data;
22636   WHEN OTHERS THEN
22637     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
22638     x_msg_data := l_msg_data;
22639 END create_onetime_address;
22640 --end of procedure  siahmed
22641 ----------------------------------------------------------------------------------------------
22642 --update onetime address
22643 --CREATED BY SIAHMED FOR 12.1.2 PROJECT siahmed
22644 --this procdure will called during updation of address.
22645 PROCEDURE update_onetime_address
22646 (    p_service_req_rec     IN  service_request_rec_type,
22647      x_msg_count           OUT NOCOPY  NUMBER,
22648      x_msg_data            OUT NOCOPY  VARCHAR2,
22649      x_return_status       OUT NOCOPY  VARCHAR2)
22650 Is
22651    l_service_req_rec      service_request_rec_type DEFAULT p_service_req_rec;
22652 
22653    l_location_rec      HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
22654    l_location_id       NUMBER;
22655    l_loc_id            NUMBER;
22656    l_created_by_module VARCHAR2(150);
22657    l_application_id    NUMBER;
22658    l_init_msg_list     VARCHAR2(10);
22659    l_do_addr_val       VARCHAR2(10);
22660    -- party site related variables
22661    l_party_site_rec      HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
22662    l_party_site_id       NUMBER;
22663    -- common attributes for all return types
22664    l_return_status       VARCHAR2(1);
22665    l_msg_count           NUMBER;
22666    l_msg_data            VARCHAR2(2000);
22667 
22668    l_ps_object_version_number NUMBER;
22669    l_loc_object_version_number NUMBER;
22670    l_addr_val_status          VARCHAR2(10);
22671    l_addr_warn_msg            VARCHAR2(200);
22672 
22673 
22674    --variables for address
22675    l_address1               hz_locations.address1%TYPE;
22676    l_address2               hz_locations.address2%TYPE;
22677    l_address3               hz_locations.address3%TYPE;
22678    l_address4               hz_locations.address4%TYPE;
22679    l_city                   hz_locations.city%TYPE;
22680    l_state                  hz_locations.state%TYPE;
22681    l_postal_code            hz_locations.postal_code%TYPE;
22682    l_county                 hz_locations.county%TYPE;
22683    l_province               hz_locations.province%TYPE;
22684    l_country                hz_locations.country%TYPE;
22685    l_postal_plus4_code      hz_locations.postal_plus4_code%TYPE;
22686    l_address_lines_phonetic hz_locations.address_lines_phonetic%TYPE;
22687    l_party_site_number      hz_party_sites.party_site_number%TYPE;
22688    l_party_site_name        hz_party_sites.party_site_name%TYPE;
22689    l_addressee              hz_party_sites.addressee%TYPE;
22690 
22691 BEGIN
22692    SELECT a.location_id,
22693           a.address1,
22694           a.address2,
22695           a.address3,
22696           a.address4,
22697 	  a.city,
22698           a.state,
22699           a.postal_code,
22700           a.county,
22701 	  a.province,
22702           a.country,
22703           a.postal_plus4_code ,
22704           a.address_lines_phonetic,
22705 	  b.party_site_number,
22706           b.party_site_name,
22707 	  b.addressee,
22708 	  a.object_version_number,
22709 	  b.object_version_number
22710     INTO
22711           l_loc_id,
22712           l_address1,
22713           l_address2,
22714           l_address3,
22715           l_address4,
22716           l_city,
22717           l_state,
22718           l_postal_code,
22719           l_county,
22720           l_province,
22721           l_country,
22722           l_postal_plus4_code,
22723           l_address_lines_phonetic,
22724           l_party_site_number,
22725           l_party_site_name,
22726           l_addressee,
22727 	  l_loc_object_version_number,
22728 	  l_ps_object_version_number
22729     from hz_locations a,
22730          hz_party_sites b
22731     where b.party_site_id = l_service_req_rec.incident_location_id
22732     and   b.location_id = a.location_id
22733     and   b.created_by_module = a.created_by_module;
22734 
22735    l_created_by_module  := 'SR_ONETIME';
22736 
22737 
22738           --well not be checking if the current site ifnromation is the same as the old site information
22739           --as site information are not stored in the incidents table (CS_INCIDENT_ALL B)
22740           --we are going to just check if site information is coming in if so then just update
22741 
22742           IF ((nvl(l_service_req_rec.site_name,' ')   <> nvl(l_party_site_name,' ')) OR
22743               (nvl(l_service_req_rec.site_number,' ') <> nvl(l_party_site_number,' ')) OR
22744               (nvl(l_service_req_rec.addressee,' ')   <> nvl(l_addressee,' '))) THEN
22745 
22746               --party_site initialization
22747               l_party_site_rec.party_site_id     := l_service_req_rec.incident_location_id;
22748               l_party_site_rec.party_id          := l_service_req_rec.customer_id;
22749               l_party_site_rec.party_site_number := l_service_req_rec.site_number;
22750               -- we are doing the NVL during assignment because null is not an accepted
22751               -- value by the TCA api and we have to pass G_MISS_NUM OR CHAR as needed
22752               l_party_site_rec.party_site_name   := nvl(l_service_req_rec.site_name,FND_API.G_MISS_CHAR);
22753               l_party_site_rec.addressee         := nvl(l_service_req_rec.addressee,FND_API.G_MISS_CHAR);
22754               l_party_site_rec.created_by_module := l_created_by_module;
22755 
22756               SAVEPOINT UPDATE_PARTY_SITE;
22757 
22758               -- update  the party site
22759               HZ_PARTY_SITE_V2PUB.UPDATE_PARTY_SITE(
22760                 p_init_msg_list          => l_init_msg_list,
22761                 p_party_site_rec         => l_party_site_rec,
22762                 p_object_version_number  => l_ps_object_version_number,
22763                 x_return_status          => l_return_status,
22764                 x_msg_count              => l_msg_count,
22765                 x_msg_data               => l_msg_data
22766                 );
22767 
22768 
22769              If l_return_status = FND_API.G_RET_STS_SUCCESS Then
22770                   x_return_status := l_return_status;
22771                   x_msg_count     := l_msg_count;
22772                   x_msg_data      := l_msg_data;
22773              elsif l_return_status <> FND_API.G_RET_STS_SUCCESS Then
22774                   x_return_status := l_return_status;
22775                   x_msg_count     := l_msg_count;
22776                   x_msg_data      := l_msg_data;
22777 
22778                   ROLLBACK to UPDATE_PARTY_SITE;
22779                   --raise exception here
22780               END IF;
22781 
22782           END IF; --end of update party site
22783 
22784 
22785           --check if any of the location fiels have been changed
22786           IF ((nvl(l_service_req_rec.incident_address,' ')  <> nvl(l_address1,' ')) OR
22787               (nvl(l_service_req_rec.incident_address2,' ') <> nvl(l_address2,' ')) OR
22788               (nvl(l_service_req_rec.incident_address3,' ') <> nvl(l_address3,' ')) OR
22789               (nvl(l_service_req_rec.incident_address4,' ') <> nvl(l_address4,' ')) OR
22790               (nvl(l_service_req_rec.incident_city,' ')     <> nvl(l_city,' ')) OR
22791               (nvl(l_service_req_rec.incident_state,' ')    <> nvl(l_state,' ')) OR
22792               (nvl(l_service_req_rec.incident_postal_code,' ') <> nvl(l_postal_code,' ')) OR
22793               (nvl(l_service_req_rec.incident_county,' ')   <> nvl(l_county,' ')) OR
22794               (nvl(l_service_req_rec.incident_province,' ') <> nvl(l_province,' ')) OR
22795               (nvl(l_service_req_rec.incident_country,' ')  <> nvl(l_country,' '))  OR
22796               (nvl(l_service_req_rec.incident_postal_plus4_code,' ') <> nvl(l_postal_plus4_code,' ')) OR
22797               (nvl(l_service_req_rec.incident_addr_lines_phonetic,' ') <> nvl(l_address_lines_phonetic,' '))) THEN
22798 
22799                -- prepare the location_rec with the values that has been passed in the service_request_rec_type
22800                -- over here we are doing nvl with G_MISS_CHAR because the TCA api does not accept nuull values
22801                   l_location_rec.location_id         := l_loc_id;
22802                   l_location_rec.address1            := nvl(l_service_req_rec.incident_address,FND_API.G_MISS_CHAR);
22803                   l_location_rec.address2            := nvl(l_service_req_rec.incident_address2,FND_API.G_MISS_CHAR);
22804                   l_location_rec.address3            := nvl(l_service_req_rec.incident_address3,FND_API.G_MISS_CHAR);
22805                   l_location_rec.address4            := nvl(l_service_req_rec.incident_address4,FND_API.G_MISS_CHAR);
22806                   l_location_rec.city                := nvl(l_service_req_rec.incident_city,FND_API.G_MISS_CHAR);
22807                   l_location_rec.state               := nvl(l_service_req_rec.incident_state,FND_API.G_MISS_CHAR);
22808                   l_location_rec.postal_code         := nvl(l_service_req_rec.incident_postal_code,FND_API.G_MISS_CHAR);
22809                   l_location_rec.county              := nvl(l_service_req_rec.incident_county,FND_API.G_MISS_CHAR);
22810                   l_location_rec.province            := nvl(l_service_req_rec.incident_province,FND_API.G_MISS_CHAR);
22811                   l_location_rec.country             := nvl(l_service_req_rec.incident_country,FND_API.G_MISS_CHAR);
22812                   l_location_rec.created_by_module   := l_created_by_module;
22813                   l_location_rec.postal_plus4_code   := nvl(l_service_req_rec.incident_postal_plus4_code,FND_API.G_MISS_CHAR);
22814                   l_location_rec.address_lines_phonetic := nvl(l_service_req_rec.incident_addr_lines_phonetic,FND_API.G_MISS_CHAR);
22815 
22816                   SAVEPOINT UPDATE_LOCATION;
22817 		   IF (fnd_profile.value('CS_SR_VALIDATE_ONE_TIME_ADDRESS_AGAINST_TCA_GEOGRAPHY') = 'Y') THEN
22818 			l_do_addr_val := 'Y';
22819 		   else
22820 			l_do_addr_val := 'N';
22821 		   END IF;
22822 
22823                   HZ_LOCATION_V2PUB.update_location (
22824                        p_init_msg_list           => FND_API.G_FALSE,
22825                        p_location_rec            => l_location_rec,
22826 		       p_do_addr_val             => l_do_addr_val,
22827                        p_object_version_number   => l_loc_object_version_number,
22828 		       x_addr_val_status         => l_addr_val_status,
22829 		       x_addr_warn_msg           => l_addr_warn_msg,
22830                        x_return_status           => l_return_status,
22831                        x_msg_count               => l_msg_count,
22832                        x_msg_data                => l_msg_data
22833                        );
22834 
22835                   If l_return_status = FND_API.G_RET_STS_SUCCESS Then
22836                       -- if location creation and party_site creation is both successful then pass the location_id
22837                       x_return_status := l_return_status;
22838                       x_msg_count     := l_msg_count;
22839                       x_msg_data      := l_msg_data;
22840                   elsif l_return_status <> FND_API.G_RET_STS_SUCCESS Then
22841                       x_return_status := l_return_status;
22842                       x_msg_count     := l_msg_count;
22843                       x_msg_data      := l_msg_data;
22844 
22845                       ROLLBACK to UPDATE_LOCATION;
22846                       --raise exception here
22847                   END IF;
22848 
22849          END IF; --end of updating location
22850 
22851 
22852 EXCEPTION
22853   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
22854     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
22855   WHEN OTHERS THEN
22856     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
22857 END update_onetime_address;
22858 --end of procedure  siahmed
22859 
22860 ----------------------------------------------------------------------------------------------
22861 
22862 
22863 END CS_ServiceRequest_PVT;