DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKL_CURE_WF

Source


1 PACKAGE BODY OKL_CURE_WF  as
2 /* $Header: OKLCOWFB.pls 120.4 2007/06/18 19:31:28 pdevaraj noship $ */
3 
4     G_MODULE VARCHAR2(255) := 'okl.stream.esg.okl_esg_transport_pvt';
5     G_DEBUG_ENABLED CONSTANT VARCHAR2(10) := OKL_DEBUG_PUB.CHECK_LOG_ENABLED;
6     G_IS_DEBUG_STATEMENT_ON BOOLEAN;
7 
8 
9 --private procedure
10 /**Name   AddMissingArgMsg
11   **Appends to a message  the api name, parameter name and parameter Value
12  */
13 
14 PROCEDURE AddMissingArgMsg
15   ( p_api_name	    IN	VARCHAR2,
16     p_param_name	IN	VARCHAR2 )IS
17 BEGIN
18         fnd_message.set_name('OKL', 'OKL_API_ALL_MISSING_PARAM');
19         fnd_message.set_token('API_NAME', p_api_name);
20         fnd_message.set_token('MISSING_PARAM', p_param_name);
21         fnd_msg_pub.add;
22 
23 END AddMissingArgMsg;
24 
25 /**Name   AddFailMsg
26   **Appends to a message  the name of the object and
27   ** the operation (insert, update ,delete)
28 */
29 
30 PROCEDURE AddfailMsg
31   ( p_object	    IN	VARCHAR2,
32     p_operation 	IN	VARCHAR2 ) IS
33 
34 BEGIN
35       fnd_message.set_name('OKL', 'OKL_FAILED_OPERATION');
36       fnd_message.set_token('OBJECT',    p_object);
37       fnd_message.set_token('OPERATION', p_operation);
38       fnd_msg_pub.add;
39 
40 END    AddfailMsg;
41 
42 
43 PROCEDURE Get_Messages (
44 p_message_count IN  NUMBER,
45 x_message       OUT NOCOPY VARCHAR2) IS
46 
47 
48   l_msg_list        VARCHAR2(32627) := '';
49   l_temp_msg        VARCHAR2(32627);
50   l_appl_short_name  VARCHAR2(50) ;
51   l_message_name    VARCHAR2(50) ;
52   l_id              NUMBER;
53   l_message_num     NUMBER;
54   l_msg_count       NUMBER;
55   l_msg_data        VARCHAR2(32627);
56 
57   Cursor Get_Appl_Id (x_short_name VARCHAR2) IS
58          SELECT  application_id
59          FROM    fnd_application_vl
60          WHERE   application_short_name = x_short_name;
61 
62   Cursor Get_Message_Num (x_msg VARCHAR2, x_id NUMBER, x_lang_id NUMBER) IS
63          SELECT  msg.message_number
64          FROM    fnd_new_messages msg, fnd_languages_vl lng
65          WHERE   msg.message_name = x_msg
66           and   msg.application_id = x_id
67           and   lng.LANGUAGE_CODE = msg.language_code
68           and   lng.language_id = x_lang_id;
69 
70 BEGIN
71       FOR l_count in 1..p_message_count LOOP
72 
73           l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_true);
74           fnd_message.parse_encoded(l_temp_msg, l_appl_short_name, l_message_name);
75           OPEN Get_Appl_Id (l_appl_short_name);
76           FETCH Get_Appl_Id into l_id;
77           CLOSE Get_Appl_Id;
78 
79           l_message_num := NULL;
80           IF l_id is not NULL
81           THEN
82               OPEN Get_Message_Num (l_message_name, l_id,
83                         to_number(NVL(FND_PROFILE.Value('LANGUAGE'), '0')));
84               FETCH Get_Message_Num into l_message_num;
85               CLOSE Get_Message_Num;
86           END IF;
87 
88           l_temp_msg := fnd_msg_pub.get(fnd_msg_pub.g_previous, fnd_api.g_true);
89 
90           IF NVL(l_message_num, 0) <> 0
91           THEN
92             l_temp_msg := 'APP-' || to_char(l_message_num) || ': ';
93           ELSE
94             l_temp_msg := NULL;
95           END IF;
96 
97           IF l_count = 1
98           THEN
99               l_msg_list := l_msg_list || l_temp_msg ||
100                         fnd_msg_pub.get(fnd_msg_pub.g_first, fnd_api.g_false);
101           ELSE
102               l_msg_list := l_msg_list || l_temp_msg ||
103                         fnd_msg_pub.get(fnd_msg_pub.g_next, fnd_api.g_false);
104           END IF;
105 
106           l_msg_list := l_msg_list || '';
107 
108       END LOOP;
109 
110       x_message := l_msg_list;
111 
112 
113 END Get_Messages;
114 
115 PROCEDURE  invoke_report_wf(
116                     p_report_id       IN NUMBER
117             	   ,x_return_status   OUT NOCOPY VARCHAR2
118                    ,x_msg_count       OUT NOCOPY NUMBER
119                    ,x_msg_data        OUT NOCOPY VARCHAR2 ) IS
120 
121 l_parameter_list        wf_parameter_list_t;
122 l_key                   VARCHAR2(240);
123 l_seq                   NUMBER;
124 l_event_name            varchar2(240) := 'oracle.apps.okl.co.approverequest';
125 
126 l_init_msg_list VARCHAR2(1);
127 l_return_status VARCHAR2(1);
128 l_msg_count     NUMBER ;
129 l_msg_data      VARCHAR2(32627);
130 l_message       VARCHAR2(32627);
131 
132 l_api_name                CONSTANT VARCHAR2(50) := 'INVOKE_REPORT_WF';
133 l_api_name_full	          CONSTANT VARCHAR2(150):= g_pkg_name || '.'
134                                                      || l_api_name;
135 -- Selects the nextval from sequence, used later for defining event key
136 CURSOR okl_key_csr IS
137 SELECT okl_wf_item_s.nextval
138 FROM   dual;
139 
140 cursor c_get_ref_details (p_cure_report_id IN NUMBER)
141 is select  crt.report_number
142           ,pov.vendor_name
143 from okl_cure_reports crt,
144      po_vendors pov
145 where crt.vendor_id =pov.vendor_id
146 and crt.cure_report_id =p_cure_report_id;
147 
148 l_report_number  okl_cure_reports.report_number%TYPE;
149 
150 l_vendor_name   po_vendors.vendor_name%TYPE;
151 l_notification_agent varchar2(100);
152 
153 cursor c_get_agent(p_user_id IN NUMBER) is
154 select wfr.name
155 from   fnd_user fuser,wf_roles wfr
156 where   orig_system = 'PER'
157 and wfr.orig_system_id =fuser.employee_id
158 and fuser.user_id =p_user_id;
159 
160 
161 l_user_id   NUMBER := to_number(fnd_profile.value('OKL_CURE_APPROVAL_USER'));
162 
163 
164 BEGIN
165 
166   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : START');
167 
168   IF (G_DEBUG_ENABLED = 'Y') THEN
169     G_IS_DEBUG_STATEMENT_ON := OKL_DEBUG_PUB.CHECK_LOG_ON(G_MODULE, FND_LOG.LEVEL_STATEMENT);
170   END IF;
171 
172       x_return_status := FND_API.G_RET_STS_SUCCESS;
173        --set error message,so this will be prefixed before the
174        --actual message, so it makes more sense than displaying an
175       -- OKL message.
176        AddfailMsg(
177                   p_object    =>  'BEFORE CALLING WORKFLOW ',
178                   p_operation =>  'CREATE' );
179 
180       SAVEPOINT INVOKE_REPORT_WF;
181   	  OPEN okl_key_csr;
182 	  FETCH okl_key_csr INTO l_seq;
183 	  CLOSE okl_key_csr;
184       l_key := l_event_name  ||'-'||l_seq;
185 
186   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : l_key : '|| l_key);
187 
188       IF PG_DEBUG < 11  THEN
189          IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
190                     OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Event Key ' ||l_key);
191          END IF;
192       END IF;
193 
194       OPEN c_get_ref_details (p_REPORT_id );
195 
196       FETCH c_get_ref_details INTO l_report_number,
197                                     l_vendor_name;
198 
199       CLOSE c_get_ref_details;
200 
201   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : l_report_number : '|| l_report_number);
202   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : l_vendor_name : '|| l_vendor_name);
203 
204      OPEN c_get_agent (l_user_id);
205      FETCH c_get_agent INTO l_notification_agent;
206      CLOSE c_get_Agent;
207 
208      IF l_notification_agent IS NULL THEN
209           l_notification_agent := 'SYSADMIN';
210      END IF;
211 
212   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : l_notification_agent : '|| l_notification_agent);
213 
214       wf_event.AddParameterToList('NOTIFY_AGENT',
215                                       l_notification_agent,
216                                       l_parameter_list);
217 
218       wf_event.AddParameterToList('REPORT_ID',
219                                       to_char(p_report_id),
220                                       l_parameter_list);
221 
222 
223       wf_event.AddParameterToList('VENDOR_NAME',
224                                       l_vendor_name,
225                                       l_parameter_list);
226 
227      wf_event.AddParameterToList('REPORT_NUMBER',
228                                       l_REPORT_number,
229                                       l_parameter_list);
230      --added by akrangan
231      wf_event.AddParameterToList('ORG_ID',mo_global.get_current_org_id ,l_parameter_list);
232 
233 
234      IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
235             OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'before launching workflow');
236 
237      END IF;
238 
239       wf_event.raise(p_event_name  => l_event_name
240                      ,p_event_key  => l_key
241                     ,p_parameters  => l_parameter_list);
242 
243       COMMIT ;
244       l_parameter_list.DELETE;
245 
246   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : after launching cure request wf');
247 
248       IF PG_DEBUG < 11  THEN
249          IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
250                     OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Successfully launched Cure REPORT workflow');
251          END IF;
252       END IF;
253 
254 
255       FND_MSG_PUB.Count_And_Get
256       (  p_count          =>   x_msg_count,
257          p_data           =>   x_msg_data
258       );
259 
260   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : END');
261 
262  EXCEPTION
263  WHEN OTHERS THEN
264       ROLLBACK TO INVOKE_REPORT_WF;
265       okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : error launching cure request wf');
266       x_return_status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
267       x_msg_count := l_msg_count ;
268       x_msg_data := l_msg_data ;
269       Fnd_Msg_Pub.ADD_EXC_MSG('OKL_CURE_WF','INVOKE_REPORT_WF');
270       Fnd_Msg_Pub.count_and_get(
271              p_count   => x_msg_count
272             ,p_data    => x_msg_data);
273 
274 End  invoke_REPORT_wf;
275 
276 
277 PROCEDURE  approve_cure_reports
278              (  p_api_version          IN NUMBER
279                ,p_init_msg_list        IN VARCHAR2 DEFAULT OKC_API.G_TRUE
280                ,p_commit               IN VARCHAR2 DEFAULT OKC_API.G_FALSE
281                ,p_report_id            IN NUMBER
282                ,x_return_status       OUT NOCOPY VARCHAR2
283                ,x_msg_count           OUT NOCOPY NUMBER
284                ,x_msg_data            OUT NOCOPY VARCHAR2
285                )IS
286 l_init_msg_list VARCHAR2(1);
287 l_return_status VARCHAR2(1);
288 l_msg_count     NUMBER ;
289 l_msg_data      VARCHAR2(32627);
290 l_message       VARCHAR2(32627);
291 l_api_name                CONSTANT VARCHAR2(50) := 'APPROVE_CURE_REPORTS';
292 l_api_name_full	          CONSTANT VARCHAR2(150):= g_pkg_name || '.'
293                                                      || l_api_name;
294  lp_crtv_rec         okl_crt_pvt.crtv_rec_type;
295  lx_crtv_rec     	 okl_crt_pvt.crtv_rec_type;
296 
297 cursor c_get_obj_ver(p_report_id IN NUMBER) is
298 select object_version_number
299 from okl_cure_reports
300 where cure_report_id =p_report_id;
301 
302 
303 BEGIN
304 
305   okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : START');
306   okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : p_report_id : '||p_report_id);
307       SAVEPOINT APPROVE_CURE_REPORTS;
308       -- Initialize message list if p_init_msg_list is set to TRUE.
309       IF FND_API.to_Boolean( p_init_msg_list )
310       THEN
311           FND_MSG_PUB.initialize;
312       END IF;
313 
314       x_return_status := FND_API.G_RET_STS_SUCCESS;
315      --call refund_workflow
316       invoke_report_wf(
317                   p_report_id=>p_report_id
318             	 ,x_return_status	=> l_return_status
319 			      ,x_msg_count		=> l_msg_count
320 			      ,x_msg_data	    => l_msg_data );
321 
322   okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : invoke_report_wf : '||l_return_status);
323 
324  	 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS)  THEN
325 	      Get_Messages (l_msg_count,l_message);
326            IF PG_DEBUG < 11  THEN
327               IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
328                               OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Error after calling WF' ||l_message);
329               END IF;
330            END IF;
331           raise FND_API.G_EXC_ERROR;
332      ELSE
333           FND_MSG_PUB.initialize;
334     END IF;
335 
336 
337     --Update Cure REPORTS headers table
338     --set error message,so this will be prefixed before the
339     --actual message, so it makes more sense than displaying an
340     -- OKL message.
341        AddfailMsg(
342                   p_object    =>  'RECORD IN OKL_CURE_REPORTS ',
343                   p_operation =>  'UPDATE' );
344 
345       lp_crtv_rec.cure_report_id :=p_report_id;
346       lp_crtv_rec.approval_status :='PENDING';
347 
348       OPEN c_get_obj_ver(p_report_id);
349       FETCH c_get_obj_ver INTO  lp_crtv_rec.object_version_number;
350       CLOSE  c_get_obj_ver;
351 
352      OKL_cure_reports_pub.update_cure_reports(
353                            p_api_version     => 1.0
354                           ,p_init_msg_list   => 'F'
355                           ,x_return_status   => l_return_status
356                           ,x_msg_count       => l_msg_count
357                           ,x_msg_data        => l_msg_data
358                           ,p_crtv_rec        => lp_crtv_rec
359                           ,x_crtv_rec        => lx_crtv_rec);
360 
361   okl_debug_pub.logmessage('OKL_CURE_WF: invoke_report_wf : OKL_cure_reports_pub.update_cure_reports : '||l_return_status);
362 
363  	 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS)  THEN
364 	      Get_Messages (l_msg_count,l_message);
365            IF PG_DEBUG < 11  THEN
366               IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
367                               OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Error after updating cure reports'
368                                            ||l_message);
369               END IF;
370            END IF;
371           raise FND_API.G_EXC_ERROR;
372      ELSE
373            IF PG_DEBUG < 11  THEN
374               IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
375                               OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Success -updated cure refund header' );
376               END IF;
377            END IF;
378            FND_MSG_PUB.initialize;
379     END IF;
380 
381    IF x_return_status =FND_API.G_RET_STS_SUCCESS THEN
382         FND_MSG_PUB.initialize;
383     END IF;
384 
385  -- Standard check for p_commit
386       IF FND_API.to_Boolean( p_commit )THEN
387          COMMIT WORK;
388       END IF;
389 
390       FND_MSG_PUB.Count_And_Get
391       (  p_count          =>   x_msg_count,
392          p_data           =>   x_msg_data
393       );
394 
395   okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : END');
396 
397 EXCEPTION
398     WHEN Fnd_Api.G_EXC_ERROR THEN
399       ROLLBACK TO APPROVE_CURE_REPORTS;
400       okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : Fnd_Api.G_EXC_ERROR');
401       x_return_status := Fnd_Api.G_RET_STS_ERROR;
402       x_msg_count := l_msg_count ;
403       x_msg_data := l_msg_data ;
404       Fnd_Msg_Pub.count_and_get(
405              p_count   => x_msg_count
406             ,p_data    => x_msg_data);
407     WHEN Fnd_Api.G_EXC_UNEXPECTED_ERROR THEN
408       ROLLBACK TO APPROVE_CURE_REPORTS;
409       okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : Fnd_Api.G_EXC_UNEXPECTED_ERROR');
410       x_return_status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
411       x_msg_count := l_msg_count ;
412       x_msg_data := l_msg_data ;
413       Fnd_Msg_Pub.count_and_get(
414              p_count   => x_msg_count
415             ,p_data    => x_msg_data);
416     WHEN OTHERS THEN
417       ROLLBACK TO APPROVE_CURE_REPORTS;
418       okl_debug_pub.logmessage('OKL_CURE_WF: approve_cure_reports : OTHERS');
419       x_return_status := Fnd_Api.G_RET_STS_UNEXP_ERROR;
420       x_msg_count := l_msg_count ;
421       x_msg_data := l_msg_data ;
422       Fnd_Msg_Pub.ADD_EXC_MSG('OKL_CURE_WF','APPROVE_CURE_REPORTS');
423       Fnd_Msg_Pub.count_and_get(
424              p_count   => x_msg_count
425             ,p_data    => x_msg_data);
426 
427 
428 END APPROVE_CURE_REPORTS;
429 
430 
431 
432 
433 /**
434   called from the workflow to update cure reports based on
435   the approval
436 **/
437   PROCEDURE set_approval_status (itemtype        in varchar2,
438                                  itemkey         in varchar2,
439                                  actid           in number,
440                                  funcmode        in varchar2,
441                                  result       out nocopy varchar2) IS
442 l_api_version   NUMBER := 1;
443 l_init_msg_list VARCHAR2(1);
444 l_return_status VARCHAR2(1);
445 l_msg_count     NUMBER ;
446 l_msg_data      VARCHAR2(32627);
447 l_message      VARCHAR2(32627);
448 
449 l_cure_report_id     VARCHAR2(32627);
450 lp_crtv_rec         okl_crt_pvt.crtv_rec_type;
451 lx_crtv_rec     	okl_crt_pvt.crtv_rec_type;
452 
453 cursor c_get_obj_ver(p_report_id IN NUMBER) is
454 select object_version_number
455 from okl_cure_reports
456 where cure_report_id =p_report_id;
457 
458 
459 BEGIN
460 
461   okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : START');
462 
463   IF (G_DEBUG_ENABLED = 'Y') THEN
464     G_IS_DEBUG_STATEMENT_ON := OKL_DEBUG_PUB.CHECK_LOG_ON(G_MODULE, FND_LOG.LEVEL_STATEMENT);
465   END IF;
466 
467         if funcmode <> 'RUN' then
468           result := wf_engine.eng_null;
469           return;
470        end if;
471 
472        l_cure_report_id:= wf_engine.GetItemAttrText(
473                                            itemtype  => itemtype,
474                                            itemkey   => itemkey,
475                                            aname     => 'REPORT_ID');
476 
477   okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : l_cure_report_id : '||l_cure_report_id);
478 
479       lp_crtv_rec.cure_report_id :=l_cure_report_id;
480       lp_crtv_rec.approval_status :='APPROVED';
481 
482       OPEN c_get_obj_ver(l_cure_report_id);
483       FETCH c_get_obj_ver INTO  lp_crtv_rec.object_version_number;
484       CLOSE  c_get_obj_ver;
485 
486      OKL_cure_reports_pub.update_cure_reports(
487                            p_api_version     => 1.0
488                           ,p_init_msg_list   => 'F'
489                           ,x_return_status   => l_return_status
490                           ,x_msg_count       => l_msg_count
491                           ,x_msg_data        => l_msg_data
492                           ,p_crtv_rec        => lp_crtv_rec
493                           ,x_crtv_rec        => lx_crtv_rec);
494 
495   okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : OKL_cure_reports_pub.update_cure_reports : '||l_return_status);
496 
497  	 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS)  THEN
498 	      Get_Messages (l_msg_count,l_message);
499            IF PG_DEBUG < 11  THEN
500               IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
501                               OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Error after updating cure reports'
502                                            ||l_message);
503               END IF;
504            END IF;
505           raise FND_API.G_EXC_ERROR;
506      END IF;
507 
508   okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : END');
509 
510   EXCEPTION
511     WHEN FND_API.G_EXC_ERROR THEN
512 
513       okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : FND_API.G_EXC_ERROR');
514        --resultout := wf_engine.eng_completed ||':'||wf_no;
515        wf_core.context('OKL_CURE_WF',
516                        'set_approval_status',
517                        itemtype,
518                        itemkey,
519                        to_char(actid),
520                        funcmode);
521        raise;
522 
523     when others then
524       okl_debug_pub.logmessage('OKL_CURE_WF: set_approval_status : OTHERS');
525        --resultout := wf_engine.eng_completed ||':'||wf_no;
526        wf_core.context('OKL_CURE_WF',
527                        'set_approval_status',
528                        itemtype,
529                        itemkey,
530                        to_char(actid),
531                        funcmode);
532        raise;
533 
534  END set_approval_status;
535 
536 /**
537   called from the workflow to update cure reports based on
538   the approval
539 **/
540   PROCEDURE set_reject_status (itemtype        in varchar2,
541                                  itemkey         in varchar2,
542                                  actid           in number,
543                                  funcmode        in varchar2,
544                                  result       out nocopy varchar2) IS
545 l_api_version   NUMBER := 1;
546 l_init_msg_list VARCHAR2(1);
547 l_return_status VARCHAR2(1);
548 l_msg_count     NUMBER ;
549 l_msg_data      VARCHAR2(32627);
550 l_message      VARCHAR2(32627);
551 
552 l_cure_report_id VARCHAR2(32627);
553 lp_crtv_rec         okl_crt_pvt.crtv_rec_type;
554 lx_crtv_rec     	okl_crt_pvt.crtv_rec_type;
555 cursor c_get_obj_ver(p_report_id IN NUMBER) is
556 select object_version_number
557 from okl_cure_reports
558 where cure_report_id =p_report_id;
559 
560 
561 
562 BEGIN
563 
564   okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : START');
565 
566   IF (G_DEBUG_ENABLED = 'Y') THEN
567     G_IS_DEBUG_STATEMENT_ON := OKL_DEBUG_PUB.CHECK_LOG_ON(G_MODULE, FND_LOG.LEVEL_STATEMENT);
568   END IF;
569 
570         if funcmode <> 'RUN' then
571           result := wf_engine.eng_null;
572           return;
573        end if;
574 
575        l_cure_report_id:= wf_engine.GetItemAttrText(
576                                            itemtype  => itemtype,
577                                            itemkey   => itemkey,
578                                            aname     => 'REPORT_ID');
579 
580 
581   okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : l_cure_report_id : '||l_cure_report_id);
582 
583       lp_crtv_rec.cure_report_id :=l_cure_report_id;
584       lp_crtv_rec.approval_status :='REJECTED';
585 
586       OPEN c_get_obj_ver(l_cure_report_id);
587       FETCH c_get_obj_ver INTO  lp_crtv_rec.object_version_number;
588       CLOSE  c_get_obj_ver;
589 
590      OKL_cure_reports_pub.update_cure_reports(
591                            p_api_version     => 1.0
592                           ,p_init_msg_list   => 'F'
593                           ,x_return_status   => l_return_status
594                           ,x_msg_count       => l_msg_count
595                           ,x_msg_data        => l_msg_data
596                           ,p_crtv_rec        => lp_crtv_rec
597                           ,x_crtv_rec        => lx_crtv_rec);
598 
599   okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : OKL_cure_reports_pub.update_cure_reports : '||l_return_status);
600 
601  	 IF ( l_return_status <> FND_API.G_RET_STS_SUCCESS)  THEN
602 	      Get_Messages (l_msg_count,l_message);
603            IF PG_DEBUG < 11  THEN
604               IF (G_IS_DEBUG_STATEMENT_ON = true) THEN
605                               OKL_DEBUG_PUB.LOG_DEBUG(FND_LOG.LEVEL_STATEMENT, G_MODULE,'Error after updating cure reports'
606                                            ||l_message);
607               END IF;
608            END IF;
609           raise FND_API.G_EXC_ERROR;
610      END IF;
611 
612   okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : END');
613 
614   EXCEPTION
615     WHEN FND_API.G_EXC_ERROR THEN
616 
617       okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : FND_API.G_EXC_ERROR');
618        --resultout := wf_engine.eng_completed ||':'||wf_no;
619        wf_core.context('OKL_CURE_WF',
620                        'set_reject_status',
621                        itemtype,
622                        itemkey,
623                        to_char(actid),
624                        funcmode);
625        raise;
626 
627     when others then
628 
629       okl_debug_pub.logmessage('OKL_CURE_WF: set_reject_status : OTHERS');
630        --resultout := wf_engine.eng_completed ||':'||wf_no;
631        wf_core.context('OKL_CURE_WF',
632                        'set_reject_status',
633                        itemtype,
634                        itemkey,
635                        to_char(actid),
636                        funcmode);
637        raise;
638 
639  END set_reject_status;
640 
641 END OKL_CURE_WF;