DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_ONLINE_AUTHORING_WF_ACTIONS

Source


1 PACKAGE BODY PO_ONLINE_AUTHORING_WF_ACTIONS AS
2 /* $Header: PO_ONLINE_AUTHORING_WF_ACTIONS.plb 120.10 2011/10/10 12:39:12 venuthot ship $ */
3 
4 -- Read the profile option that enables/disables the debug log
5 g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
6 -- The module base for this package.
7 D_PACKAGE_BASE CONSTANT VARCHAR2(50) :=
8   PO_LOG.get_package_base('PO_ONLINE_AUTHORING_WF_ACTIONS');
9 
10 -- The module base for the subprogram.
11 D_start_authoring_enabled_wf CONSTANT VARCHAR2(100) :=
12   PO_LOG.get_subprogram_base(D_PACKAGE_BASE,'start_authoring_enabled_wf');
13 
14 -- The module base for the subprogram.
15 D_start_changes_discarded_wf CONSTANT VARCHAR2(100) :=
16   PO_LOG.get_subprogram_base(D_PACKAGE_BASE,'start_changes_discarded_wf');
17 
18 -- The module base for the subprogram.
19 D_get_wf_role_for_suppliers CONSTANT VARCHAR2(100) :=
20   PO_LOG.get_subprogram_base(D_PACKAGE_BASE,'get_wf_role_for_suppliers');
21 
22 D_get_wf_role_for_lock_owner CONSTANT VARCHAR2(100) :=
23   PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'D_get_wf_role_for_lock_owner');
24 
25 -- The following are local/Private procedure that support the workflow APIs:
26 
27 g_batch_size       NUMBER := 2500;
28 
29 ------------------------------------------------------------------------------
30 --Start of Comments
31 --Name: start_authoring_enabled_wf
32 --Pre-reqs:
33 --  None
34 --Modifies:
35 --  None except the workflow item attributes
36 --Locks:
37 --  None
38 --Function:
39 --   1. Get the supplier usernames associated with the po_headers_all.vendor_id
40 --      and get the role associated with that list
41 --   2. Create AGREEMENT_AUTHORING_ENABLED process
42 --   3. Set the item attributes for this process(set the supplier role in
43 --      FORWARD_TO_ROLE item attribute)
44 --   4. Start the workflow process
45 --Parameters:
46 --IN:
47 --  p_agreement_id
48 --    po_header_id
49 --  p_agreement_info
50 --    The agreement information portion of the notification title
51 --    This is retrieved by the calling program's controller (Calls getTitle)
52 --    e.g. "Blanket Agreement 4611, 0"
53 --  p_ou_name
54 --    Operating Unit Name
55 --  p_buyer_user_id
56 --    Buyer user id
57 --OUT:
58 --  none
59 --End of Comments
60 -------------------------------------------------------------------------------
61 
62 PROCEDURE start_authoring_enabled_wf(p_agreement_id       IN NUMBER,
63                                      p_agreement_info     IN VARCHAR2,
64                                      p_ou_name            IN VARCHAR2,
65                                      p_buyer_user_id      IN NUMBER)
66 IS
67 l_seq_for_item_key     varchar2(10)  := null;
68 l_item_type            po_headers_all.wf_item_type%type := 'POAUTH';
69 l_item_key             po_headers_all.wf_item_key%type := null;
70 l_supplier_user_name   fnd_user.user_name%type;
71 l_progress             NUMBER := 0;
72 -- bug 4733423: Modified the link to access edit blanket page
73 l_edit_agreement_url   varchar2(1000) :=
74      'JSP:/OA_HTML/OA.jsp?OAFunc=PO_BLANKET' ||'&' ||
75      'poHeaderId='||to_char(p_agreement_id) || '&' ||
76      'poMode=update' || '&' ||
77      'poCallingModule=notification' || '&' ||
78      'poCallingNotifId=-&#NID-' || '&' ||
79      'retainAM=Y' || '&' ||
80      'addBreadCrumb=Y' || '&' ||
81      'role=SUPPLIER';
82 
83 l_supplier_list        DBMS_SQL.VARCHAR2_TABLE;
84 l_buyer_user_name      fnd_user.user_name%type;
85 l_buyer_display_name   per_people_f.full_name%type;
86 l_role_name            WF_USER_ROLES.ROLE_NAME%TYPE;
87 d_mod                  CONSTANT VARCHAR2(100) := D_start_authoring_enabled_wf;
88 
89 BEGIN
90   l_progress := 10;
91   IF PO_LOG.d_proc THEN
92     PO_LOG.proc_begin(d_mod,'p_agreement_id',p_agreement_id);
93     PO_LOG.proc_begin(d_mod,'p_agreement_info',p_agreement_info);
94     PO_LOG.proc_begin(d_mod,'p_ou_name',p_ou_name);
95     PO_LOG.proc_begin(d_mod,'p_buyer_user_id',p_buyer_user_id);
96   END IF;
97 
98   l_role_name := get_wf_role_for_suppliers(p_agreement_id, 'PA_BLANKET');
99   IF PO_LOG.d_stmt THEN
100     PO_LOG.stmt(d_mod,l_progress, 'l_role_name', l_role_name);
101   END IF;
102 
103   -- Get the Buyer Name
104   l_progress := 40;
105   PO_REQAPPROVAL_INIT1.get_user_name(p_buyer_user_id,
106                                      l_buyer_user_name,
107                                      l_buyer_display_name);
108   IF PO_LOG.d_stmt THEN
109     PO_LOG.stmt(d_mod,l_progress,'l_buyer_user_name', l_buyer_user_name);
110     PO_LOG.stmt(d_mod,l_progress,'l_buyer_display_name', l_buyer_display_name);
111   END IF;
112 
113   -- Send the notification to all supplier users registered with the
114   -- vendor_id of the document
115   l_progress := 100;
116   -- Formulate the item key for each Supplier notification
117   select to_char(PO_WF_ITEMKEY_S.NEXTVAL)
118   into l_seq_for_item_key
119   from sys.dual;
120 
121   l_progress := 150;
122   l_item_key := to_char(p_agreement_id) || '-' || l_seq_for_item_key;
123 
124   IF PO_LOG.d_stmt THEN
125     PO_LOG.stmt(d_mod, l_progress, 'Creating Process with l_item_key', l_item_key);
126   END IF;
127 
128   -- Create the process
129   l_progress := 200;
130 
131   wf_engine.createProcess ( ItemType  => l_item_type,
132                             ItemKey   => l_item_key,
133 			    Process   => 'AGREEMENT_AUTHORING_ENABLED');
134   IF PO_LOG.d_stmt THEN
135     PO_LOG.stmt(d_mod,l_progress,'Process Created; Setting Attributes and Starting Process ...');
136   END IF;
137 
138   l_progress := 300;
139   wf_engine.SetItemAttrText ( itemtype => l_item_type,
140                               itemkey  => l_item_key,
141                               aname    => 'PO_HEADER_ID',
142                               avalue   => p_agreement_id);
143 
144   l_progress := 400;
145   wf_engine.SetItemAttrText ( itemtype => l_item_type,
146                               itemkey  => l_item_key,
147                               aname    => 'OPERATING_UNIT_NAME',
148                               avalue   => p_ou_name);
149 
150   l_progress := 500;
151   wf_engine.SetItemAttrText ( itemtype => l_item_type,
152                               itemkey  => l_item_key,
153                               aname    => 'FORWARD_FROM_USER_NAME',
154                               avalue   => l_buyer_display_name);
155 
156   l_progress := 600;
157   wf_engine.SetItemAttrText ( itemtype => l_item_type,
158                               itemkey  => l_item_key,
159                               aname    => 'FORWARD_TO_ROLE',
160                               avalue   => l_role_name);
161 
162   l_progress := 700;
163   wf_engine.SetItemAttrText ( itemtype => l_item_type,
164                               itemkey  => l_item_key,
165                               aname    => 'AGREEMENT_INFO',
166                               avalue   => p_agreement_info);
167 
168   l_progress := 800;
169   wf_engine.SetItemAttrText ( itemtype => l_item_type,
170                               itemkey  => l_item_key,
171                               aname    => 'EDIT_AGREEMENT_URL',
172                               avalue   => l_edit_agreement_url);
173 
174   wf_engine.SetItemOwner( itemtype => l_item_type,
175         		  itemkey  => l_item_key,
176 			  owner    => l_buyer_user_name);
177 
178 
179     l_progress := 900;
180     wf_engine.StartProcess ( ItemType  => l_item_type,
181                              ItemKey   => l_item_key );
182   IF PO_LOG.d_proc THEN
183     PO_LOG.stmt(d_mod,l_progress,'End of start_authoring_enabled_wf: WF Process Started.');
184   END IF;
185 
186   IF PO_LOG.d_proc THEN
187     PO_LOG.proc_end(d_mod);
188   END IF;
189 
190 EXCEPTION
191 
192   WHEN OTHERS THEN
193     WF_CORE.context('PO_ONLINE_AUTHORING_WF_ACTIONS' , 'start_authoring_enabled_wf', l_item_type, l_item_key, l_progress);
194     RAISE;
195 
196 END start_authoring_enabled_wf;
197 
198 -- bug5090429 START
199 ------------------------------------------------------------------------------
200 --Start of Comments
201 --Name: start_changes_discarded_wf
202 --Pre-reqs:
203 --  None
204 --Modifies:
205 --  None except the workflow item attributes
206 --Locks:
207 --  None
208 --Function:
209 --   Sends notification to the user who's currently locking the document
210 --   about the lock being released and pending changes being discarded
211 --Parameters:
212 --IN:
213 --  p_agreement_id
214 --    po_header_id
215 --  p_agreement_info
216 --    The agreement information portion of the notification title
217 --    This is retrieved by the calling program's controller (Calls getTitle)
218 --    e.g. "Blanket Agreement 4611, 0"
219 --  p_lock_owner_role
220 --    Role of the user holding the lock
221 --  p_lock_owner_user_id
222 --    User ID of the user holding the lock
223 --  p_buyer_user_id
224 --    agent id of the buyer
225 --OUT:
226 --  none
227 --End of Comments
228 -------------------------------------------------------------------------------
229 PROCEDURE start_changes_discarded_wf
230 ( p_agreement_id        IN NUMBER,
231 	p_agreement_info     IN VARCHAR2,
232 	p_lock_owner_role    IN VARCHAR2,
233 	p_lock_owner_user_id IN NUMBER,
234 	p_buyer_user_id      IN NUMBER
235 ) IS
236 
237 d_mod      CONSTANT VARCHAR2(100) := D_start_changes_discarded_wf;
238 d_position NUMBER;
239 
240 c_ITEM_TYPE CONSTANT po_headers_all.wf_item_type%type := 'POAUTH';
241 c_PROCESS   CONSTANT VARCHAR2(30) := 'AGREEMENT_CHANGES_DISCARDED';
242 
243 l_seq_for_item_key     NUMBER := NULL;
244 l_item_key             po_headers_all.wf_item_key%type := null;
245 
246 l_buyer_user_name      fnd_user.user_name%type;
247 l_buyer_display_name   per_people_f.full_name%type;
248 
249 l_lock_owner_user_name      fnd_user.user_name%type;
250 
251 l_forward_to_role      WF_USER_ROLES.ROLE_NAME%TYPE;
252 l_forward_to_role_dsp  VARCHAR2(500);
253 BEGIN
254   d_position := 0;
255 
256   IF PO_LOG.d_proc THEN
257     PO_LOG.proc_begin(d_mod,'p_agreement_id',p_agreement_id);
258   END IF;
259 
260   -- bug5249393
261   -- get lock owner role
262   get_wf_role_for_lock_owner
263   ( p_po_header_id => p_agreement_id,
264     p_lock_owner_role => p_lock_owner_role,
265     p_lock_owner_user_id => p_lock_owner_user_id,
266     x_wf_role_name => l_forward_to_role,
267     x_wf_role_name_dsp => l_forward_to_role_dsp
268   );
269 
270 
271   PO_REQAPPROVAL_INIT1.get_user_name(p_buyer_user_id,
272                                      l_buyer_user_name,
273                                      l_buyer_display_name);
274 
275   d_position := 10;
276 
277   SELECT PO_WF_ITEMKEY_S.NEXTVAL
278   INTO   l_seq_for_item_key
279   FROM   DUAL;
280 
281   l_item_key := p_agreement_id || '-' || l_seq_for_item_key;
282 
283   d_position := 20;
284 
285   WF_ENGINE.createProcess ( ItemType  => c_ITEM_TYPE,
286                             ItemKey   => l_item_key,
287                             Process   => c_PROCESS);
288 
289   d_position := 30;
290 
291   WF_ENGINE.SetItemAttrText ( itemtype => c_ITEM_TYPE,
292                               itemkey  => l_item_key,
293                               aname    => 'AGREEMENT_INFO',
294                               avalue   => p_agreement_info);
295 
296   WF_ENGINE.SetItemAttrText ( itemtype => c_ITEM_TYPE,
297                               itemkey  => l_item_key,
298                               aname    => 'FORWARD_FROM_USER_NAME',
299                               avalue   => l_buyer_display_name);
300 
301   WF_ENGINE.SetItemAttrText ( itemtype => c_ITEM_TYPE,
302                               itemkey  => l_item_key,
303                               aname    => 'FORWARD_FROM_FULL_NAME',
304                               avalue   => l_buyer_display_name);
305 
306   WF_ENGINE.SetItemAttrText ( itemtype => c_ITEM_TYPE,
307                               itemkey  => l_item_key,
308                               aname    => 'FORWARD_TO_ROLE',
309                               avalue   => l_forward_to_role);
310 
311   d_position := 40;
312 
313   WF_ENGINE.StartProcess ( ItemType  => c_ITEM_TYPE,
314                            ItemKey   => l_item_key );
315 
316   IF PO_LOG.d_proc THEN
317     PO_LOG.proc_end(d_mod,'p_agreement_id',p_agreement_id);
318   END IF;
319 
320 EXCEPTION
321 
322   WHEN OTHERS THEN
323     WF_CORE.context('PO_ONLINE_AUTHORING_WF_ACTIONS' , 'start_changes_discarded_wf', c_ITEM_TYPE, l_item_key, d_position);
324     RAISE;
325 
326 END start_changes_discarded_wf;
327 -- bug5090429 END
328 
329 ------------------------------------------------------------------------------
330 --Start of Comments
331 --Name: get_wf_role_for_suppliers
332 --Pre-reqs:
333 --  None
334 --Modifies:
335 --  wf_role to create a new role
336 --Locks:
337 --  None
338 --Function:
339 --  For  give po_header_id, this procedure
340 --   1. Finds the supplier user names associated with po_headers_all.vendor_id
341 --   2. Checks if there is already a role associated with this supplier list
342 --   3. If not, then create an adhoc role for this supplier list
343 --   4. If there is already a role for this supplier list, use it.
344 --Parameters:
345 --IN:
346 --  p_document_id
347 --    po_header_id
348 --  p_document_type
349 --    Document type as expected by po_vendors_grp.get_external_userlist
350 --    'PO_STANDARD', 'PA_BLANKET', 'PA_CONTRACT'
351 --    Eventhough currently this code is being called only with PA_CONTRACT,
352 --    we will use this as a generic utility method to get supplier role.
353 --RETURN:
354 --  Workflow role for the supplier list associated with po_headers_all.vendor_id
355 --End of Comments
356 -------------------------------------------------------------------------------
357 
358 FUNCTION get_wf_role_for_suppliers ( p_document_id    in     number,
359                                      p_document_type  in     varchar2)
360 return varchar2 IS
361 
362 l_progress             NUMBER;
363 
364 -- declare local variables to hold output of get_supplier_userlist call
365 l_supplier_user_tbl    po_vendors_grp.external_user_tbl_type;
366 l_namelist             varchar2(31990):=null;
367 l_namelist_for_sql     varchar2(32000):=null;
368 l_num_users            NUMBER := 0;
369 l_vendor_id            NUMBER;
370 l_return_status        VARCHAR2(1);
371 l_msg_count            NUMBER := 0;
372 l_msg_data             VARCHAR2(2000);
373 
374 -- local variables for role creation
375 l_role_name            WF_USER_ROLES.ROLE_NAME%TYPE := NULL;
376 l_role_display_name    varchar2(100):=null;
377 d_mod                  CONSTANT VARCHAR2(100) := D_get_wf_role_for_suppliers;
378 
379 
380 BEGIN
381   l_progress  := 100;
382   IF PO_LOG.d_proc THEN
383     PO_LOG.proc_begin(d_mod,'p_agreement_id', p_document_id );
384     PO_LOG.proc_begin(d_mod,'p_document_type', p_document_type );
385   END IF;
386 
387   -- Get the supplier user name list for a give po_header_id
388   po_vendors_grp.get_external_userlist
389           (p_api_version               => 1.0
390           ,p_init_msg_list             => FND_API.G_FALSE
391           ,p_document_id               => p_document_id
392           ,p_document_type             => p_document_type
393           ,x_return_status             => l_return_status
394           ,x_msg_count                 => l_msg_count
395           ,x_msg_data                  => l_msg_data
396           ,x_external_user_tbl         => l_supplier_user_tbl
397           ,x_supplier_userlist         => l_namelist
398           ,x_supplier_userlist_for_sql => l_namelist_for_sql
399           ,x_num_users                 => l_num_users
400           ,x_vendor_id                 => l_vendor_id);
401 
402   IF PO_LOG.d_stmt THEN
403     PO_LOG.stmt(d_mod,l_progress,'x_supplier_userlist',l_namelist );
404     PO_LOG.stmt(d_mod,l_progress,'x_num_users', l_num_users);
405     PO_LOG.stmt(d_mod,l_progress,'x_vendor_id', l_vendor_id);
406   END IF;
407 
408   l_progress  := 110;
409 
410   -- Proceed if return status is success
411   if(l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
412 
413     l_progress  := 120;
414 
415     if(l_namelist is null) then
416       l_role_name := null;
417     else
418       l_progress  := 130;
419       begin
420         -- Role display name is the Supplier name
421         select vendor_name
422           into l_role_display_name
423           from po_vendors
424           where vendor_id=l_vendor_id;
425         exception
426           when others then
427             l_role_display_name:=' ';
428       end;
429       l_progress  := 140;
430       IF PO_LOG.d_stmt THEN
431         PO_LOG.stmt(d_mod, l_progress, 'l_role_display_name',l_role_display_name );
432       END IF;
433 
434       -- Check for an existing role for this supplier list
435       l_role_name:= PO_REQAPPROVAL_INIT1.get_wf_role_for_users(l_namelist_for_sql, l_num_users);
436       IF PO_LOG.d_stmt THEN
437         PO_LOG.stmt(d_mod,l_progress,'l_role_name',l_role_name );
438       END IF;
439 
440       l_progress  := 150;
441       -- If no role already exist for this supplier list, create one
442       if (l_role_name is null ) then
443 
444         l_progress  := 160;
445         -- We need to give a role name before creating an ADHOC role.
446         l_role_name := substr('ADHOC' || to_char(sysdate, 'JSSSSS')|| to_char(p_document_id) || p_document_type, 1, 30);
447 
448         l_progress  := 170;
449         -- Create a role
450         IF PO_LOG.d_stmt THEN
451           PO_LOG.stmt(d_mod,'Creating l_role_name',l_role_name );
452         END IF;
453         WF_DIRECTORY.CreateAdHocRole( l_role_name,          -- role_name
454                                       l_role_display_name , -- role_display_name
455                                       null,       -- language
456                                       null,       -- territory
457                                       null,       -- role_description
458                                       'MAILHTML', -- Both email and view notif
459                                       l_namelist, -- role_users
460                                       null,       -- email_address
461                                       null,       -- fax
462                                       'ACTIVE',   -- status
463                                       null);      -- expiration_date
464         IF PO_LOG.d_stmt THEN
465           PO_LOG.stmt(d_mod,l_progress,'Created l_role_name',l_role_name );
466         END IF;
467         l_progress  := 180;
468         -- newly created adhoc role
469       end if; -- if (l_role_name is null )
470 
471     end if; -- if(l_namelist is null)
472 
473   END IF; -- if(l_return_status = FND_API.G_RET_STS_SUCCESS)
474 
475   IF PO_LOG.d_stmt THEN
476     PO_LOG.stmt(d_mod,l_progress, 'Returning l_role_name',l_role_name );
477   END IF;
478 
479   IF PO_LOG.d_proc THEN
480     PO_LOG.proc_end(d_mod);
481   END IF;
482   l_progress  := 200;
483   return l_role_name;
484 
485 EXCEPTION
486   WHEN OTHERS THEN
487     wf_core.context('PO_ONLINE_AUTHORING_WF_ACTIONS.get_wf_role_for_suppliers failed at:',l_progress);
488     wf_core.context('PO_ONLINE_AUTHORING_WF_ACTIONS.get_wf_role_for_suppliers',l_role_name||sqlerrm);
489     RETURN NULL;
490 end get_wf_role_for_suppliers;
491 
492 -- bug5249393 START
493 ------------------------------------------------------------------------------
494 --Start of Comments
495 --Name: get_wf_role_for_lock_owner
496 --Pre-reqs:
497 --  None
498 --Modifies:
499 --  get wf role for the person locking the document
500 --Locks:
501 --  None
502 --Function:
503 --  If lock owner is cat admin, then wf role will be the user name of
504 --     the user and the dsp name will be the one listed in WF directory
505 --  If lock owner is supplier, then we need to create a adhoc user if one
506 --     does not exist. This is because we want to the role to have the display
507 --     name equal to vendor name, which may not exist in the system
508 --Parameters:
509 --IN:
510 --  p_po_header_id
511 --    Document unique identifier
512 --  p_lock_owner_role
513 --    Role of the user locking the document
514 --  p_lock_owner_user_id
515 --OUT:
516 --  x_wf_role_name
517 --    Workflow adhoc role name
518 --  x_wf_role_name_dsp
519 --    Workflow adhoc role display name
520 --RETURN:
521 --  Workflow role for the supplier list associated with po_headers_all.vendor_id
522 --End of Comments
523 -------------------------------------------------------------------------------
524 PROCEDURE get_wf_role_for_lock_owner
525 ( p_po_header_id IN NUMBER,
526   p_lock_owner_role IN VARCHAR2,
527   p_lock_owner_user_id IN NUMBER,
528   x_wf_role_name OUT NOCOPY VARCHAR2,
529 	x_wf_role_name_dsp OUT NOCOPY VARCHAR2
530 )
531 IS
532 
533 d_mod      CONSTANT VARCHAR2(100) := D_get_wf_role_for_lock_owner;
534 d_position NUMBER;
535 
536 l_vendor_name PO_VENDORS.vendor_name%TYPE;
537 l_emp_id FND_USER.employee_id%TYPE;
538 l_user_name FND_USER.user_name%TYPE;
539 l_expected_wf_role_name WF_USER_ROLES.role_name%TYPE;
540 l_user_table WF_DIRECTORY.UserTable; --Added as part of Bug 13059528 fix
541 
542 BEGIN
543 
544   d_position := 0;
545 
546   IF PO_LOG.d_proc THEN
547     PO_LOG.proc_begin(d_mod);
548   END IF;
549 
550   IF (p_lock_owner_role = PO_GLOBAL.g_role_CAT_ADMIN) THEN
551     d_position := 10;
552 
553     SELECT employee_id
554     INTO   l_emp_id
555 		FROM   fnd_user
556     WHERE  user_id = p_lock_owner_user_id;
557 
558     d_position := 20;
559 
560     PO_REQAPPROVAL_INIT1.get_user_name
561     ( p_employee_id       => l_emp_id,
562       x_username          => x_wf_role_name,
563       x_user_display_name => x_wf_role_name_dsp
564     );
565 
566   ELSIF (p_lock_owner_role = PO_GLOBAL.g_role_SUPPLIER) THEN
567     d_position := 30;
568 
569     SELECT user_name
570     INTO   l_user_name
571     FROM   fnd_user
572     WHERE  user_id = p_lock_owner_user_id;
573 
574     SELECT PV.vendor_name
575     INTO   x_wf_role_name_dsp
576     FROM   po_headers_all POH,
577            po_vendors PV
578     WHERE  POH.po_header_id = p_po_header_id
579     AND    POH.vendor_id = PV.vendor_id;
580 
581     l_expected_wf_role_name :=
582 		  'ADHOC_PO_LOCK_OWNER_' || l_user_name;
583 
584     -- Check whether an existing ad hoc role for the supplier user has been
585     -- creatd already
586     SELECT MAX(role_name)
587     INTO   x_wf_role_name
588     FROM   WF_USER_ROLES
589     WHERE  role_name = l_expected_wf_role_name;
590 
591     d_position := 40;
592 
593     IF (x_wf_role_name IS NULL) THEN
594       -- Need to create a new ad hoc role
595       d_position := 50;
596 
597       x_wf_role_name := l_expected_wf_role_name;
598 
599       --Start of code changes for the bug 13059528
600       /*
601       WF_DIRECTORY.CreateAdHocRole
602       ( x_wf_role_name,
603         x_wf_role_name_dsp,
604         NULL,
605         NULL,
606         NULL,
607         'MAILHTML',
608         l_user_name,
609         NULL,
610         NULL,
611         'ACTIVE',
612         NULL
613       );*/
614 
615       l_user_table(0) := l_user_name;
616 
617       WF_DIRECTORY.CreateAdHocRole2
618       ( x_wf_role_name,
619         x_wf_role_name_dsp,
620         NULL,
621         NULL,
622         NULL,
623         'MAILHTML',
624         l_user_table,
625         NULL,
626         NULL,
627         'ACTIVE',
628         NULL
629       );
630       --End of code changes for the bug 13059528
631     ELSE
632         -- if a role already exists, make sure that the role display name
633         -- is up to date
634         WF_DIRECTORY.setAdHocRoleAttr
635         ( x_wf_role_name,
636           x_wf_role_name_dsp,
637           NULL,
638           NULL,
639           NULL,
640           NULL,
641           NULL,
642           NULL,
643           NULL,
644           NULL
645         );
646     END IF;
647 
648   ELSE
649     d_position := 60;
650 
651     -- We should never come to here
652     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
653   END IF;
654 
655   IF PO_LOG.d_proc THEN
656     PO_LOG.proc_end(d_mod);
657   END IF;
658 
659 EXCEPTION
660 
661 WHEN OTHERS THEN
662   PO_MESSAGE_S.add_exc_msg
663   ( p_pkg_name => D_PACKAGE_BASE,
664     p_procedure_name => d_mod || '.' || d_position
665   );
666 
667   WF_CORE.context('PO_ONLINE_AUTHORING_WF_ACTIONS' , 'get_adhoc_wf_role_for_lock_owner', d_position);
668   RAISE;
669 END get_wf_role_for_lock_owner;
670 -- bug5249393 END
671 
672 
673 PROCEDURE create_buyer_acceptance_wf(p_po_header_id    IN NUMBER,
674 				     p_role            IN VARCHAR2,
675 				     p_role_user_id    IN NUMBER)
676 IS
677 l_progress varchar2(4) := '000';
678 BEGIN
679   l_progress := '010';
680   --TO DO: Add iP call here
681 END create_buyer_acceptance_wf;
682 
683 END PO_ONLINE_AUTHORING_WF_ACTIONS;