DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSFW_SERVICEREQUEST_PUB

Source


1 PACKAGE BODY csfw_servicerequest_pub AS
2 /*  $Header: csfwpsrb.pls 120.6 2009/07/29 11:57:59 syenduri ship $ */
3 /*===========================================================================+
4  |  PROCEDURE NAME                                                           |
5  |    update_request_resolution                                              |
6  |                                                                           |
7  |  DESCRIPTION                                                              |
8  |    To update the resolution of a service request (=Incident)              |
9  |                                                                           |
10  |  NOTES                                                                    |
11  |    Error handling is not yet implemented!!!                               |
12  |                                                                           |
13  |  DEPENDENCIES                                                             |
14  |                                                                           |
15  |  HISTORY                                                                  |
16  |    18-JAN-2001  M. Raap  Created.                                         |
17  |                                                                           |
18  |    11-JUN-2001  P. Giri edited for an extra )  at line 269                |
19  |    30-AUG-2004  pgiri     Added parameters for spares to use this API     |
20  |                           API update_request_resolution                   |
21  |                                                                           |
22  |    23-oct-2004  pgiri   Added new parameter to update_request_resolution  |
23  |    29-Jul-2009  syenduri Added new parameter p_incident_severity_id       |
24  +===========================================================================*/
25 PROCEDURE update_request_resolution
26   ( p_incident_id     IN  NUMBER
27   , p_resolution_code IN  VARCHAR2
28   , P_RESOLUTION_SUMMARY IN  VARCHAR2
29   , p_problem_code IN varchar2
30   , p_cust_po_number   IN varchar2
31   , p_commit       IN Boolean
32   , p_init_msg_list  IN BOOLEAN
33   , X_RETURN_STATUS   OUT NOCOPY VARCHAR2
34   , X_MSG_COUNT       OUT NOCOPY INTEGER
35   , X_MSG_DATA        OUT NOCOPY VARCHAR2
36   , p_object_version_number IN NUMBER default null
37   , p_incident_severity_id IN  NUMBER default null -- For enhancement in FSTP 12.1.2 Project
38   )
39 IS
40 
41   l_return_status        VARCHAR2(10);
42   l_msg_count            NUMBER;
43   l_msg_data             VARCHAR2(2000);
44 
45   l_counter              NUMBER(3);
46   l_data                 VARCHAR2(2000);
47   l_msg_index_out        NUMBER;
48 
49   lr_service_request_rec cs_servicerequest_pub.service_request_rec_type;
50   lt_notes_tab           cs_servicerequest_pub.notes_table;
51   lt_contacts_tab        cs_servicerequest_pub.contacts_table;
52 
53   l_workflow_process_id  NUMBER;
54   l_interaction_id       NUMBER;
55 
56   l_user_id	NUMBER;
57   l_object_version_number NUMBER;
58   l_incident_number varchar2(30);
59   l_type_id number;
60   L_LAST_UPDATE_PROGRAM_CODE VARCHAR2(30);
61   l_msg varchar2(250);
62   r_msg varchar2(250);
63 
64 cursor c_version(v_incident_id number) is
65 select object_version_number from cs_incidents_all_vl where incident_id = v_incident_id;
66 
67 cursor c_incident_type_id (v_incident_id number) is
68 select INCIDENT_TYPE_ID,
69        incident_number,
70        LAST_UPDATE_PROGRAM_CODE
71   from cs_incidents_all_b where incident_id = v_incident_id;
72 
73 r_incident_type_id           c_incident_type_id%ROWTYPE;
74 
75 BEGIN
76   l_user_id := FND_GLOBAL.user_id ;
77 
78     if p_init_msg_list then
79         fnd_msg_pub.initialize;
80     end if;
81 
82 IF p_object_version_number IS NULL THEN
83   open c_version(p_incident_id);
84   fetch c_version into l_object_version_number;
85   close c_version ;
86 ELSE
87  l_object_version_number := p_object_version_number ;
88 END IF;
89 
90   cs_servicerequest_pub.initialize_rec
91     ( p_sr_record => lr_service_request_rec
92     );
93 
94 
95   open c_incident_type_id(p_incident_id);
96   fetch c_incident_type_id into r_incident_type_id ;
97   close c_incident_type_id ;
98 
99   l_type_id := r_incident_type_id.INCIDENT_TYPE_ID;
100 --  l_incident_number := r_incident_type_id.incident_number;
101   L_LAST_UPDATE_PROGRAM_CODE:= r_incident_type_id.LAST_UPDATE_PROGRAM_CODE;
102 
103 --dbms_output.put_line(' in csfw pub statring with incident '||p_incident_id);
104 
105   lr_service_request_rec.resolution_code := p_resolution_code;
106 
107   if P_RESOLUTION_SUMMARY IS NOT NULL THEN
108 	lr_service_request_rec.resolution_summary := P_RESOLUTION_SUMMARY;
109   END IF;
110 
111   IF  p_problem_code IS NOT NULL THEN
112     lr_service_request_rec.problem_code := p_problem_code;
113   END IF;
114 
115   IF  p_cust_po_number IS NOT NULL THEN
116     lr_service_request_rec.cust_po_number := p_cust_po_number;
117   END IF;
118 
119   -- For enhancement in FSTP 12.1.3 Project
120    IF p_incident_severity_id IS NOT NULL THEN
121       lr_service_request_rec.severity_id := p_incident_severity_id;
122    END IF;
123 
124   lr_service_request_rec.type_id          := l_type_id;
125   lr_service_request_rec.last_update_program_code :=L_LAST_UPDATE_PROGRAM_CODE;
126 
127   cs_servicerequest_pub.update_servicerequest
128     (
129   p_api_version            => 3.0 ,
130   p_init_msg_list          => FND_API.G_FALSE,
131   p_commit                 => FND_API.G_TRUE,
132   x_return_status          => l_return_status,
133   x_msg_count              => l_msg_count,
134   x_msg_data               => l_msg_data,
135   p_request_id             => p_incident_id,
136   p_request_number         => null,--l_incident_number,
137   p_audit_comments         => NULL,
138   p_object_version_number  => l_object_version_number,
139   p_resp_appl_id           => NULL,
140   p_resp_id                => NULL,
141   p_last_updated_by        => l_user_id ,
142   p_last_update_login      => NULL,
143   p_last_update_date       => sysdate ,
144   p_service_request_rec    => lr_service_request_rec,
145   p_notes                  => lt_notes_tab,
146   p_contacts               => lt_contacts_tab,
147   p_called_by_workflow     => FND_API.G_FALSE,
148   p_workflow_process_id    => NULL,
149   x_workflow_process_id    => l_workflow_process_id,
150   x_interaction_id         => l_interaction_id
151     );
152 
153 
154 --dbms_output.put_line(' in csfw pub , cs_pub returned status =  '||l_return_status);
155 
156     X_RETURN_STATUS         := l_return_status;       -- output-parameter
157     X_MSG_COUNT             := l_msg_count;           -- output-parameter
158 
159     --dbms_output.put_line('return_status: '||l_return_status);
160   IF l_return_status = FND_API.G_RET_STS_SUCCESS
161   THEN
162      if p_commit then
163       commit;
164      end if;
165   ELSE
166       FOR l_counter IN 1 .. l_msg_count
167       LOOP
168         fnd_msg_pub.get
169           ( p_msg_index     => l_counter
170           , p_encoded       => FND_API.G_FALSE
171           , p_data          => l_data
172           , p_msg_index_out => l_msg_index_out
173           );
174         --dbms_output.put_line( 'Message: '||l_data );
175       END LOOP ;
176       X_MSG_DATA := l_data;
177   END IF;
178 
179 EXCEPTION
180   WHEN OTHERS
181   THEN
182     --dbms_output.put_line('Exception');
183     --dbms_output.put_line(SQLERRM);
184     X_MSG_DATA := SQLERRM;
185 END update_request_resolution;
186 
187 /*===========================================================================+
188  |  PROCEDURE NAME                                                           |
189  |    get_reaction_time                                                      |
190  |                                                                           |
191  |  DESCRIPTION                                                              |
192  |    To retrieve the reaction time, specified in a contract, of a service   |
193  |    request (=Incident)                                                    |
194  |                                                                           |
195  |  NOTES                                                                    |
196  |    Error handling is not yet implemented!!!                               |
197  |                                                                           |
198  |  DEPENDENCIES                                                             |
199  |                                                                           |
200  |  HISTORY                                                                  |
201  |    23-JAN-2001  M. Raap  Created.
202  |    01-MAY-2001  mmerchan  Contract Number added for reaction time
203  |    14-NOV-2001  mmerchan  contract service id returned
204  |                                                                           |
205  +===========================================================================*/
206 PROCEDURE get_reaction_time
207   ( p_incident_id   IN  NUMBER
208   , p_task_id       IN  NUMBER
209   , p_resource_id   IN  NUMBER
210   , p_error_type    OUT NOCOPY NUMBER
211   , p_error         OUT NOCOPY VARCHAR2
212   , x_react_within  OUT NOCOPY NUMBER
213   , x_react_tuom    OUT NOCOPY VARCHAR2
214   , x_react_by_date OUT NOCOPY VARCHAR2
215   , x_contract_service_id OUT NOCOPY NUMBER
216   , x_contract_number OUT NOCOPY VARCHAR2
217   , x_txn_group_id OUT NOCOPY NUMBER
218   )
219 IS
220 
221 
222   CURSOR c_incident
223     ( b_incident_id cs_incidents_all_b.incident_id%TYPE
224     )
225   IS
226     SELECT ci_all_b.incident_date   incident_date    -- bug # 4337147
227     ,      ci_all_b.incident_severity_id incident_severity_id
228     ,      ci_all_b.contract_service_id  contract_service_id
229     ,      cit.business_process_id       business_process_id
230     ,	   ci_all_b.contract_number	 contract_number
231     FROM   cs_incidents_all_b ci_all_b
232     ,      cs_incident_types  cit
233     WHERE  ci_all_b.incident_type_id = cit.incident_type_id
234     AND    ci_all_b.incident_id      = b_incident_id;
235 
236   -- cursor is modified
237   -- bug # 4337147
238   CURSOR C_TXN_GROUP_ID(v_business_process_id NUMBER,
239 	v_contract_service_id NUMBER)
240   IS
241    SELECT BPL.Id
242    FROM OKS_K_Lines_B KSL,
243         OKC_K_LINES_B BPL
244   WHERE KSL.Cle_ID = v_contract_service_id
245     AND BPL.Cle_ID = KSL.COVERAGE_ID
246     AND BPL.Lse_Id IN (3,16,21)
247     AND EXISTS (SELECT 'x'
248                    FROM OKC_K_Items BIT
249                   WHERE BIT.Cle_id = BPL.Id
250                     AND Object1_Id1 = v_business_process_id
251                     AND Jtot_Object1_Code = 'OKX_BUSIPROC');
252    /*
253   Select a.id
254   from okc_k_lines_b a
255   where a.lse_id in (3,16,21)
256   and exists (select 'x'
257    	      from okc_k_items
258               where cle_id = a.id and
259               object1_id1 = v_business_process_id and
260               jtot_object1_code = 'OKX_BUSIPROC')
261   connect by a.cle_id = prior(a.id)
262   start with a.id = v_contract_service_id;
263   */
264 
265   r_incident           c_incident%ROWTYPE;
266 
267   --l_server_timezone_id VARCHAR2(200);
268   l_server_timezone_id NUMBER;
269   l_server_timezone_name VARCHAR2(200);
270 
271   l_counter            NUMBER(3);
272   l_data               VARCHAR2(2000);
273   l_msg_index_out      NUMBER;
274   l_return_status      VARCHAR2(10);
275   l_msg_count          NUMBER;
276   l_msg_data           VARCHAR2(200);
277   l_react_by_date DATE;
278   l_date_format        varchar(30);
279   p_inp_rec     oks_entitlements_pub.grt_inp_rec_type;
280   x_resolve_rec oks_entitlements_pub.rcn_rsn_rec_type;
281   x_react_rec   oks_entitlements_pub.rcn_rsn_rec_type;
282   l_client_tz_id number;
283   l_server_tz_id number;
284   l_client_date date;
285 
286 
287 BEGIN
288 
289   p_error_type := 0; -- Assume success
290 
291 
292   OPEN c_incident
293     ( b_incident_id => p_incident_id
294     );
295   FETCH c_incident
296   INTO r_incident;
297   CLOSE c_incident;
298 
299   --dbms_output.put_line('INCIDENT_DATE: '||r_incident.incident_date);
300   --dbms_output.put_line('INCIDENT_SEVERITY_ID: '||r_incident.incident_severity_id);
301   --dbms_output.put_line('CONTRACT_SERVICE_ID: '||r_incident.contract_service_id);
302   --dbms_output.put_line('CONTRACT_NUMBER: '||r_incident.contract_number);
303   --dbms_output.put_line('BUSINESS_PROCESS_ID: '||r_incident.business_process_id);
304 
305   /*
306   FND_PROFILE.Get
307     ( name => 'SERVER_TIMEZONE_ID'
308     , val  => l_server_timezone_id
309     );
310   */
311   -- bug # 4337147
312   -- Get timezone using SR API
313   CS_TZ_GET_DETAILS_PVT.CUSTOMER_PREFERRED_TIME_ZONE
314   ( p_incident_id             => p_incident_id
315   , p_task_id                 => p_task_id
316   , p_resource_id             => p_resource_id
317   , p_cont_pref_time_zone_id  => NULL
318   , p_incident_location_id    => NULL
319   , p_incident_location_type  => NULL
320   , p_contact_party_id        => NULL
321   , p_contact_phone_id        => NULL
322   , p_contact_address_id      => NULL
323   , p_customer_id             => NULL
324   , p_customer_phone_id       => NULL
325   , p_customer_address_id     => NULL
326   , x_timezone_id             => l_server_timezone_id
327   , x_timezone_name           => l_server_timezone_name
328   );
329 
330   --dbms_output.put_line('SERVER_TIMEZONE_ID: '||l_server_timezone_id);
331 
332   IF r_incident.contract_service_id IS NULL
333   THEN
334     /* There is no contract attached to incident */
335     --dbms_output.put_line('No contract for this service request');
336     p_error_type := 2; -- No Contract
337     --- not translated message. JSP should translate
338     p_error := 'No contract for this service request';
339   ELSE
340 
341     x_contract_service_id := r_incident.contract_service_id;
342     x_contract_number := r_incident.contract_number;
343 
344     p_inp_rec.contract_line_id     := r_incident.contract_service_id;
345     p_inp_rec.business_process_id  := r_incident.business_process_id;
346     p_inp_rec.severity_id          := r_incident.incident_severity_id;
347     p_inp_rec.request_date         := r_incident.incident_date;
348     p_inp_rec.time_zone_id         := l_server_timezone_id;
349     p_inp_rec.category_rcn_rsn     := oks_entitlements_pub.G_RESOLUTION;
350     p_inp_rec.compute_option       := oks_entitlements_pub.G_FIRST;
351 
352     /* There is a contract attached to the incident. Retrieve reaction time. */
353      oks_entitlements_pub.get_react_resolve_by_time
354     (p_api_version		=> 1.0
355     ,p_init_msg_list		=> FND_API.G_TRUE
356     ,p_inp_rec                  => p_inp_rec
357     ,x_return_status 		=> l_return_status
358     ,x_msg_count		=> l_msg_count
359     ,x_msg_data			=> l_msg_data
360     ,x_react_rec                => x_react_rec
361     ,x_resolve_rec              => x_resolve_rec);
362 
363 
364      /* Find the contract line id / txn group id associated with the business
365 	process for the contract related to the service request */
366      x_txn_group_id := -1;
367      OPEN C_TXN_GROUP_ID(r_incident.business_process_id,
368 	r_incident.contract_service_id);
369      FETCH C_TXN_GROUP_ID
370      INTO x_txn_group_id;
371      CLOSE C_TXN_GROUP_ID;
372 
373 /*
374     oks_entitlements_pub.check_reaction_times
375       ( p_api_version         => 1.0
376       , p_init_msg_list       => FND_API.G_TRUE
377       , p_business_process_id => r_incident.business_process_id
378       , p_request_date        => r_incident.incident_date
379       , p_sr_severity         => r_incident.incident_severity_id
380       , p_time_zone_id        => l_server_timezone_id
381       , p_contract_line_id    => r_incident.contract_service_id
382       , x_return_status       => l_return_status
383       , x_msg_count           => l_msg_count
384       , x_msg_data            => l_msg_data
385       , x_react_within        => x_react_within
386       , x_react_tuom          => x_react_tuom
387       , x_react_by_date       => l_react_by_date
388       );
389   */
390 
391     IF l_return_status = FND_API.G_RET_STS_SUCCESS
392     THEN
393         /* API-call was successfull */
394         --dbms_output.put_line('duration: '||x_resolve_rec.duration);
395         --dbms_output.put_line('uom: '||x_resolve_rec.uom);
396         --dbms_output.put_line('by_date_end: '||to_char(x_resolve_rec.by_date_end, 'MM/DD/YYYY HH24:MI:SS'));
397 
398         -- Lets get the Resolution record's values;
399         -- l_react_by_date is actually the resolve by date.
400         -- We used to use it for React time which is now obsolete
401         x_react_within        := x_resolve_rec.duration;
402         x_react_tuom          := x_resolve_rec.uom;
403         l_react_by_date := x_resolve_rec.by_date_end;
404 
405         -- bug 3035563 l_react_by_date to Convert to timezone of the client(found in 11.5.8)
406         l_react_by_date := CSFW_TIMEZONE_PUB.GET_CLIENT_TIME(l_react_by_date);
407 
408         -- Now get the profile option to get the data
409         FND_PROFILE.GET('ICX_DATE_FORMAT_MASK', l_date_format);
410 
411         -- Bug 2862796. Modfication for using ICX: Date Format Mask in place of CSFW: Date Format
412         IF l_date_format IS NULL
413         THEN
414             l_date_format := 'DD/MM/YYYY';
415         END IF;
416 
417         l_date_format := l_date_format || ' HH24:MI:SS';
418         x_react_by_date := to_char(l_react_by_date, l_date_format);
419 
420         /*
421         IF l_date_format = 'DD-MM-YYYY'
422         THEN
423             x_react_by_date := to_char(l_react_by_date, 'DD-MM-YYYY HH24:MI:SS');
424         ELSIF l_date_format = 'DD/MM/YYYY'
425         THEN
426             x_react_by_date := to_char(l_react_by_date, 'DD/MM/YYYY HH24:MI:SS');
427         ELSIF l_date_format = 'MM-DD-YYYY'
428         THEN
429             x_react_by_date := to_char(l_react_by_date, 'MM-DD-YYYY HH24:MI:SS');
430         ELSIF l_date_format = 'MM/DD/YYYY'
431         THEN
432             x_react_by_date := to_char(l_react_by_date, 'MM/DD/YYYY HH24:MI:SS');
433         ELSIF l_date_format = 'YYYY-MM-DD'
434         THEN
435             x_react_by_date := to_char(l_react_by_date, 'YYYY-MM-DD HH24:MI:SS');
436         ELSIF l_date_format = 'YYYY/MM/DD'
437         THEN
438             x_react_by_date := to_char(l_react_by_date, 'YYYY/MM/DD HH24:MI:SS');
439 
440         ELSIF l_date_format = 'DD-MM-YY'
441         THEN
442             x_react_by_date := to_char(l_react_by_date, 'DD-MM-YY HH24:MI:SS');
443         ELSIF l_date_format = 'DD/MM/YY'
444         THEN
445             x_react_by_date := to_char(l_react_by_date, 'DD/MM/YY HH24:MI:SS');
446         ELSIF l_date_format = 'MM-DD-YY'
447         THEN
448             x_react_by_date := to_char(l_react_by_date, 'MM-DD-YY HH24:MI:SS');
449         ELSIF l_date_format = 'MM/DD/YY'
450         THEN
451             x_react_by_date := to_char(l_react_by_date, 'MM/DD/YY HH24:MI:SS');
452         ELSIF l_date_format = 'YY-MM-DD'
453         THEN
454             x_react_by_date := to_char(l_react_by_date, 'YY-MM-DD HH24:MI:SS');
455         ELSIF l_date_format = 'YY/MM/DD'
456         THEN
457             x_react_by_date := to_char(l_react_by_date, 'YY/MM/DD HH24:MI:SS');
458         ELSE
459             x_react_by_date := to_char(l_react_by_date, 'DD/MM/YYYY HH24:MI:SS');
460         END IF;
461         */
462     ELSE
463       /* API-call was unsuccessfull */
464          --dbms_output.put_line('Error retrieving reaction time through API');
465          --dbms_output.put_line('return_status: '||l_return_status);
466          --dbms_output.put_line('msg_count: '||l_msg_count);
467          --dbms_output.put_line('msg_data: '||l_msg_data);
468       /* To display the error-messages */
469     BEGIN
470       FOR l_counter IN 1 .. l_msg_count
471       LOOP
472         fnd_msg_pub.get
473           ( p_msg_index     => l_counter
474           , p_encoded       => FND_API.G_FALSE
475           , p_data          => l_data
476           , p_msg_index_out => l_msg_index_out
477           );
478         --dbms_output.put_line( 'Message: '||l_data );
479       END LOOP ;
480         p_error_type := 1; -- Failure
481         p_error := l_data;
482      EXCEPTION
483 	WHEN OTHERS THEN
484 		p_error_type := 1; -- Failure
485         	p_error := 'Cant get FND msg';
486      END;
487     END IF;
488   END IF;
489 
490 EXCEPTION
491   WHEN OTHERS
492   THEN
493        --dbms_output.put_line('Exception');
494        --dbms_output.put_line(SQLERRM);
495         p_error_type := -1;-- Failure
496         p_error := SQLERRM;
497 END get_reaction_time;
498 
499 /* Get Billing Types
500 PROCEDURE get_billing_types
501 
502     SELECT billing_type, name, to_char(txn_group_id)
503     from OKS_ENT_BILL_TYPES_V
504     where txn_group_id = b_contract_service_id;
505 
506     SELECT covered_amount, covered_percent
507     from OKS_ENT_BILL_TYPES_V
508     where txn_group_id = b_contract_service_id
509     and billing_type = b_billing_type;
510 
511 
512 
513 END get_billing_types;
514 */
515 
516 
517 
518 /*===========================================================================+
519  |  PROCEDURE NAME                                                           |
520  |    update_request_flex						     |
521  |                                                                           |
522  |  DESCRIPTION                                                              |
523  |    Wrapper on update_servicerequest for updating task fled field	     |
524  |                                                                           |
525  |  DEPENDENCIES                                                             |
526  |                                                                           |
527  |  HISTORY                                                                  |
528  |  20-Apr-2005 hgotur	Created                                              |
529  |                                                                           |
530  +===========================================================================*/
531 PROCEDURE update_request_flex
532   ( p_incident_id	IN  NUMBER
533   , p_attribute_1	IN VARCHAR2
534   , p_attribute_2	IN VARCHAR2
535   , p_attribute_3	IN VARCHAR2
536   , p_attribute_4	IN VARCHAR2
537   , p_attribute_5	IN VARCHAR2
538   , p_attribute_6	IN VARCHAR2
539   , p_attribute_7	IN VARCHAR2
540   , p_attribute_8	IN VARCHAR2
541   , p_attribute_9	IN VARCHAR2
542   , p_attribute_10	IN VARCHAR2
543   , p_attribute_11	IN VARCHAR2
544   , p_attribute_12	IN VARCHAR2
545   , p_attribute_13	IN VARCHAR2
546   , p_attribute_14	IN VARCHAR2
547   , p_attribute_15	IN VARCHAR2
548   , p_context		IN VARCHAR2
549   , X_RETURN_STATUS   OUT NOCOPY VARCHAR2
550   , X_MSG_COUNT		OUT NOCOPY INTEGER
551   , X_MSG_DATA		OUT NOCOPY VARCHAR2
552   )
553 IS
554 
555   l_return_status        VARCHAR2(10);
556   l_msg_count            NUMBER;
557   l_msg_data             VARCHAR2(2000);
558 
559   l_counter              NUMBER(3);
560   l_data                 VARCHAR2(2000);
561   l_msg_index_out        NUMBER;
562 
563   lr_service_request_rec cs_servicerequest_pub.service_request_rec_type;
564   lt_notes_tab           cs_servicerequest_pub.notes_table;
565   lt_contacts_tab        cs_servicerequest_pub.contacts_table;
566 
567   l_workflow_process_id  NUMBER;
568   l_interaction_id       NUMBER;
569 
570   l_user_id	NUMBER;
571   l_object_version_number NUMBER;
572   l_incident_number varchar2(30);
573   l_type_id number;
574   L_LAST_UPDATE_PROGRAM_CODE VARCHAR2(30);
575 
576 cursor c_version(v_incident_id number) is
577 select object_version_number from cs_incidents_all_vl where incident_id = v_incident_id;
578 
579 cursor c_incident_type_id (v_incident_id number) is
580 select INCIDENT_TYPE_ID,
581        incident_number,
582        LAST_UPDATE_PROGRAM_CODE
583   from cs_incidents_all_b where incident_id = v_incident_id;
584 
585 r_incident_type_id           c_incident_type_id%ROWTYPE;
586 
587 BEGIN
588   l_user_id := FND_GLOBAL.user_id ;
589 
590   open c_version(p_incident_id);
591   fetch c_version into l_object_version_number;
592   close c_version ;
593 
594   cs_servicerequest_pub.initialize_rec
595     ( p_sr_record => lr_service_request_rec
596     );
597 
598 
599   open c_incident_type_id(p_incident_id);
600   fetch c_incident_type_id into r_incident_type_id ;
601   close c_incident_type_id ;
602 
603   l_type_id := r_incident_type_id.INCIDENT_TYPE_ID;
604   L_LAST_UPDATE_PROGRAM_CODE:= r_incident_type_id.LAST_UPDATE_PROGRAM_CODE;
605 
606 
607   -- setting the values of Sr record which are to be updated
608   lr_service_request_rec.request_attribute_1	:= p_attribute_1 ;
609   lr_service_request_rec.request_attribute_2	:= p_attribute_2 ;
610   lr_service_request_rec.request_attribute_3	:= p_attribute_3 ;
611   lr_service_request_rec.request_attribute_4	:= p_attribute_4 ;
612   lr_service_request_rec.request_attribute_5	:= p_attribute_5 ;
613   lr_service_request_rec.request_attribute_6	:= p_attribute_6 ;
614   lr_service_request_rec.request_attribute_7	:= p_attribute_7 ;
615   lr_service_request_rec.request_attribute_8	:= p_attribute_8 ;
616   lr_service_request_rec.request_attribute_9	:= p_attribute_9 ;
617   lr_service_request_rec.request_attribute_10	:= p_attribute_10 ;
618   lr_service_request_rec.request_attribute_11	:= p_attribute_11 ;
619   lr_service_request_rec.request_attribute_12	:= p_attribute_12 ;
620   lr_service_request_rec.request_attribute_13	:= p_attribute_13 ;
621   lr_service_request_rec.request_attribute_14	:= p_attribute_14 ;
622   lr_service_request_rec.request_attribute_15	:= p_attribute_15 ;
623   lr_service_request_rec.request_context	:= p_context ;
624 
625   lr_service_request_rec.type_id          := l_type_id;
626   lr_service_request_rec.last_update_program_code :=L_LAST_UPDATE_PROGRAM_CODE;
627   cs_servicerequest_pub.update_servicerequest
628     (
629   p_api_version            => 3.0 ,
630   p_init_msg_list          => FND_API.G_FALSE,
631   p_commit                 => FND_API.G_TRUE,
632   x_return_status          => l_return_status,
633   x_msg_count              => l_msg_count,
634   x_msg_data               => l_msg_data,
635   p_request_id             => p_incident_id,
636   p_request_number         => null,--l_incident_number,
637   p_audit_comments         => NULL,
638   p_object_version_number  => l_object_version_number,
639   p_resp_appl_id           => NULL,
640   p_resp_id                => NULL,
641   p_last_updated_by        => l_user_id ,
642   p_last_update_login      => NULL,
643   p_last_update_date       => sysdate ,
644   p_service_request_rec    => lr_service_request_rec,
645   p_notes                  => lt_notes_tab,
646   p_contacts               => lt_contacts_tab,
647   p_called_by_workflow     => FND_API.G_FALSE,
648   p_workflow_process_id    => NULL,
649   x_workflow_process_id    => l_workflow_process_id,
650   x_interaction_id         => l_interaction_id
651     );
652 
653     X_RETURN_STATUS         := l_return_status;       -- output-parameter
654     X_MSG_COUNT             := l_msg_count;           -- output-parameter
655 
656     --dbms_output.put_line('return_status: '||l_return_status);
657   IF l_return_status = FND_API.G_RET_STS_SUCCESS
658   THEN
659     /* API-call was successfull */
660       null;
661       commit;
662   ELSE
663       FOR l_counter IN 1 .. l_msg_count
664       LOOP
665         fnd_msg_pub.get
666           ( p_msg_index     => l_counter
667           , p_encoded       => FND_API.G_FALSE
668           , p_data          => l_data
669           , p_msg_index_out => l_msg_index_out
670           );
671         --dbms_output.put_line( 'Message: '||l_data );
672       END LOOP ;
673       X_MSG_DATA := l_data;
674   END IF;
675 
676 EXCEPTION
677   WHEN OTHERS
678   THEN
679     --dbms_output.put_line('Exception');
680     --dbms_output.put_line(SQLERRM);
681     X_MSG_DATA := SQLERRM;
682 END update_request_flex;
683 
684 
685 
686 END csfw_servicerequest_pub;
687