DBA Data[Home] [Help]

PACKAGE BODY: APPS.PJM_MASS_TRANSFER_WF

Source


1 PACKAGE BODY PJM_MASS_TRANSFER_WF AS
2 /* $Header: PJMWMXFB.pls 115.8 2004/02/23 18:20:20 yliou noship $ */
3 
4 --
5 -- Global Variables
6 --
7 Requestor  VARCHAR2(80);
8 
9 --
10 -- Private Functions and Procedures
11 --
12 PROCEDURE Apps_Initialize
13 ( ItemType            IN      VARCHAR2
14 , ItemKey             IN      VARCHAR2
15 ) IS
16 
17 UserID      NUMBER;
18 RespID      NUMBER;
19 RespApplID  NUMBER;
20 
21 BEGIN
22 
23   FND_GLOBAL.apps_initialize
24   ( WF_ENGINE.GetItemAttrNumber( ItemType , ItemKey , 'USER_ID' )
25   , WF_ENGINE.GetItemAttrNumber( ItemType , ItemKey , 'RESP_ID' )
26   , WF_ENGINE.GetItemAttrNumber( ItemType , ItemKey , 'RESP_APPL_ID' )
27   );
28 
29 END Apps_Initialize;
30 
31 
32 FUNCTION Find_Proj_Mgr
33 ( X_Project_ID  NUMBER
34 , X_Requestor   VARCHAR2 )
35 RETURN VARCHAR2 IS
36 
37 CURSOR c IS
38   SELECT R.name
39   FROM   pa_project_players P , wf_roles R
40   WHERE  P.project_role_type = 'PROJECT MANAGER'
41   AND    P.project_id = X_Project_ID
42   AND    sysdate BETWEEN P.start_date_active AND nvl(P.end_date_active , sysdate + 1)
43   AND    R.orig_system_id = P.person_id
44   AND    R.orig_system = 'PER'
45   ORDER BY decode(R.name , X_Requestor , 0 , 1) , R.name;
46 
47 RoleName  VARCHAR2(80);
48 
49 BEGIN
50 
51   OPEN c;
52   FETCH c INTO RoleName;
53   CLOSE c;
54 
55   RETURN ( RoleName );
56 
57 END Find_Proj_Mgr;
58 
59 
60 FUNCTION Is_Project_Seiban ( X_Project_ID  NUMBER )
61 RETURN VARCHAR2 IS
62 
63 CURSOR c IS
64   SELECT 'Y'
65   FROM   pjm_seiban_numbers
66   WHERE  project_id = X_Project_ID;
67 
68 Result   VARCHAR2(1);
69 
70 BEGIN
71 
72   OPEN c;
73   FETCH c INTO Result;
74   IF ( c%notfound ) THEN
75     CLOSE c;
76     RETURN ( 'N' );
77   ELSE
78     CLOSE c;
79     RETURN ( 'Y' );
80   END IF;
81 
82 END Is_Project_Seiban;
83 
84 
85 --
86 -- Public Functions and Procedures
87 --
88 
89 --
90 --  Name          : Initialize
91 --  Pre-reqs      : Must be called from WF activity
92 --  Function      : This procedure initializes the remaining of the item
93 --                  attributes not set during launch
94 --
95 --  Parameters    :
96 --  IN            : ItemType
97 --                  ItemKey
98 --                  ActID
99 --                  FuncMode
100 --  OUT           : ResultOut ( None )
101 --
102 --  Returns       : None
103 --
104 PROCEDURE Initialize
105 ( ItemType            IN             VARCHAR2
106 , ItemKey             IN             VARCHAR2
107 , ActID               IN             NUMBER
108 , FuncMode            IN             VARCHAR2
109 , ResultOut           OUT NOCOPY     VARCHAR2
110 ) IS
111 
112 CURSOR c ( X_Transfer_ID  NUMBER ) IS
113   SELECT p.organization_id
114   ,      mp.organization_code
115   ,      org.name organization_name
116   ,      p.from_project_id
117   ,      p.to_project_id
118   ,      p.transfer_date
119   ,      p.transfer_mode
120   ,      p.inventory_item_id
121   ,      p.category_set_id
122   ,      p.category_id
123   ,      r.reason_name transfer_reason
124   ,      p.transfer_reference
125   FROM   pjm_mass_transfers p
126   ,      mtl_parameters mp
127   ,      hr_all_organization_units_tl org
128   ,      mtl_transaction_reasons r
129   WHERE  p.mass_transfer_id = X_Transfer_ID
130   AND    mp.organization_id = p.organization_id
131   AND    org.organization_id = mp.organization_id
132   AND    org.language = userenv('LANG')
133   AND    r.reason_id (+) = p.transfer_reason_id
134   ;
135 
136 crec       c%rowtype;
137 
138 CURSOR p ( X_Project_ID  NUMBER ) IS
139   SELECT segment1 project_num , name project_name , description project_desc
140   FROM   pa_projects_all
141   WHERE  project_id = X_Project_ID
142   UNION ALL
143   SELECT project_number , project_name , project_name
144   FROM   pjm_seiban_numbers
145   WHERE  project_id = X_Project_ID;
146 
147 prec       p%rowtype;
148 
149 CURSOR ic ( X_Transfer_Mode   NUMBER
150           , X_Organization_ID NUMBER
151           , X_Item_ID         NUMBER
152           , X_Category_ID     NUMBER ) IS
153   SELECT concatenated_segments , description
154   FROM   mtl_system_items_b_kfv
155   WHERE  organization_id = X_Organization_ID
156   AND    inventory_item_id = X_Item_ID
157   AND    X_Transfer_Mode = PJM_MASS_TRANSFER_PUB.G_TXFR_MODE_ONE_ITEM
158   UNION ALL
159   SELECT concatenated_segments , description
160   FROM   mtl_categories_b_kfv
161   WHERE  category_id = X_Category_ID
162   AND    X_Transfer_Mode = PJM_MASS_TRANSFER_PUB.G_TXFR_MODE_CATEGORY;
163 
164 icrec      ic%rowtype;
165 
166 ItemCat    VARCHAR2(2000);
167 
168 ProjMgr    VARCHAR2(80);
169 
170 BEGIN
171 
172   IF ( FuncMode = 'RUN' ) THEN
173 
174     Requestor := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'REQUESTOR' );
175 
176     OPEN c ( to_number( ItemKey ) );
177     FETCH c INTO crec;
178     CLOSE c;
179 
180     WF_ENGINE.SetItemAttrText( itemtype => ItemType
181                              , itemkey  => ItemKey
182                              , aname    => 'TRANSFER_ID'
183                              , avalue   => ItemKey );
184 
185     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
186                                , itemkey  => ItemKey
187                                , aname    => 'ORGANIZATION_ID'
188                                , avalue   => crec.organization_id );
189 
190     WF_ENGINE.SetItemAttrText( itemtype => ItemType
191                              , itemkey  => ItemKey
192                              , aname    => 'ORGANIZATION_CODE'
193                              , avalue   => crec.organization_code );
194 
195     WF_ENGINE.SetItemAttrText( itemtype => ItemType
196                              , itemkey  => ItemKey
197                              , aname    => 'ORGANIZATION_NAME'
198                              , avalue   => crec.organization_name );
199 
200     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
201                                , itemkey  => ItemKey
202                                , aname    => 'FROM_PROJECT_ID'
203                                , avalue   => crec.from_project_id );
204 
205     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
206                                , itemkey  => ItemKey
207                                , aname    => 'TO_PROJECT_ID'
208                                , avalue   => crec.to_project_id );
209 
210     WF_ENGINE.SetItemAttrDate( itemtype => ItemType
211                              , itemkey  => ItemKey
212                              , aname    => 'TRANSFER_DATE'
213                              , avalue   => crec.transfer_date );
214 
215     WF_ENGINE.SetItemAttrText( itemtype => ItemType
216                              , itemkey  => ItemKey
217                              , aname    => 'TRANSFER_MODE'
218                              , avalue   => crec.transfer_mode );
219 
220     WF_ENGINE.SetItemAttrText( itemtype => ItemType
221                              , itemkey  => ItemKey
222                              , aname    => 'TRANSFER_REASON'
223                              , avalue   => crec.transfer_reason );
224 
225     WF_ENGINE.SetItemAttrText( itemtype => ItemType
226                              , itemkey  => ItemKey
227                              , aname    => 'REFERENCE'
228                              , avalue   => crec.transfer_reference );
229 
230     WF_ENGINE.SetItemAttrText( itemtype => ItemType
231                              , itemkey  => ItemKey
232                              , aname    => 'DETAILS'
233                              , avalue   => 'PLSQL:PJM_MASS_TRANSFER_WF.TRANSFER_DETAILS/'
234                                            || ItemType || ':' || ItemKey );
235 
236     --
237     -- Get Details of From Project
238     --
239     OPEN p ( crec.from_project_id );
240     FETCH p INTO prec;
241     CLOSE p;
242 
243     ProjMgr := Find_Proj_Mgr( crec.from_project_id , Requestor );
244 
245     WF_ENGINE.SetItemAttrText( itemtype => ItemType
246                              , itemkey  => ItemKey
247                              , aname    => 'FROM_PROJECT_NUM'
248                              , avalue   => prec.project_num );
249 
250     WF_ENGINE.SetItemAttrText( itemtype => ItemType
251                              , itemkey  => ItemKey
252                              , aname    => 'FROM_PROJECT_NAME'
253                              , avalue   => prec.project_name );
254 
255     WF_ENGINE.SetItemAttrText( itemtype => ItemType
256                              , itemkey  => ItemKey
257                              , aname    => 'FROM_PROJECT_DESC'
258                              , avalue   => prec.project_desc );
259 
260     WF_ENGINE.SetItemAttrText( itemtype => ItemType
261                              , itemkey  => ItemKey
262                              , aname    => 'FROM_PROJECT_MGR'
263                              , avalue   => ProjMgr );
264 
265     --
266     -- Get Details of To Project
267     --
268     IF ( crec.to_project_id IS NOT NULL ) THEN
269 
270       OPEN p ( crec.to_project_id );
271       FETCH p INTO prec;
272       CLOSE p;
273 
274       ProjMgr := Find_Proj_Mgr( crec.to_project_id , Requestor );
275 
276       WF_ENGINE.SetItemAttrText( itemtype => ItemType
277                                , itemkey  => ItemKey
278                                , aname    => 'TO_PROJECT_NUM'
279                                , avalue   => prec.project_num );
280 
281       WF_ENGINE.SetItemAttrText( itemtype => ItemType
282                                , itemkey  => ItemKey
283                                , aname    => 'TO_PROJECT_NAME'
284                                , avalue   => prec.project_name );
285 
286       WF_ENGINE.SetItemAttrText( itemtype => ItemType
287                                , itemkey  => ItemKey
288                                , aname    => 'TO_PROJECT_DESC'
289                                , avalue   => prec.project_desc );
290 
291       WF_ENGINE.SetItemAttrText( itemtype => ItemType
292                                , itemkey  => ItemKey
293                                , aname    => 'TO_PROJECT_MGR'
294                                , avalue   => ProjMgr );
295 
296     END IF;
297 
298     --
299     -- Get Displayable info for item / category
300     --
301     IF ( crec.transfer_mode in ( PJM_MASS_TRANSFER_PUB.G_TXFR_MODE_ONE_ITEM
302                                , PJM_MASS_TRANSFER_PUB.G_TXFR_MODE_CATEGORY ) ) THEN
303 
304       OPEN ic ( crec.transfer_mode , crec.organization_id , crec.inventory_item_id , crec.category_id );
305       FETCH ic INTO icrec;
306       CLOSE ic;
307 
308       WF_ENGINE.SetItemAttrText( itemtype => ItemType
309                                , itemkey  => ItemKey
310                                , aname    => 'ITEMCAT'
311                                , avalue   => icrec.concatenated_segments );
312 
313       WF_ENGINE.SetItemAttrText( itemtype => ItemType
314                                , itemkey  => ItemKey
315                                , aname    => 'ITEMCAT_DESC'
316                                , avalue   => icrec.description );
317 
318     END IF;
319 
320     ResultOut := 'COMPLETE:';
321     RETURN;
322 
323   END IF;
324 
325   IF ( FuncMode = 'CANCEL' ) THEN
326 
327     ResultOut := '';
328     RETURN;
329 
330   END IF;
331 
332   IF ( FuncMode = 'TIMEOUT' ) THEN
333 
334     ResultOut := '';
335     RETURN;
336 
337   END IF;
338 
339 EXCEPTION
340 WHEN OTHERS THEN
341   ResultOut := 'ERROR';
342   WF_ENGINE.SetItemAttrText
343   ( ItemType => ItemType , ItemKey => ItemKey , AName => 'ERRORTEXT' , AValue => sqlerrm );
344   WF_CORE.Context( 'PJM_MASS_TRANSFER_WF'
345                  , 'INITIALIZE'
346                  , ItemType , ItemKey , to_char(ActID) , FuncMode , ResultOut );
347   RAISE;
348 
349 END Initialize;
350 
351 
352 --
353 --  Name          : Approval_Required_F
354 --  Pre-reqs      : Must be called from WF activity
355 --  Function      : This procedure determines if the requestor is also
356 --                  the project manager of the From Project
357 --
358 --  Parameters    :
359 --  IN            : ItemType
360 --                  ItemKey
361 --                  ActID
362 --                  FuncMode
363 --  OUT           : ResultOut ( WFSTD_YES_NO )
364 --
365 --  Returns       : None
366 --
367 PROCEDURE Approval_Required_F
368 ( ItemType            IN             VARCHAR2
369 , ItemKey             IN             VARCHAR2
370 , ActID               IN             NUMBER
371 , FuncMode            IN             VARCHAR2
372 , ResultOut           OUT NOCOPY     VARCHAR2
373 ) IS
374 
375 ProjectID  NUMBER;
376 ProjMgr    VARCHAR2(80);
377 
378 BEGIN
379 
380   IF ( FuncMode = 'RUN' ) THEN
381 
382     ResultOut := 'COMPLETE:Y';
383 
384     Requestor := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'REQUESTOR' );
385 
386     --
387     -- Approval not required if From Project is a Seiban
388     --
389     ProjectID := WF_ENGINE.GetItemAttrNumber( ItemType , ItemKey , 'FROM_PROJECT_ID' );
390     IF ( Is_Project_Seiban( ProjectID ) = 'Y' ) THEN
391       ResultOut := 'COMPLETE:N';
392       RETURN;
393     END IF;
394 
395     --
396     -- Approval not required if Requestor is also the From Project Manager
397     --
398     ProjMgr   := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'FROM_PROJECT_MGR' );
399     IF ( Requestor = ProjMgr ) THEN
400       ResultOut := 'COMPLETE:N';
401       RETURN;
402     END IF;
403 
404     RETURN;
405 
406   END IF;
407 
408   IF ( FuncMode = 'CANCEL' ) THEN
409 
410     ResultOut := '';
411     RETURN;
412 
413   END IF;
414 
415   IF ( FuncMode = 'TIMEOUT' ) THEN
416 
417     ResultOut := '';
418     RETURN;
419 
420   END IF;
421 
422 EXCEPTION
423 WHEN OTHERS THEN
424   ResultOut := 'ERROR';
425   WF_ENGINE.SetItemAttrText
426   ( ItemType => ItemType , ItemKey => ItemKey , AName => 'ERRORTEXT' , AValue => sqlerrm );
427   WF_CORE.Context( 'PJM_MASS_TRANSFER_WF'
428                  , 'APPROVAL_REQUIRED_F'
429                  , ItemType , ItemKey , to_char(ActID) , FuncMode , ResultOut );
430   RAISE;
431 
432 END Approval_Required_F;
433 
434 
435 --
436 --  Name          : Approval_Required_T
437 --  Pre-reqs      : Must be called from WF activity
438 --  Function      : This procedure determines if the requestor is also
439 --                  the project manager of the To Project
440 --
441 --  Parameters    :
442 --  IN            : ItemType
443 --                  ItemKey
444 --                  ActID
445 --                  FuncMode
446 --  OUT           : ResultOut ( WFSTD_YES_NO )
447 --
448 --  Returns       : None
449 --
450 PROCEDURE Approval_Required_T
451 ( ItemType            IN             VARCHAR2
452 , ItemKey             IN             VARCHAR2
453 , ActID               IN             NUMBER
454 , FuncMode            IN             VARCHAR2
455 , ResultOut           OUT NOCOPY     VARCHAR2
456 ) IS
457 
458 ProjectID  NUMBER;
459 ProjMgr    VARCHAR2(80);
460 FProjMgr   VARCHAR2(80);
461 
462 BEGIN
463 
464   IF ( FuncMode = 'RUN' ) THEN
465 
466     ResultOut := 'COMPLETE:Y';
467 
468     Requestor := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'REQUESTOR' );
469 
470     ProjectID := WF_ENGINE.GetItemAttrNumber( ItemType , ItemKey , 'TO_PROJECT_ID' );
471     --
472     -- Transfer to Common does not require approval
473     --
474     IF ( ProjectID IS NULL ) THEN
475       ResultOut := 'COMPLETE:N';
476       RETURN;
477     END IF;
478 
479     --
480     -- Transfer to Seiban does not require approval
481     --
482     IF ( Is_Project_Seiban( ProjectID ) = 'Y' ) THEN
483       ResultOut := 'COMPLETE:N';
484       RETURN;
485     END IF;
486 
487     --
488     -- Approval not required if Requestor is also the To Project Manager
489     --
490     ProjMgr   := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'TO_PROJECT_MGR' );
491     IF ( Requestor = ProjMgr ) THEN
492       ResultOut := 'COMPLETE:N';
493       RETURN;
494     END IF;
495 
496     --
497     -- Approval not required to To Project Manager is the same as From Project Manager
498     -- Approval will be obtained from the "From Project" side only
499     --
500     FProjMgr  := WF_ENGINE.GetItemAttrText( ItemType , ItemKey , 'FROM_PROJECT_MGR' );
501     IF ( ProjMgr = FProjMgr ) THEN
502       ResultOut := 'COMPLETE:N';
503       RETURN;
504     END IF;
505 
506     RETURN;
507 
508   END IF;
509 
510   IF ( FuncMode = 'CANCEL' ) THEN
511 
512     ResultOut := '';
513     RETURN;
514 
515   END IF;
516 
517   IF ( FuncMode = 'TIMEOUT' ) THEN
518 
519     ResultOut := '';
520     RETURN;
521 
522   END IF;
523 
524 EXCEPTION
525 WHEN OTHERS THEN
526   ResultOut := 'ERROR';
527   WF_ENGINE.SetItemAttrText
528   ( ItemType => ItemType , ItemKey => ItemKey , AName => 'ERRORTEXT' , AValue => sqlerrm );
529   WF_CORE.Context( 'PJM_MASS_TRANSFER_WF'
530                  , 'APPROVAL_REQUIRED_T'
531                  , ItemType , ItemKey , to_char(ActID) , FuncMode , ResultOut );
532   RAISE;
533 
534 END Approval_Required_T;
535 
536 
537 --
538 --  Name          : Execute
539 --  Pre-reqs      : Must be called from WF activity
540 --  Function      : This procedure executes the mass transfer by
541 --                  invoking the mass transfer process
542 --
543 --  Parameters    :
544 --  IN            : ItemType
545 --                  ItemKey
546 --                  ActID
547 --                  FuncMode
548 --  OUT           : ResultOut ( None )
549 --
550 --  Returns       : None
551 --
552 PROCEDURE Execute
553 ( ItemType            IN             VARCHAR2
554 , ItemKey             IN             VARCHAR2
555 , ActID               IN             NUMBER
556 , FuncMode            IN             VARCHAR2
557 , ResultOut           OUT NOCOPY     VARCHAR2
558 ) IS
559 
560 Return_Status   VARCHAR2(1);
561 Msg_Count       NUMBER;
562 Msg_Data        VARCHAR2(2000);
563 Txn_Count       NUMBER;
564 Txn_Header_ID   NUMBER;
565 Request_ID      NUMBER;
566 
567 BEGIN
568 
569   IF ( FuncMode = 'RUN' ) THEN
570 
571     Apps_Initialize( itemtype => ItemType , itemkey => ItemKey );
572 
573     PJM_MASS_TRANSFER_PUB.Mass_Transfer
574     ( P_api_version      => 1.0
575     , P_init_msg_list    => FND_API.G_TRUE
576     , P_commit           => FND_API.G_FALSE
577     , X_Return_Status    => Return_Status
578     , X_Msg_Count        => Msg_Count
579     , X_Msg_Data         => Msg_Data
580     , P_Transfer_ID      => to_number(ItemKey)
581     , X_Txn_Header_ID    => Txn_Header_ID
582     , X_Txn_Count        => Txn_Count
583     , X_Request_ID       => Request_ID
584     );
585 
586     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
587                                , itemkey  => ItemKey
588                                , aname    => 'CONC_REQUEST_ID'
589                                , avalue   => Request_ID );
590 
591     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
592                                , itemkey  => ItemKey
593                                , aname    => 'TXN_HEADER_ID'
594                                , avalue   => Txn_Header_ID );
595 
596     WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
597                                , itemkey  => ItemKey
598                                , aname    => 'TXN_COUNT'
599                                , avalue   => Txn_Count );
600 
601     ResultOut := 'COMPLETE:Y';
602     RETURN;
603 
604   END IF;
605 
606   IF ( FuncMode = 'CANCEL' ) THEN
607 
608     ResultOut := '';
609     RETURN;
610 
611   END IF;
612 
613   IF ( FuncMode = 'TIMEOUT' ) THEN
614 
615     ResultOut := '';
616     RETURN;
617 
618   END IF;
619 
620 EXCEPTION
621 WHEN OTHERS THEN
622   ResultOut := 'COMPLETE:N';
623   WF_ENGINE.SetItemAttrText
624   ( ItemType => ItemType , ItemKey => ItemKey , AName => 'ERRORTEXT' , AValue => sqlerrm );
625   WF_CORE.Context( 'PJM_MASS_TRANSFER_WF'
626                  , 'EXECUTE'
627                  , ItemType , ItemKey , to_char(ActID) , FuncMode , ResultOut );
628   RAISE;
629 
630 END Execute;
631 
632 
633 --
634 --  Name          : Transfer_Details
635 --  Pre-reqs      : Must be called from WF activity
636 --  Function      : This PL/SQL document procedure returns the transfer
637 --                  details for use in various notifications
638 --
639 --  Parameters    :
640 --  IN            : Document_ID ( ItemType:ItemKey )
641 --                  Display_Type
642 --                  Document_Type
643 --  OUT           : Document
644 --                  Document_Type
645 --
646 --  Returns       : None
647 --
648 PROCEDURE Transfer_Details
649 ( Document_ID         IN             VARCHAR2
650 , Display_Type        IN             VARCHAR2
651 , Document            OUT NOCOPY     VARCHAR2
652 , Document_Type       IN OUT NOCOPY  VARCHAR2
653 ) IS
654 
655 CURSOR c ( X_Transfer_ID  NUMBER ) IS
656 SELECT from_task_id
657 ,      to_task_id
658 FROM   pjm_mass_transfer_tasks
659 WHERE  mass_transfer_id = X_Transfer_ID;
660 
661 crec           c%rowtype;
662 
663 CURSOR t ( X_Task_ID  NUMBER ) IS
664 SELECT task_number
665 ,      task_name
666 FROM   pa_tasks
667 WHERE  task_id = X_Task_ID;
668 
669 trec           t%rowtype;
670 
671 ItemType       WF_ITEMS.item_type%TYPE;
672 ItemKey        WF_ITEMS.item_key%TYPE;
673 DocOut         VARCHAR2(32767);
674 
675 CR             VARCHAR2(10) := FND_GLOBAL.newline;
676 BS             VARCHAR2(10) := ' ';
677 
678 BEGIN
679 
680   ItemType := substr( Document_ID , 1 , instr(Document_ID , ':') - 1 );
681   ItemKey  := substr( Document_ID , instr(Document_ID , ':') + 1
682                     , length(Document_ID) - 2);
683 
684   IF ( Display_Type = 'text/plain' ) THEN
685 
686     Document := '';
687 
688   ELSE
689 
690     DocOut := CR || CR || '<!-- TRANSFER_DETAILS -->' || CR || CR;
691     --
692     -- Section Header
693     --
694     DocOut := DocOut
695            || '<table border=0 cellspacing=2 cellpadding=2 width=100%>'
696            || '<tr><td class=OraHeader>' || fnd_message.get_string('PJM' , 'MXFR-TRANSFER DETAILS')
697            || '</td></tr>' || CR
698            || '<tr><td class=OraBGAccentDark></td></tr>' || CR;
699 
700     --
701     -- Table Header
702     --
703     DocOut := DocOut || '<tr><td>' || CR;
704     DocOut := DocOut
705            || '<table class=OraTable border=0 cellspacing=2 cellpadding=2 width=100%>' || CR || '<tr>' || CR;
706     DocOut := DocOut
707            || '<th class=OraTableColumnHeader width=20%>'
708            || fnd_message.get_string('PJM' , 'MXFR-FROM TASK NUM')
709            || '</th>' || CR;
710     DocOut := DocOut
711            || '<th class=OraTableColumnHeader width=30%>'
712            || fnd_message.get_string('PJM' , 'MXFR-FROM TASK NAME')
713            || '</th>' || CR;
714     DocOut := DocOut
715            || '<th class=OraTableColumnHeader width=20%>'
716            || fnd_message.get_string('PJM' , 'MXFR-TO TASK NUM')
717            || '</th>' || CR;
718     DocOut := DocOut
719            || '<th class=OraTableColumnHeader width=30%>'
720            || fnd_message.get_string('PJM' , 'MXFR-TO TASK NAME')
721            || '</th>' || CR || '</tr>' || CR;
722 
723     FOR crec IN c ( to_number(ItemKey) ) LOOP
724 
725       DocOut := DocOut || '<tr>' || CR;
726 
727       IF ( crec.from_task_id > 0 ) THEN
728 
729         OPEN t ( crec.from_task_id );
730         FETCH t INTO trec;
731         CLOSE t;
732 
733         DocOut := DocOut
734                || '<td class=OraTableCellText>'
735                || trec.task_number
736                || '</td>' || CR;
737         DocOut := DocOut
738                || '<td class=OraTableCellText>'
739                || trec.task_name
740                || '</td>' || CR;
741 
742       ELSE
743 
744         DocOut := DocOut
745                || '<td colspan=2 class=OraTableCellText>'
746                || FND_MESSAGE.get_string('PJM' , 'MXFR-PROJECT LEVEL')
747                || '</td>' || CR;
748 
749       END IF;
750 
751       IF ( crec.to_task_id > 0 ) THEN
752 
753         OPEN t ( crec.to_task_id );
754         FETCH t INTO trec;
755         CLOSE t;
756 
757         DocOut := DocOut
758                || '<td class=OraTableCellText>'
759                || trec.task_number
760                || '</td>' || CR;
761         DocOut := DocOut
762                || '<td class=OraTableCellText>'
763                || trec.task_name
764                || '</td>' || CR || '</tr>' || CR;
765 
766       ELSE
767 
768         DocOut := DocOut
769                || '<td colspan=2 class=OraTableCellText>'
770                || FND_MESSAGE.get_string('PJM' , 'MXFR-PROJECT LEVEL')
771                || '</td>' || CR || '</tr>' || CR;
772 
773       END IF;
774 
775     END LOOP;
776 
777     DocOut := DocOut
778            || '</td></tr></table>' || CR
779            || '</table>' || CR || '<p>' || CR;
780 
781     Document := DocOut;
782     Document_Type := 'text/html';
783 
784   END IF;
785 
786 END Transfer_Details;
787 
788 
789 --
790 --  Name          : Start_Process
791 --  Pre-reqs      : None
792 --  Function      : This PL/SQL procedure starts the specified WF process
793 --
794 --  Parameters    :
795 --  IN            : ItemType
796 --                  Process
797 --                  ItemKey
798 --  OUT           : None
799 --
800 --  Returns       : None
801 --
802 PROCEDURE Start_Process
803 ( ItemType            IN      VARCHAR2
804 , Process             IN      VARCHAR2
805 , ItemKey             IN      VARCHAR2
806 ) IS
807 
808 BEGIN
809 
810   WF_ENGINE.CreateProcess( itemtype => ItemType
811                          , process  => Process
812                          , itemkey  => ItemKey );
813 
814   WF_ENGINE.SetItemUserKey( itemtype => ItemType
815                           , itemkey  => ItemKey
816                           , userkey  => ItemKey );
817 
818   WF_ENGINE.SetItemOwner( itemtype => ItemType
819                         , itemkey  => ItemKey
820                         , owner    => FND_GLOBAL.User_Name );
821 
822   WF_ENGINE.SetItemAttrText( itemtype => ItemType
823                            , itemkey  => ItemKey
824                            , aname    => 'REQUESTOR'
825                            , avalue   => FND_GLOBAL.User_Name );
826 
827   WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
828                              , itemkey  => ItemKey
829                              , aname    => 'USER_ID'
830                              , avalue   => FND_GLOBAL.User_ID );
831 
832   WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
833                              , itemkey  => ItemKey
834                              , aname    => 'RESP_APPL_ID'
835                              , avalue   => FND_GLOBAL.Resp_Appl_ID );
836 
837   WF_ENGINE.SetItemAttrNumber( itemtype => ItemType
838                              , itemkey  => ItemKey
839                              , aname    => 'RESP_ID'
840                              , avalue   => FND_GLOBAL.Resp_ID );
841 
842   WF_ENGINE.StartProcess( itemtype => ItemType
843                         , itemkey  => ItemKey );
844 
845 EXCEPTION
846 WHEN OTHERS THEN
847   RAISE;
848 END Start_Process;
849 
850 
851 END PJM_MASS_TRANSFER_WF;