[Home] [Help]
PACKAGE BODY: APPS.PO_REQAPPROVAL_INIT1
Source
1 PACKAGE BODY po_reqapproval_init1 AS
2 /* $Header: POXWPA1B.pls 120.141.12020000.8 2013/03/31 10:32:55 vpeddi ship $ */
3 -- Read the profile option that enables/disables the debug log
4 g_po_wf_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('PO_SET_DEBUG_WORKFLOW_ON'),'N');
5 -- Read the profile option that determines whether the promise date will be defaulted with need-by date or not
6 g_default_promise_date VARCHAR2(1) := NVL(FND_PROFILE.VALUE('POS_DEFAULT_PROMISE_DATE_ACK'),'N');
7 g_document_subtype PO_HEADERS_ALL.TYPE_LOOKUP_CODE%TYPE;
8 --Bug#3497033
9 --g_currency_format_mask declared to pass in as the second parameter
10 --in FND_CURRENCY.GET_FORMAT_MASK
11 g_currency_format_mask NUMBER := 60;
12 /*=======================================================================+
13 | FILENAME
14 | POXWPA1B.pls
15 |
16 | DESCRIPTION
17 | PL/SQL body for package: PO_REQAPPROVAL_INIT1
18 |
19 | NOTES Ben Chihaoui Created 6/15/97
20 | MODIFIED (MM/DD/YY)
21 | davidng 06/04/2002 Fix for bug 2401183. Used the Workflow Utility
22 | Package wrapper function and procedure to get
23 | and set attributes REL_NUM and REL_NUM_DASH
24 | in procedure PO_REQAPPROVAL_INIT1.Initialise_Error
25 *=======================================================================*/
26 --
27 TYPE g_refcur
28 IS
29 REF
30 CURSOR;
31 -- Bug#3147435
32 -- Added contractor_requisition_flag and contractor_status to GetRecHdr_csr
33 CURSOR GetRecHdr_csr(p_requisition_header_id NUMBER)
34 RETURN ReqHdrRecord
35 IS
36 SELECT REQUISITION_HEADER_ID,
37 DESCRIPTION,
38 AUTHORIZATION_STATUS,
39 TYPE_LOOKUP_CODE,
40 PREPARER_ID,
41 SEGMENT1,
42 CLOSED_CODE,
43 EMERGENCY_PO_NUM,
44 NVL(CONTRACTOR_REQUISITION_FLAG, 'N'),
45 NVL(CONTRACTOR_STATUS, 'NULL'),
46 NOTE_TO_AUTHORIZER
47 FROM po_requisition_headers_all
48 WHERE REQUISITION_HEADER_ID = p_requisition_header_id;
49 /*****************************************************************************
50 * The following are local/Private procedure that support the workflow APIs: *
51 *****************************************************************************/
52 PROCEDURE SetReqHdrAttributes
53 (
54 itemtype IN VARCHAR2,
55 itemkey IN VARCHAR2);
56 --
57 PROCEDURE SetReqAuthStat
58 (
59 p_document_id IN NUMBER,
60 itemtype IN VARCHAR2,
61 itemkey IN VARCHAR2,
62 note VARCHAR2,
63 p_auth_status VARCHAR2);
64 --
65 PROCEDURE SetPOAuthStat
66 (
67 p_document_id IN NUMBER,
68 itemtype IN VARCHAR2,
69 itemkey IN VARCHAR2,
70 note VARCHAR2,
71 p_auth_status VARCHAR2,
72 p_draft_id IN NUMBER DEFAULT -1, --Mod Project
73 p_update_sign VARCHAR2 DEFAULT 'N');
74 --
75 PROCEDURE SetRelAuthStat
76 (
77 p_document_id IN NUMBER,
78 itemtype IN VARCHAR2,
79 itemkey IN VARCHAR2,
80 note VARCHAR2,
81 p_auth_status VARCHAR2);
82 --
83 PROCEDURE UpdtReqItemtype
84 (
85 itemtype IN VARCHAR2,
86 itemkey IN VARCHAR2,
87 p_doc_id NUMBER);
88 --
89 PROCEDURE UpdtPOItemtype
90 (
91 itemtype IN VARCHAR2,
92 itemkey IN VARCHAR2,
93 p_doc_id NUMBER);
94 --
95 PROCEDURE UpdtRelItemtype
96 (
97 itemtype IN VARCHAR2,
98 itemkey IN VARCHAR2,
99 p_doc_id NUMBER);
100 --
101 PROCEDURE GetCanOwnerApprove
102 (
103 itemtype IN VARCHAR2,
104 itemkey IN VARCHAR2,
105 CanOwnerApproveFlag OUT NOCOPY VARCHAR2);
106 PROCEDURE InsertActionHistSubmit
107 (
108 itemtype VARCHAR2,
109 itemkey VARCHAR2,
110 p_doc_id NUMBER,
111 p_doc_type VARCHAR2,
112 p_doc_subtype VARCHAR2,
113 p_employee_id NUMBER,
114 p_action VARCHAR2,
115 p_note VARCHAR2,
116 p_path_id NUMBER,
117 p_draft_id NUMBER DEFAULT -1); -- Mod Project
118 PROCEDURE get_wf_attrs_from_docstyle
119 (
120 DocumentId NUMBER,
121 DraftId NUMBER,
122 l_itemtype OUT NOCOPY VARCHAR2,
123 l_workflow_process OUT NOCOPY VARCHAR2,
124 l_ame_transaction_type OUT NOCOPY VARCHAR2);
125 --
126 -- Bug 3845048 : Added update action history procedure as an autonomous transaction
127 PROCEDURE UpdateActionHistory
128 (
129 p_doc_id IN NUMBER,
130 p_doc_type IN VARCHAR2,
131 p_doc_subtype IN VARCHAR2,
132 p_action IN VARCHAR2 ) ;
133 -- <ENCUMBRANCE FPJ START>
134 FUNCTION EncumbOn_DocUnreserved
135 (
136 p_doc_type VARCHAR2,
137 p_doc_subtype VARCHAR2,
138 p_doc_id NUMBER)
139 RETURN VARCHAR2;
140 -- <ENCUMBRANCE FPJ END>
141 PROCEDURE PrintDocument
142 (
143 itemtype VARCHAR2,
144 itemkey VARCHAR2);
145 -- DKC 10/10/99
146 PROCEDURE FaxDocument
147 (
148 itemtype VARCHAR2,
149 itemkey VARCHAR2);
150 FUNCTION Print_Requisition
151 (
152 p_doc_num VARCHAR2,
153 p_qty_precision VARCHAR,
154 p_user_id VARCHAR2)
155 RETURN NUMBER ;
156 --Bug 6692126 Added p_document_id ,document subtype,with terms ,document type parameters
157 FUNCTION Print_PO
158 (
159 p_doc_num VARCHAR2,
160 p_qty_precision VARCHAR,
161 p_user_id VARCHAR2,
162 p_document_id NUMBER DEFAULT NULL,
163 p_draft_id NUMBER DEFAULT -1, --CLM Mod
164 p_document_subtype VARCHAR2 DEFAULT NULL,
165 p_withterms VARCHAR2 DEFAULT NULL)
166 RETURN NUMBER ;
167 --DKC 10/10/99
168 --Bug 6692126 Added p_document_id ,document subtype,with terms ,document type parameters
169 FUNCTION Fax_PO
170 (
171 p_doc_num VARCHAR2,
172 p_qty_precision VARCHAR,
173 p_user_id VARCHAR2,
174 p_fax_enable VARCHAR2,
175 p_fax_num VARCHAR2,
176 p_document_id NUMBER DEFAULT NULL,
177 p_draft_id NUMBER DEFAULT -1,
178 p_document_subtype VARCHAR2 DEFAULT NULL,
179 p_withterms VARCHAR2 DEFAULT NULL)
180 RETURN NUMBER ;
181 --Bug 6692126 Added p_document_id ,document subtype,with terms ,document type parameters
182 FUNCTION Print_Release
183 (
184 p_doc_num VARCHAR2,
185 p_qty_precision VARCHAR,
186 p_release_num VARCHAR2,
187 p_user_id VARCHAR2,
188 p_document_id NUMBER DEFAULT NULL)
189 RETURN NUMBER ;
190 -- DKC 10/10/99
191 --Bug 6692126 Added p_document_id ,document subtype,with terms ,document type parameters
192 FUNCTION Fax_Release
193 (
194 p_doc_num VARCHAR2,
195 p_qty_precision VARCHAR,
196 p_release_num VARCHAR2,
197 p_user_id VARCHAR2,
198 p_fax_enable VARCHAR2,
199 p_fax_num VARCHAR2,
200 p_document_id NUMBER DEFAULT NULL)
201 RETURN NUMBER ;
202 PROCEDURE CLOSE_OLD_NOTIF
203 (
204 itemtype IN VARCHAR2,
205 itemkey IN VARCHAR2);
206 PROCEDURE Insert_Acc_Rejection_Row
207 (
208 itemtype IN VARCHAR2,
209 itemkey IN VARCHAR2,
210 actid IN NUMBER,
211 flag IN VARCHAR2);
212
213 /* added as part of bug 10399957 - deadlock issue during updating comm_rev_num value */
214 PROCEDURE Set_Comm_Rev_Num
215 (
216 l_doc_type IN VARCHAR2,
217 l_po_header_id IN NUMBER,
218 l_po_revision_num_curr IN NUMBER);
219 /************************************************************************************
220 * Added this procedure as part of Bug #: 2843760
221 * This procedure basically checks if archive_on_print option is selected, and if yes
222 * call procedure PO_ARCHIVE_PO_SV.ARCHIVE_PO to archive the PO
223 *************************************************************************************/
224 PROCEDURE archive_po
225 (
226 p_document_id IN NUMBER,
227 p_document_type IN VARCHAR2,
228 p_document_subtype IN VARCHAR2);
229 -- <HTML Agreement R12 START>
230 PROCEDURE unlock_document
231 (
232 p_po_header_id IN NUMBER );
233 -- <HTML Agreement R12 END>
234 /**************************************************************************************
235 * The following are the global APIs. *
236 **************************************************************************************/
237 /*******************************************************************
238 < Added this procedure as part of Bug #: 2810150 >
239 PROCEDURE NAME: get_diff_in_user_list
240 DESCRIPTION :
241 Given a two lists of users, this procedure gives the difference of the two lists.
242 The users must be present in the fnd_user table.
243 Referenced by : locate_notifier
244 parameters :
245 Input:
246 p_super_set : A string having the list of user names
247 Example string: 'GE1', 'GE2', 'GE22'
248 p_subset : A list of string having the subset of user names present in the
249 previous list.
250 Output:
251 x_name_list: A list users present in the super set but not in
252 subset.
253 x_users_count: The number of users in the above list.
254 CHANGE History: Created 27-Feb-2003 jpasala
255 *******************************************************************/
256 PROCEDURE get_diff_in_user_list
257 (
258 p_super_set IN VARCHAR2,
259 p_subset IN VARCHAR2 ,
260 x_name_list OUT nocopy VARCHAR2,
261 x_name_list_for_sql OUT nocopy VARCHAR2,
262 x_users_count OUT nocopy NUMBER )
263 IS
264 l_refcur g_refcur;
265 l_name_list VARCHAR2(2000);
266 l_count NUMBER;
267 l_user_name FND_USER.USER_NAME%type;
268 l_progress VARCHAR2(255);
269 BEGIN
270 l_count := 0;
271 OPEN l_refcur FOR 'select distinct fu.user_name
272
273 from fnd_user fu
274
275 where fu.user_name in ('|| p_super_set || ')
276
277 and fu.user_name not in (' || p_subset || ')';
278 -- Loop through the cursor and construct the
279 -- user list.
280 LOOP
281 FETCH l_refcur INTO l_user_name;
282 IF l_refcur%notfound THEN
283 EXIT;
284 END IF;
285 IF l_count = 0 THEN
286 l_count := l_count+1;
287 x_name_list_for_sql := '''' ||l_user_name ||'''';
288 x_name_list := l_user_name;
289 ELSE
290 l_count := l_count+1;
291 x_name_list_for_sql := x_name_list_for_sql || ', ' || '''' || l_user_name||'''';
292 x_name_list := x_name_list || ' ' || l_user_name;
293 END IF;
294 END LOOP;
295 -- If there are no users found simply
296 -- send back null.
297 IF l_count = 0 THEN
298 x_name_list := ' NULL ';
299 END IF;
300 x_users_count := l_count;
301 EXCEPTION
302 WHEN OTHERS THEN
303 x_name_list := NULL;
304 l_progress := 'PO_REQAPPROVAL_INIT1.get_diff_in_user_list : Failed to get the list of users';
305 po_message_s.sql_error('In Exception of get_diff_in_user_list ()', l_progress, SQLCODE);
306 END;
307 /*******************************************************************
308 < Added this function as part of Bug #: 2810150 >
309 PROCEDURE NAME: get_wf_role_for_users
310 DESCRIPTION :
311 Given a list of users, the procedure looks through the wf_user_roles
312 to get a role that has exactly same set of input list of users.
313 Referenced by : locate_notifier
314 parameters :
315 Input:
316 p_list_of_users - String containing the list of users
317 Example string: 'GE1', 'GE2', 'GE22'
318 p_num_users - number of users in the above list
319 Output:
320 A string containg the role name ( or null , if such role
321 does not exist ).
322 CHANGE History: Created 27-Feb-2003 jpasala
323 *******************************************************************/
324 FUNCTION get_wf_role_for_users
325 (
326 p_list_of_users IN VARCHAR2,
327 p_num_users IN NUMBER)
328 RETURN VARCHAR2
329 IS
330 l_role_name WF_USER_ROLES.ROLE_NAME%TYPE;
331 l_adhoc VARCHAR2(10);
332 l_progress VARCHAR2(255);
333 l_offset PLS_INTEGER;
334 l_length PLS_INTEGER;
335 l_start PLS_INTEGER;
336 l_end PLS_INTEGER;
337 l_user_name fnd_user.user_name%TYPE;
338 l_count PLS_INTEGER;
339 CURSOR l_cur
340 IS
341 SELECT role_name
342 FROM
343 (SELECT role_name
344 FROM wf_user_roles
345 WHERE role_name IN
346 (SELECT role_name
347 FROM wf_user_roles
348 WHERE user_name IN
349 (SELECT user_name FROM po_wf_user_tmp
350 )
351 AND role_name LIKE 'ADHOC%'
352 AND NVL(EXPIRATION_DATE,SYSDATE+1) > SYSDATE
353 GROUP BY role_name
354 HAVING COUNT(role_name) = p_num_users
355 )
356 GROUP BY role_name
357 HAVING COUNT(role_name) = p_num_users
358 )
359 WHERE ROWNUM < 2;
360 BEGIN
361 DELETE po_wf_user_tmp; -- delete rows in the global temp table
362 -- split the user names from p_list_of_users and insert them to the
363 -- global temp table
364 l_offset := 1;
365 l_count := 0;
366 WHILE TRUE
367 LOOP
368 l_start := Instr(p_list_of_users, '''', l_offset);
369 IF l_start = 0 THEN
370 EXIT;
371 END IF;
372 l_end := Instr(p_list_of_users, '''', l_start + 1);
373 IF l_end = 0 THEN
374 EXIT;
375 END IF;
376 l_user_name := SUBSTR(p_list_of_users, l_start+1, l_end - l_start - 1);
377 l_offset := l_end + 1;
378 INSERT INTO po_wf_user_tmp
379 (user_name
380 ) VALUES
381 (l_user_name
382 );
383
384 l_count := l_count + 1;
385 END LOOP;
386 IF l_count = 0 OR l_count <> p_num_users THEN
387 RETURN NULL;
388 END IF;
389 OPEN l_cur;
390 FETCH l_cur INTO l_role_name;
391 IF l_cur%notfound THEN
392 l_role_name := NULL;
393 END IF;
394 CLOSE l_cur;
395 DELETE po_wf_user_tmp;
396 RETURN l_role_name;
397 EXCEPTION
398 WHEN OTHERS THEN
399 l_role_name := NULL;
400 l_progress := 'PO_REQAPPROVAL_INIT1.get_wf_role_for_users: Failed to get the list of users';
401 po_message_s.sql_error('In Exception of get_wf_role_for_users()', l_progress, SQLCODE);
402 END get_wf_role_for_users;
403 /**
404 < Added this function as part of Bug #: 2810150 >
405 FUNCTION NAME: get_function_id
406 Get the function id given the function name as in FND_FORM_FUNCTIONS table
407 String p_function_name - Function name
408 Return Number - The function id
409 CHANGE History : Created 27-Feb-2003 JPASALA
410 */
411 FUNCTION get_function_id
412 (
413 p_function_name IN VARCHAR2)
414 RETURN NUMBER
415 IS
416 CURSOR l_cur
417 IS
418 SELECT function_id
419 FROM fnd_form_functions
420 WHERE function_name = p_function_name;
421
422 l_function_id NUMBER:=0;
423 BEGIN
424 OPEN l_cur;
425 FETCH l_cur INTO l_function_id;
426
427 CLOSE l_cur;
428 IF( l_function_id IS NULL ) THEN
429 l_function_id := -1;
430 END IF;
431 RETURN l_function_id;
432 EXCEPTION
433 WHEN OTHERS THEN
434 l_function_id := -1;
435 RETURN l_function_id;
436 END get_function_id;
437 /*******************************************************************
438 < Added this procedure as part of Bug #: 2810150 >
439 PROCEDURE NAME: get_user_list_with_resp
440 DESCRIPTION :
441 Given a set of users and and a set of responsibilities,
442 this procedures returns a new set of users that are
443 assigned atleast one of the responsibilities in the
444 given set.
445 Referenced by : locate_notifier
446 parameters :
447 Input:
448 p_function_id - function id
449 p_namelist - String containing the list of users
450 Example string: 'GE1', 'GE2', 'GE22'
451 Output:
452 x_new_list - list of users that have the given responsibility.
453 x_count - number of users in the above list
454 CHANGE History: Created 27-Feb-2003 jpasala
455 *******************************************************************/
456 PROCEDURE get_user_list_with_resp
457 (
458 p_function_id IN NUMBER,
459 p_namelist IN VARCHAR2,
460 x_new_list OUT NOCOPY VARCHAR2,
461 x_new_list_for_sql OUT NOCOPY VARCHAR2,
462 x_count OUT nocopy NUMBER)
463 IS
464 l_refcur g_refcur;
465 l_first BOOLEAN;
466 l_user_name VARCHAR2(100);
467 l_count NUMBER;
468 l_progress VARCHAR2(200);
469 l_f VARCHAR2 (10);
470 BEGIN
471 l_count := 0;
472 l_f := '''' || 'F' || '''';
473 OPEN l_refcur FOR 'select distinct fu.user_name
474
475 from fnd_user fu, fnd_user_resp_groups furg
476
477 where fu.user_id = furg.user_id
478
479 and furg.responsibility_id in
480
481 (
482
483 SELECT
484
485 responsibility_id
486
487 FROM fnd_responsibility fr
488
489 WHERE menu_id in
490
491 ( SELECT fme.menu_id
492
493 FROM fnd_menu_entries fme
494
495 START WITH fme.function_id ='|| p_function_id ||'
496
497 CONNECT BY PRIOR menu_id = sub_menu_id
498
499 )
500
501 and (end_date is null or end_date > sysdate) '|| ' and fr.responsibility_id not in (select responsibility_id from fnd_resp_functions
502
503 where action_id= '|| p_function_id || ' and rule_type=' || l_f || ' )' || ' )
504
505 and fu.user_name in (' || p_namelist || ')
506
507 and (furg.end_date is null or furg.end_date > sysdate )' ;
508 -- Loop through the cursor and construct the
509 -- user list.
510 LOOP
511 FETCH l_refcur INTO l_user_name;
512 IF l_refcur%notfound THEN
513 EXIT;
514 END IF;
515 IF l_count = 0 THEN
516 l_count := l_count+1;
517 x_new_list_for_sql := '''' ||l_user_name ||'''';
518 x_new_list := l_user_name;
519 ELSE
520 l_count := l_count+1;
521 x_new_list_for_sql := x_new_list_for_sql || ', ' || '''' || l_user_name||'''';
522 x_new_list := x_new_list || ' ' || l_user_name;
523 END IF;
524 END LOOP;
525 -- If there are no users found simply
526 -- send back null.
527 IF l_count = 0 THEN
528 x_new_list := ' NULL ';
529 END IF;
530 x_count := l_count;
531 EXCEPTION
532 WHEN OTHERS THEN
533 x_new_list := ' null ';
534 l_progress := 'PO_REQAPPROVAL_INIT1.get_user_list_with_resp: Failed to get the list of users';
535 po_message_s.sql_error('In Exception of get_user_list_with_resp()', l_progress, SQLCODE);
536 END get_user_list_with_resp;
537 -------------------------------------------------------------------------------
538 --Start of Comments
539 --Name: start_wf_process
540 --Pre-reqs:
541 -- N/A
542 --Modifies:
543 -- N/A
544 --Locks:
545 -- None
546 --Function:
547 -- Starts a Document Approval workflow process.
548 --Parameters:
549 --IN:
550 --ItemType
551 -- Item Type of the workflow to be started; if NULL, we will use the default
552 -- Approval Workflow Item Type for the given DocumentType
553 --ItemKey
554 -- Item Key for starting the workflow; if NULL, we will construct a new key
555 -- from the sequence
556 --WorkflowProcess
557 -- Workflow process to be started; if NULL, we will use the default Approval
558 -- Workflow Process for the given DocumentType
559 --ActionOriginatedFrom
560 -- Indicates the caller of this procedure. If 'CANCEL', then the approval will
561 -- not insert into the action history.
562 --DocumentID
563 -- This value for this parameter depends on the DocumentType:
564 -- 'REQUISITION': PO_REQUISITION_HEADERS_ALL.requisition_header_id
565 -- 'PO' or 'PA': PO_HEADERS_ALL.po_header_id
566 -- 'RELEASE': PO_RELEASES_ALL.po_release_id
567 --DocumentNumber
568 -- (Obsolete) This parameter is ignored. This procedure will derive the
569 -- document number from DocumentID and DocumentType. (Bug 3284628)
570 --PreparerID
571 -- Requester (for Requisitions) or buyer (for other document types)
572 -- whose approval authority should be used in the approval workflow
573 --DocumentType
574 -- 'REQUISITION', 'PO', 'PA', 'RELEASE'
575 --DocumentSubType
576 -- The value for this parameter depends on the DocumentType:
577 -- 'REQUISITION': PO_REQUISITION_HEADERS_ALL.type_lookup_code
578 -- 'PO' or 'PA': PO_HEADERS_ALL.type_lookup_code
579 -- 'RELEASE': PO_RELEASES_ALL.release_type
580 --SubmitterAction
581 -- (Unused) This parameter is not currently used.
582 --ForwardToID
583 -- Requester (for Requisitions) or buyer (for other document types)
584 -- that this document is being forwarded to
585 --ForwardFromID
586 -- Requester (for Requisitions) or buyer (for other document types)
587 -- that this document is being forwarded from.
588 --DefaultApprovalPathID
589 -- Approval hierarchy to use in the approval workflow
590 --Note
591 -- Note to be entered into Action History for this document
592 --PrintFlag
593 -- If 'Y', this document will be printed.
594 --FaxFlag
595 -- If 'Y', this document will be faxed.
596 --FaxNumber
597 -- Phone number that this document will be faxed to
598 --EmailFlag
599 -- If 'Y', this document will be emailed.
600 --EmailAddress
601 -- Email address that this document will be sent to
602 --CreateSourcingRule
603 -- Blankets only: If 'Y', the workflow will create new sourcing rules,
604 -- rule assignments, and ASL entries.
605 --ReleaseGenMethod
606 -- Blankets only: Release Generation Method to use when creating ASL entries
607 --UpdateSourcingRule
608 -- Blankets only: If 'Y', the workflow will update existing sourcing rules
609 -- and ASL entries.
610 --MassUpdateReleases
611 -- <RETROACTIVE FPI> Blankets / GAs only: If 'Y', we will update the price
612 -- on the releases of the blanket or standard POs of the GA with the
613 -- retroactive price change on the blanket/GA line.
614 --RetroactivePriceChange
615 -- <RETROACTIVE FPI> Releases / Standard POs only: If 'Y', indicates that
616 -- this release/PO has been updated with a retroactive price change.
617 -- This flag is used to differentiate between approval of releases from
618 -- the form and from the Mass Update Releases concurrent program.
619 --OrgAssignChange
620 -- <GA FPI> Global Agreements only: If 'Y', indicates that an Organization
621 -- Assignment change has been made to this GA.
622 --CommunicatePriceChange
623 -- <RETROACTIVE FPJ> Blankets only: If 'Y', we will communicate any releases
624 -- or POs that were retroactively priced to the Supplier.
625 --p_background_flag
626 -- <DROPSHIP FPJ> If 'Y', we will do the following:
627 -- 1. No database commit
628 -- 2. Change the authorization_status to 'IN PROCESS'.
629 -- 3. Launch the approval workflow with background_flag set to 'Y', so that
630 -- it blocks immediately at a deferred activity.
631 -- As a result, the caller can choose to commit or rollback its changes.
632 --p_Initiator
633 -- Added for RCO Enhancement changes for R12. RCO will pass this parameter
634 -- value as : 'SUPPLIER' or 'REQUESTER'. Other callers will pass as NULL
635 -- value (default). The corresponding value('REQUESTER'/'SUPPLIER') is used
636 -- to set INITIATOR wf attribute in RCO wf.
637 --p_xml_flag
638 -- If 'Y' or 'N', this procedure will update the xml_flag in PO_HEADERS_ALL
639 -- or PO_RELEASES_ALL accordingly. This is used by HTML Orders. (Bug 5218538)
640 -- If null, no updates will be made.
641 -- p_source_type_code VARCHAR2 DEFAULT null
642 -- For the internal change order for requisitions the value will be INVENTORY
643 --End of Comments
644 -------------------------------------------------------------------------------
645 -- Mod Project
646 PROCEDURE Start_WF_Process
647 (
648 ItemType VARCHAR2,
649 ItemKey VARCHAR2,
650 WorkflowProcess VARCHAR2,
651 ActionOriginatedFrom VARCHAR2,
652 DocumentID NUMBER,
653 DocumentNumber VARCHAR2,
654 PreparerID NUMBER,
655 DocumentTypeCode VARCHAR2,
656 DocumentSubtype VARCHAR2,
657 SubmitterAction VARCHAR2,
658 forwardToID NUMBER,
659 forwardFromID NUMBER,
660 DefaultApprovalPathID NUMBER,
661 Note VARCHAR2,
662 PrintFlag VARCHAR2,
663 FaxFlag VARCHAR2,
664 FaxNumber VARCHAR2,
665 EmailFlag VARCHAR2,
666 EmailAddress VARCHAR2,
667 CreateSourcingRule VARCHAR2,
668 ReleaseGenMethod VARCHAR2,
669 UpdateSourcingRule VARCHAR2,
670 MassUpdateReleases VARCHAR2,
671 RetroactivePriceChange VARCHAR2,
672 OrgAssignChange VARCHAR2, -- GA FPI
673 CommunicatePriceChange VARCHAR2, -- <FPJ Retroactive>
674 p_Background_Flag VARCHAR2 DEFAULT 'N', -- <DropShip FPJ>
675 p_Initiator VARCHAR2 DEFAULT NULL,
676 p_xml_flag VARCHAR2 DEFAULT NULL,
677 /* Bug6708182 FPDS-NG ER. */
678 /* Added */
679 FpdsngFlag VARCHAR2 DEFAULT 'N' ,
680 p_source_type_code VARCHAR2 DEFAULT NULL
681 /* End Added*/
682 ,
683 DraftId NUMBER DEFAULT -1 -- Mod Project
684 ,p_bypass_checks_flag VARCHAR2 DEFAULT 'N' /*Bug 11727653: BYPASSING MULTIPLE SUBMISSION CHECKS IN WORKFLOW*/
685 )
686 IS
687 l_responsibility_id NUMBER;
688 l_user_id NUMBER;
689 l_application_id NUMBER;
690 x_progress VARCHAR2(300);
691 x_wf_created NUMBER;
692 x_orgid NUMBER;
693 EmailAddProfile VARCHAR2(60);
694 x_acceptance_required_flag VARCHAR2(1) := NULL;
695 x_acceptance_due_date DATE;
696 x_agent_id NUMBER;
697 x_buyer_username VARCHAR2(100);
698 x_buyer_display_name VARCHAR2(240);
699 l_userkey VARCHAR2(40);
700 l_doc_num_rel VARCHAR2(100);
701 l_doc_display_name FND_NEW_MESSAGES.message_text%TYPE; -- Bug 3215186
702 l_release_num PO_RELEASES.release_num%TYPE; -- Bug 3215186
703 l_revision_num PO_HEADERS.revision_num%TYPE; -- Bug 3215186
704 l_ga_flag VARCHAR2(1) := NULL; -- FPI GA
705 /* RETROACTIVE FPI START */
706 l_seq_for_item_key VARCHAR2(25) := NULL; --Bug14305923
707 l_can_change_forward_from_flag po_document_types.can_change_forward_from_flag%type;
708 l_can_change_forward_to_flag po_document_types.can_change_forward_to_flag%type;
709 l_can_change_approval_path po_document_types.can_change_approval_path_flag%type;
710 l_can_preparer_approve_flag po_document_types.can_preparer_approve_flag%type;
711 l_default_approval_path_id po_document_types.default_approval_path_id%type;
712 l_can_approver_modify_flag po_document_types.can_approver_modify_doc_flag%type;
713 l_forwarding_mode_code po_document_types.forwarding_mode_code%type;
714 l_itemtype po_document_types.wf_approval_itemtype%type;
715 l_itemtype_st po_document_types.wf_approval_itemtype%type;
716 l_workflow_process po_document_types.wf_approval_process%type;
717 l_workflow_process_st po_document_types.wf_approval_process%type;
718 l_itemkey VARCHAR2(60);
719 l_type_name po_document_types.type_name%type;
720 /* RETROACTIVE FPI END */
721 l_drop_ship_flag po_line_locations.drop_ship_flag%type; -- <DropShip FPJ>
722 l_conterms_exist_flag PO_HEADERS_ALL.CONTERMS_EXIST_FLAG%TYPE; --<CONTERMS FPJ>
723 --bug##3682458 replaced legal entity name with operating unit
724 l_operating_unit hr_all_organization_units_tl.name%TYPE; --<POC FPJ>
725 l_document_number PO_HEADERS_ALL.segment1%TYPE; -- Bug 3284628
726 l_consigned_flag PO_HEADERS_ALL.CONSIGNED_CONSUMPTION_FLAG%TYPE;
727 l_autoapprove_retro VARCHAR2(1);
728 l_okc_doc_type VARCHAR2(20); -- <Word Integration 11.5.10+>
729 l_vendor po_vendors.vendor_name%type; --Bug 4254468
730 l_vendor_site_code po_vendor_sites_all.vendor_site_code%type; --Bug 4254468
731 l_new_vendor po_vendors.vendor_name%type; --multi-mod
732 l_new_vendor_site_code po_vendor_sites_all.vendor_site_code%type; --multi-mod
733 l_multi_mod_req_id PO_MULTI_MOD_DOCS.MULTI_MOD_REQUEST_ID%TYPE; -- multi-mod
734 l_multi_mod_req_type PO_MULTI_MOD_REQUESTS.MULTI_MOD_REQUEST_TYPE%TYPE; --multi-mod
735 l_supplier_change_note varchar2(320); --multi-mod
736 l_supplier_site_change_note varchar2(320); --multi-mod
737 l_validation_details_url varchar2(320); --multi-mod
738 l_communicatePriceChange VARCHAR2(1); -- bug4176111
739 --CLM PR Amendment
740 l_federal_flag VARCHAR2(1) := 'N';
741 l_conformed_header_id NUMBER;
742 l_clm_document_number PO_HEADERS_ALL.clm_document_number%TYPE;
743 l_modification_number PO_DRAFTS.modification_number%TYPE;
744 /* Mod Project */
745 l_is_mod VARCHAR2(1) := 'N';
746 l_ame_approval_id NUMBER;
747 l_document_id_temp NUMBER;
748 l_ame_transaction_type PO_DOC_STYLE_HEADERS.ame_transaction_type%TYPE;
749 /* The new workflow with AME will be used for PO and PA */
750 /* Mod Project */
751 -- CLM CO signature ER
752 l_clm_contract_officer po_headers_all.clm_contract_officer%TYPE;
753 l_ko_sign_required VARCHAR2(1);
754 x_ko_username VARCHAR2(100);
755 x_ko_display_name VARCHAR2(240);
756 -- CLM CO signature ER
757
758 emp_user_id NUMBER; -- Bug 14078118
759 l_org_id NUMBER; -- CLM Controls Project
760 -- PAR Project : Approval
761 l_draft_type PO_DRAFTS.DRAFT_TYPE%TYPE;
762 BEGIN
763 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: at beginning of Start_WF_Process';
764 IF (g_po_wf_debug = 'Y') THEN
765 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
766 END IF;
767 --
768 -- Start Process :
769 -- - If a process is passed then it will be run
770 -- - If a process is not passed then the selector function defined in
771 -- item type will be determine which process to run
772 --
773 /* RETROACTIVE FPI START.
774 * Get the itemtype and WorkflowProcess from po_document_types
775 * if it is not set.
776 */
777 IF ((ItemType IS NULL) OR (WorkflowProcess IS NULL)) THEN
778 po_approve_sv.get_document_types
779 ( p_document_type_code => DocumentTypeCode,
780 p_document_subtype => DocumentSubtype,
781 x_can_change_forward_from_flag =>l_can_change_forward_from_flag,
782 x_can_change_forward_to_flag => l_can_change_forward_to_flag,
783 x_can_change_approval_path => l_can_change_approval_path,
784 x_default_approval_path_id => l_default_approval_path_id,
785 x_can_preparer_approve_flag => l_can_preparer_approve_flag, -- Bug 2737257
786 x_can_approver_modify_flag => l_can_approver_modify_flag,
787 x_forwarding_mode_code => l_forwarding_mode_code,
788 x_wf_approval_itemtype => l_itemtype,
789 x_wf_approval_process => l_workflow_process,
790 x_type_name => l_type_name);
791 ELSE
792 l_itemtype := ItemType;
793 l_workflow_process := WorkflowProcess;
794 END IF;
795 -- Mod Project
796 IF DocumentTypeCode = 'PO' OR DocumentTypeCode = 'PA' THEN
797 -- Get the workflow attributed form Doc styles
798 get_wf_attrs_from_docstyle(DocumentId, DraftId,l_itemtype_st, l_workflow_process_st, l_ame_transaction_type);
799 IF l_workflow_process_st IS NOT NULL OR l_itemtype_st IS NOT NULL THEN
800 l_itemtype := l_itemtype_st;
801 l_workflow_process := l_workflow_process_st;
802 END IF;
803 END IF;
804 -- Mod Project
805 IF (ItemKey IS NULL) THEN
806 SELECT TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL) INTO l_seq_for_item_key FROM sys.dual;
807
808 l_itemkey := TO_CHAR(DocumentID) || '-' || l_seq_for_item_key;
809 ELSE
810 l_itemkey := ItemKey;
811 END IF;
812 /* RETROACTIVE FPI END */
813 IF ( l_itemtype IS NOT NULL ) AND ( l_itemkey IS NOT NULL) AND ( DocumentID IS NOT NULL ) THEN
814 -- bug 852056: check to see if process has already been created
815 -- if it has, don't create process again.
816 BEGIN
817 SELECT COUNT(*)
818 INTO x_wf_created
819 FROM wf_items
820 WHERE item_type = l_itemtype
821 AND item_key = l_itemkey;
822 EXCEPTION
823 WHEN OTHERS THEN
824 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: check process existance';
825 po_message_s.sql_error('In Exception of Start_WF_Process()', x_progress, SQLCODE);
826 raise;
827 END;
828 -- Bug 5218538 START
829 -- Update the XML/EDI flags in the database based on p_xml_flag.
830 -- Do this before the commit, to avoid deadlock situations.
831 IF ((p_xml_flag IS NOT NULL) AND ((DocumentTypeCode='RELEASE' AND DocumentSubtype='BLANKET') OR (DocumentTypeCode='PO' AND DocumentSubtype='STANDARD'))) THEN
832 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: Updating the xml_flag: ' || p_xml_flag;
833 IF (g_po_wf_debug = 'Y') THEN
834 /* DEBUG */
835 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
836 END IF;
837 IF (p_xml_flag = 'Y') THEN
838 IF (DocumentTypeCode = 'RELEASE') THEN
839 UPDATE po_releases_all
840 SET xml_flag = 'Y',
841 edi_processed_flag = 'N'
842 WHERE po_release_id = DocumentID;
843 ELSE
844 UPDATE po_headers_all
845 SET xml_flag = 'Y',
846 edi_processed_flag = 'N'
847 WHERE po_header_id = DocumentID;
848 END IF;
849 ELSIF (p_xml_flag = 'N') THEN
850 IF (DocumentTypeCode = 'RELEASE') THEN
851 UPDATE po_releases_all SET xml_flag = 'N' WHERE po_release_id = DocumentID;
852 ELSE
853 UPDATE po_headers_all SET xml_flag = 'N' WHERE po_header_id = DocumentID;
854 END IF;
855 END IF; -- p_xml_flag = 'Y'
856 END IF; -- p_xml_flag IS NOT NULL
857 -- Bug 5218538 END
858 --<DropShip FPJ Start>
859 --commit only when background flag is not N.
860 --Default value is N which will commit to retain behavior of current callers.
861 --background flag is passed as 'Y' when called from OM for Drop Ship FPJ, commit not done
862 /*Mod Project */
863 IF DocumentTypeCode = 'PO' OR DocumentTypeCode = 'PA' THEN
864 IF DraftId <> -1 THEN
865 -- PAR Project : Approval
866 SELECT draft_type
867 INTO l_draft_type
868 FROM po_drafts
869 WHERE draft_id = DraftID;
870 ELSE
871 l_draft_type := NULL;
872 END IF;
873
874 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: draft Type : ' || l_draft_type;
875 IF (g_po_wf_debug = 'Y') THEN
876 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
877 END IF;
878
879 -- Made changes for PO AME commercial project.
880 IF l_draft_type IS NULL THEN --l_is_mod = 'N' THEN
881 -- When the document is resubmitted after it is rejected
882 -- we assign a new ame_approval_id
883 SELECT decode(authorization_status,
884 'REJECTED', 0,
885 ame_approval_id),
886 ame_transaction_type
887 INTO l_ame_approval_id,
888 l_ame_transaction_type
889 FROM po_headers_all
890 WHERE po_header_id = DocumentID;
891
892 if l_ame_transaction_type is not null AND ( l_ame_approval_id IS NULL or l_ame_approval_id = 0) THEN
893 --if l_ame_approval_id = 0 then
894 select po_ame_approvals_s.nextval into l_ame_approval_id from dual;
895 update po_headers_all
896 set ame_approval_id = l_ame_approval_id,
897 ame_transaction_type = l_ame_transaction_type
898 where po_header_id = DocumentID;
899 end if;
900
901 ELSIF l_draft_type IN ('PAR', 'MOD') THEN
902
903 SELECT decode(pd.status,
904 'REJECTED', 0,
905 phda.ame_approval_id),
906 phda.ame_transaction_type
907 INTO l_ame_approval_id,
908 l_ame_transaction_type
909 FROM po_headers_draft_all phda,
910 po_drafts pd
911 WHERE phda.po_header_id = DocumentID
912 AND phda.draft_id = DraftID
913 AND phda.draft_id = pd.draft_id;
914
915 if l_ame_approval_id = 0 then
916 select po_ame_approvals_s.nextval into l_ame_approval_id from dual;
917 update po_headers_draft_all
918 set ame_approval_id = l_ame_approval_id
919 where po_header_id = DocumentID
920 and draft_id = DraftID;
921 end if;
922
923 END IF;
924
925 END IF;
926 /*Mod Project */
927 IF p_Background_Flag <> 'Y' THEN
928 COMMIT;
929 END IF;
930 --<DropShip FPJ End>
931 IF x_wf_created = 0 THEN
932 wf_engine.CreateProcess( ItemType => l_itemtype, ItemKey => l_itemkey, process => l_workflow_process );
933 END IF;
934 --
935 -- Initialize workflow item attributes
936 --
937 /* get the profile option value for the second Email Address */
938 FND_PROFILE.GET('PO_SECONDRY_EMAIL_ADD', EmailAddProfile);
939 IF NVL(ActionOriginatedFrom, 'Approval') = 'POS_DATE_CHG' THEN
940 -- Mod Project
941 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'WEB_SUPPLIER_REQUEST', avalue => 'Y');
942 END IF;
943
944 -- Multi-Mod changes
945 -- Get changed vendor names from modification.
946 IF ActionOriginatedFrom = 'MULTI_MOD' THEN
947
948 SELECT pov.vendor_name, pvs.vendor_site_code
949 INTO l_vendor, l_vendor_site_code
950 FROM po_vendors pov,
951 po_headers poh,
952 po_vendor_sites_all pvs
953 WHERE pov.vendor_id = poh.vendor_id
954 AND poh.po_header_id = DocumentId
955 AND poh.vendor_site_id = pvs.vendor_site_id;
956
957
958 SELECT MULTI_MOD_REQUEST_ID
959 INTO l_multi_mod_req_id
960 FROM PO_MULTI_MOD_DOCS
961 WHERE DRAFT_ID = DraftID;
962
963 SELECT MULTI_MOD_REQUEST_TYPE
964 INTO l_multi_mod_req_type
965 FROM PO_MULTI_MOD_REQUESTS
966 WHERE MULTI_MOD_REQUEST_ID = l_multi_mod_req_id;
967
968 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'APPROVAL_SOURCE', avalue => ActionOriginatedFrom);
969
970 IF l_multi_mod_req_type = 'VENDOR_CHANGE' THEN
971
972 SELECT pv.vendor_name, pvs.vendor_site_code
973 INTO l_new_vendor, l_new_vendor_site_code
974 FROM po_headers_draft_all phda,
975 po_vendors pv,
976 po_vendor_sites_all pvs
977 WHERE draft_id = DraftID
978 AND phda.vendor_id = pv.vendor_id
979 AND phda.vendor_site_id = pvs.vendor_site_id;
980
981 l_supplier_change_note := '(Note: Supplier has changed from ' || l_vendor || ' to ' || l_new_vendor || ')';
982 l_supplier_site_change_note := '(Note: Supplier site has changed from ' || l_vendor_site_code || ' to ' || l_new_vendor_site_code || ')';
983
984 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SUPPLIER_CHANGE_NOTE', avalue => l_supplier_change_note);
985 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SUPPLIER_SITE_CHANGE_NOTE', avalue => l_supplier_site_change_note);
986
987 --set link to validation details page
988 l_validation_details_url := 'OA.jsp?page=/oracle/apps/po/document/common/webui/MultiModValidationDetailsPG&MultiModRequestId=' || l_multi_mod_req_id || '&poHeaderId=' || DocumentID || '&retainAM=Y&addBreadCrumb=Y';
989 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'VALIDATION_DETAILS_URL', avalue => l_validation_details_url);
990
991 END IF;
992 END IF;
993
994 --< Bug 3631960 Start >
995 /* bug 4621626 : passing ActionOriginatedFrom to INTERFACE_SOURCE_CODE,
996 instead of NULL in case of CANCEL, will use the same in the workflow
997 to skip the PO_APPROVED notification ,when wf is called from cancel.
998 */
999 x_progress := 'start wf process called interface source code:'||ActionOriginatedFrom;
1000 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
1001 IF (ActionOriginatedFrom = 'CANCEL') THEN
1002 -- If approval workflow is being called from a Cancel action, then
1003 -- do not insert into action history.
1004 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'INSERT_ACTION_HIST_FLAG' , avalue => 'N' );
1005 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'INTERFACE_SOURCE_CODE' , avalue => ActionOriginatedFrom );
1006 -- Bug 5701051 We should always bypass the approval hierarchy
1007 -- for a Cancel action, since the approval workflow is only being
1008 -- invoked for communication and archival purposes.
1009 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'BYPASS_APPROVAL_HIERARCHY_FLAG' , avalue => 'Y' );
1010 ELSE
1011 -- All other cases, we need to insert into action history.
1012 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'INSERT_ACTION_HIST_FLAG' , avalue => 'Y' );
1013 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'INTERFACE_SOURCE_CODE' , avalue => ActionOriginatedFrom );
1014 -- Bug 5701051 We do not need to bypass the approval hierarchy
1015 -- for other actions.
1016 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'BYPASS_APPROVAL_HIERARCHY_FLAG' , avalue => 'N' );
1017 END IF; --< if ActionOriginatedFrom ... >
1018 --< Bug 3631960 End >
1019 IF (p_Initiator IS NOT NULL) THEN
1020 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype , itemkey => l_itemkey , aname => 'INITIATOR' , avalue => p_Initiator );
1021 END IF;
1022 --
1023 x_progress := 'Document_ID:'||DocumentID||'Document_Type :'|| DocumentTypeCode||'Document_Subtype :'||DocumentSubtype||'AmeTransactionType: '||l_ame_transaction_type;
1024 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
1025 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_ID', avalue => DocumentID);
1026 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_TYPE', avalue => DocumentTypeCode);
1027 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_SUBTYPE', avalue => DocumentSubtype);
1028 --<POC FPJ>
1029 g_document_subtype := DocumentSubtype;
1030 -- Mod Project
1031 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'AME_TRANSACTION_ID', avalue => l_ame_approval_id);
1032 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DRAFT_ID', avalue => DraftID);
1033 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'AME_TRANSACTION_TYPE', avalue => l_ame_transaction_type);
1034 -- Mod Project
1035 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PREPARER_ID', avalue => PreparerID);
1036 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FORWARD_TO_ID', avalue => ForwardToID);
1037 -- PAR Project : Approval - Stamp DRAFT TYPE
1038 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DRAFT_TYPE', avalue => l_draft_type);
1039 --
1040 /* PO AME Approval Changes : Setting workflow attributes ame_transaction_id and ame_transaction_type. */
1041 -- Start :
1042 IF (DocumentTypeCode = 'PO' OR DocumentTypeCode = 'PA') AND l_ame_transaction_type is not NULL THEN
1043 x_progress := 'PO_REQAPPROVAL_INIT1.setting notifictaion regions ' ;
1044
1045 IF (g_po_wf_debug = 'Y') THEN
1046 /* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
1047 END IF;
1048
1049 po_wf_util_pkg.setitemattrtext ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'NOTIFICATION_REGION', avalue => 'JSP:/OA_HTML/OA.jsp?OAFunc=PO_APPRV_NOTIF&poHeaderId=' || DocumentID);
1050 po_wf_util_pkg.setitemattrtext ( itemtype => l_itemtype, itemkey => l_itemkey, aname => '#HISTORY', avalue => 'JSP:/OA_HTML/OA.jsp?OAFunc=PO_APPRV_NTF_ACTION_DETAILS&poHeaderId=' || DocumentID || '&showActions=Y');
1051 po_wf_util_pkg.setitemattrtext(itemtype => l_itemtype, itemkey => l_itemkey, aname => '#HISTORY_SUPP', avalue => 'JSP:/OA_HTML/OA.jsp?OAFunc=PO_APPRV_NTF_ACTION_DETAILS&poHeaderId=' || DocumentID || '&showActions=N');
1052
1053 END IF;
1054 -- END PO AME Approval Changes
1055
1056
1057 /* Bug# 2308846: kagarwal
1058 ** Description: The forward from user was always set to the preparer
1059 ** in the Approval process. Hence if the forward from user was
1060 ** different from the preparer, the forward from was showing
1061 ** wrong information.
1062 **
1063 ** Fix Details: Modified the procedure Start_WF_Process() and
1064 ** Set_Startup_Values() to set the forward from attributes
1065 ** correctly.
1066 */
1067 IF (forwardFromID IS NOT NULL) THEN
1068 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FORWARD_FROM_ID', avalue => forwardFromID);
1069 ELSE
1070 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FORWARD_FROM_ID', avalue => forwardFromID);
1071 END IF;
1072 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'APPROVAL_PATH_ID', avalue => DefaultApprovalPathID);
1073 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'NOTE', avalue => Note);
1074 --Mod Project
1075 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PRINT_DOCUMENT', avalue => PrintFlag);
1076 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'JUSTIFICATION', avalue => Note);
1077 IF (DocumentTypeCode = 'REQUISITION') THEN
1078 SELECT PRH.segment1
1079 INTO l_document_number
1080 FROM po_requisition_headers PRH
1081 WHERE PRH.requisition_header_id = DocumentID;
1082 BEGIN
1083 wf_engine.SetItemUserKey(itemtype => l_itemtype, itemkey => l_itemkey, userkey => l_document_number);
1084 EXCEPTION
1085 WHEN OTHERS THEN
1086 NULL;
1087 END;
1088 END IF;
1089 -- end if;
1090 -- DKC 10/13/99
1091 IF DocumentTypeCode IN ('PO', 'PA', 'RELEASE') THEN
1092 /*Document Numbering Start*/
1093 -- CLM bug 9663554 - Handling the exception.
1094 --Start of code changes as part of bug 15989068 fix
1095 IF DocumentTypeCode IN ('PO', 'PA') THEN
1096 BEGIN
1097 SELECT clm_document_number
1098 INTO l_clm_document_number
1099 FROM po_headers_all
1100 WHERE po_header_id = DocumentID;
1101 EXCEPTION
1102 WHEN no_data_found THEN
1103 l_clm_document_number := NULL;
1104 END;
1105 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CLM_DOCUMENT_NUMBER', avalue => l_clm_document_number);
1106 IF DraftID <> -1 THEN
1107 BEGIN
1108 SELECT modification_number
1109 INTO l_modification_number
1110 FROM po_drafts
1111 WHERE draft_id = DraftID;
1112 EXCEPTION
1113 WHEN no_data_found THEN
1114 l_modification_number := NULL;
1115 END;
1116 END IF;
1117 END IF; -- DocumentTypeCode IN ('PO', 'PA') if condition
1118 --END of code changes as part of bug 15989068 fix
1119
1120 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,'l_modification_number: '||l_modification_number);
1121 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'MODIFICATION_NUMBER', avalue => l_modification_number);
1122 /*Document Numbering End*/
1123 /* Bug6708182 FPDS-NG ER. */
1124 /* Bug 6708182 Start */
1125 IF DocumentTypeCode IN ('PO', 'RELEASE') THEN
1126 --Mod Project
1127 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FPDSNG_FLAG', avalue => FpdsngFlag);
1128 -- end if;
1129 END IF;
1130 /* Bug 6708182 End */
1131 IF DocumentTypeCode <> 'RELEASE' THEN
1132 SELECT poh.acceptance_required_flag,
1133 poh.acceptance_due_date,
1134 poh.agent_id
1135 INTO x_acceptance_required_flag,
1136 x_acceptance_due_date,
1137 x_agent_id
1138 FROM po_headers poh
1139 WHERE poh.po_header_id = DocumentID;
1140 ELSE
1141 SELECT por.acceptance_required_flag,
1142 por.acceptance_due_date,
1143 por.agent_id
1144 INTO x_acceptance_required_flag,
1145 x_acceptance_due_date,
1146 x_agent_id
1147 FROM po_releases por,
1148 po_headers_all poh -- <R12 MOAC>
1149 WHERE por.po_release_id = DocumentID
1150 AND por.po_header_id = poh.po_header_id;
1151 END IF;
1152 --Mod Project
1153 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'ACCEPTANCE_REQUIRED', avalue => x_acceptance_required_flag);
1154 PO_WF_UTIL_PKG.SetItemAttrDate ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'ACCEPTANCE_DUE_DATE', avalue => x_acceptance_due_date);
1155 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'BUYER_EMPLOYEE_ID', avalue => x_agent_id); /*bug 11713924-buyer user id was set with the agent id(employee_id). Modified to set the buyer_employee_id*/
1156
1157 /*
1158 Bug 14078118
1159 Added setItemAttrNumber() for 'BUYER_USER_ID' to be used later in PO_Mass_Update_PO_PVT.
1160 */
1161 BEGIN
1162 select user_id
1163 into emp_user_id
1164 from fnd_user
1165 where employee_id = x_agent_id
1166 and rownum = 1
1167 and sysdate < nvl(end_date, sysdate + 1);
1168 EXCEPTION
1169 WHEN OTHERS THEN
1170 null;
1171 END;
1172 PO_WF_UTIL_PKG.SetItemAttrNumber( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'BUYER_USER_ID', avalue => emp_user_id);
1173
1174
1175 IF (DocumentTypeCode IN ('PO', 'PA')) THEN
1176 /* FPI GA Start */
1177 -- <GC FPJ>
1178 -- Pass ga flag to the wf for all PA documents (BLANKET and CONTRACT)
1179 IF DocumentTypeCode = 'PA' THEN
1180 SELECT global_agreement_flag
1181 INTO l_ga_flag
1182 FROM po_headers_all
1183 WHERE po_header_id = DocumentID;
1184
1185 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'GLOBAL_AGREEMENT_FLAG', avalue => l_ga_flag);
1186 END IF;
1187 /* FPI GA End */
1188 /* bug 2115200 */
1189 /* Added logic to derive the doc display name */
1190 --CONTERMS FPJ Extracting Contract Terms value in this Query as well
1191 IF l_is_mod = 'N' THEN -- Mod Project
1192 SELECT revision_num,
1193 DECODE(TYPE_LOOKUP_CODE, 'BLANKET',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_BLKT'),
1194 'CONTRACT',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_CNTR'),
1195 'STANDARD',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_STD'),
1196 'PLANNED',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_PLND')),
1197 NVL(CONTERMS_EXIST_FLAG,'N'), --<CONTERMS FPJ>
1198 segment1 -- Bug 3284628
1199 INTO l_revision_num,
1200 l_doc_display_name,
1201 l_conterms_exist_flag, --<CONTERMS FPJ>
1202 l_document_number -- Bug 3284628
1203 FROM po_headers
1204 WHERE po_header_id = DocumentID;
1205 ELSE -- Mod Project
1206 SELECT 0,
1207 FND_MESSAGE.GET_STRING('PO','PO_MODIFICATION'),
1208 NVL(CONTERMS_EXIST_FLAG,'N'),
1209 segment1
1210 INTO l_revision_num,
1211 l_doc_display_name,
1212 l_conterms_exist_flag,
1213 l_document_number
1214 FROM po_headers_draft_all
1215 WHERE po_header_id = DocumentID
1216 AND draft_id = DraftId;
1217 END IF; -- l_is_mod = 'N' then
1218 l_doc_num_rel := l_document_number;
1219 --<CONTERMS FPJ Start>
1220 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CONTERMS_EXIST_FLAG', avalue => l_conterms_exist_flag);
1221 --<CONTERMS FPJ END>
1222 /* FPI GA Start */
1223 IF l_ga_flag = 'Y' AND l_draft_type IS NULL --l_is_mod = 'N' -- Mod Project
1224 THEN
1225 l_doc_display_name := FND_MESSAGE.GET_STRING('PO','PO_GA_TYPE');
1226 END IF;
1227 /* FPI GA End */
1228 elsif (DocumentTypeCode = 'RELEASE') THEN
1229 -- Bug 3859714. Workflow attribute WITH_TERMS should be set to 'N' for
1230 -- a Release because a release will not have Terms.
1231 l_conterms_exist_flag := 'N';
1232 /* bug 2115200 */
1233 SELECT POR.revision_num,
1234 POR.release_num,
1235 DECODE(POR.release_type, 'BLANKET', FND_MESSAGE.GET_STRING('POS','POS_POTYPE_BLKTR'), 'SCHEDULED',FND_MESSAGE.GET_STRING('POS','POS_POTYPE_PLNDR')),
1236 POH.segment1 -- Bug 3284628
1237 INTO l_revision_num,
1238 l_release_num,
1239 l_doc_display_name,
1240 l_document_number -- Bug 3284628
1241 FROM po_releases POR,
1242 po_headers_all POH -- <R12 MOAC>
1243 WHERE POR.po_release_id = DocumentID
1244 AND POR.po_header_id = POH.po_header_id; -- JOIN
1245 l_doc_num_rel := l_document_number || '-' || l_release_num;
1246 END IF; -- DocumentTypeCode
1247 -- Bug 3284628 END
1248 /* Bug# 2474660: kagarwal
1249 ** Desc: Setting the item user key for all documents.
1250 ** The item user key will be the document number for PO/PA/Requisitions
1251 ** and BPA Number - Release Num for releases.
1252 */
1253 IF (DocumentTypeCode = 'RELEASE') THEN
1254 l_userkey := l_doc_num_rel;
1255 ELSE
1256 l_userkey := l_document_number; -- Bug 3284628
1257 END IF;
1258 BEGIN
1259 wf_engine.SetItemUserKey(itemtype => l_itemtype, itemkey => l_itemkey, userkey => l_userkey);
1260 EXCEPTION
1261 WHEN OTHERS THEN
1262 NULL;
1263 END;
1264 -- bug4176111
1265 -- The default of communicate price change should be 'Y' for Standard PO
1266 -- /Releases, and 'N' for everything else
1267 l_communicatePriceChange := CommunicatePriceChange;
1268 IF (l_CommunicatePriceChange IS NULL) THEN
1269 IF (DocumentTypeCode ='RELEASE' AND DocumentSubtype='BLANKET') OR (DocumentTypeCode='PO' AND DocumentSubtype='STANDARD') THEN
1270 l_communicatePriceChange := 'Y';
1271 ELSE
1272 l_communicatePriceChange := 'N';
1273 END IF;
1274 END IF;
1275
1276 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_NUMBER', avalue => l_document_number);
1277 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_NUM_REL', avalue => l_doc_num_rel);
1278 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'REVISION_NUMBER', avalue => l_revision_num);
1279 PO_WF_UTIL_PKG.SetItemAttrNumber (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PO_REVISION_NUM', avalue => l_revision_num);
1280 IF (DocumentTypeCode = 'PA' AND DocumentSubtype IN ('BLANKET','CONTRACT')) OR (DocumentTypeCode = 'PO' AND DocumentSubtype = 'STANDARD') THEN
1281 l_doc_display_name := PO_DOC_STYLE_PVT.GET_STYLE_DISPLAY_NAME(DocumentID);
1282 END IF;
1283 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DOCUMENT_DISPLAY_NAME', avalue => l_doc_display_name);
1284 IF x_agent_id IS NOT NULL THEN
1285 x_progress := '003';
1286 -- Get the buyer user name
1287 WF_DIRECTORY.GetUserName( 'PER', x_agent_id, x_buyer_username, x_buyer_display_name);
1288 x_progress := '004';
1289 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'BUYER_USER_NAME', avalue => x_buyer_username);
1290 END IF;
1291 -- CLM KO signature ER
1292 -- CLM Controls Project changes
1293 if DocumentTypeCode = 'PA' or DocumentTypeCode='PO' then
1294 SELECT org_id
1295 INTO l_org_id
1296 FROM po_headers_all
1297 WHERE po_header_id = DocumentID;
1298 l_ko_sign_required := PO_CORE_S.retrieveOptionValue(p_org_id => l_org_id,
1299 p_option_column => PO_CORE_S.g_KO_SIGNATURE_REQD_COL);
1300 --NVL(FND_PROFILE.VALUE('PO_CLM_KO_SIGNATURE_REQD'),'N');
1301 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'KO_SIGNATURE_PROFILE', avalue => l_ko_sign_required);
1302 end if;
1303 IF DraftID = -1 THEN
1304 BEGIN
1305 SELECT CLM_CONTRACT_OFFICER
1306 INTO l_clm_contract_officer
1307 FROM po_headers_all
1308 WHERE po_header_id = DocumentID;
1309
1310 EXCEPTION
1311 WHEN no_data_found THEN
1312 l_clm_contract_officer := null;
1313 END;
1314 ELSE
1315 BEGIN
1316 SELECT CLM_CONTRACT_OFFICER
1317 INTO l_clm_contract_officer
1318 FROM po_drafts
1319 WHERE draft_id = DraftID;
1320
1321 EXCEPTION
1322 WHEN no_data_found THEN
1323 l_clm_contract_officer := null;
1324 END;
1325 END IF;
1326
1327 IF l_clm_contract_officer IS NOT NULL THEN
1328 -- Get the KO user name
1329 WF_DIRECTORY.GetUserName( 'PER', l_clm_contract_officer, x_ko_username, x_ko_display_name);
1330 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'KO_USER_NAME', avalue => x_ko_username);
1331 END IF;
1332 --DKC 10/10/99
1333 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FAX_DOCUMENT', avalue => FaxFlag);
1334 --DKC 10/10/99
1335 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FAX_NUMBER', avalue => FaxNumber);
1336 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'EMAIL_DOCUMENT', avalue => EmailFlag);
1337 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'EMAIL_ADDRESS', avalue => EmailAddress);
1338 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'EMAIL_ADD_FROM_PROFILE', avalue => EmailAddProfile);
1339 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CREATE_SOURCING_RULE', avalue => createsourcingrule);
1340 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'UPDATE_SOURCING_RULE', avalue => updatesourcingrule);
1341 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'RELEASE_GENERATION_METHOD', avalue => ReleaseGenMethod);
1342 /* RETROACTIVE FPI START */
1343 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'MASSUPDATE_RELEASES', avalue => MassUpdateReleases);
1344 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CO_R_RETRO_CHANGE', avalue => RetroactivePriceChange);
1345 /* RETROACTIVE FPI END */
1346 /* GA FPI start */
1347 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'GA_ORG_ASSIGN_CHANGE', avalue => OrgAssignChange);
1348 /* GA FPI End */
1349 -- <FPJ Retroactive START>
1350 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CO_H_RETROACTIVE_SUPPLIER_COMM', avalue => l_communicatePriceChange); -- bug4176111
1351 -- <FPJ Retroactive END>
1352 --<DropShip FPJ Start>
1353 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => l_itemtype, itemkey => l_itemkey, aname => 'BACKGROUND_FLAG', avalue => p_background_flag);
1354 -- l_drop_ship_flag indicates if current Release/PO has any DropShip Shipments
1355 BEGIN
1356 l_drop_ship_flag := 'N';
1357 IF DocumentTypeCode = 'RELEASE' THEN
1358 SELECT 'Y'
1359 INTO l_drop_ship_flag
1360 FROM dual
1361 WHERE EXISTS
1362 (SELECT 'Release DropShip Shipment Exists'
1363 FROM po_line_locations
1364 WHERE po_release_id = DocumentId
1365 AND drop_ship_flag = 'Y'
1366 );
1367 ELSIF DocumentTypeCode = 'PO' THEN
1368 SELECT 'Y'
1369 INTO l_drop_ship_flag
1370 FROM dual
1371 WHERE EXISTS
1372 (SELECT 'PO DropShip Shipment Exists'
1373 FROM po_line_locations
1374 WHERE po_header_id = DocumentId
1375 AND drop_ship_flag = 'Y'
1376 );
1377 END IF;
1378 EXCEPTION
1379 WHEN NO_DATA_FOUND THEN
1380 l_drop_ship_flag := 'N';
1381 END;
1382 -- Workflow Attribute DROP_SHIP_FLAG added for any customizations to refer to it.
1383 -- Base Purchasing code does NOT refer to DROP_SHIP_FLAG attribute
1384 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => l_itemtype, itemkey => l_itemkey, aname => 'DROP_SHIP_FLAG', avalue => l_drop_ship_flag);
1385 --<DropShip FPJ End>
1386 -- Bug 3318625 START
1387 -- Set the autoapprove attribute for retroactively priced consumption
1388 -- advices so that they are always routed through change order skipping
1389 -- the authority checks
1390 BEGIN
1391 l_consigned_flag := 'N';
1392 IF DocumentTypeCode = 'RELEASE' THEN
1393 SELECT NVL(consigned_consumption_flag, 'N') -- Bug 3318625
1394 INTO l_consigned_flag
1395 FROM po_releases_all
1396 WHERE po_release_id = DocumentId;
1397 ELSIF DocumentTypeCode = 'PO' THEN
1398 SELECT NVL(consigned_consumption_flag, 'N')
1399 INTO l_consigned_flag
1400 FROM po_headers_all
1401 WHERE po_header_id = DocumentId;
1402 END IF;
1403 EXCEPTION
1404 WHEN NO_DATA_FOUND THEN
1405 l_consigned_flag := 'N';
1406 END;
1407 IF l_consigned_flag = 'Y' THEN
1408 l_autoapprove_retro := 'Y';
1409 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CO_H_RETROACTIVE_AUTOAPPROVAL', avalue => l_autoapprove_retro);
1410 END IF;
1411 -- Bug 3318625 END
1412 -- end if; --Mod Project
1413 /* Get the multi-org context and store it in item attribute ORG_ID. This will be
1414 ** By all other activities.
1415 */
1416 PO_REQAPPROVAL_INIT1.get_multiorg_context (DocumentTypeCode, DocumentID, x_orgid);
1417 IF x_orgid IS NOT NULL THEN
1418 PO_MOAC_UTILS_PVT.set_org_context(x_orgid) ; -- <R12 MOAC>
1419 /* Set the Org_id item attribute. We will use it to get the context for every activity */
1420 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'ORG_ID', avalue => x_orgid);
1421 END IF;
1422 -- DKC 02/06/01
1423 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PO_EMAIL_HEADER', avalue => 'PLSQL:PO_EMAIL_GENERATE.GENERATE_HEADER/'|| l_itemtype || ':' || l_itemkey);--<BUG 9858430 Passing Itemtype and itemkey>
1424 -- DKC 02/06/01
1425 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PO_EMAIL_BODY', avalue => 'PLSQLCLOB:PO_EMAIL_GENERATE.GENERATE_HTML/'|| l_itemtype || ':' || l_itemkey);--<BUG 9858430 Passing Itemtype and itemkey>
1426 /* set the terms and conditions read from a file */
1427 --EMAILPO FPH--
1428 -- GENERATE_TERMS is changed to take itemtype and itemkey instead of DocumentID and DocumentTypeCode
1429 -- as itemtype and itemkey are necessary for retrieving the profile options
1430 -- Upgrade related issues are handled in PO_EMAIL_GENERATE.GENERATE_TERMS procedure
1431 /* Bug 2687751. When we refactored start_wf_process, we defaulted
1432 * item type and item key and changed all the occurences of
1433 * itemkey to use local variable l_itemkey. This was left out in the
1434 * SetItemAttrText for PO_TERMS_CONDITIONS. Changing this as part
1435 * of bug 2687751.
1436 */
1437 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PO_TERMS_CONDITIONS', avalue => 'PLSQLCLOB:PO_EMAIL_GENERATE.GENERATE_TERMS/'|| l_itemtype || ':' || l_itemkey);
1438 -- Bug 3284628 START
1439 -- end if; --Mod Project
1440 ELSIF (DocumentTypeCode = 'REQUISITION') THEN
1441 --CLM PR Amendment
1442 SELECT PRH.segment1,
1443 PRH.federal_flag,
1444 PRH.revision_num,
1445 PRH.conformed_header_id
1446 INTO l_document_number,
1447 l_federal_flag,
1448 l_revision_num,
1449 l_conformed_header_id
1450 FROM po_requisition_headers PRH
1451 WHERE PRH.requisition_header_id = DocumentID;
1452
1453 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'FEDERAL_FLAG', avalue => l_federal_flag);
1454 IF(l_revision_num IS NOT NULL) THEN
1455 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'IS_AMENDMENT_APPROVAL', avalue => 'Y');
1456 ELSE
1457 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'IS_AMENDMENT_APPROVAL', avalue => 'N');
1458 END IF;
1459 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'CONFORMED_HEADER_ID', avalue => l_conformed_header_id);
1460 PO_WF_UTIL_PKG.SetItemAttrNumber (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'REVISION_NUM', avalue => l_revision_num);
1461 END IF;
1462 --<Bug 4254468 Start> Need to show supplier and operating unit in
1463 -- PO Approval notifications
1464 BEGIN
1465 IF DocumentTypeCode <> 'RELEASE' THEN
1466 SELECT pov.vendor_name,
1467 pvs.vendor_site_code
1468 INTO l_vendor,
1469 l_vendor_site_code
1470 FROM po_vendors pov,
1471 po_headers poh,
1472 po_vendor_sites_all pvs
1473 WHERE pov.vendor_id = poh.vendor_id
1474 AND poh.po_header_id = DocumentId
1475 AND poh.vendor_site_id = pvs.vendor_site_id;
1476 ELSE
1477 SELECT pov.vendor_name,
1478 pvs.vendor_site_code
1479 INTO l_vendor,
1480 l_vendor_site_code
1481 FROM po_releases por,
1482 po_headers poh,
1483 po_vendors pov,
1484 po_vendor_sites_all pvs
1485 WHERE por.po_release_id = DocumentId
1486 AND por.po_header_id = poh.po_header_id
1487 AND poh.vendor_id = pov.vendor_id
1488 AND poh.vendor_site_id = pvs.vendor_site_id;
1489 END IF;
1490 EXCEPTION
1491 WHEN OTHERS THEN
1492 --In case of any exception, the supplier will show up as null
1493 NULL;
1494 END;
1495 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SUPPLIER', avalue => l_vendor);
1496 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SUPPLIER_SITE', avalue => l_vendor_site_code);
1497 --Brought the following code out of POC FPJ block
1498 --Need to display the Legal Entity Name on the Notification Subject
1499 IF x_orgid IS NOT NULL THEN
1500 --bug#3682458 replaced the sql that retrieves legal entity
1501 --name with sql that retrieves operating unit name
1502 BEGIN
1503 SELECT hou.name
1504 INTO l_operating_unit
1505 FROM hr_organization_units hou
1506 WHERE hou.organization_id = x_orgid;
1507 EXCEPTION
1508 WHEN OTHERS THEN
1509 l_operating_unit:=NULL;
1510 END;
1511 END IF;
1512 --bug#3682458 replaced legal_entity_name with operating_unit_name
1513 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => l_itemtype, itemkey => l_itemkey, aname => 'OPERATING_UNIT_NAME', avalue=>l_operating_unit);
1514 --<Bug 4254468 End>
1515 --<POC FPJ Start>
1516 --Bug#3528330 used the procedure po_communication_profile() to check for the
1517 --PO output format option instead of checking for the installation of
1518 --XDO product
1519 IF PO_COMMUNICATION_PVT.PO_COMMUNICATION_PROFILE = 'T'
1520 OR l_ame_transaction_type is not NULL THEN -- PO AME Project
1521 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'WITH_TERMS', avalue =>l_conterms_exist_flag);
1522 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'LANGUAGE_CODE', avalue =>userenv('LANG'));
1523 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => l_itemtype, itemkey => l_itemkey, aname => 'EMAIL_TEXT_WITH_PDF', avalue=>FND_MESSAGE.GET_STRING('PO','PO_PDF_EMAIL_TEXT'));
1524 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PO_PDF_ERROR', avalue=>FND_MESSAGE.GET_STRING('PO','PO_PDF_ERROR'));
1525 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PDF_ATTACHMENT_BUYER', avalue => 'PLSQLBLOB:PO_COMMUNICATION_PVT.PDF_ATTACH_APP/'|| l_itemtype||':'||l_itemkey);
1526 -- Bug 3851357. Replaced PDF_ATTACH_SUPP with PDF_ATTACH so that the procedure
1527 -- PO_COMMUNICATION_PKG.PDF_ATTACH is consistently called for all Approval PDF
1528 -- supplier notifications
1529 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PDF_ATTACHMENT_SUPP', avalue => 'PLSQLBLOB:PO_COMMUNICATION_PVT.PDF_ATTACH/'|| l_itemtype||':'||l_itemkey);
1530 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'PDF_ATTACHMENT', avalue => 'PLSQLBLOB:PO_COMMUNICATION_PVT.PDF_ATTACH/'||l_itemtype||':'||l_itemkey);
1531 -- <Start Word Integration 11.5.10+>
1532 -- <Set up okc doc attachmetn attribute, if necessary>
1533 IF (l_conterms_exist_flag = 'Y') THEN
1534 IF l_draft_type IS NULL THEN--l_is_mod = 'N' THEN -- Mod Project
1535 l_okc_doc_type := PO_CONTERMS_UTL_GRP.get_po_contract_doctype(DocumentSubtype);
1536 l_document_id_temp := DocumentID;
1537 ELSE
1538 l_okc_doc_type := PO_CONTERMS_UTL_GRP.get_po_contract_doctype_mod(DocumentSubtype);
1539 l_document_id_temp := DraftID;
1540 END IF;
1541 IF ( ('STRUCTURED' <> OKC_TERMS_UTIL_GRP.get_contract_source_code(p_document_type => l_okc_doc_type ,p_document_id => l_document_id_temp))
1542 AND ('N' = OKC_TERMS_UTIL_GRP.is_primary_terms_doc_mergeable(p_document_type => l_okc_doc_type ,p_document_id => l_document_id_temp)) )
1543 THEN--Mod Project
1544 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'OKC_DOC_ATTACHMENT', avalue => 'PLSQLBLOB:PO_COMMUNICATION_PVT.OKC_DOC_ATTACH/'|| l_itemtype||':'||l_itemkey);
1545 END IF; -- not structured and not mergeable
1546 -- <Start Contract Dev. Report 11.5.10+>: Set up attachments links region.
1547 -- create attchment with actual l revision number instead of -99
1548 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype,
1549 itemkey => l_itemkey,
1550 aname => 'PO_OKC_ATTACHMENTS',
1551 avalue => 'FND:entity=OKC_CONTRACT_DOCS' || '&' || 'pk1name=BusinessDocumentType' || '&' || 'pk1value=' ||
1552 DocumentTypeCode || '_' || DocumentSubtype || '&' || 'pk2name=BusinessDocumentId' || '&' || 'pk2value=' ||
1553 --DocumentID || '&' || 'pk3name=BusinessDocumentVersion' || --Mod Project
1554 l_document_id_temp || '&' || 'pk3name=BusinessDocumentVersion' || '&' || 'pk3value=' || '-99' || '&' || 'categories=OKC_REPO_CONTRACT,OKC_REPO_APP_ABSTRACT');
1555 -- <End Contract Dev. Report 11.5.10+>
1556 END IF; -- l_conterms_exist_flag = 'Y'
1557 -- <End Word Integration 11.5.10+>
1558 END IF;
1559 --<POC FPJ End>
1560 IF DocumentTypeCode = 'REQUISITION' AND p_source_type_code = 'INVENTORY' THEN
1561 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SOURCE_TYPE_CODE', avalue => p_source_type_code);
1562 END IF;
1563 -- R12 PO change Order tolerances ECO : 4716963
1564 -- Retrive the tolerances from the new PO tolerances table and
1565 -- set the corresponding workflow attributes if the values in
1566 -- the table are not null.
1567 IF DocumentTypeCode = 'PO' THEN
1568 PO_CHORD_WF6.Set_Wf_Order_Tol(l_itemtype, l_itemkey , DocumentSubtype);
1569 ELSIF DocumentTypeCode = 'PA' THEN
1570 PO_CHORD_WF6.Set_Wf_Agreement_Tol(l_itemtype, l_itemkey , DocumentSubtype);
1571 ELSIF DocumentTypeCode = 'RELEASE' THEN
1572 PO_CHORD_WF6.Set_Wf_Release_Tol(l_itemtype, l_itemkey , DocumentSubtype);
1573 END IF;
1574 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: Before call to FND_PROFILE';
1575 IF (g_po_wf_debug = 'Y') THEN
1576 PO_WF_DEBUG_PKG.insert_debug(l_itemtype,l_itemkey,x_progress);
1577 END IF;
1578 /* Get the USER_ID and the RESPONSIBLITY_ID for the current forms session.
1579 ** This will be used in later calls to APPS_INITIALIZE(), before calling
1580 ** the Document Manager.
1581 */
1582 IF (x_wf_created = 0) THEN
1583
1584 l_user_id := fnd_global.user_id;
1585 l_responsibility_id := fnd_global.resp_id;
1586 l_application_id := fnd_global.resp_appl_id;
1587
1588
1589 IF (l_user_id = -1) THEN
1590 l_user_id := NULL;
1591 END IF;
1592 IF (l_responsibility_id = -1) THEN
1593 l_responsibility_id := NULL;
1594 END IF;
1595 IF (l_application_id = -1) THEN
1596 l_application_id := NULL;
1597 END IF;
1598 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'USER_ID', avalue => l_user_id);
1599 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'APPLICATION_ID', avalue => l_application_id);
1600 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'RESPONSIBILITY_ID', avalue => l_responsibility_id);
1601 IF x_orgid IS NOT NULL THEN
1602 PO_MOAC_UTILS_PVT.set_org_context(x_orgid) ; -- <R12 MOAC>
1603 END IF;
1604 END IF;
1605 --<DropShip FPJ Start>
1606 -- When background flag is 'Y' the approval workflow blocks at a background activity
1607 -- set authorization_status to IN PROCESS so that the header is 'locked'
1608 -- while the workflow process is waiting for background engine to pick it up
1609 IF p_background_flag = 'Y' THEN
1610 IF DocumentTypeCode = 'RELEASE' THEN
1611 UPDATE po_releases
1612 SET AUTHORIZATION_STATUS = 'IN PROCESS',
1613 last_updated_by = fnd_global.user_id,
1614 last_update_login = fnd_global.login_id,
1615 last_update_date = sysdate
1616 WHERE po_release_id = DocumentID;
1617 ELSE --PO or PA
1618 IF l_draft_type IS NULL THEN--l_is_mod = 'N' THEN -- Mod Project
1619 UPDATE po_headers
1620 SET AUTHORIZATION_STATUS = 'IN PROCESS',
1621 last_updated_by = fnd_global.user_id,
1622 last_update_login = fnd_global.login_id,
1623 last_update_date = sysdate
1624 WHERE po_header_id = DocumentID;
1625 ELSE
1626 UPDATE po_drafts
1627 SET STATUS = 'IN PROCESS',
1628 last_updated_by = fnd_global.user_id,
1629 last_update_login = fnd_global.login_id,
1630 last_update_date = sysdate
1631 WHERE draft_id = DraftID;
1632 END IF; -- Mod project
1633 END IF;
1634 END IF; -- END of IF p_background_flag = 'Y'
1635 --<DropShip FPJ End>
1636
1637 /*Bug 11727653: BYPASSING MULTIPLE SUBMISSION CHECKS IN WORKFLOW. Setting the BYPASS_CHECKS_FLAG*/
1638 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => l_itemtype, itemkey => l_itemkey, aname => 'BYPASS_CHECKS_FLAG', avalue => p_bypass_checks_flag);
1639
1640 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: Before call to wf_engine.StartProcess()' || ' parameter DefaultApprovalPathID= ' || TO_CHAR(DefaultApprovalPathID);
1641 IF (g_po_wf_debug = 'Y') THEN
1642 PO_WF_DEBUG_PKG.insert_debug(itemtype,l_itemkey,x_progress);
1643 END IF;
1644 --
1645 wf_engine.StartProcess( itemtype => l_itemtype, itemkey => l_itemkey );
1646 END IF;
1647 EXCEPTION
1648 WHEN OTHERS THEN
1649 x_progress := 'PO_REQAPPROVAL_INIT1.Start_WF_Process: In Exception handler';
1650 IF (g_po_wf_debug = 'Y') THEN
1651 /* DEBUG */
1652 PO_WF_DEBUG_PKG.insert_debug(itemtype,l_itemkey,x_progress);
1653 END IF;
1654 po_message_s.sql_error('In Exception of Start_WF_Process()', x_progress, SQLCODE);
1655 RAISE;
1656 END Start_WF_Process;
1657 -- SetStartupValues
1658 -- Iinitialize/assigns startup values to workflow attributes.
1659 --
1660 -- IN
1661 -- itemtype, itemkey, actid, funcmode
1662 -- OUT
1663 -- Resultout
1664 -- - Completed - Activity was completed without any errors.
1665 --
1666 PROCEDURE Set_Startup_Values
1667 (
1668 itemtype IN VARCHAR2,
1669 itemkey IN VARCHAR2,
1670 actid IN NUMBER,
1671 funcmode IN VARCHAR2,
1672 resultout OUT NOCOPY VARCHAR2 )
1673 IS
1674 l_document_type VARCHAR2(25);
1675 l_doc_subtype VARCHAR2(25);
1676 l_document_id NUMBER;
1677 l_preparer_id NUMBER;
1678 x_username VARCHAR2(100);
1679 x_user_display_name VARCHAR2(240);
1680 x_ff_username VARCHAR2(100);
1681 x_ff_user_display_name VARCHAR2(240);
1682 x_ft_username VARCHAR2(100);
1683 x_ft_user_display_name VARCHAR2(240);
1684 l_forward_to_id NUMBER;
1685 l_forward_from_id NUMBER;
1686 l_authorization_status VARCHAR2(25);
1687 l_open_form VARCHAR2(200);
1688 l_update_req_url VARCHAR2(1000);
1689 l_open_req_url VARCHAR2(1000);
1690 l_resubmit_req_url VARCHAR2(1000); -- Bug 636924, lpo, 03/31/98
1691 --Bug#3147435
1692 --Variables for VIEW_REQ_DTLS_URL, EDIT_REQ_URL and RESUBMIT_REQ_URL
1693 l_view_req_dtls_url VARCHAR2(1000);
1694 l_edit_req_url VARCHAR2(1000);
1695 l_resubmit_url VARCHAR2(1000);
1696 l_error_msg VARCHAR2(200);
1697 x_orgid NUMBER;
1698 l_doc_string VARCHAR2(200);
1699 l_preparer_user_name VARCHAR2(100);
1700 l_po_revision NUMBER;
1701 l_interface_source VARCHAR2(30);
1702 l_can_modify_flag VARCHAR2(1);
1703 l_view_po_url VARCHAR2(1000); -- HTML Orders R12
1704 l_edit_po_url VARCHAR2(1000); -- HTML Orders R12
1705 l_style_id po_headers_all.style_id%TYPE;
1706 l_ga_flag po_headers_all.global_agreement_flag%TYPE;
1707 /* Bug 7535468
1708 Increasing the length of x_progress from 200 to 1200 */
1709 x_progress VARCHAR2(1200);
1710 l_draft_id NUMBER:=-1; --Mod Project
1711 --Context Setting Revamp
1712 l_printer VARCHAR2(30);
1713 l_conc_copies NUMBER;
1714 l_conc_save_output VARCHAR2(1);
1715 --Bug 6164753
1716 l_external_url VARCHAR2(500);
1717 --Added by Eric Ma for IL PO Notification on Apr-13,2009,Begin
1718 ---------------------------------------------------------------------------
1719 lv_tax_region VARCHAR2(30); --tax region code
1720 ---------------------------------------------------------------------------
1721 --Added by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1722 l_conf_header_id NUMBER;
1723 l_imp_amendment_url VARCHAR2(1000);
1724 is_clm_enabled VARCHAR2(1);
1725 l_review_msg varchar2(200); -- PO AME Project
1726
1727 BEGIN
1728 x_progress := 'PO_REQAPPROVAL_INIT1.Set_Startup_Values: 01';
1729 IF (g_po_wf_debug = 'Y') THEN
1730 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1731 END IF;
1732 -- Do nothing in cancel or timeout mode
1733 --
1734 IF (funcmode <> wf_engine.eng_run) THEN
1735 resultout := wf_engine.eng_null;
1736 RETURN;
1737 END IF;
1738 -- Set the multi-org context
1739 x_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
1740 IF x_orgid IS NOT NULL THEN
1741 PO_MOAC_UTILS_PVT.set_org_context(x_orgid) ; -- <R12 MOAC>
1742 END IF;
1743 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
1744 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
1745 l_doc_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
1746 -- CLM Apprvl
1747 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'DRAFT_ID');
1748 IF l_draft_id IS NULL THEN
1749 l_draft_id := -1;
1750 END IF;
1751 /* Since we are just starting the workflow assign the preparer_id to
1752 ** variable APPROVER_EMPID. This variable always holds the
1753 ** employee id of the approver i.e. activity VERIFY AUTHORITY will
1754 ** always use this employee id to verify authority against.
1755 ** If the preparer can not approve, then process FIND APPROVER will
1756 ** find an approver and put his/her employee_id in APPROVER_EMPID
1757 ** item attribute.
1758 */
1759 l_preparer_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_ID');
1760 /*7125551, including the sql to get the value of l_can_modify_flag here*/
1761 SELECT CAN_APPROVER_MODIFY_DOC_FLAG
1762 INTO l_can_modify_flag
1763 FROM po_document_types
1764 WHERE DOCUMENT_TYPE_CODE = l_document_type
1765 AND DOCUMENT_SUBTYPE = l_doc_subtype;
1766
1767 PO_WF_UTIL_PKG.SetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'APPROVER_EMPID', avalue => l_preparer_id);
1768 /* Get the username and display_name of the preparer. This will
1769 ** be used as the FORWARD-FROM in the notifications.
1770 ** Initially the preparer is also considered as the approver, so
1771 ** set the approver_username also.
1772 */
1773 PO_REQAPPROVAL_INIT1.get_user_name(l_preparer_id, x_username, x_user_display_name);
1774 -- Bug 711141 fix (setting process owner here)
1775 wf_engine.SetItemOwner (itemtype => itemtype, itemkey => itemkey,
1776 /* { Bug 2148872: owner => 'PER:' || l_preparer_id);
1777 wf_engine.SetItemOwner needs 'owner' parameter to be passed as
1778 the internal user name of the owner in wf_users. To pass it as
1779 "PER:person_id" has been disallowed by WF. */
1780 owner => x_username); -- Bug 2148872 }
1781 -- Context Setting revamp (begin)
1782 l_printer := fnd_profile.value('PRINTER');
1783 l_conc_copies := to_number(fnd_profile.value('CONC_COPIES'));
1784 l_conc_save_output := fnd_profile.value('CONC_SAVE_OUTPUT');
1785 /* changed the call from wf_engine.setiteattrtext to
1786 po_wf_util_pkg.setitemattrtext because the later handles
1787 attrbute not found exception. req change order wf also
1788 uses these procedures and does not have the preparer_printer
1789 attribute, hence this was required */
1790 po_wf_util_pkg.SetItemAttrText (itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_PRINTER', avalue => l_printer);
1791 po_wf_util_pkg.SetItemAttrNumber (itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_CONC_COPIES', avalue => l_conc_copies);
1792 po_wf_util_pkg.SetItemAttrText (itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_CONC_SAVE_OUTPUT', avalue => l_conc_save_output);
1793 --Context Setting revamp (end)
1794 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_USER_NAME' , avalue => x_username);
1795 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_DISPLAY_NAME' , avalue => x_user_display_name);
1796 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'APPROVER_USER_NAME' , avalue => x_username);
1797 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'APPROVER_DISPLAY_NAME' , avalue => x_user_display_name);
1798 /* Bug# 2308846: kagarwal
1799 ** Description: The forward from user was always set to the preparer
1800 ** in the Approval process. Hence if the forward from user was
1801 ** different from the preparer, the forward from was showing
1802 ** wrong information.
1803 **
1804 ** Fix Details: Modified the procedure Start_WF_Process() and
1805 ** Set_Startup_Values() to set the forward from attributes
1806 ** correctly.
1807 */
1808 l_forward_from_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'FORWARD_FROM_ID');
1809 IF (l_forward_from_id <> l_preparer_id) THEN
1810 PO_REQAPPROVAL_INIT1.get_user_name(l_forward_from_id, x_ff_username, x_ff_user_display_name);
1811 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_FROM_USER_NAME' , avalue => x_ff_username);
1812 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_FROM_DISP_NAME' , avalue => x_ff_user_display_name);
1813 ELSE
1814 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_FROM_USER_NAME' , avalue => x_username);
1815 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_FROM_DISP_NAME' , avalue => x_user_display_name);
1816 END IF;
1817 /* Get the username (this is the name used to forward the notification to)
1818 ** from the FORWARD_TO_ID. We need to do this here!
1819 ** Also set the item attribute FORWARD_TO_USERNAME to that username.
1820 */
1821 l_forward_to_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'FORWARD_TO_ID');
1822 IF l_forward_to_id IS NOT NULL THEN
1823 /* kagarwal: Use a diff variable for username and display name
1824 ** for forward to as later we set the responder attributes to same
1825 ** as that of preparer using the var x_username and
1826 ** x_user_display_name
1827 */
1828 /* Get the forward-to display name */
1829 PO_REQAPPROVAL_INIT1.get_user_name(l_forward_to_id, x_ft_username, x_ft_user_display_name);
1830 /* Set the forward-to display name */
1831 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_TO_USERNAME' , avalue => x_ft_username);
1832 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'FORWARD_TO_DISPLAY_NAME' , avalue => x_ft_user_display_name);
1833 END IF;
1834 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
1835 -------------------------------------------------------------------------------------
1836 lv_tax_region := JAI_PO_WF_UTIL_PUB.Get_Tax_Region (pn_org_id => x_orgid);
1837 -------------------------------------------------------------------------------------
1838 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1839 /* Bug 1064651
1840 ** Init RESPONDER to PREPARER if document is a requisition.
1841 */
1842 IF l_document_type = 'REQUISITION' THEN
1843 PO_WF_UTIL_PKG.SetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'RESPONDER_ID', avalue => l_preparer_id);
1844 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'RESPONDER_USER_NAME' , avalue => x_username);
1845 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'RESPONDER_DISPLAY_NAME' , avalue => x_user_display_name);
1846 /* Bug 3800933
1847 ** Need to set the preparer's language as worflow attribute for info template attachment of req approval
1848 */
1849 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_LANGUAGE', avalue => userenv('LANG'));
1850 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
1851 -------------------------------------------------------------------------------------
1852 IF lv_tax_region='JAI' THEN
1853 --open indian localization form
1854 l_open_form:=JAI_PO_WF_UTIL_PUB.Get_Jai_Open_Form_Command (pv_document_type => JAI_PO_WF_UTIL_PUB.G_REQ_DOC_TYPE);
1855 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'OPEN_FORM_COMMAND' , avalue => l_open_form );
1856 END IF;
1857 -------------------------------------------------------------------------------------
1858 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1859 END IF;
1860 -- Set the Command for the button that opens the Enter PO/Releases form
1861 -- Note: the Open Form command for the requisition is hard-coded in the
1862 -- Requisition approval workflow.
1863 IF l_document_type IN ('PO', 'PA') THEN
1864 -- <HTML Orders R12 Start >
1865 -- Set the URL and form link attributes based on doc style and type
1866 IF l_doc_subtype IN ('BLANKET', 'CONTRACT') THEN
1867 l_ga_flag := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'GLOBAL_AGREEMENT_FLAG');
1868 END IF;
1869 IF (NVL(l_ga_flag,'N') = 'N' AND (l_doc_subtype = 'BLANKET' OR l_doc_subtype = 'CONTRACT')) OR l_doc_subtype = 'PLANNED' THEN --added the condition to check for contract PO also as part of bug 7125551 fix
1870 -- HTML Orders R12
1871 -- The url links are not applicable for local agreements
1872 l_view_po_url := NULL;
1873 l_edit_po_url := NULL;
1874 -- Modified by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
1875 -------------------------------------------------------------------------------------
1876 IF (lv_tax_region='JAI' AND l_doc_subtype = 'PLANNED') THEN
1877 --open indian localization form
1878 l_open_form:=JAI_PO_WF_UTIL_PUB.Get_Jai_Open_Form_Command (pv_document_type => JAI_PO_WF_UTIL_PUB.G_PO_DOC_TYPE);
1879 ELSE
1880 --Bug 7716930
1881 --Bug8399676 Removed the double quotes around MODIFY and POXSTNOT
1882 l_open_form := 'PO_POXPOEPO:PO_HEADER_ID=' || '&' || 'DOCUMENT_ID' || ' ACCESS_LEVEL_CODE=MODIFY' || ' POXPOEPO_CALLING_FORM=POXSTNOT';
1883 END IF;
1884 -------------------------------------------------------------------------------------
1885 -- Modified by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1886 ELSIF NVL(l_ga_flag,'N') = 'Y' OR l_doc_subtype = 'STANDARD' THEN
1887 BEGIN
1888 SELECT style_id
1889 INTO l_style_id
1890 FROM po_headers_all
1891 WHERE po_header_id = l_document_id;
1892 EXCEPTION
1893 WHEN OTHERS THEN
1894 l_style_id := NULL;
1895 END;
1896 --CLM Apprvl
1897 IF l_draft_id IS NOT NULL AND l_draft_id <> -1 THEN
1898 l_view_po_url := get_mod_url(p_po_header_id => l_document_id, p_draft_id => l_draft_id, p_doc_subtype => l_doc_subtype, p_mode => 'viewOnly');
1899 ELSE
1900 l_view_po_url := get_po_url(p_po_header_id => l_document_id, p_doc_subtype => l_doc_subtype, p_mode => 'viewOnly');
1901 END IF;
1902 x_progress := 'PO_REQAPPROVAL_INIT1.get_po_url viewOnly' || 'l_view_po_url ::'|| l_view_po_url;
1903 IF (g_po_wf_debug = 'Y') THEN
1904 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1905 END IF;
1906 IF NVL(l_can_modify_flag,'N') = 'Y' THEN
1907 /*Bug 7125551, edit document link should not be available if approver can modify is
1908 unchecked for the document type.*/
1909 --CLM Apprvl
1910 IF l_draft_id IS NOT NULL AND l_draft_id <> -1 THEN
1911 l_edit_po_url := get_mod_url(p_po_header_id => l_document_id,p_draft_id => l_draft_id, p_doc_subtype => l_doc_subtype, p_mode => 'update');
1912 ELSE
1913 l_edit_po_url := get_po_url(p_po_header_id => l_document_id, p_doc_subtype => l_doc_subtype, p_mode => 'update');
1914 END IF;
1915 x_progress := 'PO_REQAPPROVAL_INIT1.get_po_url update' || 'l_edit_po_url ::'|| l_edit_po_url;
1916 IF (g_po_wf_debug = 'Y') THEN
1917 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
1918 END IF;
1919 ELSE
1920 l_edit_po_url := NULL;
1921 END IF;
1922 IF PO_DOC_STYLE_GRP.is_standard_doc_style(l_style_id) = 'Y' THEN
1923 -- Modified by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
1924 -------------------------------------------------------------------------------------
1925 IF lv_tax_region='JAI' THEN
1926 --open indian localization form
1927 l_open_form:=JAI_PO_WF_UTIL_PUB.Get_Jai_Open_Form_Command (pv_document_type => JAI_PO_WF_UTIL_PUB.G_PO_DOC_TYPE);
1928 ELSE
1929 --STANDARD PO FORM
1930 --Bug 7716930
1931 l_open_form := 'PO_POXPOEPO:PO_HEADER_ID=' || '&' || 'DOCUMENT_ID' || ' ACCESS_LEVEL_CODE=MODIFY' || ' POXPOEPO_CALLING_FORM=POXSTNOT';
1932 END IF;
1933 -------------------------------------------------------------------------------------
1934 -- Modified by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1935 ELSE
1936 l_open_form := NULL;
1937 END IF;
1938 END IF;
1939 -- <HTML Orders R12 End >
1940 ELSIF l_document_type = 'RELEASE' THEN
1941 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
1942 -------------------------------------------------------------------------------------
1943 IF lv_tax_region='JAI' THEN
1944 --open indian localization form
1945 l_open_form:=JAI_PO_WF_UTIL_PUB.Get_Jai_Open_Form_Command (pv_document_type => JAI_PO_WF_UTIL_PUB.G_REL_DOC_TYPE);
1946 ELSE
1947 --STANDARD RELEASE FORM
1948 --Bug 7716930
1949 l_open_form := 'PO_POXPOERL:PO_RELEASE_ID=' || '&' || 'DOCUMENT_ID' || ' ACCESS_LEVEL_CODE=MODIFY' || ' POXPOERL_CALLING_FORM=POXSTNOT';
1950 END IF;
1951 -------------------------------------------------------------------------------------
1952 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,End
1953 -- HTML Orders R12
1954 -- The url links are not applicable for releases
1955 l_view_po_url := NULL;
1956 l_edit_po_url := NULL;
1957 END IF;
1958 IF (l_document_type <> 'REQUISITION') THEN
1959 -- HTML Orders R12
1960 -- Set the URL and form attributes
1961 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'OPEN_FORM_COMMAND' , avalue => l_open_form);
1962 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'VIEW_DOC_URL' , avalue => l_view_po_url);
1963 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'EDIT_DOC_URL' , avalue => l_edit_po_url);
1964 END IF;
1965 IF (fnd_profile.value('POR_SSP4_INSTALLED') = 'Y' AND l_document_type = 'REQUISITION' AND po_core_s.get_product_install_status('ICX') = 'I') THEN
1966 --Bug#3147435
1967 --Set the values for workflow attribute
1968 --VIEW_REQ_DTLS_URL and EDIT_REQ_URL
1969 l_view_req_dtls_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=ICX_POR_LAUNCH_IP' || '&' || 'porMode=viewReq' || '&' || 'porReqHeaderId=' || TO_CHAR(l_document_id) || '&' ||
1970 '_OrgId=' || TO_CHAR(x_orgid) || '&' || 'addBreadCrumb=Y'|| '&' || 'currNid=-NID-' ;
1971 l_edit_req_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=ICX_POR_LAUNCH_IP' || '&' || 'porMode=approverCheckout' || '&' || 'porReqHeaderId=' || TO_CHAR(l_document_id) || '&' || '_OrgId=' || TO_CHAR(x_orgid) || '&' || 'currNid=-NID-';
1972 l_resubmit_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=ICX_POR_LAUNCH_IP' || '&' || 'porMode=resubmitReq' || '&' || 'porReqHeaderId=' || TO_CHAR(l_document_id) || '&' || '_OrgId=' || TO_CHAR(x_orgid);
1973 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'VIEW_REQ_DTLS_URL', avalue => l_view_req_dtls_url);
1974 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'EDIT_REQ_URL', avalue => l_edit_req_url);
1975 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'RESUBMIT_REQ_URL', avalue => l_resubmit_url);
1976 is_clm_enabled := NVL(FND_PROFILE.VALUE('POR_IS_CLM_ENABLED'),'N');
1977 IF is_clm_enabled = 'Y' THEN
1978 l_conf_header_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'CONFORMED_HEADER_ID');
1979 l_imp_amendment_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=ICX_POR_LAUNCH_IP' || '&' ||
1980 'porMode=implementAmendment' || '&' || 'porReqHeaderId=' || TO_CHAR(l_document_id) || '&' || '_OrgId=' ||
1981 TO_CHAR(x_orgid) || '&' || 'porConfHeaderId=' || TO_CHAR(l_conf_header_id) || '&' || 'porCaller=BUYER';
1982 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'IMPL_AMENDMENT_BUYER_URL', avalue => l_imp_amendment_url);
1983 l_imp_amendment_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=ICX_POR_LAUNCH_IP' || '&' || 'porMode=implementAmendment' || '&' ||
1984 'porReqHeaderId=' || TO_CHAR(l_document_id) || '&' || '_OrgId=' || TO_CHAR(x_orgid) || '&' ||
1985 'porConfHeaderId=' || TO_CHAR(l_conf_header_id) || '&' || 'porCaller=SOURCING_BUYER';
1986 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'IMPL_AMENDMENT_NEG_URL', avalue => l_imp_amendment_url);
1987 END IF;
1988 /* Removed call for jumpIntoFunction() to set the attributes value.
1989 Instead of that setting the values of l_view_req_dtls_url, l_edit_req_url and l_resubmit_url variables
1990 into corrosponding attributes */
1991 l_open_req_url := l_view_req_dtls_url;
1992 l_update_req_url := l_edit_req_url;
1993 -- Bug 636924, lpo, 03/31/98
1994 -- Added resubmit link.
1995 l_resubmit_req_url := l_resubmit_url;
1996 -- End of fix. Bug 636924, lpo, 03/31/98
1997 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'REQ_URL' , avalue => l_open_req_url);
1998 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'REQ_UPDATE_URL' , avalue => l_update_req_url);
1999 -- Bug 636924, lpo, 03/31/98
2000 -- Added resubmit workflow attribute.
2001 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'REQ_RESUBMIT_URL' , avalue => l_resubmit_req_url);
2002 l_interface_source := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'INTERFACE_SOURCE_CODE');
2003 l_doc_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
2004 -- Not showing the open form icon if this is an IP req and owner can't
2005 -- modify.
2006 IF l_can_modify_flag = 'N' AND l_interface_source = 'POR' THEN
2007 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'OPEN_FORM_COMMAND' , avalue => '');
2008 END IF;
2009 END IF;
2010 /* Set the Subject of the Approval notification initially to
2011 ** "requires your approval". If the user enters an invalid forward-to
2012 ** then this messages gets nulled-out and the "Invalid Forward-to"
2013 ** message gets a value (see notification: Approve Requisition).
2014 */
2015 fnd_message.set_name ('PO','PO_WF_NOTIF_REQUIRES_APPROVAL');
2016 l_error_msg := fnd_message.get;
2017 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'REQUIRES_APPROVAL_MSG' , avalue => l_error_msg);
2018 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'WRONG_FORWARD_TO_MSG' , avalue => '');
2019 /* Get the orignial authorization status from the document
2020 ** This has to be done here as we set the document status to
2021 ** IN-PROCESS after this.
2022 */
2023 IF l_document_type='REQUISITION' THEN
2024 SELECT AUTHORIZATION_STATUS
2025 INTO l_authorization_status
2026 FROM po_requisition_headers_all
2027 WHERE REQUISITION_HEADER_ID = l_document_id;
2028 /* Bug#1810322: kagarwal
2029 ** Desc: If the original authorization status is IN PROCESS or PRE-APPROVED
2030 ** for Reqs then we need to store INCOMPLETE as the original authorization
2031 ** status.
2032 */
2033 IF l_authorization_status IN ('IN PROCESS', 'PRE-APPROVED') THEN
2034 l_authorization_status := 'INCOMPLETE';
2035 END IF;
2036 ELSIF l_document_type IN ('PO','PA') THEN
2037 -- Mod Project Start
2038 SELECT DECODE(draft_id, -1, AUTHORIZATION_STATUS, STATUS),
2039 NVL(REVISION_NUM,0)
2040 INTO l_authorization_status,
2041 l_po_revision
2042 FROM po_headers_merge_v
2043 WHERE PO_HEADER_ID = l_document_id
2044 AND draft_id = l_draft_id;
2045 --Mod Project end
2046 /* Bug#1810322: kagarwal
2047 ** Desc: If the original authorization status is IN PROCESS or PRE-APPROVED
2048 ** for PO/Releases then we need to store REQUIRES REAPPROVAL as the original
2049 ** authorization status if the revision number is greater than 0 else
2050 ** INCOMPLETE.
2051 */
2052 IF (l_authorization_status IN ('IN PROCESS', 'PRE-APPROVED') AND l_draft_id =-1) THEN
2053 IF l_po_revision > 0 THEN
2054 l_authorization_status := 'REQUIRES REAPPROVAL';
2055 ELSE
2056 l_authorization_status := 'INCOMPLETE';
2057 END IF;
2058 ELSIF (l_authorization_status IN ('IN PROCESS', 'PRE-APPROVED') AND l_draft_id <>-1) THEN
2059 l_authorization_status := 'DRAFT';
2060 END IF;
2061 ELSIF l_document_type = 'RELEASE' THEN
2062 SELECT AUTHORIZATION_STATUS,
2063 NVL(REVISION_NUM,0)
2064 INTO l_authorization_status,
2065 l_po_revision
2066 FROM po_releases_all
2067 WHERE PO_RELEASE_ID = l_document_id;
2068 IF l_authorization_status IN ('IN PROCESS', 'PRE-APPROVED') THEN
2069 IF l_po_revision > 0 THEN
2070 l_authorization_status := 'REQUIRES REAPPROVAL';
2071 ELSE
2072 l_authorization_status := 'INCOMPLETE';
2073 END IF;
2074 END IF;
2075 END IF;
2076 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'ORIG_AUTH_STATUS' , avalue => l_authorization_status);
2077 IF l_document_type='REQUISITION' THEN
2078 /* bug 2480327 notification UI enhancement
2079 add NID to PLSQL document attributes
2080 */
2081 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_REQ_APPROVE_MSG', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_PO_REQ_APPROVE_MSG/'|| itemtype||':'|| itemkey||':'|| '&'||'#NID');
2082 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_REQ_APPROVED_MSG', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_PO_REQ_APPROVED_MSG/'|| itemtype||':'|| itemkey||':'|| '&'||'#NID');
2083 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_REQ_NO_APPROVER_MSG', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_PO_REQ_NO_APPROVER_MSG/'|| itemtype||':'|| itemkey||':'|| '&'||'#NID');
2084 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_REQ_REJECT_MSG', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_PO_REQ_REJECT_MSG/'|| itemtype||':'|| itemkey||':'|| '&'||'#NID');
2085 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'REQ_LINES_DETAILS', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_REQ_LINES_DETAILS/'|| itemtype||':'|| itemkey);
2086 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'ACTION_HISTORY', avalue => 'PLSQL:PO_WF_REQ_NOTIFICATION.GET_ACTION_HISTORY/'|| itemtype||':'|| itemkey);
2087 elsif l_document_type IN ('PO', 'PA', 'RELEASE') THEN
2088 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_APPROVE_MSG', avalue => 'PLSQL:PO_WF_PO_NOTIFICATION.GET_PO_APPROVE_MSG/' || itemtype || ':' || itemkey);
2089 -- <BUG 7006113>
2090 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'PO_LINES_DETAILS', avalue => 'PLSQLCLOB:PO_WF_PO_NOTIFICATION.GET_PO_LINES_DETAILS/'|| itemtype||':'|| itemkey);
2091 wf_engine.SetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'ACTION_HISTORY', avalue => 'PLSQL:PO_WF_PO_NOTIFICATION.GET_ACTION_HISTORY/'|| itemtype||':'|| itemkey);
2092 END IF;
2093 --Bug 6164753
2094 l_external_url := fnd_profile.value('POS_EXTERNAL_URL');
2095 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => '#WFM_HTMLAGENT', avalue => l_external_url);
2096 --Bug 6164753
2097
2098 /* PO AME Project :Start
2099 Setting requires review message */
2100 fnd_message.set_name ('PO','PO_WF_NOTIF_REQUIRES_REVIEW');
2101 l_review_msg := fnd_message.get;
2102 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => itemType, itemkey => itemkey, aname => 'REQUIRES_REVIEW_MSG' , avalue => l_review_msg);
2103 /* PO AME Project :End */
2104
2105 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2106 --
2107 x_progress := 'PO_REQAPPROVAL_INIT1.Set_Startup_Values: 03'|| 'Open Form Command= ' || l_open_form;
2108 IF (g_po_wf_debug = 'Y') THEN
2109 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2110 END IF;
2111 EXCEPTION
2112 WHEN OTHERS THEN
2113 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2114 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2115 wf_core.context('PO_REQAPPROVAL_INIT1','Set_Startup_Values',x_progress);
2116 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.SET_STARTUP_VALUES');
2117 raise;
2118 END Set_Startup_Values;
2119 --
2120 -- Get_Req_Attributes
2121 -- Get the requisition values on the doc header and assigns then to workflow attributes
2122 --
2123 PROCEDURE Get_Req_Attributes
2124 (
2125 itemtype IN VARCHAR2,
2126 itemkey IN VARCHAR2,
2127 actid IN NUMBER,
2128 funcmode IN VARCHAR2,
2129 resultout OUT NOCOPY VARCHAR2 )
2130 IS
2131 l_requisition_header_id NUMBER;
2132 l_authorization_status VARCHAR2(25);
2133 l_orgid NUMBER;
2134 x_progress VARCHAR2(100);
2135 l_doc_string VARCHAR2(200);
2136 l_preparer_user_name VARCHAR2(100);
2137 BEGIN
2138 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Req_Attributes: 01';
2139 IF (g_po_wf_debug = 'Y') THEN
2140 /* DEBUG */
2141 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2142 END IF;
2143 -- Do nothing in cancel or timeout mode
2144 --
2145 IF (funcmode <> wf_engine.eng_run) THEN
2146 resultout := wf_engine.eng_null;
2147 RETURN;
2148 END IF;
2149 /* Bug# 2377333
2150 ** Setting application context
2151 */
2152 --Context Setting Revamp
2153 /* PO_REQAPPROVAL_INIT1.Set_doc_mgr_context(itemtype, itemkey); */
2154 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2155 IF l_orgid IS NOT NULL THEN
2156 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2157 END IF;
2158 l_requisition_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2159 GetReqAttributes(l_requisition_header_id,itemtype,itemkey);
2160 --
2161 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2162 --
2163 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Req_Attributes: 02';
2164 IF (g_po_wf_debug = 'Y') THEN
2165 /* DEBUG */
2166 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2167 END IF;
2168 EXCEPTION
2169 WHEN OTHERS THEN
2170 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2171 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2172 wf_core.context('PO_REQAPPROVAL_INIT1','Get_Req_Attributes',x_progress);
2173 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.GET_REQ_ATTRIBUTES');
2174 raise;
2175 END Get_Req_Attributes;
2176 -- set_doc_stat_preapproved
2177 -- Added for WR4
2178 PROCEDURE set_doc_stat_preapproved
2179 (
2180 itemtype IN VARCHAR2,
2181 itemkey IN VARCHAR2,
2182 actid IN NUMBER,
2183 funcmode IN VARCHAR2,
2184 resultout OUT NOCOPY VARCHAR2 )
2185 IS
2186 -- Bug 3326847: Change l_requisition_header_id to l_doc__header_id
2187 -- This is because the PO Approval WF will now call this as code as well.
2188 l_doc_header_id NUMBER;
2189 l_po_header_id NUMBER;
2190 l_doc_type VARCHAR2(14);
2191 l_authorization_stat VARCHAR2(25);
2192 l_note VARCHAR2(4000);
2193 l_orgid NUMBER;
2194 x_progress VARCHAR2(100);
2195 l_doc_string VARCHAR2(200);
2196 l_preparer_user_name VARCHAR2(100);
2197 l_draft_id NUMBER := -1; --Mod Project
2198 BEGIN
2199 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_preapproved: 01';
2200 --
2201 IF (funcmode <> wf_engine.eng_run) THEN
2202 resultout := wf_engine.eng_null;
2203 RETURN;
2204 END IF;
2205 -- Set the multi-org context
2206 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2207 IF l_orgid IS NOT NULL THEN
2208 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2209 END IF;
2210 -- Bug 3326847: Change l_requisition_header_id to l_doc_header_id
2211 l_doc_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2212 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2213 l_authorization_stat := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS');
2214 l_note := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'NOTE');
2215 IF l_doc_type = 'REQUISITION' THEN
2216 -- Bug 3326847: Change l_requisition_header_id to l_doc_header_id
2217 SetReqAuthStat(l_doc_header_id, itemtype,itemkey,l_note, 'PRE-APPROVED');
2218 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => 'PRE-APPROVED');
2219 ELSIF l_doc_type IN ('PO', 'PA') THEN
2220 -- Bug 3327847: Added code to set POs to 'PRE-APPROVED' status.
2221 -- CLM Aprvl
2222 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'DRAFT_ID');
2223 IF l_draft_id IS NULL THEN
2224 l_draft_id := -1;
2225 END IF;
2226 -- CLM Aprvl
2227 -- Adding the new parameter Draft Id
2228 SetPOAuthStat(l_doc_header_id, itemtype, itemkey, l_note, 'PRE-APPROVED', l_draft_id);
2229 --SetPOAuthStat(l_doc_header_id, itemtype, itemkey, l_note, 'PRE-APPROVED');
2230 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => 'PRE-APPROVED');
2231 ELSIF l_doc_type = 'RELEASE' THEN
2232 -- Bug 3327847: Added code to set Releases to 'PRE-APPROVED' status.
2233 SetRelAuthStat(l_doc_header_id, itemtype, itemkey, l_note, 'PRE-APPROVED');
2234 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => 'PRE-APPROVED');
2235 END IF;
2236 --
2237 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2238 --
2239 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_inprocess: 02';
2240 IF (g_po_wf_debug = 'Y') THEN
2241 /* DEBUG */
2242 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2243 END IF;
2244 EXCEPTION
2245 WHEN OTHERS THEN
2246 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2247 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2248 wf_core.context('PO_REQAPPROVAL_INIT1','set_doc_stat_preapproved',x_progress);
2249 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.SET_DOC_STAT_PREAPPROVED');
2250 raise;
2251 END set_doc_stat_preapproved;
2252 /* New procedure for set status preapproved added to call from workflow POAPPAME*/
2253 PROCEDURE set_doc_stat_preapproved1
2254 (
2255 itemtype IN VARCHAR2,
2256 itemkey IN VARCHAR2,
2257 actid IN NUMBER,
2258 funcmode IN VARCHAR2,
2259 resultout OUT NOCOPY VARCHAR2 )
2260 IS
2261 -- Bug 3326847: Change l_requisition_header_id to l_doc__header_id
2262 -- This is because the PO Approval WF will now call this as code as well.
2263 l_doc_header_id NUMBER;
2264 l_po_header_id NUMBER;
2265 l_doc_type VARCHAR2(14);
2266 l_authorization_stat VARCHAR2(25);
2267 l_note VARCHAR2(4000);
2268 l_orgid NUMBER;
2269 x_progress VARCHAR2(100);
2270 l_doc_string VARCHAR2(200);
2271 l_preparer_user_name VARCHAR2(100);
2272 l_draft_id NUMBER := -1; --Mod Project
2273 BEGIN
2274 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_preapproved: 01';
2275 --
2276 IF (funcmode <> wf_engine.eng_run) THEN
2277 resultout := wf_engine.eng_null;
2278 RETURN;
2279 END IF;
2280 -- Set the multi-org context
2281 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2282 IF l_orgid IS NOT NULL THEN
2283 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2284 END IF;
2285 -- Bug 3326847: Change l_requisition_header_id to l_doc_header_id
2286 l_doc_header_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2287 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2288 l_authorization_stat := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS');
2289 l_note := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'NOTE');
2290 IF l_doc_type IN ('PO', 'PA') THEN
2291 -- Bug 3327847: Added code to set POs to 'PRE-APPROVED' status.
2292 -- CLM Aprvl
2293 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'DRAFT_ID');
2294 IF l_draft_id IS NULL THEN
2295 l_draft_id := -1;
2296 END IF;
2297 -- CLM Aprvl
2298 -- Adding the new parameter Draft Id
2299 SetPOAuthStat(l_doc_header_id, itemtype, itemkey, l_note, 'PRE-APPROVED', l_draft_id, 'Y');
2300 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => 'PRE-APPROVED');
2301 END IF;
2302 --
2303 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2304 --
2305 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_preapproved: 02';
2306 IF (g_po_wf_debug = 'Y') THEN
2307 /* DEBUG */
2308 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2309 END IF;
2310 EXCEPTION
2311 WHEN OTHERS THEN
2312 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2313 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2314 wf_core.context('PO_REQAPPROVAL_INIT1','set_doc_stat_preapproved',x_progress);
2315 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.SET_DOC_STAT_PREAPPROVED');
2316 raise;
2317 END set_doc_stat_preapproved1;
2318 -- set_doc_stat_inprocess
2319 -- Set the Doc status to In process and update the Doc Header table with the Itemtype
2320 -- and Itemkey indicating that this doc has been submitted to workflow.
2321 --
2322 PROCEDURE set_doc_stat_inprocess
2323 (
2324 itemtype IN VARCHAR2,
2325 itemkey IN VARCHAR2,
2326 actid IN NUMBER,
2327 funcmode IN VARCHAR2,
2328 resultout OUT NOCOPY VARCHAR2 )
2329 IS
2330 l_document_id NUMBER;
2331 l_doc_type VARCHAR2(14);
2332 l_authorization_stat VARCHAR2(25);
2333 l_note VARCHAR2(4000);
2334 l_orgid NUMBER;
2335 x_progress VARCHAR2(100);
2336 l_doc_string VARCHAR2(200);
2337 l_preparer_user_name VARCHAR2(100);
2338 l_draft_id NUMBER := -1; --Mod Project
2339 BEGIN
2340 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_inprocess: 01';
2341 IF (g_po_wf_debug = 'Y') THEN
2342 /* DEBUG */
2343 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2344 END IF;
2345 -- Do nothing in cancel or timeout mode
2346 --
2347 IF (funcmode <> wf_engine.eng_run) THEN
2348 resultout := wf_engine.eng_null;
2349 RETURN;
2350 END IF;
2351 -- Set the multi-org context
2352 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2353 IF l_orgid IS NOT NULL THEN
2354 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2355 END IF;
2356 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2357 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2358 l_authorization_stat := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS');
2359 l_note := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'NOTE');
2360 /* If the Doc is INCOMPLETE or REJECTED (not IN PROCESS or PRE-APPROVED), then
2361 ** we want to set it to IN PROCESS and update the ITEMTYPE/ITEMKEY columns.
2362 ** If this is an upgrade to R11, then we need to update the ITEMTYPE/ITEMKEY columns
2363 ** Note that we only pickup docs is IN PROCESS or PRE-APPROVED in the upgrade step.
2364 */
2365 IF ( NVL(l_authorization_stat, 'INCOMPLETE') NOT IN ('IN PROCESS', 'PRE-APPROVED') ) THEN
2366 IF l_doc_type = 'REQUISITION' THEN
2367 SetReqAuthStat(l_document_id, itemtype,itemkey,l_note, 'IN PROCESS');
2368 ELSIF l_doc_type IN ('PO', 'PA') THEN
2369 --Mod Project
2370 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DRAFT_ID');
2371 If l_draft_id is Null Then
2372 l_draft_id := -1;
2373 End If;
2374 -- Bug 9906656 issue fix
2375 -- For SGD project, check whether modification document updated after
2376 -- generating the change description and set the value 'Y' or 'N'
2377 -- accordingly in the MODUPDATED_AFTERCDGENERATED column of po_drafts table
2378 IF l_draft_id <> -1 THEN
2379 SetModUpdateAfterCDGenFlag(l_draft_id);
2380 END IF;
2381 -- CLM Aprvl
2382 -- Adding the new parameter Draft Id
2383 SetPOAuthStat(l_document_id, itemtype, itemkey, l_note, 'IN PROCESS', l_draft_id);
2384 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_inprocess: 02 unlock document';
2385 IF (g_po_wf_debug = 'Y') THEN
2386 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2387 END IF;
2388 IF l_draft_id = -1 THEN
2389 -- Mod Project
2390 -- Unlock document deletes the draft records , that is needed only for
2391 -- non mods
2392 unlock_document ( p_po_header_id => l_document_id);
2393 -- <HTML Agreement R12 END>
2394 END IF;
2395 ELSIF l_doc_type = 'RELEASE' THEN
2396 SetRelAuthStat(l_document_id, itemtype,itemkey,l_note, 'IN PROCESS');
2397 END IF;
2398 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => 'IN PROCESS' );
2399 END IF;
2400 --
2401 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2402 --
2403 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_stat_inprocess: 02';
2404 IF (g_po_wf_debug = 'Y') THEN
2405 /* DEBUG */
2406 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2407 END IF;
2408 EXCEPTION
2409 WHEN OTHERS THEN
2410 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2411 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2412 wf_core.context('PO_REQAPPROVAL_INIT1','set_doc_stat_inprocess',x_progress);
2413 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.SET_DOC_STAT_INPROCESS');
2414 raise;
2415 END set_doc_stat_inprocess;
2416 --
2417 PROCEDURE set_doc_to_originalstat
2418 (
2419 itemtype IN VARCHAR2,
2420 itemkey IN VARCHAR2,
2421 actid IN NUMBER,
2422 funcmode IN VARCHAR2,
2423 resultout OUT NOCOPY VARCHAR2 )
2424 IS
2425 l_orig_auth_stat VARCHAR2(25);
2426 l_auth_stat VARCHAR2(25);
2427 l_requisition_header_id NUMBER;
2428 l_po_header_id NUMBER;
2429 l_doc_id NUMBER;
2430 l_doc_type VARCHAR2(14);
2431 l_doc_subtype VARCHAR2(25);
2432 l_orgid NUMBER;
2433 x_progress VARCHAR2(200);
2434 l_doc_string VARCHAR2(200);
2435 l_preparer_user_name VARCHAR2(100);
2436 l_draft_id NUMBER :=-1; --Mod Project
2437 BEGIN
2438 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_to_originalstat: 01';
2439 IF (g_po_wf_debug = 'Y') THEN
2440 /* DEBUG */
2441 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2442 END IF;
2443 -- Do nothing in cancel or timeout mode
2444 --
2445 IF (funcmode <> wf_engine.eng_run) THEN
2446 resultout := wf_engine.eng_null;
2447 RETURN;
2448 END IF;
2449 -- Set the multi-org context
2450 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2451 IF l_orgid IS NOT NULL THEN
2452 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2453 END IF;
2454 l_orig_auth_stat := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'ORIG_AUTH_STATUS');
2455 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2456 l_doc_subtype := wf_engine.GetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
2457 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2458 -- Mod Project
2459 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype,itemkey => itemkey,aname => 'DRAFT_ID');
2460 IF l_draft_id IS NULL THEN
2461 l_draft_id := -1;
2462 END IF;
2463 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_to_originalstat: parameters ';
2464 x_progress := x_progress || l_orig_auth_stat || '- ORIG_AUTH_STATUS';
2465 x_progress := x_progress || l_doc_type || '- DOCUMENT_TYPE';
2466 x_progress := x_progress || l_doc_subtype || '- DOCUMENT_SUBTYPE';
2467 x_progress := x_progress || l_doc_id || '- DOCUMENT_ID';
2468 x_progress := x_progress || l_draft_id || '- DRAFT_ID';
2469 IF (g_po_wf_debug = 'Y') THEN
2470 /* DEBUG */
2471 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2472 END IF;
2473 /* If the doc is APPROVED then don't reset the status. We should
2474 ** not run into this case. But this is to prevent any problems
2475 */
2476 IF l_doc_type = 'REQUISITION' THEN
2477 SELECT NVL(authorization_status, 'INCOMPLETE')
2478 INTO l_auth_stat
2479 FROM PO_REQUISITION_HEADERS
2480 WHERE requisition_header_id = l_doc_id;
2481 IF l_auth_stat <> 'APPROVED' THEN
2482 SetReqAuthStat(l_doc_id, itemtype,itemkey,NULL, l_orig_auth_stat);
2483 END IF;
2484 ELSIF l_doc_type IN ('PO', 'PA') THEN
2485 IF l_draft_id <> -1 AND l_draft_id IS NOT NULL THEN
2486 SELECT NVL(status,'DRAFT')
2487 INTO l_auth_stat
2488 FROM po_drafts
2489 WHERE draft_id = l_draft_id;
2490 ELSE
2491 SELECT NVL(authorization_status,'INCOMPLETE')
2492 INTO l_auth_stat
2493 FROM PO_HEADERS
2494 WHERE po_header_id = l_doc_id;
2495 END IF;
2496 IF (l_auth_stat <> 'APPROVED' AND l_auth_stat <> 'COMPLETED') THEN
2497 -- Adding the new parameter Draft Id
2498 SetPOAuthStat(l_doc_id, itemtype, itemkey, NULL, l_orig_auth_stat, l_draft_id);
2499 END IF;
2500 ELSIF l_doc_type = 'RELEASE' THEN
2501 SELECT NVL(authorization_status,'INCOMPLETE')
2502 INTO l_auth_stat
2503 FROM PO_RELEASES
2504 WHERE po_release_id = l_doc_id;
2505 IF l_auth_stat <> 'APPROVED' THEN
2506 SetRelAuthStat(l_doc_id, itemtype,itemkey,NULL, l_orig_auth_stat );
2507 END IF;
2508 END IF;
2509 IF l_auth_stat <> 'APPROVED' THEN
2510 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => l_orig_auth_stat);
2511 END IF;
2512 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_to_originalstat: 02' || ' Auth_status= ' || l_auth_stat || ', Orig_auth_stat= ' || l_orig_auth_stat;
2513 IF (g_po_wf_debug = 'Y') THEN
2514 /* DEBUG */
2515 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2516 END IF;
2517 -- Bug 3845048: Added the code to update the action history with 'no action'
2518 -- so that the action history code is completed properly when the document
2519 -- is returned to the submitter, in case of no approver found or time out
2520 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_to_originalstat: 03' || 'Update Action History' || 'Action Code = No Action';
2521 IF (g_po_wf_debug = 'Y') THEN
2522 /* DEBUG */
2523 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2524 END IF;
2525 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2526 EXCEPTION
2527 WHEN OTHERS THEN
2528 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2529 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2530 wf_core.context('PO_REQAPPROVAL_INIT1','set_doc_stat_inprocess',x_progress);
2531 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.SET_DOC_STAT_INPROCESS');
2532 raise;
2533 END set_doc_to_originalstat;
2534 -- Register_doc_submitted
2535 --
2536 -- Update the DOC HEADER with the Workflow Itemtype and ItemKey
2537 --
2538 PROCEDURE Register_doc_submitted
2539 (
2540 itemtype IN VARCHAR2,
2541 itemkey IN VARCHAR2,
2542 actid IN NUMBER,
2543 funcmode IN VARCHAR2,
2544 resultout OUT NOCOPY VARCHAR2 )
2545 IS
2546 l_doc_id NUMBER;
2547 l_doc_type VARCHAR2(25);
2548 l_authorization_stat VARCHAR2(25);
2549 l_orgid NUMBER;
2550 x_progress VARCHAR2(100);
2551 l_doc_string VARCHAR2(200);
2552 l_preparer_user_name VARCHAR2(100);
2553 BEGIN
2554 x_progress := 'PO_REQAPPROVAL_INIT1.Register_doc_submitted: 01';
2555 IF (g_po_wf_debug = 'Y') THEN
2556 /* DEBUG */
2557 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2558 END IF;
2559 -- Do nothing in cancel or timeout mode
2560 --
2561 IF (funcmode <> wf_engine.eng_run) THEN
2562 resultout := wf_engine.eng_null;
2563 RETURN;
2564 END IF;
2565 -- Set the multi-org context
2566 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2567 IF l_orgid IS NOT NULL THEN
2568 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2569 END IF;
2570 l_doc_id := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2571 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2572 IF l_doc_type = 'REQUISITION' THEN
2573 UpdtReqItemtype(itemtype,itemkey, l_doc_id);
2574 ELSIF l_doc_type IN ('PO', 'PA') THEN
2575 UpdtPOItemtype(itemtype,itemkey, l_doc_id );
2576 ELSIF l_doc_type = 'RELEASE' THEN
2577 UpdtRelItemtype(itemtype,itemkey, l_doc_id);
2578 END IF;
2579 --
2580 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED';
2581 --
2582 x_progress := 'PO_REQAPPROVAL_INIT1.Register_doc_submitted: 02';
2583 IF (g_po_wf_debug = 'Y') THEN
2584 /* DEBUG */
2585 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2586 END IF;
2587 EXCEPTION
2588 WHEN OTHERS THEN
2589 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2590 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2591 wf_core.context('PO_REQAPPROVAL_INIT1','Register_doc_submitted',x_progress);
2592 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.REGISTER_DOC_SUBMITTED');
2593 raise;
2594 END Register_doc_submitted;
2595 --
2596 -- can_owner_approve
2597 -- Get the requisition values on the doc header and assigns then to workflow attributes
2598 --
2599 PROCEDURE can_owner_approve
2600 (
2601 itemtype IN VARCHAR2,
2602 itemkey IN VARCHAR2,
2603 actid IN NUMBER,
2604 funcmode IN VARCHAR2,
2605 resultout OUT NOCOPY VARCHAR2 )
2606 IS
2607 l_document_type VARCHAR2(25);
2608 l_document_id NUMBER;
2609 l_orgid NUMBER;
2610 x_CanOwnerApproveFlag VARCHAR2(1);
2611 l_interface_source VARCHAR2(30);
2612 x_progress VARCHAR2(100);
2613 l_doc_string VARCHAR2(200);
2614 l_preparer_user_name VARCHAR2(100);
2615 BEGIN
2616 x_progress := 'PO_REQAPPROVAL_INIT1.can_owner_approve: 01';
2617 IF (g_po_wf_debug = 'Y') THEN
2618 /* DEBUG */
2619 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2620 END IF;
2621 -- Do nothing in cancel or timeout mode
2622 --
2623 IF (funcmode <> wf_engine.eng_run) THEN
2624 resultout := wf_engine.eng_null;
2625 RETURN;
2626 END IF;
2627 l_interface_source := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'INTERFACE_SOURCE_CODE');
2628 /* For one time upgrade of notifications for the client, we want to
2629 ** follow a certain path in the workflow. We do not want to go through
2630 ** the VERIFY AUTHORITY path. Therefore, set the RESULT to N
2631 */
2632 IF NVL(l_interface_source,'X') = 'ONE_TIME_UPGRADE' THEN
2633 --
2634 resultout := wf_engine.eng_completed || ':' || 'N';
2635 --
2636 ELSE
2637 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2638 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2639 -- Set the multi-org context
2640 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2641 IF l_orgid IS NOT NULL THEN
2642 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2643 END IF;
2644 PO_REQAPPROVAL_INIT1.GetCanOwnerApprove(itemtype, itemkey, x_CanOwnerApproveFlag);
2645 --
2646 resultout := wf_engine.eng_completed || ':' || x_CanOwnerApproveFlag ;
2647 --
2648 END IF;
2649 x_progress := 'PO_REQAPPROVAL_INIT1.can_owner_approve: 02';
2650 IF (g_po_wf_debug = 'Y') THEN
2651 /* DEBUG */
2652 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2653 END IF;
2654 EXCEPTION
2655 WHEN OTHERS THEN
2656 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2657 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2658 wf_core.context('PO_REQAPPROVAL_INIT1','can_owner_approve',x_progress);
2659 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.CAN_OWNER_APPROVE');
2660 raise;
2661 END can_owner_approve;
2662
2663 -- Bug 10013322
2664 -- Is_Submitter_Same_As_Preparer
2665 -- Check whether Submitter is same as preparer
2666 --
2667
2668 procedure Is_Submitter_Same_As_Preparer(itemtype in varchar2,
2669 itemkey in varchar2,
2670 actid in number,
2671 funcmode in varchar2,
2672 resultout out NOCOPY varchar2 ) IS
2673 l_preparer_id NUMBER;
2674 l_submitter_id NUMBER;
2675 l_approver_id NUMBER;
2676
2677 BEGIN
2678 l_preparer_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
2679 itemkey => itemkey,
2680 aname => 'PREPARER_ID');
2681
2682 l_submitter_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
2683 itemkey => itemkey,
2684 aname => 'SUBMITTER_ID');
2685
2686 IF(((l_preparer_id IS NOT NULL) AND (l_submitter_id IS NOT NULL)) AND (l_preparer_id <> l_submitter_id))THEN
2687
2688 resultout := wf_engine.eng_completed || ':' || 'N' ;
2689
2690 ELSE
2691
2692 resultout := wf_engine.eng_completed || ':' || 'Y' ;
2693
2694 END IF;
2695
2696 END Is_Submitter_Same_As_Preparer ;
2697
2698
2699 --
2700 -- Is_doc_preapproved
2701 -- Is document status pre-approved
2702 --
2703 PROCEDURE Is_doc_preapproved
2704 (
2705 itemtype IN VARCHAR2,
2706 itemkey IN VARCHAR2,
2707 actid IN NUMBER,
2708 funcmode IN VARCHAR2,
2709 resultout OUT NOCOPY VARCHAR2 )
2710 IS
2711 l_auth_stat VARCHAR2(25);
2712 l_doc_type VARCHAR2(25);
2713 l_doc_id NUMBER;
2714 l_orgid NUMBER;
2715 x_progress VARCHAR2(200);
2716 l_doc_string VARCHAR2(200);
2717 l_preparer_user_name VARCHAR2(100);
2718 BEGIN
2719 x_progress := 'PO_REQAPPROVAL_INIT1.Is_doc_preapproved: 01';
2720 IF (g_po_wf_debug = 'Y') THEN
2721 /* DEBUG */
2722 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2723 END IF;
2724 -- Do nothing in cancel or timeout mode
2725 --
2726 IF (funcmode <> wf_engine.eng_run) THEN
2727 resultout := wf_engine.eng_null;
2728 RETURN;
2729 END IF;
2730 /* Bug# 2353153
2731 ** Setting application context
2732 */
2733 --Context Setting Revamp
2734 /* PO_REQAPPROVAL_INIT1.Set_doc_mgr_context(itemtype, itemkey); */
2735 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2736 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2737 -- Bug 762194: Need to set multi-org context.
2738 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2739 IF l_orgid IS NOT NULL THEN
2740 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2741 END IF;
2742 IF l_doc_type = 'REQUISITION' THEN
2743 SELECT NVL(authorization_status, 'INCOMPLETE')
2744 INTO l_auth_stat
2745 FROM PO_REQUISITION_HEADERS
2746 WHERE requisition_header_id = l_doc_id;
2747 ELSIF l_doc_type IN ('PO', 'PA') THEN
2748 SELECT NVL(authorization_status,'INCOMPLETE')
2749 INTO l_auth_stat
2750 FROM PO_HEADERS
2751 WHERE po_header_id = l_doc_id;
2752 ELSIF l_doc_type = 'RELEASE' THEN
2753 SELECT NVL(authorization_status,'INCOMPLETE')
2754 INTO l_auth_stat
2755 FROM PO_RELEASES
2756 WHERE po_release_id = l_doc_id;
2757 END IF;
2758 IF l_auth_stat = 'PRE-APPROVED' THEN
2759 --
2760 resultout := wf_engine.eng_completed || ':' || 'Y' ;
2761 --
2762 ELSIF l_auth_stat = 'IN PROCESS' THEN
2763 --
2764 resultout := wf_engine.eng_completed || ':' || 'N' ;
2765 --
2766 ELSE
2767 -- The doc is either APPROVED, INCOMPLETE or REJECTED. This invalid, therefore
2768 -- we will exit the workflow with an INVALID ACTION status.
2769 resultout := wf_engine.eng_completed || ':' || 'INVALID_AUTH_STATUS' ;
2770 --
2771 END IF;
2772 x_progress := 'PO_REQAPPROVAL_INIT1.Is_doc_preapproved: 02' || ' Authorization_status= ' || l_auth_stat ;
2773 IF (g_po_wf_debug = 'Y') THEN
2774 /* DEBUG */
2775 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2776 END IF;
2777 EXCEPTION
2778 WHEN OTHERS THEN
2779 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2780 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2781 wf_core.context('PO_REQAPPROVAL_INIT1','Is_doc_preapproved',x_progress);
2782 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.IS_DOC_PREAPPROVED');
2783 raise;
2784 END Is_doc_preapproved;
2785 --
2786 --
2787 -- Ins_actionhist_submit
2788 -- When we start the workflow, if the document status is NOT 'IN PROCESS' or
2789 -- PRE-APPROVED, then insert a SUBMIT action row into PO_ACTION_HISTORY
2790 -- to signal the submission of the document for approval.
2791 -- Also, insert an additional row with a NULL ACTION_CODE (to simulate a
2792 -- forward-to since the DOC status is IN PROCESS. The code in the DOC-MANAGER
2793 -- looks for this row.
2794 --
2795 PROCEDURE Ins_actionhist_submit
2796 (
2797 itemtype IN VARCHAR2,
2798 itemkey IN VARCHAR2,
2799 actid IN NUMBER,
2800 funcmode IN VARCHAR2,
2801 resultout OUT NOCOPY VARCHAR2 )
2802 IS
2803 l_doc_id NUMBER;
2804 l_doc_type VARCHAR2(25);
2805 l_doc_subtype VARCHAR2(25);
2806 l_note PO_ACTION_HISTORY.note%TYPE;
2807 l_employee_id NUMBER;
2808 l_orgid NUMBER;
2809 x_progress VARCHAR2(100);
2810 l_doc_string VARCHAR2(200);
2811 l_preparer_user_name VARCHAR2(100);
2812 l_path_id NUMBER;
2813 l_draft_id NUMBER := -1; --Mod Project
2814 BEGIN
2815 x_progress := 'PO_REQAPPROVAL_INIT1.Ins_actionhist_submit: 01';
2816 IF (g_po_wf_debug = 'Y') THEN
2817 /* DEBUG */
2818 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2819 END IF;
2820 -- Do nothing in cancel or timeout mode
2821 --
2822 IF (funcmode <> wf_engine.eng_run) THEN
2823 resultout := wf_engine.eng_null;
2824 RETURN;
2825 END IF;
2826 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
2827 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
2828 l_doc_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
2829 -- Mod Project
2830 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DRAFT_ID');
2831 IF l_draft_id IS NULL THEN
2832 l_draft_id := -1;
2833 END IF;
2834 -- Mod Project
2835 /* Bug 1100247 Amitabh
2836 ** Desc:Initially the Workflow sets the preparer_id, approver_empid
2837 ** as the value passed to it by the POXAPAPC.pld file. As it always
2838 ** assumed that an Incomplete Requisition would get approved by
2839 ** preparer only. Then when it calls the GetReqAttributes()
2840 ** it would reget the preparer_id from the po_requisition_headers_all
2841 ** table hence if the preparer_id and approver_empid are different
2842 ** then the action history would be wrongly updated.
2843 **
2844 ** Modifying the parameter l_employee_id to be passed to
2845 ** InsertActionHistSubmit() from PREPARER_ID to
2846 ** APPROVER_EMPID.
2847 **
2848 ** Also modified the SetReqHdrAttributes() to also set the
2849 ** PREPARER_USER_NAME and PREPARER_DISPLAY_NAME.
2850 **
2851 */
2852 l_employee_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'APPROVER_EMPID');
2853 PO_WF_UTIL_PKG.SetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'SUBMITTER_ID', avalue => l_employee_id);
2854 l_note := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'NOTE');
2855 -- Set the multi-org context
2856 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
2857 IF l_orgid IS NOT NULL THEN
2858 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
2859 END IF;
2860 l_path_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'APPROVAL_PATH_ID');
2861 -- Mod Project; added draft_id to the next proc.
2862 PO_REQAPPROVAL_INIT1.InsertActionHistSubmit(itemtype,itemkey,l_doc_id, l_doc_type, l_doc_subtype, l_employee_id, 'SUBMIT', l_note, l_path_id, l_draft_id);
2863 --
2864 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED' ;
2865 --
2866 x_progress := 'PO_REQAPPROVAL_INIT1.Ins_actionhist_submit: 02';
2867 IF (g_po_wf_debug = 'Y') THEN
2868 /* DEBUG */
2869 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2870 END IF;
2871 EXCEPTION
2872 WHEN OTHERS THEN
2873 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
2874 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
2875 wf_core.context('PO_REQAPPROVAL_INIT1','Ins_actionhist_submit',x_progress);
2876 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.INS_ACTIONHIST_SUBMIT');
2877 raise;
2878 END Ins_actionhist_submit;
2879 --
2880 -- Set_End_VerifyDoc_Passed
2881 -- Sets the value of the transition to PASSED_VERIFICATION to match the
2882 -- transition value for the VERIFY_REQUISITION Process
2883 --
2884 -- IN
2885 -- itemtype -- itemkey -- actid -- funcmode
2886 -- OUT
2887 -- Resultout
2888 -- - Activity Performed - Activity was completed without any errors.
2889 --
2890 PROCEDURE Set_End_VerifyDoc_Passed
2891 (
2892 itemtype IN VARCHAR2,
2893 itemkey IN VARCHAR2,
2894 actid IN NUMBER,
2895 funcmode IN VARCHAR2,
2896 resultout OUT NOCOPY VARCHAR2 )
2897 IS
2898 BEGIN
2899 -- Do nothing in cancel or timeout mode
2900 --
2901 IF (funcmode <> wf_engine.eng_run) THEN
2902 resultout := wf_engine.eng_null;
2903 RETURN;
2904 END IF;
2905 --
2906 resultout := wf_engine.eng_completed || ':' || 'PASSED_VERIFICATION' ;
2907 --
2908 END Set_End_VerifyDoc_Passed;
2909 --
2910 -- Set_End_VerifyDoc_Passed
2911 -- Sets the value of the transition to PASSED_VERIFICATION to match the
2912 -- transition value for the VERIFY_REQUISITION Process
2913 --
2914 -- IN
2915 -- itemtype -- itemkey -- actid -- funcmode
2916 -- OUT
2917 -- Resultout
2918 -- - Activity Performed - Activity was completed without any errors.
2919 --
2920 PROCEDURE Set_End_VerifyDoc_Failed
2921 (
2922 itemtype IN VARCHAR2,
2923 itemkey IN VARCHAR2,
2924 actid IN NUMBER,
2925 funcmode IN VARCHAR2,
2926 resultout OUT NOCOPY VARCHAR2 )
2927 IS
2928 BEGIN
2929 -- Do nothing in cancel or timeout mode
2930 --
2931 IF (funcmode <> wf_engine.eng_run) THEN
2932 resultout := wf_engine.eng_null;
2933 RETURN;
2934 END IF;
2935 --
2936 resultout := wf_engine.eng_completed || ':' || 'FAILED_VERIFICATION' ;
2937 --
2938 END Set_End_VerifyDoc_Failed;
2939 --
2940 -- Set_End_Valid_Action
2941 -- Sets the value of the transition to VALID_ACTION to match the
2942 -- transition value for the APPROVE_REQUISITION, APPROVE_PO,
2943 -- APPROVE_AND_FORWARD_REQUISITION and APPROVE_AND_FORWARD_PO Processes.
2944 --
2945 -- IN
2946 -- itemtype -- itemkey -- actid -- funcmode
2947 -- OUT
2948 -- Resultout
2949 -- - VALID_ACTION
2950 --
2951 PROCEDURE Set_End_Valid_Action
2952 (
2953 itemtype IN VARCHAR2,
2954 itemkey IN VARCHAR2,
2955 actid IN NUMBER,
2956 funcmode IN VARCHAR2,
2957 resultout OUT NOCOPY VARCHAR2 )
2958 IS
2959 x_progress VARCHAR2(100);
2960 BEGIN
2961 --
2962 resultout := wf_engine.eng_completed || ':' || 'VALID_ACTION' ;
2963 --
2964 x_progress := 'PO_REQAPPROVAL_INIT1.Set_End_Valid_Action: RESULT=VALID_ACTION';
2965 IF (g_po_wf_debug = 'Y') THEN
2966 /* DEBUG */
2967 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
2968 END IF;
2969 END Set_End_Valid_Action;
2970 --
2971 -- Set_End_Invalid_Action
2972 -- Sets the value of the transition to VALID_ACTION to match the
2973 -- transition value for the APPROVE_REQUISITION, APPROVE_PO,
2974 -- APPROVE_AND_FORWARD_REQUISITION and APPROVE_AND_FORWARD_PO Processes.
2975 --
2976 -- IN
2977 -- itemtype -- itemkey -- actid -- funcmode
2978 -- OUT
2979 -- Resultout
2980 -- - VALID_ACTION
2981 --
2982 PROCEDURE Set_End_Invalid_Action
2983 (
2984 itemtype IN VARCHAR2,
2985 itemkey IN VARCHAR2,
2986 actid IN NUMBER,
2987 funcmode IN VARCHAR2,
2988 resultout OUT NOCOPY VARCHAR2 )
2989 IS
2990 BEGIN
2991 --
2992 resultout := wf_engine.eng_completed || ':' || 'INVALID_ACTION' ;
2993 --
2994 END Set_End_Invalid_Action;
2995 --
2996 -- Is_Interface_ReqImport
2997 -- IN
2998 -- itemtype -- itemkey -- actid -- funcmode
2999 -- OUT
3000 -- Resultout
3001 -- - Y/N
3002 -- Is the calling module REQ IMPORT. If it is, then we need to RESERVE the doc.
3003 -- Web Requisition come through REQ IMPORT.
3004 PROCEDURE Is_Interface_ReqImport
3005 (
3006 itemtype IN VARCHAR2,
3007 itemkey IN VARCHAR2,
3008 actid IN NUMBER,
3009 funcmode IN VARCHAR2,
3010 resultout OUT NOCOPY VARCHAR2 )
3011 IS
3012 l_interface_source VARCHAR2(25);
3013 BEGIN
3014 l_interface_source := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'INTERFACE_SOURCE_CODE');
3015 IF l_interface_source <> 'PO_FORM' THEN
3016 --
3017 resultout := wf_engine.eng_completed || ':' || 'Y' ;
3018 --
3019 ELSE
3020 --
3021 resultout := wf_engine.eng_completed || ':' || 'N' ;
3022 --
3023 END IF;
3024 END Is_Interface_ReqImport;
3025 --
3026 -- Encumb_on_doc_unreserved
3027 -- IN
3028 -- itemtype -- itemkey -- actid -- funcmode
3029 -- OUT
3030 -- Resultout
3031 -- - Y/N
3032 -- If Encumbrance is ON and Document is NOT reserved, then return Y.
3033 -- We need to reserve the doc.
3034 PROCEDURE Encumb_on_doc_unreserved
3035 (
3036 itemtype IN VARCHAR2,
3037 itemkey IN VARCHAR2,
3038 actid IN NUMBER,
3039 funcmode IN VARCHAR2,
3040 resultout OUT NOCOPY VARCHAR2 )
3041 IS
3042 l_document_type VARCHAR2(25);
3043 l_document_subtype VARCHAR2(25) := NULL;
3044 l_document_id NUMBER;
3045 l_orgid NUMBER;
3046 x_progress VARCHAR2(100);
3047 l_doc_string VARCHAR2(200);
3048 l_preparer_user_name VARCHAR2(100);
3049 BEGIN
3050 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3051 -- <ENCUMBRANCE FPJ START>
3052 -- Get the subtype for doc type other than requisition
3053 IF l_document_type <> 'REQUISITION' THEN
3054 l_document_subtype := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3055 END IF;
3056 -- <ENCUMBRANCE FPJ END>
3057 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3058 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
3059 IF l_orgid IS NOT NULL THEN
3060 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
3061 END IF;
3062 IF ( EncumbOn_DocUnreserved( p_doc_type => l_document_type, p_doc_subtype => l_document_subtype, p_doc_id => l_document_id) = 'Y' ) THEN
3063 --
3064 resultout := wf_engine.eng_completed || ':' || 'Y' ;
3065 --
3066 x_progress := 'PO_REQAPPROVAL_INIT1.Encumb_on_doc_unreserved: 01';
3067 IF (g_po_wf_debug = 'Y') THEN
3068 /* DEBUG */
3069 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3070 END IF;
3071 ELSE
3072 --
3073 resultout := wf_engine.eng_completed || ':' || 'N' ;
3074 --
3075 x_progress := 'PO_REQAPPROVAL_INIT1.Encumb_on_doc_unreserved: 02';
3076 IF (g_po_wf_debug = 'Y') THEN
3077 /* DEBUG */
3078 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3079 END IF;
3080 END IF;
3081 EXCEPTION
3082 WHEN OTHERS THEN
3083 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3084 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3085 wf_core.context('PO_REQAPPROVAL_INIT1.Encumb_on_doc_unreserved',x_progress);
3086 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.ENCUMB_ON_DOC_UNRESERVED');
3087 raise;
3088 END Encumb_on_doc_unreserved;
3089 --
3090 --
3091 -- RESERVE_AT_COMPLETION_CHECK
3092 -- IN
3093 -- itemtype -- itemkey -- actid -- funcmode
3094 -- OUT
3095 -- Resultout
3096 -- - Y/N
3097 -- If the reserve at completion flag is checked, then return Y.
3098 PROCEDURE RESERVE_AT_COMPLETION_CHECK
3099 (
3100 itemtype IN VARCHAR2,
3101 itemkey IN VARCHAR2,
3102 actid IN NUMBER,
3103 funcmode IN VARCHAR2,
3104 resultout OUT NOCOPY VARCHAR2 )
3105 IS
3106 l_reserve_at_compl VARCHAR2(1);
3107 x_CanOwnerApproveFlag VARCHAR2(1);
3108 x_progress VARCHAR2(100);
3109 l_doc_string VARCHAR2(200);
3110 l_preparer_user_name VARCHAR2(100);
3111 /* <<CLM Partial Funding Changes>> */
3112 l_document_type PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE;
3113 l_document_id NUMBER;
3114 l_is_clm_doc VARCHAR2(1) := NULL ;
3115 /* <<CLM Partial Funding Changes>> */
3116 BEGIN
3117 /* Bug# 2234341: kagarwal
3118 ** Desc: The preparer cannot reserve a requisiton at the start of the
3119 ** approval workflow, if the preparer cannot approve and also the reserve
3120 ** at completion is No.
3121 ** The logic that follows here is that the owner/preparer is also an
3122 ** approver, if the preparer can approve is allowed.
3123 */
3124 SELECT NVL(fsp.reserve_at_completion_flag,'N')
3125 INTO l_reserve_at_compl
3126 FROM financials_system_parameters fsp;
3127 /* <<CLM Partial Funding Changes>> */
3128 /* Reserve at completion will be false for CLM document. */
3129 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3130 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3131 IF l_document_type ='REQUISITION' THEN
3132 l_document_type := 'REQ' ;
3133 END IF;
3134 l_is_clm_doc := po_partial_funding_pkg.Is_clm_document(p_Doc_type => l_document_type, p_Doc_Level_Id => l_document_id) ;
3135 IF l_is_clm_doc = 'Y' THEN
3136 l_reserve_at_compl := 'N' ;
3137 END IF;
3138 x_progress := 'PO_REQAPPROVAL_INIT1.Encumb_on_doc_commit.l_document_id=' || l_document_id || ', l_is_clm_doc=' || l_is_clm_doc ;
3139 IF (g_po_wf_debug = 'Y') THEN
3140 /* DEBUG */
3141 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3142 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_reserve_at_compl=' || l_reserve_at_compl );
3143 END IF;
3144 /* <<CLM Partial Funding Changes>> */
3145 PO_REQAPPROVAL_INIT1.GetCanOwnerApprove(itemtype, itemkey, x_CanOwnerApproveFlag);
3146 /*Bug 8520350 - Removing the check on OWNER_CAN_APPROVE.Since the two are not interdependent */
3147 IF ((l_reserve_at_compl = 'N' )) THEN
3148 --
3149 resultout := wf_engine.eng_completed || ':' || 'N' ;
3150 --
3151 x_progress := 'PO_REQAPPROVAL_INIT1.Encumb_on_doc_commit: 01';
3152 IF (g_po_wf_debug = 'Y') THEN
3153 /* DEBUG */
3154 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3155 END IF;
3156 ELSE
3157 --
3158 resultout := wf_engine.eng_completed || ':' || 'Y' ;
3159 --
3160 x_progress := 'PO_REQAPPROVAL_INIT1.Encumb_on_doc_commit: 02';
3161 IF (g_po_wf_debug = 'Y') THEN
3162 /* DEBUG */
3163 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3164 END IF;
3165 END IF;
3166 EXCEPTION
3167 WHEN OTHERS THEN
3168 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3169 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3170 wf_core.context('PO_REQAPPROVAL_INIT1.Encumb_on_doc_unreserved',x_progress);
3171 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.RESERVE_AT_COMPLETION_CHECK');
3172 raise;
3173 END RESERVE_AT_COMPLETION_CHECK;
3174 -- Remove_reminder_notif
3175 -- IN
3176 -- itemtype -- itemkey -- actid -- funcmode
3177 -- OUT
3178 -- Resultout
3179 --
3180 -- Remove the reminder notifications since this doc is now approved.
3181 PROCEDURE Remove_reminder_notif
3182 (
3183 itemtype IN VARCHAR2,
3184 itemkey IN VARCHAR2,
3185 actid IN NUMBER,
3186 funcmode IN VARCHAR2,
3187 resultout OUT NOCOPY VARCHAR2 )
3188 IS
3189 l_release_flag VARCHAR2(1);
3190 l_orgid NUMBER;
3191 l_document_type VARCHAR2(25);
3192 l_document_subtype VARCHAR2(25);
3193 l_document_id NUMBER;
3194 l_wf_item_key VARCHAR2(100);
3195 x_progress VARCHAR2(300);
3196 l_doc_string VARCHAR2(200);
3197 l_preparer_user_name VARCHAR2(100);
3198 l_draft_id NUMBER := -1; --Mod Project
3199 /*
3200 cursor po_cursor(p_header_id number) is
3201 select wf_item_key
3202 from po_headers
3203 where po_header_id= p_header_id;
3204 */
3205 -- CLM Aprvl Modifying the PO Cursor to use Merge Views
3206 CURSOR po_cursor(p_header_id NUMBER, p_draft_id NUMBER)
3207 IS
3208 SELECT wf_item_key
3209 FROM po_headers_merge_v
3210 WHERE po_header_id= p_header_id
3211 AND draft_id = p_draft_id;
3212 CURSOR req_cursor(p_header_id NUMBER)
3213 IS
3214 SELECT wf_item_key
3215 FROM po_requisition_headers
3216 WHERE requisition_header_id= p_header_id;
3217 CURSOR rel_cursor(p_header_id NUMBER)
3218 IS
3219 SELECT wf_item_key FROM po_releases WHERE po_release_id= p_header_id;
3220 BEGIN
3221 x_progress := 'PO_REQAPPROVAL_INIT1.Remove_reminder_notif: 01';
3222 IF (g_po_wf_debug = 'Y') THEN
3223 /* DEBUG */
3224 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3225 END IF;
3226 -- Do nothing in cancel or timeout mode
3227 --
3228 IF (funcmode <> wf_engine.eng_run) THEN
3229 resultout := wf_engine.eng_null;
3230 RETURN;
3231 END IF;
3232 /* Bug #: 1384323 draising
3233 Forward fix of Bug # 1338325
3234 We need to set multi org context by getting it from the
3235 database rather rather than the org id attribute.
3236 */
3237 /*
3238 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype,
3239 itemkey => itemkey,
3240 aname => 'ORG_ID');
3241 IF l_orgid is NOT NULL THEN
3242 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
3243 END IF;
3244 */
3245 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3246 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3247 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3248 PO_REQAPPROVAL_INIT1.get_multiorg_context(l_document_type,l_document_id,l_orgid);
3249 IF l_orgid IS NOT NULL THEN
3250 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
3251 wf_engine.SetItemAttrNumber (itemtype => itemtype , itemkey => itemkey , aname => 'ORG_ID' , avalue => l_orgid );
3252 END IF;
3253 /* End of fix for Bug # 1384323 */
3254 IF l_document_type = 'RELEASE' THEN
3255 l_release_flag := 'Y';
3256 ELSE
3257 l_release_flag := 'N';
3258 END IF;
3259 /* Remove reminder notifications */
3260 PO_APPROVAL_REMINDER_SV. Cancel_Notif ( l_document_subtype, l_document_id, l_release_flag);
3261 /* If the document has been previously submitted to workflow, and did not
3262 ** complete because of some error or some action such as Document being rejected,
3263 ** then notifications may have been issued to users.
3264 ** We need to remove those notifications once we submit the document to a
3265 ** new workflow run, so that the user is not confused.
3266 */
3267 IF l_document_type='REQUISITION' THEN
3268 OPEN req_cursor(l_document_id);
3269 FETCH req_cursor INTO l_wf_item_key;
3270
3271 CLOSE req_cursor;
3272 ELSIF l_document_type IN ('PO','PA') THEN
3273 -- Mod Project
3274 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DRAFT_ID');
3275 IF l_draft_id IS NULL THEN
3276 l_draft_id := -1;
3277 END IF;
3278 OPEN po_cursor(l_document_id, l_draft_id);
3279 FETCH po_cursor INTO l_wf_item_key;
3280
3281 CLOSE po_cursor;
3282 -- Mod Project
3283 ELSIF l_document_type = 'RELEASE' THEN
3284 OPEN rel_cursor(l_document_id);
3285 FETCH rel_cursor INTO l_wf_item_key;
3286
3287 CLOSE rel_cursor;
3288 END IF;
3289 IF l_wf_item_key IS NOT NULL THEN
3290 Close_Old_Notif(itemtype, l_wf_item_key);
3291 END IF;
3292 resultout := wf_engine.eng_completed ;
3293 x_progress := 'PO_REQAPPROVAL_INIT1.Remove_reminder_notif: 02.';
3294 IF (g_po_wf_debug = 'Y') THEN
3295 /* DEBUG */
3296 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3297 END IF;
3298 EXCEPTION
3299 WHEN OTHERS THEN
3300 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3301 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3302 wf_core.context('PO_REQAPPROVAL_INIT1.Remove_reminder_notif',x_progress);
3303 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.REMOVE_REMINDER_NOTIF');
3304 raise;
3305 END Remove_reminder_notif;
3306 PROCEDURE Print_Doc_Yes_No
3307 (
3308 itemtype IN VARCHAR2,
3309 itemkey IN VARCHAR2,
3310 actid IN NUMBER,
3311 funcmode IN VARCHAR2,
3312 resultout OUT NOCOPY VARCHAR2 )
3313 IS
3314 l_orgid NUMBER;
3315 l_print_doc VARCHAR2(2);
3316 x_progress VARCHAR2(300);
3317 l_doc_string VARCHAR2(200);
3318 l_preparer_user_name VARCHAR2(100);
3319 BEGIN
3320 x_progress := 'PO_REQAPPROVAL_INIT1.Print_Doc_Yes_No: 01';
3321 IF (g_po_wf_debug = 'Y') THEN
3322 /* DEBUG */
3323 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3324 END IF;
3325 -- Do nothing in cancel or timeout mode
3326 --
3327 IF (funcmode <> wf_engine.eng_run) THEN
3328 resultout := wf_engine.eng_null;
3329 RETURN;
3330 END IF;
3331 l_print_doc := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'PRINT_DOCUMENT');
3332 /* the value of l_print_doc should be Y or N */
3333 IF (NVL(l_print_doc,'N') <> 'Y') THEN
3334 l_print_doc := 'N';
3335 END IF;
3336 --
3337 resultout := wf_engine.eng_completed || ':' || l_print_doc ;
3338 --
3339 x_progress := 'PO_REQAPPROVAL_INIT1.Print_Doc_Yes_No: 02. Result= ' || l_print_doc;
3340 IF (g_po_wf_debug = 'Y') THEN
3341 /* DEBUG */
3342 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3343 END IF;
3344 EXCEPTION
3345 WHEN OTHERS THEN
3346 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3347 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3348 wf_core.context('PO_REQAPPROVAL_INIT1.Print_Doc_Yes_No',x_progress);
3349 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.PRINT_DOC_YES_NO');
3350 raise;
3351 END Print_Doc_Yes_No;
3352 -- DKC 10/10/99
3353 PROCEDURE Fax_Doc_Yes_No
3354 (
3355 itemtype IN VARCHAR2,
3356 itemkey IN VARCHAR2,
3357 actid IN NUMBER,
3358 funcmode IN VARCHAR2,
3359 resultout OUT NOCOPY VARCHAR2 )
3360 IS
3361 l_orgid NUMBER;
3362 l_fax_doc VARCHAR2(2);
3363 x_progress VARCHAR2(300);
3364 l_doc_string VARCHAR2(200);
3365 l_preparer_user_name VARCHAR2(100);
3366 BEGIN
3367 x_progress := 'PO_REQAPPROVAL_INIT1.Fax_Doc_Yes_No: 01';
3368 IF (g_po_wf_debug = 'Y') THEN
3369 /* DEBUG */
3370 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3371 END IF;
3372 -- Do nothing in cancel or timeout mode
3373 --
3374 IF (funcmode <> wf_engine.eng_run) THEN
3375 resultout := wf_engine.eng_null;
3376 RETURN;
3377 END IF;
3378 l_fax_doc := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'FAX_DOCUMENT');
3379 /* the value of l_fax_doc should be Y or N */
3380 IF (NVL(l_fax_doc,'N') <> 'Y') THEN
3381 l_fax_doc := 'N';
3382 END IF;
3383 --
3384 resultout := wf_engine.eng_completed || ':' || l_fax_doc ;
3385 --
3386 x_progress := 'PO_REQAPPROVAL_INIT1.Fax_Doc_Yes_No: 02. Result= ' || l_fax_doc;
3387 IF (g_po_wf_debug = 'Y') THEN
3388 /* DEBUG */
3389 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3390 END IF;
3391 EXCEPTION
3392 WHEN OTHERS THEN
3393 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3394 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3395 wf_core.context('PO_REQAPPROVAL_INIT1.Fax_Doc_Yes_No',x_progress);
3396 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.FAX_DOC_YES_NO');
3397 raise;
3398 END Fax_Doc_Yes_No;
3399 --SR-ASL FPH --
3400 PROCEDURE Create_SR_ASL_Yes_No
3401 (
3402 itemtype IN VARCHAR2,
3403 itemkey IN VARCHAR2,
3404 actid IN NUMBER,
3405 funcmode IN VARCHAR2,
3406 resultout OUT NOCOPY VARCHAR2 )
3407 IS
3408 l_orgid NUMBER;
3409 l_create_sr_asl VARCHAR2(2);
3410 x_progress VARCHAR2(300);
3411 l_doc_string VARCHAR2(200);
3412 l_preparer_user_name VARCHAR2(100);
3413 l_document_type PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE;
3414 l_document_subtype PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE;
3415 l_resp_id NUMBER;
3416 l_user_id NUMBER;
3417 l_appl_id NUMBER;
3418 BEGIN
3419 x_progress := 'PO_REQAPPROVAL_INIT1.Create_SR_ASL_Yes_No: 01';
3420 IF (g_po_wf_debug = 'Y') THEN
3421 /* DEBUG */
3422 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3423 END IF;
3424 -- Do nothing in cancel or timeout mode
3425 IF (funcmode <> wf_engine.eng_run) THEN
3426 resultout := wf_engine.eng_null;
3427 RETURN;
3428 END IF;
3429 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
3430 l_user_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'USER_ID');
3431 l_resp_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'RESPONSIBILITY_ID');
3432 l_appl_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'APPLICATION_ID');
3433 /* Since the call may be started from background engine (new seesion),
3434 * need to ensure the fnd context is correct
3435 */
3436 --Context Setting Revamp
3437 /* if (l_user_id is not null and
3438 l_resp_id is not null and
3439 l_appl_id is not null )then
3440 -- Bug 4290541,replaced apps init call with set doc mgr contxt
3441 PO_REQAPPROVAL_INIT1.Set_doc_mgr_context(itemtype, itemkey); */
3442 IF l_orgid IS NOT NULL THEN
3443 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
3444 END IF;
3445 -- end if;
3446 l_create_sr_asl := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CREATE_SOURCING_RULE');
3447 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3448 l_document_subtype := wf_engine.GetItemAttrText (itemtype =>itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3449 /* the value of CREATE_SOURCING_RULE should be Y or N */
3450 IF (NVL(l_create_sr_asl,'N') <> 'Y') THEN
3451 l_create_sr_asl := 'N';
3452 ELSE
3453 IF l_document_type = 'PA' THEN
3454 IF l_document_subtype = 'BLANKET' THEN
3455 l_create_sr_asl := 'Y';
3456 ELSE
3457 l_create_sr_asl := 'N';
3458 END IF;
3459 ELSE
3460 l_create_sr_asl := 'N';
3461 END IF;
3462 END IF;
3463 resultout := wf_engine.eng_completed || ':' || l_create_sr_asl;
3464 x_progress := 'PO_REQAPPROVAL_INIT1.Create_SR_ASL_Yes_No: 02. Result= ' || l_create_sr_asl;
3465 IF (g_po_wf_debug = 'Y') THEN
3466 /* DEBUG */
3467 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3468 END IF;
3469 EXCEPTION
3470 WHEN OTHERS THEN
3471 l_create_sr_asl := 'N';
3472 resultout := wf_engine.eng_completed || ':' || l_create_sr_asl;
3473 END Create_SR_ASL_Yes_No;
3474 -- DKC 10/10/99
3475 PROCEDURE Send_WS_Notif_Yes_No
3476 (
3477 itemtype IN VARCHAR2,
3478 itemkey IN VARCHAR2,
3479 actid IN NUMBER,
3480 funcmode IN VARCHAR2,
3481 resultout OUT NOCOPY VARCHAR2 )
3482 IS
3483 l_orgid NUMBER;
3484 l_send_notif VARCHAR2(2);
3485 x_progress VARCHAR2(300);
3486 l_document_type VARCHAR2(25);
3487 l_document_subtype po_document_types.document_subtype%type;
3488 l_document_id NUMBER;
3489 l_notifier VARCHAR2(100);
3490 l_doc_string VARCHAR2(200);
3491 l_preparer_user_name VARCHAR2(100);
3492 BEGIN
3493 x_progress := 'PO_REQAPPROVAL_INIT1.Send_Notification_Yes_No: 01';
3494 IF (g_po_wf_debug = 'Y') THEN
3495 /* DEBUG */
3496 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3497 END IF;
3498 -- Do nothing in cancel or timeout mode
3499 --
3500 IF (funcmode <> wf_engine.eng_run) THEN
3501 resultout := wf_engine.eng_null;
3502 RETURN;
3503 END IF;
3504 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3505 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3506 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3507 PO_REQAPPROVAL_INIT1.locate_notifier(l_document_id, l_document_type, l_notifier);
3508 IF (l_notifier IS NOT NULL) THEN
3509 l_send_notif := 'Y';
3510 --Bug#2843760: Call ARCHIVE_PO whenever notification is sent to supplier
3511 ARCHIVE_PO(l_document_id, l_document_type, l_document_subtype);
3512 wf_engine.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_NOTIF_PERFORMER', avalue => l_notifier);
3513 ELSE
3514 l_send_notif := 'N';
3515 END IF;
3516 resultout := wf_engine.eng_completed || ':' || l_send_notif ;
3517 x_progress := 'PO_REQAPPROVAL_INIT1.Send_Notification_Yes_No: 02. Result= ' || l_send_notif;
3518 IF (g_po_wf_debug = 'Y') THEN
3519 /* DEBUG */
3520 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3521 END IF;
3522 EXCEPTION
3523 WHEN OTHERS THEN
3524 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3525 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3526 wf_core.context('PO_REQAPPROVAL_INIT1.Send_Notification_Yes_No',x_progress);
3527 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.FAX_DOC_YES_NO');
3528 raise;
3529 END Send_WS_Notif_Yes_No;
3530 /*
3531 < Added this procedure as part of Bug #: 2810150 >
3532 */
3533 PROCEDURE Send_WS_FYI_Notif_Yes_No
3534 (
3535 itemtype IN VARCHAR2,
3536 itemkey IN VARCHAR2,
3537 actid IN NUMBER,
3538 funcmode IN VARCHAR2,
3539 resultout OUT NOCOPY VARCHAR2 )
3540 IS
3541 l_orgid NUMBER;
3542 l_send_notif VARCHAR2(2);
3543 x_progress VARCHAR2(300);
3544 l_document_type VARCHAR2(25);
3545 l_document_subtype po_document_types.document_subtype%type;
3546 l_document_id NUMBER;
3547 l_notifier VARCHAR2(100);
3548 l_notifier_resp VARCHAR2(100);
3549 l_doc_string VARCHAR2(200);
3550 l_preparer_user_name VARCHAR2(100);
3551 -- BINDING FPJ
3552 l_acceptance_flag PO_HEADERS_ALL.acceptance_required_flag%TYPE;
3553 BEGIN
3554 x_progress := 'PO_REQAPPROVAL_INIT1.Send_WS_FYI_Notif_Yes_No: 01';
3555 IF (g_po_wf_debug = 'Y') THEN
3556 /* DEBUG */
3557 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3558 END IF;
3559 -- Do nothing in cancel or timeout mode
3560 --
3561 IF (funcmode <> wf_engine.eng_run) THEN
3562 resultout := wf_engine.eng_null;
3563 RETURN;
3564 END IF;
3565 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3566 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3567 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3568 -- BINDING FPJ START
3569 IF ((l_document_type <> 'RELEASE') AND l_document_subtype IN ('STANDARD','BLANKET','CONTRACT')) THEN
3570 SELECT acceptance_required_flag
3571 INTO l_acceptance_flag
3572 FROM po_headers_all
3573 WHERE po_header_Id = l_document_id;
3574 IF l_acceptance_flag = 'S' THEN
3575 PO_REQAPPROVAL_INIT1.locate_notifier(l_document_id, l_document_type, 'Y', l_notifier, l_notifier_resp);
3576 ELSE
3577 PO_REQAPPROVAL_INIT1.locate_notifier(l_document_id, l_document_type, 'N', l_notifier, l_notifier_resp);
3578 END IF;
3579 ELSE
3580 -- BINDING FPJ END
3581 PO_REQAPPROVAL_INIT1.locate_notifier(l_document_id, l_document_type, 'N', l_notifier, l_notifier_resp);
3582 END IF;
3583 IF (l_notifier IS NOT NULL) THEN
3584 l_send_notif := 'Y';
3585 --Bug#2843760: Call ARCHIVE_PO whenever notification is sent to supplier
3586 ARCHIVE_PO(l_document_id, l_document_type, l_document_subtype);
3587 wf_engine.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_NOTIF_PERFORMER', avalue => l_notifier);
3588 ELSE
3589 l_send_notif := 'N';
3590 END IF;
3591 wf_engine.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_ACK_NOTIF_PERFORMER', avalue => l_notifier_resp);
3592 resultout := wf_engine.eng_completed || ':' || l_send_notif ;
3593 x_progress := 'PO_REQAPPROVAL_INIT1.Send_WS_FYI_Notif_Yes_No: 02. Result= ' || l_send_notif;
3594 IF (g_po_wf_debug = 'Y') THEN
3595 /* DEBUG */
3596 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3597 END IF;
3598 EXCEPTION
3599 WHEN OTHERS THEN
3600 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3601 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3602 wf_core.context('PO_REQAPPROVAL_INIT1.Send_WS_FYI_Notif_Yes_No',x_progress);
3603 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.Send_WS_FYI_Notif_Yes_No');
3604 raise;
3605 END Send_WS_FYI_Notif_Yes_No;
3606 /*
3607 < Added this procedure as part of Bug #: 2810150 >
3608 */
3609 PROCEDURE Send_WS_ACK_Notif_Yes_No
3610 (
3611 itemtype IN VARCHAR2,
3612 itemkey IN VARCHAR2,
3613 actid IN NUMBER,
3614 funcmode IN VARCHAR2,
3615 resultout OUT NOCOPY VARCHAR2 )
3616 IS
3617 l_orgid NUMBER;
3618 l_send_notif VARCHAR2(2);
3619 x_progress VARCHAR2(300);
3620 l_document_type VARCHAR2(25);
3621 l_document_subtype po_document_types.document_subtype%type;
3622 l_document_id NUMBER;
3623 l_notifier VARCHAR2(100);
3624 l_doc_string VARCHAR2(200);
3625 l_preparer_user_name VARCHAR2(100);
3626 BEGIN
3627 x_progress := 'PO_REQAPPROVAL_INIT1.Send_WS_ACK_Notif_Yes_No: 01';
3628 IF (g_po_wf_debug = 'Y') THEN
3629 /* DEBUG */
3630 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3631 END IF;
3632 -- Do nothing in cancel or timeout mode
3633 --
3634 IF (funcmode <> wf_engine.eng_run) THEN
3635 resultout := wf_engine.eng_null;
3636 RETURN;
3637 END IF;
3638 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3639 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3640 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3641 l_notifier :=wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_ACK_NOTIF_PERFORMER');
3642 IF (l_notifier IS NOT NULL) THEN
3643 --Bug#2843760: Call ARCHIVE_PO whenever notification is sent to supplier
3644 ARCHIVE_PO(l_document_id, l_document_type, l_document_subtype);
3645 l_send_notif := 'Y';
3646 ELSE
3647 l_send_notif := 'N';
3648 END IF;
3649 resultout := wf_engine.eng_completed || ':' || l_send_notif ;
3650 x_progress := 'PO_REQAPPROVAL_INIT1.Send_WS_ACK_Notif_Yes_No: 02. Result= ' || l_send_notif;
3651 IF (g_po_wf_debug = 'Y') THEN
3652 /* DEBUG */
3653 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3654 END IF;
3655 EXCEPTION
3656 WHEN OTHERS THEN
3657 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
3658 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
3659 wf_core.context('PO_REQAPPROVAL_INIT1.Send_WS_ACK_Notif_Yes_No',x_progress);
3660 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.Send_WS_ACK_Notif_Yes_No');
3661 raise;
3662 END Send_WS_ACK_Notif_Yes_No;
3663 /*
3664 For the given document_id ( ie. po_header_id ), this procedure
3665 tries to find out the correct users that need to be sent the
3666 notifications.
3667 This procedure assumes that all the supplier users related to this
3668 document need to be sent the notification.
3669 Returns the role containing all the users in the "resultout" variable
3670 */
3671 PROCEDURE locate_notifier
3672 (
3673 document_id IN VARCHAR2,
3674 document_type IN VARCHAR2,
3675 resultout IN OUT NOCOPY VARCHAR2)
3676 IS
3677 l_role_with_resp VARCHAR2(1000);
3678 l_notify_only_flag VARCHAR2(10);
3679 BEGIN
3680 l_notify_only_flag := 'Y';
3681 locate_notifier(document_id, document_type, l_notify_only_flag, resultout, l_role_with_resp);
3682 END;
3683 /*******************************************************************
3684 < Added this procedure as part of Bug #: 2810150 >
3685 PROCEDURE NAME: locate_notifier
3686 DESCRIPTION :
3687 For the given document_id ( ie. po_header_id ), this procedure
3688 tries to find out the correct users that need to be sent the
3689 notifications.
3690 Referenced by : Workflow procedures
3691 parameters :
3692 Input:
3693 document_id - the document id
3694 document_type - Document type
3695 p_notify_only_flag -
3696 The values can be 'Y' or 'N'
3697 'Y' means: The procedure will return all the users that are supplier users related to the document.
3698 Returns the role containing all the users in the "x_resultout" variable
3699 'N' means: we want users that need to be sent FYI and also the users with resp.
3700 x_resultout: will have the role for the users that need to be sent the FYI
3701 x_role_with_resp: will have the role for users having the fucntion "POS_ACK_ORDER" assigned to
3702 them.
3703 Output:
3704 x_resultout - Role for the users that need to be sent FYI
3705 x_role_with_resp - Role for the users who have the ability to acknowledge.
3706 CHANGE History: Created 27-Feb-2003 jpasala
3707 modified 10-JUL-2003 sahegde
3708 Bugs Fixed: 7233648 - Start
3709 Added a condition cancel_flag = N in where-clause of the query to calculate
3710 expiration_date. Also added if-condition to check if expiration_date is less
3711 than sysdate then expiration_date = sysdate +180, so that role's expiry date
3712 is six months from sysdate.
3713 Bugs Fixed: 7233648 - End
3714 *******************************************************************/
3715 PROCEDURE locate_notifier
3716 (
3717 p_document_id IN VARCHAR2,
3718 p_document_type IN VARCHAR2,
3719 p_notify_only_flag IN VARCHAR2,
3720 x_resultout IN OUT NOCOPY VARCHAR2,
3721 x_role_with_resp IN OUT NOCOPY VARCHAR2)
3722 IS
3723 /*CONERMS FPJ START*/
3724 -- declare local variables to hold output of get_supplier_userlist call
3725 l_supplier_user_tbl po_vendors_grp.external_user_tbl_type;
3726 l_namelist VARCHAR2(31990):=NULL;
3727 l_namelist_for_sql VARCHAR2(32000):=NULL;
3728 l_num_users NUMBER := 0;
3729 l_vendor_id NUMBER;
3730 l_return_status VARCHAR2(1);
3731 l_msg_count NUMBER := 0;
3732 l_msg_data VARCHAR2(2000);
3733 /*CONERMS FPJ END*/
3734 -- local variables for role creation
3735 l_role_name WF_USER_ROLES.ROLE_NAME%TYPE;
3736 l_role_display_name VARCHAR2(100):=NULL;
3737 l_temp VARCHAR2(100);
3738 l_expiration_date DATE;
3739 l_count NUMBER;
3740 l_select BOOLEAN;
3741 l_refcur1 g_refcur;
3742 l_users_with_resp VARCHAR2(32000);
3743 l_step VARCHAR2(32000) := '0';
3744 l_diff_users_for_sql VARCHAR2(32000);
3745 l_user_count_with_resp NUMBER:=0;
3746 l_fyi_user_count NUMBER:=0;
3747 BEGIN
3748 l_num_users := 0;
3749 l_step := '0';
3750 /* CONTERMS FPJ START */
3751 -- The code to create the user list has been sliced into another procedure
3752 -- called po_vendors_grp.get_external_userlist. This procedure now makes a
3753 -- call to it to retrieve, comma and space delimited userlist, and number
3754 -- of users, supplier list in a table and vendor id.
3755 /*po_doc_utl_pvt.get_supplier_userlist(p_document_id => p_document_id
3756 ,p_document_type => p_document_type
3757 ,x_return_status => l_return_status
3758 ,x_supplier_user_tbl => l_supplier_user_tbl
3759 ,x_supplier_userlist => l_namelist
3760 ,x_supplier_userlist_for_sql => l_namelist_for_sql
3761 ,x_num_users => l_num_users
3762 ,x_vendor_id => l_vendor_id);*/
3763
3764 po_vendors_grp.get_external_userlist (
3765 p_api_version => 1.0 , p_init_msg_list => FND_API.G_FALSE , p_document_id => p_document_id ,
3766 p_document_type => p_document_type , x_return_status => l_return_status , x_msg_count => l_msg_count ,
3767 x_msg_data => l_msg_data , x_external_user_tbl => l_supplier_user_tbl , x_supplier_userlist => l_namelist ,
3768 x_supplier_userlist_for_sql => l_namelist_for_sql , x_num_users => l_num_users , x_vendor_id => l_vendor_id);
3769 l_step := '0'||l_namelist;
3770 -- proceed if return status is success
3771 IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
3772 l_step := '4'|| l_namelist;
3773 IF(l_namelist IS NULL) THEN
3774 x_resultout := NULL;
3775 ELSE
3776 IF (p_document_type IN ('PO', 'PA')) THEN
3777 SELECT MAX(need_by_date)+180
3778 INTO l_expiration_date
3779 FROM po_line_locations
3780 WHERE po_header_id = to_number(p_document_id)
3781 AND cancel_flag = 'N';
3782 IF l_expiration_date <= sysdate THEN
3783 l_expiration_date := sysdate + 180;
3784 END IF;
3785 elsif (p_document_type = 'RELEASE') THEN
3786 SELECT MAX(need_by_date)+180
3787 INTO l_expiration_date
3788 FROM po_line_locations
3789 WHERE po_release_id = to_number(p_document_id)
3790 AND cancel_flag = 'N';
3791 IF l_expiration_date <= sysdate THEN
3792 l_expiration_date := sysdate + 180;
3793 END IF;
3794 ELSE
3795 l_expiration_date:=NULL;
3796 END IF;
3797 BEGIN
3798 SELECT vendor_name
3799 INTO l_role_display_name
3800 FROM po_vendors
3801 WHERE vendor_id=l_vendor_id;
3802 EXCEPTION
3803 WHEN OTHERS THEN
3804 l_role_display_name:=' ';
3805 END;
3806 IF p_notify_only_flag = 'Y' THEN
3807 l_role_name := get_wf_role_for_users(l_namelist_for_sql, l_num_users ) ;
3808 ELSE
3809 -- get the list of users with the given resp from the current set of users
3810 l_step := '6';
3811 get_user_list_with_resp( get_function_id('POS_ACK_ORDER'), l_namelist_for_sql, l_namelist, l_users_with_resp,l_user_count_with_resp);
3812 IF ( l_user_count_with_resp > 0 ) THEN
3813 l_step := '7 : '|| l_user_count_with_resp;
3814 x_role_with_resp := get_wf_role_for_users(l_users_with_resp, l_user_count_with_resp ) ;
3815 IF(x_role_with_resp IS NULL ) THEN
3816 x_role_with_resp :=SUBSTR('ADHOCR' || TO_CHAR(sysdate, 'JSSSSS')|| p_document_id || p_document_type, 1, 30);
3817 l_step := '17'|| x_role_with_resp ;
3818 WF_DIRECTORY.CreateAdHocRole(x_role_with_resp, l_role_display_name , NULL, NULL, NULL, 'MAILHTML', l_namelist, NULL, NULL, 'ACTIVE', l_expiration_date);
3819 END IF;
3820 ELSE
3821 x_role_with_resp := NULL;
3822 END IF;
3823 l_fyi_user_count := l_num_users - l_user_count_with_resp;
3824 IF ( l_fyi_user_count =0 ) THEN
3825 /* x_resultout := x_role_with_resp;*/
3826 /* Bug 5087421 */
3827 x_resultout :=NULL;
3828 RETURN;
3829 END IF;
3830 l_step := '10: ' ;
3831 IF ( l_user_count_with_resp > 0 ) THEN
3832 get_diff_in_user_list ( l_namelist_for_sql, l_users_with_resp , l_namelist , l_diff_users_for_sql, l_fyi_user_count);
3833 ELSE
3834 l_diff_users_for_sql:= l_namelist_for_sql;
3835 l_fyi_user_count := l_num_users;
3836 END IF;
3837 l_step := '11: count='||l_fyi_user_count ;
3838 l_role_name := get_wf_role_for_users(l_diff_users_for_sql, l_fyi_user_count ) ;
3839 END IF; -- End of notify flag check
3840 IF (l_role_name IS NULL ) THEN
3841 l_step := '17'|| l_role_name;
3842 /* Bug 2966804 START */
3843 /* We need to give a role name before creating an ADHOC role. */
3844 l_role_name := SUBSTR('ADHOC' || TO_CHAR(sysdate, 'JSSSSS')|| p_document_id || p_document_type, 1, 30);
3845 /* Bug 2966804 END */
3846 WF_DIRECTORY.CreateAdHocRole(l_role_name, l_role_display_name , NULL, NULL, NULL, 'MAILHTML', l_namelist, NULL, NULL, 'ACTIVE', l_expiration_date);
3847 x_resultout:=l_role_name;
3848 ELSE
3849 l_step := '11'|| l_role_name;
3850 x_resultout:= l_role_name;
3851 END IF;
3852 END IF;
3853 END IF;
3854 EXCEPTION
3855 WHEN OTHERS THEN
3856 wf_core.context('PO_REQAPPROVAL_INIT1.locate_notifier failed at:',l_step);
3857 wf_core.context('PO_REQAPPROVAL_INIT1.locate_notifier',l_role_name||sqlerrm);
3858 --raise_application_error(-20001,'l_role_name ='||l_role_name ||' and l_step='||l_step ||' and l_list='||l_namelist_for_sql, true);
3859 END locate_notifier;
3860 -- DKC 02/06/01
3861 PROCEDURE Email_Doc_Yes_No
3862 (
3863 itemtype IN VARCHAR2,
3864 itemkey IN VARCHAR2,
3865 actid IN NUMBER,
3866 funcmode IN VARCHAR2,
3867 resultout OUT NOCOPY VARCHAR2 )
3868 IS
3869 l_orgid NUMBER;
3870 l_email_doc VARCHAR2(2);
3871 x_progress VARCHAR2(300);
3872 l_doc_string VARCHAR2(200);
3873 l_preparer_user_name VARCHAR2(100);
3874 l_document_type VARCHAR2(25);
3875 l_document_subtype VARCHAR2(25);
3876 l_document_id NUMBER;
3877 l_po_header_id NUMBER;
3878 l_vendor_site_code VARCHAR2(15);
3879 l_vendor_site_id NUMBER;
3880 --EMAILPO FPH START--
3881 l_vendor_site_lang PO_VENDOR_SITES.LANGUAGE%TYPE;
3882 l_adhocuser_lang WF_LANGUAGES.NLS_LANGUAGE%TYPE;
3883 l_adhocuser_territory WF_LANGUAGES.NLS_TERRITORY%TYPE;
3884 --EMAILPO FPH START--
3885 /* Bug 2989951 Increased the width of the following variables */
3886 l_po_email_performer WF_USERS.NAME%TYPE;
3887 l_po_email_add WF_USERS.EMAIL_ADDRESS%TYPE;
3888 l_display_name WF_USERS.DISPLAY_NAME%TYPE;
3889 l_po_email_performer_prof WF_USERS.NAME%TYPE;
3890 l_po_email_add_prof WF_USERS.EMAIL_ADDRESS%TYPE;
3891 l_display_name_prof WF_USERS.DISPLAY_NAME%TYPE;
3892 l_performer_exists NUMBER;
3893 l_notification_preference VARCHAR2(20) := 'MAILHTM2'; -- Bug 3788367
3894 l_when_to_archive VARCHAR2(80);
3895 l_archive_result VARCHAR2(2);
3896 /* Bug 9108606 */
3897 l_note fnd_new_messages.message_text%TYPE;
3898 /* End Bug 9108606 */
3899 /*Bug 9283386*/
3900 l_doc_display_name FND_NEW_MESSAGES.message_text%TYPE;
3901 l_lang_code wf_languages.code%TYPE;
3902 /*Bug 9283386*/
3903
3904 --ER 5688144: retrieve vendor name for display name of email address
3905 l_vendor_name po_vendors.vendor_name%TYPE;
3906 --ER 5688144: End
3907 BEGIN
3908 x_progress := 'PO_REQAPPROVAL_INIT1.Email_Doc_Yes_No: 01';
3909 IF (g_po_wf_debug = 'Y') THEN
3910 /* DEBUG */
3911 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
3912 END IF;
3913 -- Do nothing in cancel or timeout mode
3914 --
3915 IF (funcmode <> wf_engine.eng_run) THEN
3916 resultout := wf_engine.eng_null;
3917 RETURN;
3918 END IF;
3919 /* Bug 2687751.
3920 * For blankets, the org context was not getting set and hence
3921 * sql query which selecs vendor_site_id below from po_vendor_sites
3922 * was throwing an exception. Hence setting the org context here.
3923 */
3924 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
3925 IF l_orgid IS NOT NULL THEN
3926 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
3927 END IF;
3928 x_progress := '001';
3929 -- Create the attribute email document
3930 l_email_doc := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'EMAIL_DOCUMENT');
3931 -- the value of l_email_doc should be Y or N
3932 IF (NVL(l_email_doc,'N') <> 'Y') THEN
3933 l_email_doc := 'N';
3934 END IF;
3935 -- Here, we are creating an entry in wf_local_users and assigning that to the email performer
3936 IF (l_email_doc = 'Y') THEN
3937 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
3938 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
3939 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
3940 l_po_email_add := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'EMAIL_ADDRESS');
3941 l_po_email_add_prof := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'EMAIL_ADD_FROM_PROFILE');
3942 IF (l_document_type IN ('PO', 'PA')) THEN
3943 l_po_header_id := l_document_id;
3944 elsif (l_document_type = 'RELEASE') THEN
3945 SELECT po_header_id
3946 INTO l_po_header_id
3947 FROM po_releases
3948 WHERE po_release_id = l_document_id;
3949 ELSE
3950 NULL;
3951 END IF;
3952 x_progress := '002';
3953 --EMAILPO FPH--
3954 --also retrieve language to set the adhocuser language to supplier site preferred language
3955 --ER 5688144: retrieve vendor_name for display name of email address
3956 SELECT poh.vendor_site_id,
3957 pvs.vendor_site_code,
3958 pvs.language, pv.vendor_name
3959 INTO l_vendor_site_id,
3960 l_vendor_site_code,
3961 l_vendor_site_lang, l_vendor_name
3962 FROM po_headers poh,
3963 po_vendor_sites pvs, po_vendors pv
3964 WHERE pvs.vendor_site_id = poh.vendor_site_id
3965 AND pv.vendor_id = poh.vendor_id
3966 AND poh.po_header_id = l_po_header_id;
3967 --ER 5688144: End
3968
3969 /* Bug 2989951
3970 l_po_email_performer := l_vendor_site_code || substr(l_vendor_site_id, 1, 15);
3971 l_display_name := l_vendor_site_code || substr(l_vendor_site_id, 1, 15); */
3972 --EMAILPO FPH START--
3973 /*Bug 9283386 fetched language code into l_lang_code*/
3974 IF l_vendor_site_lang IS NOT NULL THEN
3975 SELECT wfl.nls_language,
3976 wfl.nls_territory,
3977 wfl.code
3978 INTO l_adhocuser_lang,
3979 l_adhocuser_territory,
3980 l_lang_code
3981 FROM wf_languages wfl,
3982 fnd_languages_vl flv
3983 WHERE wfl.code = flv.language_code
3984 AND flv.nls_language = l_vendor_site_lang;
3985 ELSE
3986 SELECT wfl.nls_language,
3987 wfl.nls_territory,
3988 wfl.code
3989 INTO l_adhocuser_lang,
3990 l_adhocuser_territory,
3991 l_lang_code
3992 FROM wf_languages wfl,
3993 fnd_languages_vl flv
3994 WHERE wfl.code = flv.language_code
3995 AND flv.installed_flag = 'B';
3996 END IF;
3997 --EMAILPO FPH END--
3998 /* Bug 9108606 */
3999 /* The Message sent to Supplier should be in Supplier Language if
4000 Suppliers language is different from Buyers language */
4001 IF l_vendor_site_lang IS NOT NULL THEN
4002 BEGIN
4003 x_progress := '003';
4004 -- SQL What : Get the message in the Supliers language.
4005 SELECT message_text
4006 INTO l_note
4007 FROM fnd_new_messages fm,
4008 fnd_languages fl
4009 WHERE fm.message_name = 'PO_PDF_EMAIL_TEXT'
4010 AND fm.language_code = fl.language_code
4011 AND fl.nls_language = l_vendor_site_lang;
4012 EXCEPTION
4013 WHEN OTHERS THEN
4014 NULL;
4015 END;
4016 PO_WF_UTIL_PKG.SetItemAttrText( itemtype => itemtype, itemkey => itemkey, aname => 'EMAIL_TEXT_WITH_PDF', avalue => l_note);
4017 END IF;
4018 /* End Bug 9108606 */
4019 /*Begin Bug 9283386 Setting DOCUMENT_DISPLAY_NAME in l_lang_code*/
4020 l_doc_display_name := PO_DOC_STYLE_PVT.GET_STYLE_DISPLAY_NAME(l_po_header_id,l_lang_code);
4021 wf_engine.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_DISPLAY_NAME', avalue => l_doc_display_name);
4022 l_doc_display_name:=wf_engine.getItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_DISPLAY_NAME');
4023 /*End Bug 9283386*/
4024 /* Bug 2989951. AdHocUser Name should be concatenation of the E-mail Address and the language */
4025 l_po_email_performer := l_po_email_add||'.'||l_adhocuser_lang;
4026 l_po_email_performer := upper(l_po_email_performer);
4027 --ER 5688144: correct the display name of the adhocuser
4028 --as a concatination of the supplier name and supplier site
4029 l_display_name := l_vendor_name||'-'||l_vendor_site_code;
4030 --l_display_name := l_po_email_performer;
4031 --ER 5688144: End
4032
4033 SELECT COUNT(*)
4034 INTO l_performer_exists
4035 FROM wf_users
4036 WHERE name = l_po_email_performer;
4037 /* Bug 2864242 The wf_local_users table is obsolete after the patch 2350501. So used the
4038 wf_users view instead of wf_local_users table */
4039 x_progress := '003';
4040 IF (l_performer_exists = 0) THEN
4041 --EMAILPO FPH--
4042 -- Pass in the correct adhocuser language and territory for CreateAdHocUser and SetAdhocUserAttr instead of null
4043 WF_DIRECTORY.CreateAdHocUser(l_po_email_performer, l_display_name, l_adhocuser_lang, l_adhocuser_territory, NULL, l_notification_preference, l_po_email_add, NULL, 'ACTIVE', NULL);
4044 ELSE
4045 WF_DIRECTORY.SETADHOCUSERATTR(l_po_email_performer, l_display_name, l_notification_preference, l_adhocuser_lang, l_adhocuser_territory, l_po_email_add, NULL);
4046 END IF;
4047 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_EMAIL_PERFORMER', avalue => l_po_email_performer);
4048 /* set the performer from thr profilr to send the second email */
4049 /* Bug 2989951. Secondary AdHocUser Name should be concatenation of the Secondary E-mail Address and the language
4050 l_po_email_performer_prof := 'PO_SECONDRY_EMAIL_ADD';
4051 l_display_name_prof := 'PO_SECONDRY_EMAIL_ADD'; */
4052 l_po_email_performer_prof := l_po_email_add_prof||'.'||l_adhocuser_lang;
4053 l_po_email_performer_prof := upper(l_po_email_performer_prof);
4054 --ER 5688144: correct the display name of Secondary E-mail Address
4055 l_display_name_prof := l_po_email_add_prof;
4056 --l_display_name_prof := l_po_email_performer_prof;
4057 --ER 5688144: End
4058
4059 SELECT COUNT(*)
4060 INTO l_performer_exists
4061 FROM wf_users
4062 WHERE name = l_po_email_performer_prof;
4063 /* Bug 2864242 The wf_local_users table is obsolete after the patch 2350501. So used the
4064 wf_users view instead of wf_local_users table */
4065 --EMAILPO FPH START--
4066 -- For second email also the language and territory settings should be same as for the first one above
4067 x_progress := '004';
4068 IF (l_performer_exists = 0) THEN
4069 WF_DIRECTORY.CreateAdHocUser(l_po_email_performer_prof, l_display_name_prof, l_adhocuser_lang, l_adhocuser_territory, NULL, l_notification_preference, l_po_email_add_prof, NULL, 'ACTIVE', NULL);
4070 ELSE
4071 WF_DIRECTORY.SETADHOCUSERATTR(l_po_email_performer_prof, l_display_name_prof, l_notification_preference, l_adhocuser_lang, l_adhocuser_territory, l_po_email_add_prof, NULL);
4072 END IF;
4073 --EMAILPO FPH END--
4074 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'PO_WF_EMAIL_PERFORMER2', avalue => l_po_email_performer_prof);
4075 x_progress := '005';
4076 -- bug 4727400 : updates need to autonomous, PA needs to be take care of.
4077 update_print_count(l_document_id,l_document_type);
4078 --Bug#2843760: Moved portion of code which does the PO archiving to internal procedure ARCHIVE_PO
4079 ARCHIVE_PO(l_document_id, l_document_type, l_document_subtype);
4080 END IF;
4081 resultout := wf_engine.eng_completed || ':' || l_email_doc ;
4082 x_progress := 'PO_REQAPPROVAL_INIT1.Email_Doc_Yes_No: 02. Result= ' || l_email_doc;
4083 IF (g_po_wf_debug = 'Y') THEN
4084 /* DEBUG */
4085 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4086 END IF;
4087 -- resultout := wf_engine.eng_completed || ':' || 'Y' ;
4088 EXCEPTION
4089 WHEN OTHERS THEN
4090 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4091 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4092 wf_core.context('PO_REQAPPROVAL_INIT1.Email_Doc_Yes_No',x_progress||':'||sqlerrm);
4093 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.EMAIL_DOC_YES_NO');
4094 raise;
4095 END Email_Doc_Yes_No;
4096 -- Print_Document
4097 -- Resultout
4098 -- ACTIVITY_PERFORMED
4099 -- Print Document.
4100 PROCEDURE Print_Document
4101 (
4102 itemtype IN VARCHAR2,
4103 itemkey IN VARCHAR2,
4104 actid IN NUMBER,
4105 funcmode IN VARCHAR2,
4106 resultout OUT NOCOPY VARCHAR2 )
4107 IS
4108 l_orgid NUMBER;
4109 l_print_doc VARCHAR2(2);
4110 x_progress VARCHAR2(300);
4111 l_doc_string VARCHAR2(200);
4112 l_preparer_user_name VARCHAR2(100);
4113 BEGIN
4114 x_progress := 'PO_REQAPPROVAL_INIT1.Print_Document: 01';
4115 IF (g_po_wf_debug = 'Y') THEN
4116 /* DEBUG */
4117 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4118 END IF;
4119 -- Do nothing in cancel or timeout mode
4120 --
4121 IF (funcmode <> wf_engine.eng_run) THEN
4122 resultout := wf_engine.eng_null;
4123 RETURN;
4124 END IF;
4125 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
4126 IF l_orgid IS NOT NULL THEN
4127 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
4128 END IF;
4129 x_progress := 'PO_REQAPPROVAL_INIT1.Print_Document: 02';
4130 PrintDocument(itemtype,itemkey);
4131 --
4132 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED' ;
4133 --
4134 x_progress := 'PO_REQAPPROVAL_INIT1.Print_Document: 03';
4135 EXCEPTION
4136 WHEN OTHERS THEN
4137 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4138 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4139 wf_core.context('PO_REQAPPROVAL_INIT1.Print_Document',x_progress);
4140 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.PRINT_DOCUMENT');
4141 raise;
4142 END Print_Document;
4143 -- Procedure called by wf.
4144 -- DKC 10/10/99
4145 PROCEDURE Fax_Document
4146 (
4147 itemtype IN VARCHAR2,
4148 itemkey IN VARCHAR2,
4149 actid IN NUMBER,
4150 funcmode IN VARCHAR2,
4151 resultout OUT NOCOPY VARCHAR2 )
4152 IS
4153 l_orgid NUMBER;
4154 l_fax_doc VARCHAR2(2);
4155 x_progress VARCHAR2(300);
4156 l_doc_string VARCHAR2(200);
4157 l_preparer_user_name VARCHAR2(100);
4158 BEGIN
4159 x_progress := 'PO_REQAPPROVAL_INIT1.Fax_Document: 01';
4160 IF (g_po_wf_debug = 'Y') THEN
4161 /* DEBUG */
4162 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4163 END IF;
4164 -- Do nothing in cancel or timeout mode
4165 --
4166 IF (funcmode <> wf_engine.eng_run) THEN
4167 resultout := wf_engine.eng_null;
4168 RETURN;
4169 END IF;
4170 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
4171 IF l_orgid IS NOT NULL THEN
4172 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
4173 END IF;
4174 x_progress := 'PO_REQAPPROVAL_INIT1.Fax_Document: 02';
4175 FaxDocument(itemtype,itemkey);
4176 --
4177 resultout := wf_engine.eng_completed || ':' || 'ACTIVITY_PERFORMED' ;
4178 --
4179 x_progress := 'PO_REQAPPROVAL_INIT1.Fax_Document: 03';
4180 EXCEPTION
4181 WHEN OTHERS THEN
4182 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4183 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4184 wf_core.context('PO_REQAPPROVAL_INIT1.Fax_Document',x_progress);
4185 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.FAX_DOCUMENT');
4186 raise;
4187 END Fax_Document;
4188 -- Is_document_Approved
4189 -- IN
4190 -- itemtype -- itemkey -- actid -- funcmode
4191 -- OUT
4192 -- Resultout
4193 --
4194 -- Is the document already approved. This may be the case if the document
4195 -- was PRE-APPROVED before it goes through the reserve action. The RESERVE
4196 -- would then approve the doc after it reserved the funds.
4197 PROCEDURE Is_document_Approved
4198 (
4199 itemtype IN VARCHAR2,
4200 itemkey IN VARCHAR2,
4201 actid IN NUMBER,
4202 funcmode IN VARCHAR2,
4203 resultout OUT NOCOPY VARCHAR2 )
4204 IS
4205 l_auth_stat VARCHAR2(25);
4206 l_doc_type VARCHAR2(25);
4207 l_doc_id NUMBER;
4208 l_orgid NUMBER;
4209 x_resultout VARCHAR2(1);
4210 x_progress VARCHAR2(300);
4211 l_doc_string VARCHAR2(200);
4212 l_preparer_user_name VARCHAR2(100);
4213 BEGIN
4214 x_progress := 'PO_REQAPPROVAL_INIT1.Is_document_Approved: 01';
4215 IF (g_po_wf_debug = 'Y') THEN
4216 /* DEBUG */
4217 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4218 END IF;
4219 -- Do nothing in cancel or timeout mode
4220 --
4221 IF (funcmode <> wf_engine.eng_run) THEN
4222 resultout := wf_engine.eng_null;
4223 RETURN;
4224 END IF;
4225 /* Bug# 2377333
4226 ** Setting application context
4227 */
4228 --Context Setting Revamp
4229 --PO_REQAPPROVAL_INIT1.Set_doc_mgr_context(itemtype, itemkey);
4230 l_orgid := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
4231 IF l_orgid IS NOT NULL THEN
4232 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
4233 END IF;
4234 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
4235 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
4236 IF l_doc_type ='REQUISITION' THEN
4237 x_progress := '002';
4238 SELECT NVL(authorization_status, 'INCOMPLETE')
4239 INTO l_auth_stat
4240 FROM PO_REQUISITION_HEADERS
4241 WHERE requisition_header_id = l_doc_id;
4242 ELSIF l_doc_type IN ('PO','PA') THEN
4243 x_progress := '003';
4244 SELECT NVL(authorization_status,'INCOMPLETE')
4245 INTO l_auth_stat
4246 FROM PO_HEADERS
4247 WHERE po_header_id = l_doc_id;
4248 ELSIF l_doc_type = 'RELEASE' THEN
4249 x_progress := '004';
4250 SELECT NVL(authorization_status,'INCOMPLETE')
4251 INTO l_auth_stat
4252 FROM PO_RELEASES
4253 WHERE po_release_id = l_doc_id;
4254 END IF;
4255 IF l_auth_stat = 'APPROVED' THEN
4256 resultout := wf_engine.eng_completed || ':' || 'Y' ;
4257 x_resultout := 'Y';
4258 ELSE
4259 resultout := wf_engine.eng_completed || ':' || 'N';
4260 x_resultout := 'N';
4261 END IF;
4262 x_progress := 'PO_REQAPPROVAL_INIT1.Is_document_Approved: 02. Result=' || x_resultout;
4263 IF (g_po_wf_debug = 'Y') THEN
4264 /* DEBUG */
4265 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress );
4266 END IF;
4267 EXCEPTION
4268 WHEN OTHERS THEN
4269 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4270 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4271 wf_core.context('PO_REQAPPROVAL_INIT1','Is_document_Approved',x_progress);
4272 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.IS_DOCUMENT_APPROVED');
4273 raise;
4274 END Is_document_Approved;
4275 -- Get_Create_PO_Mode
4276 -- IN
4277 -- itemtype -- itemkey -- actid -- funcmode
4278 -- OUT
4279 -- Resultout
4280 -- Activity Performed
4281 PROCEDURE Get_Create_PO_Mode
4282 (
4283 itemtype IN VARCHAR2,
4284 itemkey IN VARCHAR2,
4285 actid IN NUMBER,
4286 funcmode IN VARCHAR2,
4287 resultout OUT NOCOPY VARCHAR2 )
4288 IS
4289 l_create_po_mode VARCHAR2(1);
4290 x_progress VARCHAR2(300);
4291 l_doc_string VARCHAR2(200);
4292 l_preparer_user_name VARCHAR2(100);
4293 BEGIN
4294 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Create_PO_Mode: 01';
4295 IF (g_po_wf_debug = 'Y') THEN
4296 /* DEBUG */
4297 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4298 END IF;
4299 -- Do nothing in cancel or timeout mode
4300 --
4301 IF (funcmode <> wf_engine.eng_run) THEN
4302 resultout := wf_engine.eng_null;
4303 RETURN;
4304 END IF;
4305 l_create_po_mode := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'SEND_CREATEPO_TO_BACKGROUND');
4306 /* Bug 678291 by dkfchan
4307 ** if the approval mode is background, set the result to 'BACKGROUD'
4308 ** Removed the original method which set the WF_ENGINE.THRESHOLD to -1.
4309 ** This fix depends on the change poxwfrqa.wft and poxwfpoa.wft also.
4310 */
4311 IF NVL(l_create_po_mode,'N') = 'Y' THEN
4312 resultout := wf_engine.eng_completed || ':' || 'BACKGROUND';
4313 ELSE
4314 resultout := wf_engine.eng_completed || ':' || 'ONLINE';
4315 END IF;
4316 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Create_PO_Mode: ' || 'Create PO Mode= ' || l_create_po_mode;
4317 IF (g_po_wf_debug = 'Y') THEN
4318 /* DEBUG */
4319 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4320 END IF;
4321 EXCEPTION
4322 WHEN OTHERS THEN
4323 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4324 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4325 wf_core.context('PO_REQAPPROVAL_INIT1','Get_Create_PO_Mode',x_progress);
4326 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.GET_CREATE_PO_MODE');
4327 raise;
4328 END Get_Create_PO_Mode;
4329 -- Get_Workflow_Approval_Mode
4330 -- IN
4331 -- itemtype -- itemkey -- actid -- funcmode
4332 -- OUT
4333 -- Resultout
4334 -- On-line
4335 -- Background
4336 PROCEDURE Get_Workflow_Approval_Mode
4337 (
4338 itemtype IN VARCHAR2,
4339 itemkey IN VARCHAR2,
4340 actid IN NUMBER,
4341 funcmode IN VARCHAR2,
4342 resultout OUT NOCOPY VARCHAR2 )
4343 IS
4344 l_approval_mode VARCHAR2(30);
4345 x_progress VARCHAR2(300);
4346 l_doc_string VARCHAR2(200);
4347 l_preparer_user_name VARCHAR2(100);
4348 BEGIN
4349 /* get the profile PO_WORKFLOW_APPROVAL_MODE and return the value */
4350 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Workflow_Approval_Mode: 01';
4351 IF (g_po_wf_debug = 'Y') THEN
4352 /* DEBUG */
4353 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4354 END IF;
4355 -- Do nothing in cancel or timeout mode
4356 --
4357 IF (funcmode <> wf_engine.eng_run) THEN
4358 resultout := wf_engine.eng_null;
4359 RETURN;
4360 END IF;
4361 fnd_profile.get('PO_WORKFLOW_APPROVAL_MODE', l_approval_mode);
4362 /* Bug 678291 by dkfchan
4363 ** if the approval mode is background, set the result to 'BACKGROUD'
4364 ** Removed the original method which set the WF_ENGINE.THRESHOLD to -1.
4365 ** This fix depends on the change poxwfrqa.wft and poxwfpoa.wft also.
4366 */
4367 IF l_approval_mode = 'BACKGROUND' OR l_approval_mode IS NULL THEN
4368 resultout := wf_engine.eng_completed || ':' || 'BACKGROUND';
4369 ELSE
4370 resultout := wf_engine.eng_completed || ':' || 'ONLINE';
4371 END IF;
4372 x_progress := 'PO_REQAPPROVAL_INIT1.Get_Workflow_Approval_Mode: ' || 'Approval Mode= ' || l_approval_mode;
4373 IF (g_po_wf_debug = 'Y') THEN
4374 /* DEBUG */
4375 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4376 END IF;
4377 EXCEPTION
4378 WHEN OTHERS THEN
4379 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
4380 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
4381 wf_core.context('PO_REQAPPROVAL_INIT1','Get_Workflow_Approval_Mode',x_progress);
4382 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.GET_WORKFLOW_APPROVAL_MODE');
4383 raise;
4384 END Get_Workflow_Approval_Mode;
4385 -- Dummy
4386 -- IN
4387 -- itemtype -- itemkey -- actid -- funcmode
4388 -- OUT
4389 -- Resultout
4390 -- Activity Performed
4391 -- Dummy procedure that does nothing (NOOP). Used to set the
4392 -- cost above the backgound engine threshold. This causes the
4393 -- workflow to execute in the background.
4394 PROCEDURE Dummy
4395 (
4396 itemtype IN VARCHAR2,
4397 itemkey IN VARCHAR2,
4398 actid IN NUMBER,
4399 funcmode IN VARCHAR2,
4400 resultout OUT NOCOPY VARCHAR2 )
4401 IS
4402 BEGIN
4403 /* Do nothing */
4404 NULL;
4405 END Dummy;
4406 /****************************************************************************
4407 * The Following are the supporting APIs to the workflow functions.
4408 * These API's are Private (Not declared in the Package specs).
4409 ****************************************************************************/
4410 PROCEDURE GetReqAttributes
4411 (
4412 p_requisition_header_id IN NUMBER,
4413 itemtype IN VARCHAR2,
4414 itemkey IN VARCHAR2)
4415 IS
4416 l_line_num VARCHAR2(80);
4417 x_progress VARCHAR2(100) := '000';
4418 counter NUMBER :=0;
4419 BEGIN
4420 x_progress := 'PO_REQAPPROVAL_INIT1.GetReqAttributes: 01';
4421 IF (g_po_wf_debug = 'Y') THEN
4422 /* DEBUG */
4423 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4424 END IF;
4425 /* Fetch the Req Header, then set the attributes. */
4426 OPEN GetRecHdr_csr(p_requisition_header_id);
4427 FETCH GetRecHdr_csr INTO ReqHdr_rec;
4428
4429 CLOSE GetRecHdr_csr;
4430 x_progress := 'PO_REQAPPROVAL_INIT1.GetReqAttributes: 02';
4431 IF (g_po_wf_debug = 'Y') THEN
4432 /* DEBUG */
4433 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4434 END IF;
4435 SetReqHdrAttributes(itemtype, itemkey);
4436 x_progress := 'PO_REQAPPROVAL_INIT1.GetReqAttributes: 03';
4437 IF (g_po_wf_debug = 'Y') THEN
4438 /* DEBUG */
4439 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4440 END IF;
4441 EXCEPTION
4442 WHEN OTHERS THEN
4443 wf_core.context('PO_REQAPPROVAL_INIT1','GetReqAttributes',x_progress);
4444 raise;
4445 END GetReqAttributes;
4446 --
4447 --------------------------------------------------------------------------------
4448 --Start of Comments
4449 --Name: getReqAmountInfo
4450 --Pre-reqs:
4451 -- None.
4452 --Modifies:
4453 -- None.
4454 --Locks:
4455 -- None.
4456 --Function:
4457 -- convert req total, req amount, req tax into approver preferred currency for display
4458 --Parameters:
4459 --IN:
4460 --itemtype
4461 -- workflow item type
4462 --itemtype
4463 -- workflow item key
4464 --p_function_currency
4465 -- functional currency
4466 --p_total_amount_disp
4467 -- req total including tax, in displayable format
4468 --p_total_amount
4469 -- req total including tax, number
4470 --p_req_amount_disp
4471 -- req total without including tax, in displayable format
4472 --p_req_amount
4473 -- req total without including tax, number
4474 --p_tax_amount_disp
4475 -- req tax, in displayable format
4476 --p_tax_amount
4477 -- req tax number
4478 --OUT:
4479 --p_amount_for_subject
4480 --p_amount_for_header
4481 --p_amount_for_tax
4482 --End of Comments
4483 -------------------------------------------------------------------------------
4484 PROCEDURE getReqAmountInfo
4485 (
4486 itemtype IN VARCHAR2,
4487 itemkey IN VARCHAR2,
4488 p_function_currency IN VARCHAR2,
4489 p_total_amount_disp IN VARCHAR2,
4490 p_total_amount IN NUMBER,
4491 p_req_amount_disp IN VARCHAR2,
4492 p_req_amount IN NUMBER,
4493 p_tax_amount_disp IN VARCHAR2,
4494 p_tax_amount IN NUMBER,
4495 x_amount_for_subject OUT nocopy VARCHAR2,
4496 x_amount_for_header OUT nocopy VARCHAR2,
4497 x_amount_for_tax OUT nocopy VARCHAR2)
4498 IS
4499 l_rate_type po_system_parameters.default_rate_type%TYPE;
4500 l_rate NUMBER;
4501 l_denominator_rate NUMBER;
4502 l_numerator_rate NUMBER;
4503 l_approval_currency VARCHAR2(30);
4504 l_amount_disp VARCHAR2(60);
4505 l_amount_approval_currency NUMBER;
4506 l_approver_user_name fnd_user.user_name%TYPE;
4507 l_user_id fnd_user.user_id%TYPE;
4508 l_progress VARCHAR2(200);
4509 l_no_rate_msg VARCHAR2(200);
4510 BEGIN
4511 SELECT default_rate_type INTO l_rate_type FROM po_system_parameters;
4512
4513 l_progress := 'getReqAmountInfo:' || l_rate_type;
4514 IF (g_po_wf_debug = 'Y') THEN
4515 /* DEBUG */
4516 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4517 END IF;
4518 l_approver_user_name := PO_WF_UTIL_PKG.GetItemAttrText(itemtype=>itemtype, itemkey=>itemkey, aname=>'APPROVER_USER_NAME');
4519 IF (l_approver_user_name IS NOT NULL) THEN
4520 SELECT user_id
4521 INTO l_user_id
4522 FROM fnd_user
4523 WHERE user_name = l_approver_user_name;
4524
4525 l_progress := 'getReqAmountInfo:' || l_user_id;
4526 IF (g_po_wf_debug = 'Y') THEN
4527 /* DEBUG */
4528 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4529 END IF;
4530 l_approval_currency := FND_PROFILE.VALUE_SPECIFIC('ICX_PREFERRED_CURRENCY', l_user_id);
4531 END IF;
4532 IF (l_approval_currency = p_function_currency OR l_approver_user_name IS NULL OR l_rate_type IS NULL OR l_approval_currency IS NULL) THEN
4533 x_amount_for_subject := p_total_amount_disp || ' ' || p_function_currency;
4534 x_amount_for_header := p_req_amount_disp || ' ' || p_function_currency;
4535 x_amount_for_tax := p_tax_amount_disp || ' ' || p_function_currency;
4536 RETURN;
4537 END IF;
4538 l_progress := 'getReqAmountInfo:' || l_approval_currency;
4539 IF (g_po_wf_debug = 'Y') THEN
4540 /* DEBUG */
4541 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4542 END IF;
4543 gl_currency_api.get_closest_triangulation_rate(
4544 x_from_currency => p_function_currency, x_to_currency => l_approval_currency,
4545 x_conversion_date => sysdate, x_conversion_type => l_rate_type, x_max_roll_days => 5,
4546 x_denominator => l_denominator_rate, x_numerator => l_numerator_rate, x_rate => l_rate);
4547 l_progress := 'getReqAmountInfo:' || substrb(TO_CHAR(l_rate), 1, 30);
4548 IF (g_po_wf_debug = 'Y') THEN
4549 /* DEBUG */
4550 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4551 END IF;
4552 /* setting amount for notification subject */
4553 l_amount_approval_currency := (p_total_amount/l_denominator_rate) * l_numerator_rate;
4554 l_amount_disp := TO_CHAR(l_amount_approval_currency, FND_CURRENCY.GET_FORMAT_MASK(l_approval_currency,g_currency_format_mask));
4555 x_amount_for_subject := l_amount_disp || ' ' || l_approval_currency;
4556 /* setting amount for header attribute */
4557 l_amount_approval_currency := (p_req_amount/l_denominator_rate) * l_numerator_rate;
4558 l_amount_disp := TO_CHAR(l_amount_approval_currency, FND_CURRENCY.GET_FORMAT_MASK(l_approval_currency,g_currency_format_mask));
4559 l_progress := 'getReqAmountInfo:' || l_amount_disp;
4560 IF (g_po_wf_debug = 'Y') THEN
4561 /* DEBUG */
4562 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4563 END IF;
4564 x_amount_for_header := p_req_amount_disp || ' ' || p_function_currency;
4565 x_amount_for_header := x_amount_for_header || ' (' || l_amount_disp || ' ' || l_approval_currency || ')';
4566 l_amount_approval_currency := (p_tax_amount/l_denominator_rate) * l_numerator_rate;
4567 l_amount_disp := TO_CHAR(l_amount_approval_currency, FND_CURRENCY.GET_FORMAT_MASK(l_approval_currency,g_currency_format_mask));
4568 x_amount_for_tax := p_tax_amount_disp || ' ' || p_function_currency;
4569 x_amount_for_tax := x_amount_for_tax || ' (' || l_amount_disp || ' ' || l_approval_currency || ')';
4570 EXCEPTION
4571 WHEN gl_currency_api.no_rate THEN
4572 l_progress := 'getReqAmountInfo: no rate';
4573 IF (g_po_wf_debug = 'Y') THEN
4574 /* DEBUG */
4575 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4576 END IF;
4577 x_amount_for_subject := p_req_amount_disp || ' ' || p_function_currency;
4578 l_no_rate_msg := fnd_message.get_string('PO', 'PO_WF_NOTIF_NO_RATE');
4579 l_no_rate_msg := REPLACE (l_no_rate_msg, 'CURRENCY', l_approval_currency);
4580 x_amount_for_header := p_req_amount_disp || ' ' || p_function_currency;
4581 x_amount_for_header := x_amount_for_header || ' (' || l_no_rate_msg || ')';
4582 x_amount_for_tax := p_tax_amount_disp || ' ' || p_function_currency;
4583 x_amount_for_tax := x_amount_for_tax || ' (' || l_no_rate_msg || ')';
4584 WHEN OTHERS THEN
4585 l_progress := 'getReqAmountInfo:' || substrb(SQLERRM, 1,200);
4586 IF (g_po_wf_debug = 'Y') THEN
4587 /* DEBUG */
4588 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
4589 END IF;
4590 x_amount_for_subject := p_req_amount_disp || ' ' || p_function_currency;
4591 x_amount_for_header := p_req_amount_disp || ' ' || p_function_currency;
4592 x_amount_for_tax := p_tax_amount_disp || ' ' || p_function_currency;
4593 END;
4594 PROCEDURE SetReqHdrAttributes
4595 (
4596 itemtype IN VARCHAR2,
4597 itemkey IN VARCHAR2)
4598 IS
4599 x_progress VARCHAR2(200) := '000';
4600 l_auth_stat VARCHAR2(80);
4601 l_closed_code VARCHAR2(80);
4602 l_doc_type VARCHAR2(25);
4603 l_doc_subtype VARCHAR2(25);
4604 l_doc_type_disp VARCHAR2(240);
4605 /* Bug# 2616355: kagarwal */
4606 -- l_doc_subtype_disp varchar2(80);
4607 l_req_amount NUMBER;
4608 l_req_amount_disp VARCHAR2(60);
4609 l_tax_amount NUMBER;
4610 l_tax_amount_disp VARCHAR2(60);
4611 l_total_amount NUMBER;
4612 l_total_amount_disp VARCHAR2(60);
4613 l_amount_for_subject VARCHAR2(400);
4614 l_amount_for_header VARCHAR2(400);
4615 l_amount_for_tax VARCHAR2(400);
4616 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,Begin
4617 ---------------------------------------------------------------------------
4618 ln_jai_excl_nr_tax NUMBER; --exclusive non-recoverable tax
4619 lv_tax_region VARCHAR2(30); --tax region code
4620 ---------------------------------------------------------------------------
4621 -- Added by Eric Ma for IL PO Notification on Apr-13,2009 ,End
4622 /* Bug# 1162252: Amitabh
4623 ** Desc: Changed the length of l_currency_code from 8 to 30
4624 ** as the call to PO_CORE_S2.get_base_currency would
4625 ** return varchar2(30).
4626 */
4627 l_currency_code VARCHAR2(30);
4628 l_doc_id NUMBER;
4629 /* Bug 1100247: Amitabh
4630 */
4631 x_username VARCHAR2(100);
4632 x_user_display_name VARCHAR2(240);
4633 /* Bug 2830992
4634 */
4635 l_num_attachments NUMBER;
4636 /*Start Bug#3406460 */
4637 l_precision NUMBER;
4638 l_ext_precision NUMBER;
4639 l_min_acct_unit NUMBER;
4640 /*End Bug#3406460 */
4641 l_is_amendment_approval VARCHAR2(1) := 'N';
4642
4643 -- MIPR Changes
4644 l_clm_mipr_type VARCHAR2(30);
4645 l_mipr_type_disp VARCHAR2(100);
4646
4647 CURSOR c1(p_auth_stat VARCHAR2)
4648 IS
4649 SELECT DISPLAYED_FIELD
4650 FROM po_lookup_codes
4651 WHERE lookup_type='AUTHORIZATION STATUS'
4652 AND lookup_code = p_auth_stat;
4653 CURSOR c2(p_closed_code VARCHAR2)
4654 IS
4655 SELECT DISPLAYED_FIELD
4656 FROM po_lookup_codes
4657 WHERE lookup_type='DOCUMENT STATE'
4658 AND lookup_code = p_closed_code;
4659 /* Bug# 2616355: kagarwal
4660 ** Desc: We will get the document type display value from
4661 ** po document types.
4662 */
4663 CURSOR c3(p_doc_type VARCHAR2, p_doc_subtype VARCHAR2)
4664 IS
4665 SELECT type_name
4666 FROM po_document_types
4667 WHERE document_type_code = p_doc_type
4668 AND document_subtype = p_doc_subtype;
4669 /*
4670 cursor c4(p_doc_subtype varchar2) is
4671 select DISPLAYED_FIELD
4672 from po_lookup_codes
4673 where lookup_type='REQUISITION TYPE'
4674 and lookup_code = p_doc_subtype;
4675 */
4676 /* Bug# 1470041: kagarwal
4677 ** Desc: Modified the cursor req_total_csr for calculating the Req Total
4678 ** in procedure SetReqHdrAttributes() to ignore the Req lines modified using
4679 ** the modify option in the autocreate form.
4680 **
4681 ** Added condition:
4682 ** AND NVL(modified_by_agent_flag, 'N') = 'N'
4683 */
4684 /*Start Bug#3406460 - Added precision parameter to round the line amount*/
4685 CURSOR req_total_csr(p_doc_id NUMBER,l_precision NUMBER)
4686 IS
4687 SELECT NVL(SUM(ROUND(DECODE(order_type_lookup_code, 'RATE', amount, 'FIXED PRICE', amount, quantity * unit_price),l_precision)) ,0)
4688 FROM po_requisition_lines
4689 WHERE requisition_header_id = p_doc_id
4690 AND NVL(cancel_flag,'N') = 'N'
4691 AND NVL(modified_by_agent_flag, 'N') = 'N';
4692 /*End Bug#3406460*/
4693 /* Bug# 2483898: kagarwal
4694 ** Desc: When calculating the Tax for Requisitons submitted for approval,
4695 ** the cancelled requisition lines should be ignored. Also the lines modified in
4696 ** the autocreate form using the modify option should also be ignored.
4697 */
4698 CURSOR req_tax_csr(p_doc_id NUMBER)
4699 IS
4700 SELECT NVL(SUM(nonrecoverable_tax), 0)
4701 FROM po_requisition_lines rl,
4702 po_req_distributions_all rd -- <R12 MOAC>
4703 WHERE rl.requisition_header_id = p_doc_id
4704 AND rd.requisition_line_id = rl.requisition_line_id
4705 AND NVL(rl.cancel_flag,'N') = 'N'
4706 AND NVL(rl.modified_by_agent_flag, 'N') = 'N';
4707
4708 -- MIPR Changes
4709 CURSOR mipr_csr(p_doc_id NUMBER) IS
4710 SELECT clm_mipr_type
4711 FROM po_requisition_headers
4712 WHERE requisition_header_id = p_doc_id
4713 AND NVL(cancel_flag,'N') = 'N';
4714
4715 BEGIN
4716 x_progress := 'PO_REQAPPROVAL_INIT1.SetReqHdrAttributes: 01';
4717 IF (g_po_wf_debug = 'Y') THEN
4718 /* DEBUG */
4719 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4720 END IF;
4721 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_NUMBER', avalue => ReqHdr_rec.segment1);
4722 --
4723 wf_engine.SetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'DOCUMENT_ID', avalue => ReqHdr_rec.requisition_header_id);
4724 --
4725 wf_engine.SetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_ID', avalue => ReqHdr_rec.preparer_id);
4726 --
4727 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS', avalue => ReqHdr_rec.authorization_status);
4728 --
4729 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'REQ_DESCRIPTION', avalue => ReqHdr_rec.description);
4730 --
4731 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'CLOSED_CODE', avalue => ReqHdr_rec.closed_code);
4732 --
4733 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'EMERGENCY_PO_NUMBER', avalue => ReqHdr_rec.emergency_po_num);
4734 --
4735 -- Bug#3147435
4736 x_progress := 'PO_REQAPPROVAL_INIT1.SetReqHdrAttributes: 02 Start of Hdr Att for JRAD';
4737 IF (g_po_wf_debug = 'Y') THEN
4738 /* DEBUG */
4739 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4740 END IF;
4741 -- Bug#3147435
4742 --Set the CONTRACTOR_REQUISITION_FLAG
4743 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CONTRACTOR_REQUISITION_FLAG', avalue => ReqHdr_rec.contractor_requisition_flag);
4744 --
4745 -- Bug#3147435
4746 --Set the CONTRACTOR_STATUS
4747 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CONTRACTOR_STATUS', avalue => ReqHdr_rec.contractor_status);
4748 --
4749 -- Bug#3147435
4750 x_progress := 'PO_REQAPPROVAL_INIT1.SetReqHdrAttributes: 03 End of Hdr Att for JRAD';
4751 IF (g_po_wf_debug = 'Y') THEN
4752 /* DEBUG */
4753 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4754 END IF;
4755 /* Bug 1100247 Amitabh*/
4756 PO_REQAPPROVAL_INIT1.get_user_name(ReqHdr_rec.preparer_id, x_username, x_user_display_name);
4757 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_USER_NAME' , avalue => x_username);
4758 wf_engine.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_DISPLAY_NAME' , avalue => x_user_display_name);
4759 /* Get the translated values for the DOC_TYPE, DOC_SUBTYPE, AUTH_STATUS and
4760 ** CLOSED_CODE. These will be displayed in the notifications.
4761 */
4762 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
4763 l_doc_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
4764 OPEN C1(ReqHdr_rec.authorization_status);
4765 FETCH C1 INTO l_auth_stat;
4766
4767 CLOSE C1;
4768 OPEN C2(ReqHdr_rec.closed_code);
4769 FETCH C2 INTO l_closed_code;
4770
4771 CLOSE C2;
4772 /* Bug# 2616355: kagarwal */
4773 OPEN C3(l_doc_type, l_doc_subtype);
4774 FETCH C3 INTO l_doc_type_disp;
4775
4776 CLOSE C3;
4777 /*
4778 OPEN C4(l_doc_subtype);
4779 FETCH C4 into l_doc_subtype_disp;
4780 CLOSE C4;
4781 */
4782 -- MIPR changes
4783 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
4784
4785 OPEN mipr_csr(l_doc_id);
4786 FETCH mipr_csr INTO l_clm_mipr_type;
4787 CLOSE mipr_csr;
4788
4789 --
4790 --PR Amendment
4791 l_is_amendment_approval := PO_WF_UTIL_PKG.GetItemAttrText(itemtype=>itemtype, itemkey=>itemkey, aname=>'IS_AMENDMENT_APPROVAL');
4792 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'AUTHORIZATION_STATUS_DISP', avalue => l_auth_stat);
4793 --
4794 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'CLOSED_CODE_DISP', avalue => l_closed_code);
4795 --
4796 IF l_clm_mipr_type IS NOT NULL THEN
4797 l_mipr_type_disp := fnd_message.get_string('ICX','ICX_CLM_MIPR') || l_clm_mipr_type;
4798 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE_DISP', avalue => l_mipr_type_disp);
4799 ELSE
4800 IF(l_is_amendment_approval <> 'Y') THEN
4801 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE_DISP', avalue => l_doc_type_disp);
4802 ELSE
4803 --Bug # 13626231
4804 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE_DISP',
4805 avalue => fnd_message.get_string('PO','PO_DOC_REQ_AMENDMENT'));
4806 END IF;
4807 END IF;
4808
4809 --
4810 /* Bug# 2616355: kagarwal
4811 ** Desc: We will only be using one display attribute for type and
4812 ** subtype - DOCUMENT_TYPE_DISP, hence commenting the code below
4813 */
4814 /*
4815 wf_engine.SetItemAttrText ( itemtype => itemtype,
4816 itemkey => itemkey,
4817 aname => 'DOCUMENT_SUBTYPE_DISP',
4818 avalue => l_doc_subtype_disp);
4819 */
4820 l_doc_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
4821 l_currency_code := PO_CORE_S2.get_base_currency;
4822 /*Start Bug#3406460 - call to fnd function to get precision */
4823 fnd_currency.get_info(l_currency_code, l_precision, l_ext_precision, l_min_acct_unit);
4824 /* End Bug#3406460*/
4825 OPEN req_total_csr(l_doc_id,l_precision); --Bug#3406460 added parameter X_precision
4826 FETCH req_total_csr INTO l_req_amount;
4827
4828 CLOSE req_total_csr;
4829 /* For REQUISITIONS, since every line could have a different currency, then
4830 ** will show the total in the BASE/FUNCTIONAL currency.
4831 ** For POs, we will show it in the Document currency specified by the user.
4832 */
4833 l_req_amount_disp := TO_CHAR(l_req_amount,FND_CURRENCY.GET_FORMAT_MASK( l_currency_code, g_currency_format_mask));
4834 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'FUNCTIONAL_CURRENCY', avalue => l_currency_code);
4835 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'REQ_AMOUNT_DSP', avalue => l_req_amount_disp);
4836 --Modified by Eric Ma for IL PO Notification on Apr-13,2009,Begin
4837 ---------------------------------------------------------------------------
4838 --get tax region
4839 lv_tax_region := JAI_PO_WF_UTIL_PUB.get_tax_region ( pv_document_type => JAI_PO_WF_UTIL_PUB.G_REQ_DOC_TYPE , pn_document_id => l_doc_id );
4840 IF (lv_tax_region ='JAI') THEN
4841 --Get IL tax
4842 JAI_PO_WF_UTIL_PUB.Get_Jai_Tax_Amount( pv_document_type => JAI_PO_WF_UTIL_PUB.G_REQ_DOC_TYPE , pn_document_id => l_doc_id , xn_excl_tax_amount => l_tax_amount , xn_excl_nr_tax_amount => ln_jai_excl_nr_tax );
4843 ELSE
4844 --Get Standard Ebtax
4845 OPEN req_tax_csr(l_doc_id);
4846 FETCH req_tax_csr INTO l_tax_amount;
4847
4848 CLOSE req_tax_csr;
4849 END IF; --(lv_tax_region ='JAI')
4850 ---------------------------------------------------------------------------
4851 --Modified by Eric Ma for IL PO Notification on Apr-13,2009,End
4852 l_tax_amount_disp := TO_CHAR(l_tax_amount,FND_CURRENCY.GET_FORMAT_MASK( l_currency_code, g_currency_format_mask));
4853 wf_engine.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'TAX_AMOUNT_DSP', avalue => l_tax_amount_disp);
4854 l_total_amount := l_req_amount + l_tax_amount;
4855 l_total_amount_disp := TO_CHAR(l_total_amount,FND_CURRENCY.GET_FORMAT_MASK( l_currency_code, g_currency_format_mask));
4856 /* bug 3105327
4857 support approval currency in notification header and subject
4858 because TOTAL_AMOUNT_DSP is only used in notification,
4859 this bug fix changes the meaning of this attribute from total to
4860 total with currency;
4861 the workflow definition is modified such that
4862 currency atribute is removed from the subject.
4863 */
4864 getReqAmountInfo(
4865 itemtype => itemtype, itemkey => itemkey, p_function_currency => l_currency_code,
4866 p_total_amount_disp => l_total_amount_disp, p_total_amount => l_total_amount,
4867 p_req_amount_disp => l_req_amount_disp, p_req_amount => l_req_amount,
4868 p_tax_amount_disp => l_tax_amount_disp, p_tax_amount => l_tax_amount,
4869 x_amount_for_subject => l_amount_for_subject, x_amount_for_header => l_amount_for_header, x_amount_for_tax => l_amount_for_tax);
4870 --Modified by Eric Ma for IL PO Notification on Apr-13,2009,Begin
4871 ---------------------------------------------------------------------------
4872 IF (lv_tax_region ='JAI') THEN
4873 --format the non recoverable tax for display
4874 l_amount_for_tax := JAI_PO_WF_UTIL_PUB.Get_Jai_Req_Tax_Disp ( pn_jai_excl_nr_tax =>ln_jai_excl_nr_tax , pv_total_tax_dsp =>l_amount_for_tax , pv_currency_code =>l_currency_code , pv_currency_mask =>g_currency_format_mask ) ;
4875 END IF; -- (lv_tax_region ='JAI')
4876 ---------------------------------------------------------------------------
4877 --Modified by Eric Ma for IL PO Notification on Apr-13,2009,End
4878 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'TOTAL_AMOUNT_DSP', avalue => l_amount_for_subject);
4879 /* begin bug 2480327 notification UI enhancement */
4880 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'REQ_AMOUNT_CURRENCY_DSP', avalue => l_amount_for_header);
4881 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'TAX_AMOUNT_CURRENCY_DSP', avalue => l_amount_for_tax);
4882 PO_WF_UTIL_PKG.SetItemAttrDocument(itemtype => itemtype, itemkey => itemkey, aname => 'ATTACHMENT', documentid => 'FND:entity=REQ_HEADERS' || '&' || 'pk1name=REQUISITION_HEADER_ID' || '&' || 'pk1value='|| ReqHdr_rec.requisition_header_id);
4883 /* end bug 2480327 notification UI enhancement */
4884 x_progress := 'SetReqHdrAttributes (end): : ' || l_auth_stat || l_currency_code || l_req_amount_disp;
4885 IF (g_po_wf_debug = 'Y') THEN
4886 /* DEBUG */
4887 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
4888 END IF;
4889 IF (ReqHdr_rec.NOTE_TO_AUTHORIZER IS NOT NULL) THEN
4890 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'JUSTIFICATION', avalue => ReqHdr_rec.NOTE_TO_AUTHORIZER);
4891 END IF;
4892 EXCEPTION
4893 WHEN OTHERS THEN
4894 wf_core.context('PO_REQAPPROVAL_INIT1','SetReqHdrAttributes',x_progress);
4895 raise;
4896 END SetReqHdrAttributes;
4897
4898 /* added as part of bug 10399957 - deadlock issue during updating comm_rev_num value */
4899 PROCEDURE Set_Comm_Rev_Num(l_doc_type IN VARCHAR2,
4900 l_po_header_id IN NUMBER,
4901 l_po_revision_num_curr IN NUMBER)
4902 IS
4903 PRAGMA AUTONOMOUS_TRANSACTION;
4904
4905 x_progress varchar2(3):= '000';
4906
4907 BEGIN
4908
4909 SAVEPOINT save_rev_num;
4910
4911 IF l_doc_type IN ('PO', 'PA') THEN
4912
4913 UPDATE po_headers_all
4914 SET comm_rev_num = l_po_revision_num_curr
4915 WHERE po_header_id = l_po_header_id;
4916
4917 -- added for bug 9072034 (to update revision number for releases.)
4918 ELSIF l_doc_type in ('RELEASE') THEN
4919
4920 UPDATE po_releases_all
4921 SET comm_rev_num = l_po_revision_num_curr
4922 WHERE po_release_id = l_po_header_id;
4923
4924 END IF;
4925
4926 commit;
4927
4928 EXCEPTION
4929 WHEN OTHERS THEN
4930 ROLLBACK TO save_rev_num;
4931 wf_core.context('PO_REQAPPROVAL_INIT1','Set_Comm_Rev_Num',x_progress);
4932 raise;
4933
4934 End Set_Comm_Rev_Num;
4935 --
4936 -- procedure SetReqAuthStat, SetPOAuthStat, SetRelAuthStat
4937 -- This procedure sets the document status to IN PROCESS, if called at the beginning of the
4938 -- Approval Workflow,
4939 -- or to INCOMPLETE if doc failed STATE VERIFICATION or COMPLETENESS check at the
4940 -- beginning of WF,
4941 -- or to it's original status if No Approver was found or doc failed STATE VERIFICATION
4942 -- or COMPLETENESS check before APPROVE, REJECT or FORWARD
4943 PROCEDURE SetReqAuthStat
4944 (
4945 p_document_id IN NUMBER,
4946 itemtype IN VARCHAR2,
4947 itemkey IN VARCHAR2,
4948 note VARCHAR2,
4949 p_auth_status IN VARCHAR2)
4950 IS
4951 pragma AUTONOMOUS_TRANSACTION;
4952 l_requisition_header_id NUMBER;
4953 x_progress VARCHAR2(3):= '000';
4954 BEGIN
4955 l_requisition_header_id := p_document_id;
4956 /* If this is for the upgrade, then only put in the ITEMTYPE/ITEMKEY.
4957 ** We should not change the doc status to IN PROCESS (it could have been
4958 ** PRE-APPROVED).
4959 ** If normal processing then at this point the status is NOT 'IN PROCESS'
4960 ** or 'PRE-APPROVED', therefore we should update the status to IN PROCESS.
4961 */
4962 /* Bug# 1894960: kagarwal
4963 ** Desc: Requisitons Upgraded from 10.7 fails to set the status of Requisiton
4964 ** to Pre-Approved.
4965 **
4966 ** Reason being that when the procedure SetReqAuthStat() is called to set the
4967 ** Requisiton status to Pre-Approved, the conditon
4968 ** "IF (note = 'UPGRADE_TO_R11')" do not set the authorization status causes
4969 ** the Requisiton to remain in the existing status.
4970 ** Hence the Upgraded Requisitons can never be set to 'Pre-Approved' status and
4971 ** the approval process will always return the Req with Notification
4972 ** "No Approver Found".
4973 **
4974 ** Whereas the reason for this condition was to not set the status of upgrade
4975 ** Reqs to IN PROCESS as it could have been PRE-APPROVED.
4976 **
4977 ** Changed the procedure SetReqAuthStat().
4978 **
4979 ** Modified the clause IF note = 'UPGRADE_TO_R11'
4980 **
4981 ** TO:
4982 **
4983 ** IF (note = 'UPGRADE_TO_R11' and p_auth_status = 'IN PROCESS') THEN
4984 **
4985 ** Now when the approval process will call the procedure SetReqAuthStat()
4986 ** to set the Requisiton to 'Pre-Approved' status then it will go to the
4987 ** else part and set its authorization status to 'Pre-Approved'.
4988 */
4989 IF (note = 'UPGRADE_TO_R11' AND p_auth_status = 'IN PROCESS') THEN
4990 UPDATE po_requisition_headers
4991 SET WF_ITEM_TYPE = itemtype,
4992 WF_ITEM_KEY = itemkey,
4993 active_shopping_cart_flag = NULL,
4994 last_updated_by = fnd_global.user_id,
4995 last_update_login = fnd_global.login_id,
4996 last_update_date = sysdate
4997 WHERE requisition_header_id = l_requisition_header_id;
4998 ELSE
4999 UPDATE po_requisition_headers
5000 SET AUTHORIZATION_STATUS = p_auth_status,
5001 WF_ITEM_TYPE = itemtype,
5002 WF_ITEM_KEY = itemkey,
5003 active_shopping_cart_flag = NULL,
5004 last_updated_by = fnd_global.user_id,
5005 last_update_login = fnd_global.login_id,
5006 last_update_date = sysdate
5007 WHERE requisition_header_id = l_requisition_header_id;
5008 END IF;
5009 COMMIT;
5010 EXCEPTION
5011 WHEN OTHERS THEN
5012 wf_core.context('PO_REQAPPROVAL_INIT1','SetReqAuthStat',x_progress);
5013 raise;
5014 END SetReqAuthStat;
5015 --
5016 PROCEDURE SetPOAuthStat
5017 (
5018 p_document_id IN NUMBER,
5019 itemtype IN VARCHAR2,
5020 itemkey IN VARCHAR2,
5021 note VARCHAR2,
5022 p_auth_status IN VARCHAR2,
5023 p_draft_id IN NUMBER DEFAULT -1, --Mod Project
5024 p_update_sign VARCHAR2 DEFAULT 'N')
5025 IS
5026 pragma AUTONOMOUS_TRANSACTION;
5027 l_po_header_id NUMBER;
5028 x_progress VARCHAR2(3):= '000';
5029 l_draft_id NUMBER :=-1; --Mod Project
5030 l_pending_signature_flag VARCHAR2(1):='N';
5031 BEGIN
5032 x_progress := '001';
5033 l_po_header_id := p_document_id;
5034 l_draft_id := p_draft_id; -- Mod Project
5035 /* If this is for the upgrade, then only put in the ITEMTYPE/ITEMKEY.
5036 ** We should not change the doc status to IN PROCESS (it could have been
5037 ** PRE-APPROVED).
5038 ** If normal processing then at this point the status is NOT 'IN PROCESS'
5039 ** or 'PRE-APPROVED', therefore we should update the status to IN PROCESS.
5040 */
5041 IF p_update_sign = 'Y' AND p_auth_status = 'PRE-APPROVED' THEN
5042 l_pending_signature_flag := 'Y';
5043 END IF;
5044 IF note = 'UPGRADE_TO_R11' THEN
5045 UPDATE po_headers
5046 SET WF_ITEM_TYPE = itemtype,
5047 WF_ITEM_KEY = itemkey,
5048 last_updated_by = fnd_global.user_id,
5049 last_update_login = fnd_global.login_id,
5050 last_update_date = sysdate
5051 WHERE po_header_id = l_po_header_id;
5052 ELSE
5053 --Mod Project
5054 IF l_draft_id = -1 THEN
5055 UPDATE po_headers
5056 SET AUTHORIZATION_STATUS = p_auth_status,
5057 WF_ITEM_TYPE = itemtype,
5058 WF_ITEM_KEY = itemkey,
5059 last_updated_by = fnd_global.user_id,
5060 last_update_login = fnd_global.login_id,
5061 last_update_date = sysdate ,
5062 submit_date = DECODE(p_auth_status, 'INCOMPLETE', to_date(NULL),submit_date) --<DBI Req Fulfillment 11.5.11>
5063 ,
5064 pending_signature_flag = DECODE(l_pending_signature_flag, 'Y', DECODE(acceptance_required_flag, 'S', 'Y', 'N'), pending_signature_flag)
5065 WHERE po_header_id = l_po_header_id;
5066 ELSE
5067 UPDATE Po_Headers_Draft_all
5068 SET WF_ITEM_TYPE = itemtype,
5069 WF_ITEM_KEY = itemkey,
5070 last_updated_by = fnd_global.user_id,
5071 last_update_login = fnd_global.login_id,
5072 last_update_date = sysdate,
5073 submit_date = DECODE(p_auth_status, 'INCOMPLETE', to_date(NULL),submit_date) ,
5074 pending_signature_flag = DECODE(l_pending_signature_flag, 'Y', DECODE(acceptance_required_flag, 'S', 'Y', 'N'), pending_signature_flag)
5075 WHERE po_header_id = l_po_header_id
5076 AND draft_id = l_draft_id;
5077 UPDATE Po_Drafts SET STATUS = p_auth_status WHERE draft_id = l_draft_id;
5078 END IF; -- Mod Project
5079 END IF;
5080 COMMIT;
5081 EXCEPTION
5082 WHEN OTHERS THEN
5083 wf_core.context('PO_REQAPPROVAL_INIT1','SetPOAuthStat',x_progress);
5084 raise;
5085 END SetPOAuthStat;
5086 --
5087 PROCEDURE SetRelAuthStat
5088 (
5089 p_document_id IN NUMBER,
5090 itemtype IN VARCHAR2,
5091 itemkey IN VARCHAR2,
5092 note VARCHAR2,
5093 p_auth_status IN VARCHAR2)
5094 IS
5095 pragma AUTONOMOUS_TRANSACTION;
5096 l_Release_header_id NUMBER;
5097 x_progress VARCHAR2(3):= '000';
5098 BEGIN
5099 x_progress := '001';
5100 l_Release_header_id := p_document_id;
5101 /* If this is for the upgrade, then only put in the ITEMTYPE/ITEMKEY.
5102 ** We should not change the doc status to IN PROCESS (it could have been
5103 ** PRE-APPROVED).
5104 ** If normal processing then at this point the status is NOT 'IN PROCESS'
5105 ** or 'PRE-APPROVED', therefore we should update the status to IN PROCESS.
5106 */
5107 IF note = 'UPGRADE_TO_R11' THEN
5108 UPDATE po_releases
5109 SET WF_ITEM_TYPE = itemtype,
5110 WF_ITEM_KEY = itemkey,
5111 last_updated_by = fnd_global.user_id,
5112 last_update_login = fnd_global.login_id,
5113 last_update_date = sysdate
5114 WHERE po_release_id = l_Release_header_id;
5115 ELSE
5116 UPDATE po_releases
5117 SET AUTHORIZATION_STATUS = p_auth_status,
5118 WF_ITEM_TYPE = itemtype,
5119 WF_ITEM_KEY = itemkey,
5120 last_updated_by = fnd_global.user_id,
5121 last_update_login = fnd_global.login_id,
5122 last_update_date = sysdate ,
5123 submit_date = DECODE(p_auth_status, 'INCOMPLETE', to_date(NULL),submit_date) --<DBI Req Fulfillment 11.5.11>
5124 WHERE po_release_id = l_Release_header_id;
5125 END IF;
5126 COMMIT;
5127 EXCEPTION
5128 WHEN OTHERS THEN
5129 wf_core.context('PO_REQAPPROVAL_INIT1','SetRelAuthStat',x_progress);
5130 raise;
5131 END SetRelAuthStat;
5132 --
5133 --
5134 PROCEDURE UpdtReqItemtype
5135 (
5136 itemtype IN VARCHAR2,
5137 itemkey IN VARCHAR2,
5138 p_doc_id IN NUMBER)
5139 IS
5140 pragma AUTONOMOUS_TRANSACTION;
5141 x_progress VARCHAR2(3):= '000';
5142 BEGIN
5143 x_progress := '001';
5144 UPDATE po_requisition_headers
5145 SET WF_ITEM_TYPE = itemtype,
5146 WF_ITEM_KEY = itemkey,
5147 last_updated_by = fnd_global.user_id,
5148 last_update_login = fnd_global.login_id,
5149 last_update_date = sysdate
5150 WHERE requisition_header_id = p_doc_id;
5151 COMMIT;
5152 EXCEPTION
5153 WHEN OTHERS THEN
5154 wf_core.context('PO_REQAPPROVAL_INIT1','UpdtReqItemtype',x_progress);
5155 raise;
5156 END UpdtReqItemtype;
5157 --
5158 PROCEDURE UpdtPOItemtype
5159 (
5160 itemtype IN VARCHAR2,
5161 itemkey IN VARCHAR2,
5162 p_doc_id IN NUMBER)
5163 IS
5164 pragma AUTONOMOUS_TRANSACTION;
5165 x_progress VARCHAR2(3):= '000';
5166 BEGIN
5167 x_progress := '001';
5168 UPDATE po_headers
5169 SET WF_ITEM_TYPE = itemtype,
5170 WF_ITEM_KEY = itemkey,
5171 last_updated_by = fnd_global.user_id,
5172 last_update_login = fnd_global.login_id,
5173 last_update_date = sysdate ,
5174 submit_date = sysdate --<DBI Req Fulfillment 11.5.11>
5175 WHERE po_header_id = p_doc_id;
5176 COMMIT;
5177 EXCEPTION
5178 WHEN OTHERS THEN
5179 wf_core.context('PO_REQAPPROVAL_INIT1','UpdtPOItemtype',x_progress);
5180 raise;
5181 END UpdtPOItemtype;
5182 --
5183 PROCEDURE UpdtRelItemtype
5184 (
5185 itemtype IN VARCHAR2,
5186 itemkey IN VARCHAR2,
5187 p_doc_id IN NUMBER)
5188 IS
5189 pragma AUTONOMOUS_TRANSACTION;
5190 x_progress VARCHAR2(3):= '000';
5191 BEGIN
5192 x_progress := '001';
5193 UPDATE po_releases
5194 SET WF_ITEM_TYPE = itemtype,
5195 WF_ITEM_KEY = itemkey,
5196 last_updated_by = fnd_global.user_id,
5197 last_update_login = fnd_global.login_id,
5198 last_update_date = sysdate ,
5199 submit_date = sysdate --<DBI Req Fulfillment 11.5.11>
5200 WHERE po_release_id = p_doc_id;
5201 COMMIT;
5202 EXCEPTION
5203 WHEN OTHERS THEN
5204 wf_core.context('PO_REQAPPROVAL_INIT1','UpdtRelItemtype',x_progress);
5205 raise;
5206 END UpdtRelItemtype;
5207 --
5208 PROCEDURE GetCanOwnerApprove
5209 (
5210 itemtype IN VARCHAR2,
5211 itemkey IN VARCHAR2,
5212 CanOwnerApproveFlag OUT NOCOPY VARCHAR2)
5213 IS
5214 CURSOR C1(p_document_type_code VARCHAR2, p_document_subtype VARCHAR2)
5215 IS
5216 SELECT NVL(can_preparer_approve_flag,'N')
5217 FROM po_document_types
5218 WHERE document_type_code = p_document_type_code
5219 AND document_subtype = p_document_subtype;
5220
5221 l_document_type_code VARCHAR2(25);
5222 l_document_subtype VARCHAR2(25);
5223 x_progress VARCHAR2(3):= '000';
5224 BEGIN
5225 x_progress := '001';
5226 l_document_type_code := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
5227 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
5228 OPEN C1(l_document_type_code, l_document_subtype);
5229 FETCH C1 INTO CanOwnerApproveFlag;
5230
5231 CLOSE C1;
5232 EXCEPTION
5233 WHEN OTHERS THEN
5234 wf_core.context('PO_REQAPPROVAL_INIT1','GetCanOwnerApprove',x_progress);
5235 raise;
5236 END GetCanOwnerApprove;
5237 --
5238 /*****************************************************************************
5239 *
5240 * Supporting APIs declared in the package spec.
5241 *****************************************************************************/
5242 PROCEDURE get_multiorg_context
5243 (
5244 document_type VARCHAR2,
5245 document_id NUMBER,
5246 x_orgid IN OUT NOCOPY NUMBER)
5247 IS
5248 CURSOR get_req_orgid
5249 IS
5250 SELECT org_id
5251 FROM po_requisition_headers_all
5252 WHERE requisition_header_id = document_id;
5253 CURSOR get_po_orgid
5254 IS
5255 SELECT org_id FROM po_headers_all WHERE po_header_id = document_id;
5256 CURSOR get_release_orgid
5257 IS
5258 SELECT org_id FROM po_releases_all WHERE po_release_id = document_id;
5259
5260 x_progress VARCHAR2(3):= '000';
5261 BEGIN
5262 x_progress := '001';
5263 IF document_type = 'REQUISITION' THEN
5264 OPEN get_req_orgid;
5265 FETCH get_req_orgid INTO x_orgid;
5266
5267 CLOSE get_req_orgid;
5268 ELSIF document_type IN ( 'PO','PA' ) THEN
5269 OPEN get_po_orgid;
5270 FETCH get_po_orgid INTO x_orgid;
5271
5272 CLOSE get_po_orgid;
5273 ELSIF document_type = 'RELEASE' THEN
5274 OPEN get_release_orgid ;
5275 FETCH get_release_orgid INTO x_orgid;
5276
5277 CLOSE get_release_orgid;
5278 END IF;
5279 EXCEPTION
5280 WHEN OTHERS THEN
5281 wf_core.context('PO_REQAPPROVAL_INIT1','get_multiorg_context',x_progress);
5282 raise;
5283 END get_multiorg_context;
5284 --
5285 PROCEDURE get_employee_id
5286 (
5287 p_username IN VARCHAR2,
5288 x_employee_id OUT NOCOPY NUMBER)
5289 IS
5290 -- DEBUG: Is this the best way to get the emp_id of the username
5291 -- entered as a forward-to in the notification?????
5292 --
5293 /* 1578061 add orig system condition to enhance performance. */
5294 CURSOR c_empid
5295 IS
5296 SELECT ORIG_SYSTEM_ID
5297 FROM wf_users WF
5298 WHERE WF.name = p_username
5299 AND ORIG_SYSTEM NOT IN ('HZ_PARTY', 'POS', 'ENG_LIST', 'CUST_CONT');
5300
5301 x_progress VARCHAR2(3):= '000';
5302 BEGIN
5303 OPEN c_empid;
5304 FETCH c_empid INTO x_employee_id;
5305 /* DEBUG: get Vance and Kevin opinion on this:
5306 ** If no employee_id is found then return null. We will
5307 ** treat that as the user not supplying a forward-to username.
5308 */
5309 IF c_empid%NOTFOUND THEN
5310 x_employee_id := NULL;
5311 END IF;
5312 CLOSE c_empid;
5313 EXCEPTION
5314 WHEN OTHERS THEN
5315 wf_core.context('PO_REQAPPROVAL_INIT1','get_employee_id',p_username);
5316 raise;
5317 END get_employee_id;
5318 --
5319 PROCEDURE get_user_name
5320 (
5321 p_employee_id IN NUMBER,
5322 x_username OUT NOCOPY VARCHAR2,
5323 x_user_display_name OUT NOCOPY VARCHAR2)
5324 IS
5325 p_orig_system VARCHAR2(20);
5326 BEGIN
5327 p_orig_system:= 'PER';
5328 WF_DIRECTORY.GetUserName(p_orig_system, p_employee_id, x_username, x_user_display_name);
5329 EXCEPTION
5330 WHEN OTHERS THEN
5331 wf_core.context('PO_REQAPPROVAL_INIT1','get_user_name',TO_CHAR(p_employee_id));
5332 raise;
5333 END get_user_name;
5334 --
5335 PROCEDURE InsertActionHistSubmit
5336 (
5337 itemtype VARCHAR2,
5338 itemkey VARCHAR2,
5339 p_doc_id NUMBER,
5340 p_doc_type VARCHAR2,
5341 p_doc_subtype VARCHAR2,
5342 p_employee_id NUMBER,
5343 p_action VARCHAR2,
5344 p_note VARCHAR2,
5345 p_path_id NUMBER ,
5346 p_draft_id NUMBER)
5347 IS
5348 pragma AUTONOMOUS_TRANSACTION;
5349 l_auth_stat VARCHAR2(25);
5350 l_action_code VARCHAR2(25);
5351 l_revision_num NUMBER := NULL;
5352 l_hist_count NUMBER := NULL;
5353 l_sequence_num NUMBER := NULL;
5354 l_approval_path_id NUMBER;
5355 l_draft_id NUMBER := p_draft_id; --Mod Project
5356 l_doc_id NUMBER := p_doc_id; --Mod Project
5357 l_doc_subtype VARCHAR2(25) := p_doc_subtype;--Mod Project
5358 l_transaction_type po_doc_style_headers.ame_transaction_type%TYPE;
5359 l_draft_type PO_DRAFTS.DRAFT_TYPE%TYPE; -- PAR Approval
5360 CURSOR action_hist_cursor(doc_id NUMBER , doc_type VARCHAR2)
5361 IS
5362 SELECT MAX(sequence_num)
5363 FROM po_action_history
5364 WHERE object_id = doc_id
5365 AND object_type_code = doc_type;
5366 -- Mod Project
5367 CURSOR action_hist_mod_cursor(draft_id NUMBER , doc_type VARCHAR2)
5368 IS
5369 SELECT MAX(sequence_num)
5370 FROM po_action_history
5371 WHERE object_id = draft_id
5372 AND object_type_code = doc_type
5373 AND object_sub_type_code IN ('MODIFICATION', 'POST_AWARD_REQUEST'); -- PAR Approval
5374 -- Mod Project
5375 CURSOR action_hist_code_cursor (doc_id NUMBER , doc_type VARCHAR2, seq_num NUMBER)
5376 IS
5377 SELECT action_code
5378 FROM po_action_history
5379 WHERE object_id = doc_id
5380 AND object_type_code = doc_type
5381 AND sequence_num = seq_num;
5382 -- Mod Project
5383 CURSOR action_hist_code_mod_cursor (draft_id NUMBER , doc_type VARCHAR2, seq_num NUMBER)
5384 IS
5385 SELECT action_code
5386 FROM po_action_history
5387 WHERE object_id = draft_id
5388 AND object_type_code = doc_type
5389 AND object_sub_type_code IN ('MODIFICATION', 'POST_AWARD_REQUEST') -- PAR Approval
5390 AND sequence_num = seq_num;
5391 -- Mod Project
5392 x_progress VARCHAR2(3):='000';
5393 BEGIN
5394 /* Get the document authorization status.
5395 ** has been submitted before, i.e.
5396 ** First insert a row with a SUBMIT action.
5397 ** Then insert a row with a NULL ACTION_CODE to simulate the forward-to
5398 ** since the doc status has been changed to IN PROCESS.
5399 */
5400 x_progress := '001';
5401 l_approval_path_id := p_path_id;
5402 IF p_doc_type ='REQUISITION' THEN
5403 x_progress := '002';
5404 SELECT NVL(authorization_status, 'INCOMPLETE')
5405 INTO l_auth_stat
5406 FROM PO_REQUISITION_HEADERS
5407 WHERE requisition_header_id = p_doc_id;
5408 ELSIF p_doc_type IN ('PO','PA') THEN
5409 x_progress := '003';
5410 -- Mod Project
5411 --Bug 12944203 Taking l_transaction_type from po_headers as workflow attribute is not committed at this time.
5412 IF l_draft_id = -1 THEN
5413 SELECT NVL(authorization_status,'INCOMPLETE'),
5414 revision_num,
5415 ame_transaction_type
5416 INTO l_auth_stat,
5417 l_revision_num,
5418 l_transaction_type
5419 FROM PO_HEADERS
5420 WHERE po_header_id = p_doc_id;
5421 ELSE
5422 SELECT NVL(status,'INCOMPLETE'),
5423 0,
5424 ame_transaction_type,
5425 draft_type -- PAR Approval
5426 INTO l_auth_stat,
5427 l_revision_num,
5428 l_transaction_type,
5429 l_draft_type
5430 FROM PO_HEADERS_MERGE_V
5431 WHERE po_header_id = p_doc_id
5432 AND draft_id = l_draft_id;
5433 END IF;
5434 --l_transaction_type := po_wf_util_pkg.GetItemAttrText( itemtype => itemtype, itemkey => itemkey, aname => 'AME_TRANSACTION_TYPE');
5435 -- Mod Project
5436 ELSIF p_doc_type = 'RELEASE' THEN
5437 x_progress := '004';
5438 SELECT NVL(authorization_status,'INCOMPLETE'),
5439 revision_num
5440 INTO l_auth_stat,
5441 l_revision_num
5442 FROM PO_RELEASES
5443 WHERE po_release_id = p_doc_id;
5444 END IF;
5445 x_progress := '005';
5446 /* Check if this document had been submitted to workflow at some point
5447 ** and somehow kicked out. If that's the case, the sequence number
5448 ** needs to be incremented by one. Otherwise start at zero.
5449 */
5450 -- Mod Project
5451 IF l_draft_id = -1 THEN
5452 OPEN action_hist_cursor(p_doc_id , p_doc_type );
5453 FETCH action_hist_cursor INTO l_sequence_num;
5454
5455 CLOSE action_hist_cursor;
5456 ELSE
5457 OPEN action_hist_mod_cursor(l_draft_id , p_doc_type );
5458 FETCH action_hist_mod_cursor INTO l_sequence_num;
5459
5460 CLOSE action_hist_mod_cursor;
5461 END IF;
5462 -- Mod Project
5463 IF l_sequence_num IS NULL THEN
5464 l_sequence_num := 1; --Bug 13579433
5465 ELSE
5466 IF l_draft_id = -1 THEN
5467 OPEN action_hist_code_cursor(p_doc_id , p_doc_type, l_sequence_num);
5468 FETCH action_hist_code_cursor INTO l_action_code;
5469 ELSE
5470 OPEN action_hist_code_mod_cursor(l_draft_id , p_doc_type, l_sequence_num);
5471 FETCH action_hist_code_mod_cursor INTO l_action_code;
5472 END IF;
5473 l_sequence_num := l_sequence_num +1;
5474 END IF;
5475 -- PAR Approval : Adding doc subtype for PAR as well.
5476 IF l_draft_id <> -1 AND l_draft_type = 'MOD' THEN
5477 l_doc_subtype := 'MODIFICATION';
5478 ELSIF l_draft_id <> -1 AND l_draft_type = 'PAR' THEN
5479 l_doc_subtype :='POST_AWARD_REQUEST';
5480 END IF;
5481 x_progress := '006';
5482 IF ((l_sequence_num = 1) OR (l_sequence_num > 1 AND l_action_code IS NOT NULL)) THEN --Bug 13579433
5483 INSERT
5484 INTO PO_ACTION_HISTORY
5485 (
5486 object_id,
5487 object_type_code,
5488 object_sub_type_code,
5489 sequence_num,
5490 last_update_date,
5491 last_updated_by,
5492 creation_date,
5493 created_by,
5494 action_code,
5495 action_date,
5496 employee_id,
5497 note,
5498 object_revision_num,
5499 last_update_login,
5500 request_id,
5501 program_application_id,
5502 program_id,
5503 program_update_date,
5504 approval_path_id,
5505 offline_code
5506 )
5507 VALUES
5508 (
5509 DECODE(l_draft_id,-1,l_doc_id,l_draft_id), --Mod Project
5510 p_doc_type,
5511 l_doc_subtype, --Mod Project
5512 l_sequence_num,
5513 sysdate,
5514 fnd_global.user_id,
5515 sysdate,
5516 fnd_global.user_id,
5517 p_action,
5518 DECODE(p_action, '',to_date(NULL), sysdate),
5519 p_employee_id,
5520 p_note,
5521 l_revision_num,
5522 fnd_global.login_id,
5523 0,
5524 0,
5525 0,
5526 '',
5527 l_approval_path_id,
5528 ''
5529 );
5530 ELSE
5531 l_sequence_num := l_sequence_num - 1;
5532 UPDATE PO_ACTION_HISTORY
5533 SET object_id = DECODE(l_draft_id,-1,l_doc_id,l_draft_id), --Mod Project
5534 object_type_code = p_doc_type,
5535 object_sub_type_code = l_doc_subtype, --Mod Project
5536 sequence_num = l_sequence_num,
5537 last_update_date = sysdate,
5538 last_updated_by = fnd_global.user_id,
5539 creation_date = sysdate,
5540 created_by = fnd_global.user_id,
5541 action_code = p_action,
5542 action_date = DECODE(p_action, '',to_date(NULL), sysdate),
5543 employee_id = p_employee_id,
5544 note = p_note,
5545 object_revision_num = l_revision_num,
5546 last_update_login = fnd_global.login_id,
5547 request_id = 0,
5548 program_application_id = 0,
5549 program_id = 0,
5550 program_update_date = '',
5551 approval_path_id = l_approval_path_id,
5552 offline_code = ''
5553 WHERE object_id = DECODE(l_draft_id,-1,l_doc_id,l_draft_id) --Mod Project
5554 AND object_type_code = p_doc_type
5555 AND object_sub_type_code = l_doc_subtype --Mod Project
5556 AND sequence_num = l_sequence_num;
5557 END IF;
5558 -- iProcurement: Approval History changes.
5559 -- Null action code will not be inserted into po_action_history table.
5560 -- bug4643013
5561 -- Still insert null action during submission except for requisition
5562 -- Null need not be inserted in case of 'PO approval using AME'
5563 --Bug 12664072 Adding nvl condition for l_transaction_type
5564 -- PAR Approval : Adding PAR transaction type to condition.
5565 IF (p_doc_type <> 'REQUISITION' AND Nvl(l_transaction_type,'NULL') NOT IN('PURCHASE_ORDER','PURCHASE_MOD', 'PURCHASE_PAR')) THEN
5566 INSERT
5567 INTO PO_ACTION_HISTORY
5568 (
5569 object_id,
5570 object_type_code,
5571 object_sub_type_code,
5572 sequence_num,
5573 last_update_date,
5574 last_updated_by,
5575 creation_date,
5576 created_by,
5577 action_code,
5578 action_date,
5579 employee_id,
5580 note,
5581 object_revision_num,
5582 last_update_login,
5583 request_id,
5584 program_application_id,
5585 program_id,
5586 program_update_date,
5587 approval_path_id,
5588 offline_code
5589 )
5590 VALUES
5591 (
5592 DECODE(l_draft_id,-1,l_doc_id,l_draft_id), --Mod Project
5593 p_doc_type,
5594 l_doc_subtype, --Mod Project
5595 l_sequence_num + 1,
5596 sysdate,
5597 fnd_global.user_id,
5598 sysdate,
5599 fnd_global.user_id,
5600 NULL, -- ACTION_CODE
5601 DECODE(p_action, '',to_date(NULL), sysdate),
5602 p_employee_id,
5603 NULL,
5604 l_revision_num,
5605 fnd_global.login_id,
5606 0,
5607 0,
5608 0,
5609 '',
5610 0,
5611 ''
5612 );
5613 END IF;
5614 x_progress := '007';
5615 COMMIT;
5616 EXCEPTION
5617 WHEN OTHERS THEN
5618 wf_core.context
5619 (
5620 'PO_REQAPPROVAL_INIT1','InsertActionHistSubmit',x_progress
5621 )
5622 ;
5623 raise;
5624 END InsertActionHistSubmit;
5625 --
5626 -- <ENCUMBRANCE FPJ START>
5627 -- Rewriting the following procedure to use the encumbrance APIs
5628 FUNCTION EncumbOn_DocUnreserved
5629 (
5630 p_doc_type VARCHAR2,
5631 p_doc_subtype VARCHAR2,
5632 p_doc_id NUMBER
5633 )
5634 RETURN VARCHAR2
5635 IS
5636 PRAGMA AUTONOMOUS_TRANSACTION;
5637 -- The autonomous_transaction is required due to the use of the global temp
5638 -- table PO_ENCUMBRANCE_GT, as the call to do_reserve later in the workflow
5639 -- process is in an autonomous transaction because it must commit.
5640 -- Without this autonomous transaction, the following error is raised:
5641 -- ORA-14450: attempt to access a transactional temp table already in use
5642 p_return_status VARCHAR2(1);
5643 p_reservable_flag VARCHAR2(1);
5644 l_progress VARCHAR2(200);
5645 l_unreserved_flag VARCHAR2(1):= 'N';
5646 l_return_exc EXCEPTION;
5647 BEGIN
5648 l_progress := '000';
5649 -- If the document is contract then we do not encumber it
5650 IF p_doc_subtype = 'CONTRACT' THEN
5651 RAISE l_return_exc;
5652 END IF;
5653 -- Check if encumbrance is on
5654 IF NOT (PO_CORE_S.is_encumbrance_on( p_doc_type => p_doc_type, p_org_id => NULL)) THEN
5655 l_progress := '010';
5656 RAISE l_return_exc;
5657 END IF;
5658 l_progress := '020';
5659 -- Check if there is any distribution that can be reserved
5660 PO_DOCUMENT_FUNDS_PVT.is_reservable
5661 (
5662 x_return_status => p_return_status , p_doc_type => p_doc_type , p_doc_subtype => p_doc_subtype , p_doc_level => PO_DOCUMENT_FUNDS_PVT.g_doc_level_HEADER , p_doc_level_id => p_doc_id , x_reservable_flag => p_reservable_flag
5663 )
5664 ;
5665 l_progress := '030';
5666 IF p_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
5667 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5668 ELSIF p_return_status = FND_API.G_RET_STS_ERROR THEN
5669 RAISE FND_API.G_EXC_ERROR;
5670 END IF;
5671 l_progress := '040';
5672 IF
5673 (
5674 p_return_status = FND_API.G_RET_STS_SUCCESS
5675 )
5676 AND (p_reservable_flag = PO_DOCUMENT_FUNDS_PVT.g_parameter_YES) THEN
5677 l_progress := '050';
5678 l_unreserved_flag := 'Y';
5679 END IF;
5680 l_progress := '060';
5681 ROLLBACK;
5682 RETURN
5683 (
5684 l_unreserved_flag
5685 )
5686 ;
5687 EXCEPTION
5688 WHEN l_return_exc THEN
5689 ROLLBACK;
5690 RETURN
5691 (
5692 l_unreserved_flag
5693 )
5694 ;
5695 WHEN OTHERS THEN
5696 wf_core.context
5697 (
5698 'PO_REQAPPROVAL_INIT1','EncumbOn_DocUnreserved', l_progress
5699 )
5700 ;
5701 ROLLBACK;
5702 RAISE;
5703 END EncumbOn_DocUnreserved;
5704 -- <ENCUMBRANCE FPJ END>
5705 PROCEDURE PrintDocument
5706 (
5707 itemtype VARCHAR2,
5708 itemkey VARCHAR2
5709 )
5710 IS
5711 l_document_type VARCHAR2
5712 (
5713 25
5714 )
5715 ;
5716 l_document_num VARCHAR2
5717 (
5718 30
5719 )
5720 ;
5721 l_release_num NUMBER;
5722 l_request_id NUMBER := 0;
5723 l_qty_precision VARCHAR2
5724 (
5725 30
5726 )
5727 ;
5728 l_user_id VARCHAR2
5729 (
5730 30
5731 )
5732 ;
5733 --Context Setting Revamp
5734 l_printer VARCHAR2
5735 (
5736 30
5737 )
5738 ;
5739 l_conc_copies NUMBER;
5740 l_conc_save_output VARCHAR2
5741 (
5742 1
5743 )
5744 ;
5745 l_conc_save_output_bool BOOLEAN;
5746 l_spo_result BOOLEAN;
5747 x_progress VARCHAR2
5748 (
5749 200
5750 )
5751 ;
5752 /*Bug 6692126 start */
5753 l_document_id NUMBER;
5754 l_withterms VARCHAR2
5755 (
5756 1
5757 )
5758 ;
5759 l_document_subtype po_headers.type_lookup_code%TYPE;
5760 /*Bug 6692126 end */
5761 l_draft_id NUMBER; -- CLM Mod
5762 BEGIN
5763 x_progress := 'PO_REQAPPROVAL_INIT1.PrintDocument: 01';
5764 IF
5765 (
5766 g_po_wf_debug = 'Y'
5767 )
5768 THEN
5769 /* DEBUG */
5770 PO_WF_DEBUG_PKG.insert_debug
5771 (
5772 itemtype,itemkey,x_progress
5773 )
5774 ;
5775 END IF;
5776 -- Get the profile option report_quantity_precision
5777 fnd_profile.get
5778 (
5779 'REPORT_QUANTITY_PRECISION', l_qty_precision
5780 )
5781 ;
5782 /* Bug 2012896: the profile option REPORT_QUANTITY_PRECISION could be
5783 NULL. Even at site level! And in that case the printing of report
5784 results into the inappropriate printing of quantities.
5785 Fix: Now, if the profile option is NULL, we are setting the variable
5786 l_qty_precision to 2, so that the printing would not fail. Why 2 ?
5787 This is the default defined in the definition of the said profile
5788 option. */
5789 IF l_qty_precision IS NULL THEN
5790 l_qty_precision := '2';
5791 END IF;
5792 -- Get the user id for the current user. This information
5793 -- is used when sending concurrent request.
5794 FND_PROFILE.GET
5795 (
5796 'USER_ID', l_user_id
5797 )
5798 ;
5799 -- Send the concurrent request to print document.
5800 l_document_type := wf_engine.GetItemAttrText
5801 (
5802 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE'
5803 )
5804 ;
5805 l_document_num := wf_engine.GetItemAttrText
5806 (
5807 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_NUMBER'
5808 )
5809 ;
5810 /*Bug 6692126 Get the item attributes DOCUMENT_ID,DOCUMENT_SUBTYPE
5811 and WITH_TERMS and pass it to Print_PO and Print_Release procedures*/
5812 l_document_id := wf_engine.GetItemAttrNumber
5813 (
5814 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID'
5815 )
5816 ;
5817 l_document_subtype := wf_engine.GetItemAttrText
5818 (
5819 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE'
5820 )
5821 ;
5822 -- Mod Project
5823 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber
5824 (
5825 itemtype => itemtype, itemkey => itemkey, aname => 'DRAFT_ID'
5826 )
5827 ;
5828 IF l_draft_id IS NULL THEN
5829 l_draft_id := -1;
5830 END IF;
5831 /*Bug6692126 Donot set the item attribute with_terms for requisitions
5832 as this attribute doesnot exist in req approval workflow*/
5833 IF l_document_type <> 'REQUISITION' THEN
5834 l_withterms := wf_engine.GetItemAttrText
5835 (
5836 itemtype => itemtype, itemkey => itemkey, aname => 'WITH_TERMS'
5837 )
5838 ;
5839 END IF;
5840 -- Bug 4918772
5841 -- The global variable 4918772 should be populated. This is used by
5842 -- the print/fax routines
5843 g_document_subtype := wf_engine.GetItemAttrText
5844 (
5845 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE'
5846 )
5847 ;
5848 -- End Bug 4918772
5849 -- Context Setting Revamp.
5850 /* changed the call from wf_engine.setiteattrtext to
5851 po_wf_util_pkg.setitemattrtext because the later handles
5852 attribute not found exception. req change order wf also
5853 uses these procedures and does not have the preparer_printer
5854 attribute, hence this was required */
5855 l_printer := po_wf_util_pkg.GetItemAttrText
5856 (
5857 itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_PRINTER'
5858 )
5859 ;
5860 -- Need to get the no of copies, and save output values for the
5861 -- preparer and pass it to the set_print_options procedure
5862 l_conc_copies := po_wf_util_pkg.GetItemAttrNumber
5863 (
5864 itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_CONC_COPIES'
5865 )
5866 ;
5867 l_conc_save_output := po_wf_util_pkg.GetItemAttrText
5868 (
5869 itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_CONC_SAVE_OUTPUT'
5870 )
5871 ;
5872 IF l_conc_save_output = 'Y' THEN
5873 l_conc_save_output_bool := TRUE;
5874 ELSE
5875 l_conc_save_output_bool := FALSE;
5876 END IF;
5877 -- <Debug start>
5878 x_progress := 'SPO : got printer as '||l_printer|| ' conc_copies '||l_conc_copies|| ' save o/p '||l_conc_save_output;
5879 IF
5880 (
5881 g_po_wf_debug = 'Y'
5882 )
5883 THEN
5884 PO_WF_DEBUG_PKG.insert_debug
5885 (
5886 itemtype,itemkey,x_progress
5887 )
5888 ;
5889 END IF;
5890 -- <debug end>
5891 IF
5892 (
5893 l_printer IS NOT NULL
5894 )
5895 THEN
5896 l_spo_result := fnd_request.set_print_options
5897 (
5898 printer=> l_printer, copies=> l_conc_copies, save_output => l_conc_save_output_bool
5899 )
5900 ;
5901 IF
5902 (
5903 l_spo_result
5904 )
5905 THEN
5906 -- <Debug start>
5907 x_progress := 'SPO:set print options successful';
5908 IF
5909 (
5910 g_po_wf_debug = 'Y'
5911 )
5912 THEN
5913 PO_WF_DEBUG_PKG.insert_debug
5914 (
5915 itemtype,itemkey,x_progress
5916 )
5917 ;
5918 END IF;
5919 -- <debug end>
5920 ELSE
5921 -- <Debug start>
5922 x_progress := 'SPO:set print options not successful ';
5923 IF
5924 (
5925 g_po_wf_debug = 'Y'
5926 )
5927 THEN
5928 PO_WF_DEBUG_PKG.insert_debug
5929 (
5930 itemtype,itemkey,x_progress
5931 )
5932 ;
5933 END IF;
5934 -- <Debug end>
5935 END IF;
5936 END IF;
5937 --End Context Setting Revamp.
5938 IF l_document_type = 'REQUISITION' THEN
5939 l_request_id := Print_Requisition
5940 (
5941 l_document_num, l_qty_precision, l_user_id
5942 )
5943 ;
5944 ELSIF l_document_type = 'RELEASE' THEN
5945 l_release_num := wf_engine.GetItemAttrNumber
5946 (
5947 itemtype => itemtype, itemkey => itemkey, aname => 'RELEASE_NUM'
5948 )
5949 ;
5950 --Bug 6692126 Pass document_id,documentsubtype parameters
5951 l_request_id := Print_Release
5952 (
5953 l_document_num, l_qty_precision, TO_CHAR(l_release_num), l_user_id, l_document_id
5954 )
5955 ;
5956 ELSE
5957 --Bug 6692126 Pass document_id,subtype and with terms parameters
5958 l_request_id := Print_PO
5959 (
5960 l_document_num, l_qty_precision, l_user_id, l_document_id, l_draft_id
5961 /*CLM Mod*/
5962 , l_document_subtype,l_withterms
5963 )
5964 ;
5965 END IF;
5966 wf_engine.SetItemAttrNumber
5967 (
5968 itemtype => itemtype, itemkey => itemkey, aname => 'CONCURRENT_REQUEST_ID', avalue => l_request_id
5969 )
5970 ;
5971 x_progress := 'PO_REQAPPROVAL_INIT1.PrintDocument: 02. request_id= ' || TO_CHAR
5972 (
5973 l_request_id
5974 )
5975 ;
5976 IF
5977 (
5978 g_po_wf_debug = 'Y'
5979 )
5980 THEN
5981 /* DEBUG */
5982 PO_WF_DEBUG_PKG.insert_debug
5983 (
5984 itemtype,itemkey,x_progress
5985 )
5986 ;
5987 END IF;
5988 EXCEPTION
5989 WHEN OTHERS THEN
5990 wf_core.context
5991 (
5992 'PO_REQAPPROVAL_INIT1','PrintDocument',x_progress
5993 )
5994 ;
5995 raise;
5996 END PrintDocument;
5997 -- DKC 10/10/99
5998 PROCEDURE FaxDocument
5999 (
6000 itemtype VARCHAR2,
6001 itemkey VARCHAR2
6002 )
6003 IS
6004 l_document_type VARCHAR2
6005 (
6006 25
6007 )
6008 ;
6009 l_document_num VARCHAR2
6010 (
6011 30
6012 )
6013 ;
6014 l_draft_id NUMBER; --CLM Mod
6015 l_release_num NUMBER;
6016 l_request_id NUMBER := 0;
6017 l_qty_precision VARCHAR2
6018 (
6019 30
6020 )
6021 ;
6022 l_user_id VARCHAR2
6023 (
6024 30
6025 )
6026 ;
6027 l_fax_enable VARCHAR2
6028 (
6029 25
6030 )
6031 ;
6032 l_fax_num VARCHAR2
6033 (
6034 30
6035 )
6036 ; -- 5765243
6037 --Context Setting Revamp
6038 l_spo_result BOOLEAN;
6039 l_printer VARCHAR2
6040 (
6041 30
6042 )
6043 ;
6044 /*Bug 6692126 start */
6045 l_document_id NUMBER;
6046 l_withterms VARCHAR2
6047 (
6048 1
6049 )
6050 ;
6051 l_document_subtype po_headers.type_lookup_code%TYPE;
6052 /*Bug 6692126 end */
6053 x_progress VARCHAR2
6054 (
6055 200
6056 )
6057 ;
6058 BEGIN
6059 x_progress := 'PO_REQAPPROVAL_INIT1.FaxDocument: 01';
6060 IF
6061 (
6062 g_po_wf_debug = 'Y'
6063 )
6064 THEN
6065 /* DEBUG */
6066 PO_WF_DEBUG_PKG.insert_debug
6067 (
6068 itemtype,itemkey,x_progress
6069 )
6070 ;
6071 END IF;
6072 -- Get the profile option report_quantity_precision
6073 fnd_profile.get
6074 (
6075 'REPORT_QUANTITY_PRECISION', l_qty_precision
6076 )
6077 ;
6078 -- Get the user id for the current user. This information
6079 -- is used when sending concurrent request.
6080 FND_PROFILE.GET
6081 (
6082 'USER_ID', l_user_id
6083 )
6084 ;
6085 -- Send the concurrent request to fax document.
6086 l_document_type := wf_engine.GetItemAttrText
6087 (
6088 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE'
6089 )
6090 ;
6091 l_document_num := wf_engine.GetItemAttrText
6092 (
6093 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_NUMBER'
6094 )
6095 ;
6096 -- Mod Project
6097 l_draft_id := PO_WF_UTIL_PKG.GetItemAttrNumber
6098 (
6099 itemtype => itemtype, itemkey => itemkey, aname => 'DRAFT_ID'
6100 )
6101 ;
6102 IF l_draft_id IS NULL THEN
6103 l_draft_id := -1;
6104 END IF;
6105 /*Bug 6692126 Get the document_id ,document subtype and with terms
6106 item attribute and pass it to Fax_PO and Fax_Release procedures
6107 Donot rely on global variable.Instead get the document subtype
6108 and pass it as a paramter */
6109 l_document_id := wf_engine.GetItemAttrNumber
6110 (
6111 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID'
6112 )
6113 ;
6114 l_document_subtype := wf_engine.GetItemAttrText
6115 (
6116 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE'
6117 )
6118 ;
6119 l_withterms := wf_engine.GetItemAttrText
6120 (
6121 itemtype => itemtype, itemkey => itemkey, aname => 'WITH_TERMS'
6122 )
6123 ;
6124 l_document_type := wf_engine.GetItemAttrText
6125 (
6126 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE'
6127 )
6128 ;
6129 -- Bug 4918772
6130 -- The global variable 4918772 should be populated. This is used by
6131 -- the print/fax routines
6132 g_document_subtype := wf_engine.GetItemAttrText
6133 (
6134 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE'
6135 )
6136 ;
6137 -- End Bug 4918772
6138 -- Context Setting revamp : setting the printer to that of the preparer, so that
6139 -- irrespective of who submits the request, the printing should happen
6140 -- on preparer's printer
6141 /* changed the call from wf_engine.setiteattrtext to
6142 po_wf_util_pkg.setitemattrtext because the later handles
6143 attrbute not found exception. req change order wf also
6144 uses these procedures and does not have the preparer_printer
6145 attribute, hence this was required */
6146 l_printer := po_wf_util_pkg.GetItemAttrText
6147 (
6148 itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_PRINTER'
6149 )
6150 ;
6151 IF
6152 (
6153 l_printer IS NOT NULL
6154 )
6155 THEN
6156 l_spo_result:= fnd_request.set_print_options
6157 (
6158 printer=> l_printer
6159 )
6160 ;
6161 END IF;
6162 IF l_document_type IN
6163 (
6164 'PO', 'PA'
6165 )
6166 THEN
6167 l_fax_enable := wf_engine.GetItemAttrText
6168 (
6169 itemtype => itemtype, itemkey => itemkey, aname => 'FAX_DOCUMENT'
6170 )
6171 ;
6172 l_fax_num := wf_engine.GetItemAttrText
6173 (
6174 itemtype => itemtype, itemkey => itemkey, aname => 'FAX_NUMBER'
6175 )
6176 ;
6177 --Bug 6692126 Pass document_id ,document subtype and with terms parameters
6178 l_request_id := Fax_PO
6179 (
6180 l_document_num, l_qty_precision, l_user_id, l_fax_enable, l_fax_num,l_document_id,l_draft_id, l_document_subtype,l_withterms
6181 )
6182 ;
6183 ELSIF l_document_type = 'RELEASE' THEN
6184 l_release_num := wf_engine.GetItemAttrNumber
6185 (
6186 itemtype => itemtype, itemkey => itemkey, aname => 'RELEASE_NUM'
6187 )
6188 ;
6189 l_fax_enable := wf_engine.GetItemAttrText
6190 (
6191 itemtype => itemtype, itemkey => itemkey, aname => 'FAX_DOCUMENT'
6192 )
6193 ;
6194 l_fax_num := wf_engine.GetItemAttrText
6195 (
6196 itemtype => itemtype, itemkey => itemkey, aname => 'FAX_NUMBER'
6197 )
6198 ;
6199 --Bug 6692126 Pass document_id ,document subtype parameters
6200 l_request_id := Fax_Release
6201 (
6202 l_document_num, l_qty_precision, TO_CHAR(l_release_num), l_user_id, l_fax_enable, l_fax_num,l_document_id
6203 )
6204 ;
6205 END IF;
6206 wf_engine.SetItemAttrNumber
6207 (
6208 itemtype => itemtype, itemkey => itemkey, aname => 'CONCURRENT_REQUEST_ID', avalue => l_request_id
6209 )
6210 ;
6211 x_progress := 'PO_REQAPPROVAL_INIT1.FaxDocument: 02. request_id= ' || TO_CHAR
6212 (
6213 l_request_id
6214 )
6215 ;
6216 IF
6217 (
6218 g_po_wf_debug = 'Y'
6219 )
6220 THEN
6221 /* DEBUG */
6222 PO_WF_DEBUG_PKG.insert_debug
6223 (
6224 itemtype,itemkey,x_progress
6225 )
6226 ;
6227 END IF;
6228 EXCEPTION
6229 WHEN OTHERS THEN
6230 wf_core.context
6231 (
6232 'PO_REQAPPROVAL_INIT1','FaxDocument',x_progress
6233 )
6234 ;
6235 raise;
6236 END FaxDocument;
6237 FUNCTION Print_Requisition
6238 (
6239 p_doc_num VARCHAR2,
6240 p_qty_precision VARCHAR,
6241 p_user_id VARCHAR2
6242 )
6243 RETURN NUMBER
6244 IS
6245 l_request_id NUMBER;
6246 x_progress VARCHAR2
6247 (
6248 200
6249 )
6250 ;
6251 BEGIN
6252 --<R12 MOAC START>
6253 po_moac_utils_pvt.set_request_context
6254 (
6255 po_moac_utils_pvt.get_current_org_id
6256 )
6257 ;
6258 --<R12 MOAC END>
6259 l_request_id := fnd_request.submit_request
6260 (
6261 'PO', 'PRINTREQ', NULL, NULL, false, 'P_REQ_NUM_FROM=' || p_doc_num,
6262 'P_REQ_NUM_TO=' || p_doc_num, 'P_QTY_PRECISION=' || p_qty_precision, fnd_global.local_chr(0),
6263 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6264 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6265 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6266 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6267 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6268 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6269 )
6270 ;
6271 RETURN
6272 (
6273 l_request_id
6274 )
6275 ;
6276 EXCEPTION
6277 WHEN OTHERS THEN
6278 wf_core.context
6279 (
6280 'PO_REQAPPROVAL_INIT1','Print_Requisition',x_progress
6281 )
6282 ;
6283 raise;
6284 END;
6285 FUNCTION Print_PO
6286 (
6287 p_doc_num VARCHAR2,
6288 p_qty_precision VARCHAR,
6289 p_user_id VARCHAR2,
6290 p_document_id NUMBER DEFAULT NULL,
6291 p_draft_id NUMBER DEFAULT -1, --CLM Mod
6292 p_document_subtype VARCHAR2 DEFAULT NULL,
6293 p_withterms VARCHAR2 DEFAULT NULL
6294 )
6295 RETURN NUMBER
6296 IS
6297 l_request_id NUMBER;
6298 x_progress VARCHAR2
6299 (
6300 200
6301 )
6302 ;
6303 l_set_lang boolean;
6304 BEGIN
6305 --<POC FPJ Start>
6306 --Bug#3528330 used the procedure po_communication_profile() to check for the
6307 --PO output format option instead of checking for the installation of
6308 --XDO product
6309 --Bug5080617 Pass the parameters P_PO_TEMPLATE_CODE and P_CONTRACT_TEMPLATE_CODE as null
6310 l_set_lang := fnd_request.set_options('NO', 'NO', NULL,NULL, NULL, FND_PROFILE.VALUE('ICX_NUMERIC_CHARACTERS'));
6311 IF
6312 (
6313 PO_COMMUNICATION_PVT.PO_COMMUNICATION_PROFILE = 'T' AND g_document_subtype <>'PLANNED'
6314 )
6315 THEN
6316 --Launching the Dispatch Purchase Order Concurrent Program
6317 --<R12 MOAC START>
6318 po_moac_utils_pvt.set_request_context
6319 (
6320 po_moac_utils_pvt.get_current_org_id
6321 )
6322 ;
6323 --<R12 MOAC END>
6324 l_request_id := fnd_request.submit_request
6325 (
6326 'PO', 'POXPOPDF', NULL, NULL, false, 'R',--P_report_type
6327 NULL , --P_agent_name
6328 p_doc_num , --P_po_num_from
6329 p_doc_num , --P_po_num_to
6330 NULL , --P_relaese_num_from
6331 NULL , --P_release_num_to
6332 NULL , --P_date_from
6333 NULL , --P_date_to
6334 NULL , --P_approved_flag
6335 'N' , --P_test_flag
6336 NULL , --P_print_releases
6337 NULL , --P_sortby
6338 p_user_id , --P_user_id
6339 NULL , --P_fax_enable
6340 NULL , --P_fax_number
6341 'Y' , --P_BLANKET_LINES
6342 'Communicate' , --View_or_Communicate,
6343 p_withterms , --P_WITHTERMS Bug# 6692126 instead of 'Y'
6344 'N' , --P_storeFlag Bug#3528330 Changed to "N"
6345 'Y' , --P_PRINT_FLAG
6346 p_document_id , --P_DOCUMENT_ID Bug# 6692126
6347 p_draft_id, --P_DRAFT_ID CLM Mod
6348 NULL , --P_REVISION_NUM
6349 NULL , --P_AUTHORIZATION_STATUS
6350 p_document_subtype, --P_DOCUMENT_TYPE Bug# 6692126
6351 0 , --P_max_zip_size, <PO Attachment Support 11i.11>
6352 NULL , --P_PO_TEMPLATE_CODE
6353 NULL , --P_CONTRACT_TEMPLATE_CODE
6354 fnd_global.local_chr(0), NULL, NULL, NULL, NULL, NULL,
6355 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6356 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6357 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6358 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6359 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6360 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6361 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6362 NULL, NULL, NULL
6363 )
6364 ;
6365 --<POC FPJ End>
6366 ELSE
6367 --<R12 MOAC START>
6368 po_moac_utils_pvt.set_request_context
6369 (
6370 po_moac_utils_pvt.get_current_org_id
6371 )
6372 ;
6373 l_set_lang := fnd_request.set_options('NO', 'NO', NULL,NULL, NULL, FND_PROFILE.VALUE('ICX_NUMERIC_CHARACTERS'));
6374 --<R12 MOAC END>
6375 l_request_id := fnd_request.submit_request
6376 (
6377 'PO', 'POXPPO', NULL, NULL, false, 'P_REPORT_TYPE=R', 'P_TEST_FLAG=N',
6378 'P_PO_NUM_FROM=' || p_doc_num, 'P_PO_NUM_TO=' || p_doc_num, 'P_USER_ID=' || p_user_id,
6379 'P_QTY_PRECISION=' || p_qty_precision, 'P_BLANKET_LINES=Y', 'P_PRINT_RELEASES=N',
6380 fnd_global.local_chr(0), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6381 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6382 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6383 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6384 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6385 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6386 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6387 )
6388 ;
6389 END IF;
6390 RETURN
6391 (
6392 l_request_id
6393 )
6394 ;
6395 EXCEPTION
6396 WHEN OTHERS THEN
6397 wf_core.context
6398 (
6399 'PO_REQAPPROVAL_INIT1','Print_PO',x_progress
6400 )
6401 ;
6402 raise;
6403 END Print_PO;
6404 --DKC 10/10/99
6405 FUNCTION Fax_PO
6406 (
6407 p_doc_num VARCHAR2,
6408 p_qty_precision VARCHAR,
6409 p_user_id VARCHAR2,
6410 p_fax_enable VARCHAR2,
6411 p_fax_num VARCHAR2,
6412 p_document_id NUMBER DEFAULT NULL,
6413 p_draft_id NUMBER DEFAULT -1, --CLM Mod
6414 p_document_subtype VARCHAR2,
6415 p_withterms VARCHAR2
6416 )
6417 RETURN NUMBER
6418 IS
6419 l_request_id NUMBER;
6420 x_progress VARCHAR2
6421 (
6422 200
6423 )
6424 ;
6425 l_set_lang boolean;
6426 BEGIN
6427 --<POC FPJ Start>
6428 --Bug#3528330 used the procedure po_communication_profile() to check for the
6429 --PO output format option instead of checking for the installation of
6430 --XDO product
6431 IF
6432 (
6433 PO_COMMUNICATION_PVT.PO_COMMUNICATION_PROFILE = 'T' AND g_document_subtype <>'PLANNED'
6434 )
6435 THEN
6436 --Launching the Dispatch Purchase Order Concurrent Program
6437 --<R12 MOAC START>
6438 po_moac_utils_pvt.set_request_context
6439 (
6440 po_moac_utils_pvt.get_current_org_id
6441 )
6442 ;
6443 --<R12 MOAC END>
6444 --Bug5080617 Pass the parameters P_PO_TEMPLATE_CODE and P_CONTRACT_TEMPLATE_CODE as null
6445 l_request_id := fnd_request.submit_request
6446 (
6447 'PO', 'POXPOFAX' , --Bug 6332444
6448 NULL, NULL, false, 'R',--P_report_type
6449 NULL , --P_agent_name
6450 p_doc_num , --P_po_num_from
6451 p_doc_num , --P_po_num_to
6452 NULL , --P_relaese_num_from
6453 NULL , --P_release_num_to
6454 NULL , --P_date_from
6455 NULL , --P_date_to
6456 NULL , --P_approved_flag
6457 'N' , --P_test_flag
6458 NULL , --P_print_releases
6459 NULL , --P_sortby
6460 p_user_id , --P_user_id
6461 'Y' , --P_fax_enable
6462 p_fax_num , --P_fax_number
6463 'Y' , --P_BLANKET_LINES
6464 'Communicate' , --View_or_Communicate,
6465 p_withterms , --P_WITHTERMS Bug# 6692126 instead of 'Y'
6466 'N' , --P_storeFlag Bug#3528330 Changed to "N"
6467 'Y' , --P_PRINT_FLAG
6468 p_document_id , --P_DOCUMENT_ID Bug# 6692126
6469 p_draft_id, --P_DRAFT_ID CLM Mod
6470 NULL , --P_REVISION_NUM
6471 NULL , --P_AUTHORIZATION_STATUS
6472 p_document_subtype, --P_DOCUMENT_TYPE Bug# 6692126
6473 0 , --P_max_zip_size, <PO Attachment Support 11i.11>
6474 NULL , --P_PO_TEMPLATE_CODE
6475 NULL , --P_CONTRACT_TEMPLATE_CODE
6476 fnd_global.local_chr(0), NULL, NULL, NULL, NULL, NULL,
6477 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6478 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6479 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6480 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6481 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6482 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6483 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6484 )
6485 ;
6486 --<POC FPJ End>
6487 ELSE
6488 --<R12 MOAC START>
6489 po_moac_utils_pvt.set_request_context
6490 (
6491 po_moac_utils_pvt.get_current_org_id
6492 )
6493 ;
6494 --<R12 MOAC END>
6495 l_set_lang := fnd_request.set_options('NO', 'NO', NULL,NULL, NULL, FND_PROFILE.VALUE('ICX_NUMERIC_CHARACTERS'));
6496 l_request_id := fnd_request.submit_request
6497 (
6498 'PO', 'POXPPO', NULL, NULL, false, 'P_REPORT_TYPE=R', 'P_TEST_FLAG=N', 'P_PO_NUM_FROM=' || p_doc_num,
6499 'P_PO_NUM_TO=' || p_doc_num, 'P_USER_ID=' || p_user_id, 'P_QTY_PRECISION=' || p_qty_precision,
6500 'P_FAX_ENABLE=' || p_fax_enable, 'P_FAX_NUM=' || p_fax_num, 'P_BLANKET_LINES=Y', -- Bug 3672088
6501 'P_PRINT_RELEASES=N', -- Bug 3672088
6502 fnd_global.local_chr(0), NULL, NULL, NULL,
6503 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6504 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6505 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6506 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6507 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6508 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6509 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6510 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6511 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6512 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6513 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6514 NULL, NULL
6515 )
6516 ;
6517 END IF;
6518 RETURN
6519 (
6520 l_request_id
6521 )
6522 ;
6523 EXCEPTION
6524 WHEN OTHERS THEN
6525 wf_core.context
6526 (
6527 'PO_REQAPPROVAL_INIT1','Fax_PO',x_progress
6528 )
6529 ;
6530 raise;
6531 END Fax_PO;
6532 FUNCTION Print_Release
6533 (
6534 p_doc_num VARCHAR2,
6535 p_qty_precision VARCHAR,
6536 p_release_num VARCHAR2,
6537 p_user_id VARCHAR2,
6538 p_document_id NUMBER DEFAULT NULL
6539 )
6540 RETURN NUMBER
6541 IS
6542 l_request_id NUMBER;
6543 x_progress VARCHAR2
6544 (
6545 200
6546 )
6547 ;
6548 l_set_lang boolean;
6549 BEGIN
6550 --<POC FPJ Start>
6551 --Bug#3528330 used the procedure po_communication_profile() to check for the
6552 --PO output format option instead of checking for the installation of
6553 --XDO product
6554 IF
6555 (
6556 PO_COMMUNICATION_PVT.PO_COMMUNICATION_PROFILE = 'T' AND g_document_subtype = 'BLANKET'
6557 )
6558 THEN
6559 --Launching the Dispatch Purchase Order Concurrent Program
6560 --<R12 MOAC START>
6561 po_moac_utils_pvt.set_request_context
6562 (
6563 po_moac_utils_pvt.get_current_org_id
6564 )
6565 ;
6566 --<R12 MOAC END>
6567 --Bug5080617 Pass the parameters P_PO_TEMPLATE_CODE and P_CONTRACT_TEMPLATE_CODE as null
6568 l_request_id := fnd_request.submit_request
6569 (
6570 'PO', 'POXPOPDF', NULL, NULL, false, 'R',--P_report_type
6571 NULL , --P_agent_name
6572 p_doc_num , --P_po_num_from
6573 p_doc_num , --P_po_num_to
6574 p_release_num , --P_release_num_from
6575 p_release_num , --P_release_num_to
6576 NULL , --P_date_from
6577 NULL , --P_date_to
6578 NULL , --P_approved_flag
6579 'N' , --P_test_flag
6580 'Y' , --P_print_releases
6581 NULL , --P_sortby
6582 p_user_id , --P_user_id
6583 NULL , --P_fax_enable
6584 NULL , --P_fax_number
6585 'Y' , --P_BLANKET_LINES
6586 'Communicate' , --View_or_Communicate,
6587 'N' , --P_WITHTERMS
6588 'N' , --P_storeFlag Bug#3528330 Changed to "N"
6589 'Y' , --P_PRINT_FLAG
6590 p_document_id , --P_DOCUMENT_ID Bug# 6692126
6591 NULL , --P_REVISION_NUM
6592 NULL , --P_AUTHORIZATION_STATUS
6593 'RELEASE' , --P_DOCUMENT_TYPE Bug# 6692126
6594 0 , --P_max_zip_size, <PO Attachment Support 11i.11>
6595 NULL , --P_PO_TEMPLATE_CODE
6596 NULL , --P_CONTRACT_TEMPLATE_CODE
6597 fnd_global.local_chr(0), NULL, NULL, NULL, NULL,
6598 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6599 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6600 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6601 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6602 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6603 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6604 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6605 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6606 NULL, NULL, NULL, NULL
6607 )
6608 ;
6609 --<POC FPJ End >
6610 ELSE
6611 -- FRKHAN 09/17/98. Change 'p_doc_num || p_release_num' from P_RELEASE_NUM_FROM and TO to just p_release_num
6612 --<R12 MOAC START>
6613 po_moac_utils_pvt.set_request_context
6614 (
6615 po_moac_utils_pvt.get_current_org_id
6616 )
6617 ;
6618 l_set_lang := fnd_request.set_options('NO', 'NO', NULL,NULL, NULL, FND_PROFILE.VALUE('ICX_NUMERIC_CHARACTERS'));
6619 --<R12 MOAC END>
6620 l_request_id := fnd_request.submit_request
6621 (
6622 'PO', 'POXPPO', NULL, NULL, false, 'P_REPORT_TYPE=R',
6623 'P_TEST_FLAG=N', 'P_USER_ID=' || p_user_id, 'P_PO_NUM_FROM=' || p_doc_num,
6624 'P_PO_NUM_TO=' || p_doc_num, 'P_RELEASE_NUM_FROM=' || p_release_num,
6625 'P_RELEASE_NUM_TO=' || p_release_num, 'P_QTY_PRECISION=' || p_qty_precision,
6626 'P_BLANKET_LINES=N', 'P_PRINT_RELEASES=Y', fnd_global.local_chr(0), NULL,
6627 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6628 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6629 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6630 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6631 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6632 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6633 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6634 )
6635 ;
6636 END IF;
6637 RETURN
6638 (
6639 l_request_id
6640 )
6641 ;
6642 EXCEPTION
6643 WHEN OTHERS THEN
6644 wf_core.context
6645 (
6646 'PO_REQAPPROVAL_INIT1','Print_Release',x_progress
6647 )
6648 ;
6649 raise;
6650 END Print_Release;
6651 -- Auto Fax
6652 -- DKC 10/10/99
6653 FUNCTION Fax_Release
6654 (
6655 p_doc_num VARCHAR2,
6656 p_qty_precision VARCHAR,
6657 p_release_num VARCHAR2,
6658 p_user_id VARCHAR2,
6659 p_fax_enable VARCHAR2,
6660 p_fax_num VARCHAR2,
6661 p_document_id NUMBER DEFAULT NULL
6662 )
6663 RETURN NUMBER
6664 IS
6665 l_request_id NUMBER;
6666 x_progress VARCHAR2
6667 (
6668 200
6669 )
6670 ;
6671 l_set_lang boolean;
6672 BEGIN
6673 --<POC FPJ Start>
6674 --Bug#3528330 used the procedure po_communication_profile() to check for the
6675 --PO output format option instead of checking for the installation of
6676 --XDO product
6677 IF
6678 (
6679 PO_COMMUNICATION_PVT.PO_COMMUNICATION_PROFILE = 'T' AND g_document_subtype = 'BLANKET'
6680 )
6681 THEN
6682 --Launching the Dispatch Purchase Order Concurrent Program
6683 --<R12 MOAC START>
6684 po_moac_utils_pvt.set_request_context
6685 (
6686 po_moac_utils_pvt.get_current_org_id
6687 )
6688 ;
6689 --<R12 MOAC END>
6690 --Bug5080617 Pass the parameters P_PO_TEMPLATE_CODE and P_CONTRACT_TEMPLATE_CODE as null
6691 l_request_id := fnd_request.submit_request
6692 (
6693 'PO', 'POXPOFAX', --Bug 13088481 fix
6694 NULL, NULL, false, 'R',--P_report_type
6695 NULL , --P_agent_name
6696 p_doc_num , --P_po_num_from
6697 p_doc_num , --P_po_num_to
6698 p_release_num , --P_relaese_num_from
6699 p_release_num , --P_release_num_to
6700 NULL , --P_date_from
6701 NULL , --P_date_to
6702 NULL , --P_approved_flag
6703 'N' , --P_test_flag
6704 'Y' , --P_print_releases
6705 NULL , --P_sortby
6706 p_user_id , --P_user_id
6707 'Y' , --P_fax_enable
6708 p_fax_num , --P_fax_number
6709 'N' , --P_BLANKET_LINES
6710 'Communicate' , --View_or_Communicate,
6711 'N' , --P_WITHTERMS
6712 'N' , --P_storeFlag Bug#3528330 Changed to "N"
6713 'Y' , --P_PRINT_FLAG
6714 p_document_id , --P_DOCUMENT_ID Bug# 6692126
6715 NULL , --P_REVISION_NUM
6716 NULL , --P_AUTHORIZATION_STATUS
6717 'RELEASE' , --P_DOCUMENT_TYPE Bug# 6692126
6718 0 , --P_max_zip_size, <PO Attachment Support 11i.11>
6719 NULL , --P_PO_TEMPLATE_CODE
6720 NULL , --P_CONTRACT_TEMPLATE_CODE
6721 fnd_global.local_chr(0), NULL, NULL, NULL, NULL,
6722 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6723 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6724 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6725 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6726 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6727 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6728 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6729 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6730 NULL, NULL, NULL, NULL
6731 )
6732 ;
6733 --<POC FPJ End>
6734 ELSE
6735 --<R12 MOAC START>
6736 po_moac_utils_pvt.set_request_context
6737 (
6738 po_moac_utils_pvt.get_current_org_id
6739 )
6740 ;
6741 l_set_lang := fnd_request.set_options('NO', 'NO', NULL,NULL, NULL, FND_PROFILE.VALUE('ICX_NUMERIC_CHARACTERS'));
6742 --<R12 MOAC END>
6743 l_request_id := fnd_request.submit_request
6744 (
6745 'PO', 'POXPPO', NULL, NULL, false, 'P_REPORT_TYPE=R', 'P_TEST_FLAG=N',
6746 'P_USER_ID=' || p_user_id, 'P_PO_NUM_FROM=' || p_doc_num,
6747 'P_PO_NUM_TO=' || p_doc_num, 'P_RELEASE_NUM_FROM=' || p_release_num,
6748 'P_RELEASE_NUM_TO=' || p_release_num, 'P_QTY_PRECISION=' || p_qty_precision,
6749 'P_FAX_ENABLE=' || p_fax_enable, 'P_FAX_NUM=' || p_fax_num, 'P_BLANKET_LINES=N', -- Bug 3672088
6750 'P_PRINT_RELEASES=Y', -- Bug 3672088
6751 fnd_global.local_chr(0), NULL, NULL, NULL, NULL, NULL, NULL,
6752 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6753 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6754 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6755 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6756 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6757 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6758 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
6759 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
6760 )
6761 ;
6762 END IF;
6763 RETURN
6764 (
6765 l_request_id
6766 )
6767 ;
6768 EXCEPTION
6769 WHEN OTHERS THEN
6770 wf_core.context
6771 (
6772 'PO_REQAPPROVAL_INIT1','Fax_Release',x_progress
6773 )
6774 ;
6775 raise;
6776 END Fax_Release;
6777 --
6778 -- Is apps source code POR ?
6779 -- Determines if the requisition is created
6780 -- through web requisition 4.0 or higher
6781 --
6782 PROCEDURE is_apps_source_POR
6783 (
6784 itemtype IN VARCHAR2,
6785 itemkey IN VARCHAR2,
6786 actid IN NUMBER,
6787 funcmode IN VARCHAR2,
6788 resultout OUT NOCOPY VARCHAR2
6789 )
6790 IS
6791 l_progress VARCHAR2
6792 (
6793 100
6794 )
6795 := '000';
6796 l_document_id NUMBER;
6797 l_apps_source_code VARCHAR2
6798 (
6799 25
6800 )
6801 :='';
6802 l_doc_string VARCHAR2
6803 (
6804 200
6805 )
6806 ;
6807 l_preparer_user_name VARCHAR2
6808 (
6809 100
6810 )
6811 ;
6812 BEGIN
6813 IF
6814 (
6815 funcmode='RUN'
6816 )
6817 THEN
6818 l_document_id := wf_engine.GetItemAttrNumber
6819 (
6820 itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID'
6821 )
6822 ;
6823 IF l_document_id IS NOT NULL THEN
6824 SELECT NVL(apps_source_code, 'PO')
6825 INTO l_apps_source_code
6826 FROM po_requisition_headers_all
6827 WHERE requisition_header_id=l_document_id;
6828 END IF;
6829 l_progress:='002-'||TO_CHAR(l_document_id);
6830 /* POR = Web Requisition 4.0 or higher */
6831 IF (l_apps_source_code='POR') THEN
6832 resultout :='COMPLETE:'||'Y';
6833 RETURN;
6834 ELSE
6835 resultout:='COMPLETE:'||'N';
6836 RETURN;
6837 END IF;
6838 END IF; -- run mode
6839 EXCEPTION
6840 WHEN OTHERS THEN
6841 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
6842 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
6843 wf_core.context('PO_REQAPPROVAL_INIT1','is_apps_source_POR',l_progress);
6844 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.IS_APPS_SOURCE_POR');
6845 RAISE;
6846 END is_apps_source_POR;
6847 -- Bug#3147435
6848 -- Is contractor status PENDING?
6849 -- Determines if the requisition has contractor_status PENDING at header level
6850 PROCEDURE is_contractor_status_pending
6851 (
6852 itemtype IN VARCHAR2,
6853 itemkey IN VARCHAR2,
6854 actid IN NUMBER,
6855 funcmode IN VARCHAR2,
6856 resultout OUT NOCOPY VARCHAR2)
6857 IS
6858 l_progress VARCHAR2(100) := '000';
6859 l_contractor_status VARCHAR2(25) := '';
6860 l_doc_string VARCHAR2(200);
6861 l_preparer_user_name VARCHAR2(100);
6862 BEGIN
6863 l_progress :='001-'||funcmode;
6864 IF (g_po_wf_debug = 'Y') THEN
6865 /* DEBUG */
6866 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
6867 END IF;
6868 IF (funcmode ='RUN') THEN
6869 l_contractor_status := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CONTRACTOR_STATUS');
6870 l_progress :='002-'||l_contractor_status;
6871 IF (g_po_wf_debug = 'Y') THEN
6872 /* DEBUG */
6873 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
6874 END IF;
6875 IF (l_contractor_status = 'PENDING') THEN
6876 --Bug#3268971
6877 --Setting the item attribute value to Y, which will be used in
6878 --ReqLinesNOtificationsCO to determine whether to display the helptext
6879 --for contractor assignment
6880 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'CONTRACTOR_ASSIGNMENT_REQD', avalue => 'Y' );
6881 resultout :='COMPLETE:'||'Y';
6882 l_progress :='003-'||resultout;
6883 IF (g_po_wf_debug = 'Y') THEN
6884 /* DEBUG */
6885 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
6886 END IF;
6887 RETURN;
6888 ELSE
6889 resultout :='COMPLETE:'||'N';
6890 l_progress :='004-'||resultout;
6891 IF (g_po_wf_debug = 'Y') THEN
6892 /* DEBUG */
6893 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
6894 END IF;
6895 RETURN;
6896 END IF;
6897 END IF; -- run mode
6898 EXCEPTION
6899 WHEN OTHERS THEN
6900 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
6901 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
6902 wf_core.context('PO_REQAPPROVAL_INIT1','is_contractor_status_pending',l_progress);
6903 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.is_contractor_status_pending');
6904 RAISE;
6905 END is_contractor_status_pending;
6906 -- Bug 823167 kbenjami
6907 --
6908 -- Is the Submitter the last Approver?
6909 -- Checks to see if submitter is also the current
6910 -- approver of the doc.
6911 -- Prevents two notifications from being sent to the
6912 -- same person.
6913 --
6914 PROCEDURE Is_Submitter_Last_Approver
6915 (
6916 itemtype IN VARCHAR2,
6917 itemkey IN VARCHAR2,
6918 actid IN NUMBER,
6919 funcmode IN VARCHAR2,
6920 resultout OUT NOCOPY VARCHAR2 )
6921 IS
6922 approver_id NUMBER;
6923 preparer_id NUMBER;
6924 x_username VARCHAR2(100);
6925 x_progress VARCHAR2(300);
6926 l_doc_string VARCHAR2(200);
6927 l_preparer_user_name VARCHAR2(100);
6928 BEGIN
6929 x_progress := 'PO_REQAPPROVAL_INIT1.Is_Submitter_Last_Approver: 01';
6930 IF (g_po_wf_debug = 'Y') THEN
6931 /* DEBUG */
6932 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey,x_progress);
6933 END IF;
6934 preparer_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_ID');
6935 approver_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'FORWARD_FROM_ID');
6936 x_username := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'FORWARD_FROM_USER_NAME');
6937 -- return Y if forward from user name is null.
6938 /* Bug5142627(forward fix 3733830) After the fix 2308846 the FORWARD_FROM_ID might be null
6939 when it is just submitted for approval and no-approver-found.
6940 So this also should be excluded.
6941 */
6942 IF (approver_id IS NULL OR preparer_id = approver_id OR x_username IS NULL) THEN
6943 resultout := wf_engine.eng_completed || ':' || 'Y';
6944 x_progress := 'PO_REQAPPROVAL_INIT1.Is_Submitter_Last_Approver: 02. Result = Yes';
6945 ELSE
6946 resultout := wf_engine.eng_completed || ':' || 'N';
6947 x_progress := 'PO_REQAPPROVAL_INIT1.Is_Submitter_Last_Approver: 02. Result = No';
6948 END IF;
6949 EXCEPTION
6950 WHEN OTHERS THEN
6951 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
6952 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
6953 wf_core.context('PO_REQAPPROVAL_INIT1','Is_Submitter_Last_Approver',x_progress);
6954 PO_REQAPPROVAL_INIT1.send_error_notif(itemType, itemkey, l_preparer_user_name, l_doc_string, sqlerrm, 'PO_REQAPPROVAL_INIT1.IS_SUBMITTER_LAST_APPROVER');
6955 raise;
6956 END Is_Submitter_Last_Approver;
6957 --
6958 FUNCTION get_error_doc
6959 (
6960 itemtype IN VARCHAR2,
6961 itemkey IN VARCHAR2)
6962 RETURN VARCHAR2
6963 IS
6964 l_doc_string VARCHAR2(200);
6965 l_document_type VARCHAR2(25);
6966 l_document_subtype VARCHAR2(25);
6967 l_document_id NUMBER;
6968 l_org_id NUMBER;
6969 BEGIN
6970 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
6971 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
6972 l_org_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
6973 PO_MOAC_UTILS_PVT.set_org_context(l_org_id) ; -- <R12 MOAC>
6974 IF (l_document_type IN ('PO', 'PA')) THEN
6975 SELECT st.DISPLAYED_FIELD
6976 || ' '
6977 || ty.DISPLAYED_FIELD
6978 || ' '
6979 || hd.SEGMENT1
6980 INTO l_doc_string
6981 FROM po_headers hd,
6982 po_lookup_codes ty,
6983 po_lookup_codes st
6984 WHERE hd.po_header_id = l_document_id
6985 AND ty.lookup_type = 'DOCUMENT TYPE'
6986 AND ty.lookup_code = l_document_type
6987 AND st.lookup_type = 'DOCUMENT SUBTYPE'
6988 AND st.lookup_code = hd.TYPE_LOOKUP_CODE;
6989 ELSIF (l_document_type = 'REQUISITION') THEN
6990 SELECT st.DISPLAYED_FIELD
6991 || ' '
6992 || ty.DISPLAYED_FIELD
6993 || ' '
6994 || hd.SEGMENT1
6995 INTO l_doc_string
6996 FROM po_requisition_headers hd,
6997 po_lookup_codes ty,
6998 po_lookup_codes st
6999 WHERE hd.requisition_header_id = l_document_id
7000 AND ty.lookup_type = 'DOCUMENT TYPE'
7001 AND ty.lookup_code = l_document_type
7002 AND st.lookup_type = 'REQUISITION TYPE'
7003 AND st.lookup_code = hd.TYPE_LOOKUP_CODE;
7004 ELSIF (l_document_type = 'RELEASE') THEN
7005 SELECT st.DISPLAYED_FIELD
7006 || ' '
7007 || ty.DISPLAYED_FIELD
7008 || ' '
7009 || hd.SEGMENT1
7010 || '-'
7011 || rl.RELEASE_NUM
7012 INTO l_doc_string
7013 FROM po_headers hd,
7014 po_releases rl,
7015 po_lookup_codes ty,
7016 po_lookup_codes st
7017 WHERE rl.po_release_id = l_document_id
7018 AND rl.po_header_id = hd.po_header_id
7019 AND ty.lookup_type = 'DOCUMENT TYPE'
7020 AND ty.lookup_code = l_document_type
7021 AND st.lookup_type = 'DOCUMENT SUBTYPE'
7022 AND st.lookup_code = rl.RELEASE_TYPE;
7023 END IF;
7024 RETURN(l_doc_string);
7025 EXCEPTION
7026 WHEN OTHERS THEN
7027 RAISE;
7028 END get_error_doc;
7029 FUNCTION get_preparer_user_name
7030 (
7031 itemtype IN VARCHAR2,
7032 itemkey IN VARCHAR2)
7033 RETURN VARCHAR2
7034 IS
7035 l_name VARCHAR2(100);
7036 l_preparer_id NUMBER;
7037 l_disp VARCHAR2(240);
7038 BEGIN
7039 l_preparer_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'PREPARER_ID');
7040 PO_REQAPPROVAL_INIT1.get_user_name(l_preparer_id, l_name, l_disp);
7041 RETURN(l_name);
7042 END;
7043 PROCEDURE send_error_notif
7044 (
7045 itemtype IN VARCHAR2,
7046 itemkey IN VARCHAR2,
7047 username IN VARCHAR2,
7048 doc IN VARCHAR2,
7049 msg IN VARCHAR2,
7050 loc IN VARCHAR2,
7051 document_id IN NUMBER)
7052 IS
7053 pragma AUTONOMOUS_TRANSACTION;
7054 /* Bug# 2074072: kagarwal
7055 ** Desc: Calling wf process to send Error Notification
7056 ** instead of the wf API.
7057 */
7058 -- l_nid NUMBER;
7059 l_seq VARCHAR2(25); --Bug14305923
7060 Err_ItemKey VARCHAR2(240);
7061 Err_ItemType VARCHAR2(240):= 'POERROR';
7062 l_document_id NUMBER;
7063 x_progress VARCHAR2(1000);
7064 BEGIN
7065 -- To be used only for PO and Req Approval wf
7066 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 10';
7067 IF (g_po_wf_debug = 'Y') THEN
7068 /* DEBUG */
7069 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7070 END IF;
7071 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 20' ||' username: '|| username ||' doc: '|| doc ||' location: '|| loc ||' error msg: '|| msg;
7072 IF (g_po_wf_debug = 'Y') THEN
7073 /* DEBUG */
7074 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7075 END IF;
7076 IF username IS NOT NULL AND doc IS NOT NULL THEN
7077 /* l_nid := wf_notification.Send(username,
7078 itemtype,
7079 'PLSQL_ERROR_OCCURS',
7080 null, null, null, null);
7081 wf_Notification.SetAttrText(l_nid, 'PLSQL_ERROR_DOC', doc);
7082 wf_Notification.SetAttrText(l_nid, 'PLSQL_ERROR_LOC', loc);
7083 wf_Notification.SetAttrText(l_nid, 'PLSQL_ERROR_MSG', msg);
7084 */
7085 -- Get Document Id for the Errored Item.
7086 IF (document_id IS NULL) THEN
7087 l_document_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
7088 ELSE
7089 l_document_id := document_id;
7090 END IF;
7091 SELECT TO_CHAR(PO_WF_ITEMKEY_S.NEXTVAL) INTO l_seq FROM sys.dual;
7092
7093 Err_ItemKey := TO_CHAR(l_document_id) || '-' || l_seq;
7094 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 50' ||' Parent Itemtype: '|| ItemType ||' Parent Itemkey: '|| ItemKey ||' Error Itemtype: '|| Err_ItemType ||' Error Itemkey: '|| Err_ItemKey;
7095 IF (g_po_wf_debug = 'Y') THEN
7096 /* DEBUG */
7097 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7098 END IF;
7099 wf_engine.CreateProcess( ItemType => Err_ItemType, ItemKey => Err_ItemKey, process => 'PLSQL_ERROR_NOTIF');
7100 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 70';
7101 IF (g_po_wf_debug = 'Y') THEN
7102 /* DEBUG */
7103 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7104 END IF;
7105 -- Set the attributes
7106 wf_engine.SetItemAttrText ( itemtype => Err_ItemType, itemkey => Err_ItemKey, aname => 'PLSQL_ERROR_DOC', avalue => doc);
7107 --
7108 wf_engine.SetItemAttrText ( itemtype => Err_ItemType, itemkey => Err_ItemKey, aname => 'PLSQL_ERROR_LOC', avalue => loc);
7109 --
7110 wf_engine.SetItemAttrText ( itemtype => Err_ItemType, itemkey => Err_ItemKey, aname => 'PLSQL_ERROR_MSG', avalue => msg);
7111 --
7112 wf_engine.SetItemAttrText ( itemtype => Err_ItemType, itemkey => Err_ItemKey, aname => 'PREPARER_USER_NAME' , avalue => username);
7113 --
7114 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 100';
7115 IF (g_po_wf_debug = 'Y') THEN
7116 /* DEBUG */
7117 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7118 END IF;
7119 wf_engine.StartProcess(itemtype => Err_ItemType, itemkey => Err_ItemKey);
7120 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: 900';
7121 IF (g_po_wf_debug = 'Y') THEN
7122 /* DEBUG */
7123 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7124 END IF;
7125 COMMIT;
7126 END IF;
7127 EXCEPTION
7128 WHEN OTHERS THEN
7129 x_progress := 'PO_REQAPPROVAL_INIT1.send_error_notif: '|| sqlerrm;
7130 IF (g_po_wf_debug = 'Y') THEN
7131 /* DEBUG */
7132 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7133 END IF;
7134 RAISE;
7135 END send_error_notif;
7136 -- This procedure will close all the notification of all the
7137 -- previous approval WF.
7138 PROCEDURE CLOSE_OLD_NOTIF
7139 (
7140 itemtype IN VARCHAR2,
7141 itemkey IN VARCHAR2)
7142 IS
7143 pragma AUTONOMOUS_TRANSACTION;
7144 BEGIN
7145 UPDATE wf_notifications
7146 SET status = 'CLOSED'
7147 WHERE notification_id IN
7148 (SELECT ias.notification_id
7149 FROM wf_item_activity_statuses ias,
7150 wf_notifications ntf
7151 WHERE ias.item_type = itemtype
7152 AND ias.item_key = itemkey
7153 AND ntf.notification_id = ias.notification_id
7154 );
7155 COMMIT;
7156 END;
7157 /* Bug# 1739194: kagarwal
7158 ** Desc: Added new procedure to check the document manager error.
7159 */
7160 PROCEDURE Is_Document_Manager_Error_1_2
7161 (
7162 itemtype IN VARCHAR2,
7163 itemkey IN VARCHAR2,
7164 actid IN NUMBER,
7165 funcmode IN VARCHAR2,
7166 resultout OUT NOCOPY VARCHAR2)
7167 IS
7168 l_progress VARCHAR2(100) := '000';
7169 l_error_number NUMBER;
7170 BEGIN
7171 IF (funcmode ='RUN') THEN
7172 l_progress := 'Is_Document_Manager_Error_1_2: 001';
7173 IF (g_po_wf_debug = 'Y') THEN
7174 /* DEBUG */
7175 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
7176 END IF;
7177 l_error_number := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DOC_MGR_ERROR_NUM');
7178 l_progress := 'Is_Document_Manager_Error_1_2: 002 - '|| TO_CHAR(l_error_number);
7179 IF (g_po_wf_debug = 'Y') THEN
7180 /* DEBUG */
7181 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
7182 END IF;
7183 IF (l_error_number = 1 OR l_error_number = 2) THEN
7184 resultout :='COMPLETE:'||'Y';
7185 RETURN;
7186 ELSE
7187 resultout:='COMPLETE:'||'N';
7188 RETURN;
7189 END IF;
7190 END IF; --run mode
7191 EXCEPTION
7192 WHEN OTHERS THEN
7193 WF_CORE.context('PO_APPROVAL_LIST_WF1S' , 'Is_Document_Manager_Error_1_2', itemtype, itemkey, l_progress);
7194 resultout:='COMPLETE:'||'N';
7195 END Is_Document_Manager_Error_1_2;
7196 /**************************************************************************/
7197 PROCEDURE PROFILE_VALUE_CHECK
7198 (
7199 itemtype IN VARCHAR2,
7200 itemkey IN VARCHAR2,
7201 actid IN NUMBER,
7202 funcmode IN VARCHAR2,
7203 resultout OUT NOCOPY VARCHAR2 )
7204 IS
7205 x_progress VARCHAR2(300);
7206 l_po_email_add_prof VARCHAR2(60);
7207 l_prof_value VARCHAR2(2);
7208 l_doc_string VARCHAR2(200);
7209 l_preparer_user_name VARCHAR2(100);
7210 BEGIN
7211 x_progress := 'PO_REQAPPROVAL_INIT1.profile_value_check: 01';
7212 IF (g_po_wf_debug = 'Y') THEN
7213 /* DEBUG */
7214 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7215 END IF;
7216 -- Do nothing in cancel or timeout mode
7217 --
7218 IF (funcmode <> wf_engine.eng_run) THEN
7219 resultout := wf_engine.eng_null;
7220 RETURN;
7221 END IF;
7222 l_po_email_add_prof := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'EMAIL_ADD_FROM_PROFILE');
7223 /* the value of l_po_email_add_prof has a value or it is null*/
7224 IF l_po_email_add_prof IS NULL THEN
7225 l_prof_value := 'N';
7226 ELSE
7227 l_prof_value := 'Y';
7228 END IF;
7229 --
7230 resultout := wf_engine.eng_completed || ':' || l_prof_value ;
7231 --
7232 x_progress := 'PO_REQAPPROVAL_INIT1.profile_value_check: 02. Result= ' || l_prof_value;
7233 IF (g_po_wf_debug = 'Y') THEN
7234 /* DEBUG */
7235 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7236 END IF;
7237 EXCEPTION
7238 WHEN OTHERS THEN
7239 l_doc_string := PO_REQAPPROVAL_INIT1.get_error_doc(itemType, itemkey);
7240 l_preparer_user_name := PO_REQAPPROVAL_INIT1.get_preparer_user_name(itemType, itemkey);
7241 WF_CORE.context('PO_REQAPPROVAL_INIT1', 'PROFILE_VALUE_CHECK' , itemtype, itemkey, x_progress);
7242 resultout:='COMPLETE:'||'N';
7243 END;
7244 PROCEDURE Check_Error_Count
7245 (
7246 itemtype IN VARCHAR2,
7247 itemkey IN VARCHAR2,
7248 actid IN NUMBER,
7249 funcmode IN VARCHAR2,
7250 resultout OUT NOCOPY VARCHAR2)
7251 IS
7252 l_progress VARCHAR2(100) := '000';
7253 l_count NUMBER;
7254 l_error_count NUMBER;
7255 l_item_type VARCHAR2(30);
7256 l_item_key VARCHAR2(30);
7257 BEGIN
7258 IF (funcmode ='RUN') THEN
7259 l_progress := 'CHECK_ERROR_COUNT: 001';
7260 IF (g_po_wf_debug = 'Y') THEN
7261 /* DEBUG */
7262 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
7263 END IF;
7264 l_item_type :=wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ERROR_ITEM_TYPE');
7265 l_item_key :=wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ERROR_ITEM_KEY');
7266 l_count := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'RETRY_COUNT');
7267 SELECT COUNT(*)
7268 INTO l_error_count
7269 FROM wf_items
7270 WHERE parent_item_type=l_item_type
7271 AND parent_item_key = l_item_key;
7272 IF (l_error_count <= l_count) THEN
7273 resultout :='COMPLETE:'||'Y'; -- retry
7274 RETURN;
7275 ELSE
7276 resultout:='COMPLETE:'||'N';
7277 RETURN;
7278 END IF;
7279 END IF; --run mode
7280 EXCEPTION
7281 WHEN OTHERS THEN
7282 WF_CORE.context('PO_APPROVAL_LIST_WF1S' , 'Check_Error_Count', itemtype, itemkey, l_progress);
7283 resultout:='COMPLETE:'||'N';
7284 END Check_Error_Count;
7285 PROCEDURE Initialise_Error
7286 (
7287 itemtype IN VARCHAR2,
7288 itemkey IN VARCHAR2,
7289 actid IN NUMBER,
7290 funcmode IN VARCHAR2,
7291 resultout OUT NOCOPY VARCHAR2)
7292 IS
7293 l_progress VARCHAR2(100) := '000';
7294 l_error_number NUMBER;
7295 l_name VARCHAR2(100);
7296 l_preparer_id NUMBER;
7297 l_disp VARCHAR2(240);
7298 l_item_type VARCHAR2(30);
7299 l_item_key VARCHAR2(30);
7300 l_doc_err_num NUMBER;
7301 l_doc_type VARCHAR2(25);
7302 /* Bug# 2655410 */
7303 l_doc_subtype VARCHAR2(25);
7304 -- l_doc_subtype_disp varchar2(30);
7305 l_doc_type_disp VARCHAR2(240);
7306 l_orgid NUMBER;
7307 l_ga_flag VARCHAR2(1) := NULL; -- FPI GA
7308 l_doc_num VARCHAR2(30);
7309 l_sys_error_msg VARCHAR2(2000) :='';
7310 l_release_num_dash VARCHAR2(30);
7311 l_release_num NUMBER; --1942901
7312 l_document_id PO_HEADERS_ALL.po_header_id%TYPE; --<R12 STYLES PHASE II>
7313 /* Bug# 2655410: kagarwal
7314 ** Desc: We will get the document type display value from
7315 ** po document types.
7316 */
7317 CURSOR docDisp(p_doc_type VARCHAR2, p_doc_subtype VARCHAR2)
7318 IS
7319 SELECT type_name
7320 FROM po_document_types
7321 WHERE document_type_code = p_doc_type
7322 AND document_subtype = p_doc_subtype;
7323 BEGIN
7324 IF (funcmode ='RUN') THEN
7325 l_progress := 'Initialise_Error: 001';
7326 IF (g_po_wf_debug = 'Y') THEN
7327 /* DEBUG */
7328 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
7329 END IF;
7330 l_item_type :=wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ERROR_ITEM_TYPE');
7331 l_item_key :=wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ERROR_ITEM_KEY');
7332 /* Bug# 2708702 kagarwal
7333 ** Fix Details: Make all the Set and Get calls for parent item type to use the PO wrapper
7334 ** PO_WF_UTIL_PKG so that the missing attribute errors are ignored.
7335 */
7336 l_preparer_id := PO_WF_UTIL_PKG.GetItemAttrNumber ( itemtype => l_item_type, itemkey => l_item_key, aname => 'PREPARER_ID');
7337 PO_REQAPPROVAL_INIT1.get_user_name(l_preparer_id, l_name, l_disp);
7338 /* Bug# 2655410: kagarwal
7339 ** Desc: We will get the document type display value from
7340 ** po document types. Hence we need to get the doc type and subtype
7341 ** from the parent wf and then set the doc type display in the
7342 ** error wf.
7343 **
7344 ** Also need to set the org context before calling the cursor
7345 */
7346 l_doc_subtype := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => l_item_type, itemkey => l_item_key, aname => 'DOCUMENT_SUBTYPE');
7347 l_doc_type := PO_WF_UTIL_PKG.GetItemAttrText ( itemtype => l_item_type, itemkey => l_item_key, aname => 'DOCUMENT_TYPE');
7348 IF l_doc_type = 'PA' AND l_doc_subtype = 'BLANKET' THEN
7349 l_ga_flag := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => l_item_type, itemkey => l_item_key, aname => 'GLOBAL_AGREEMENT_FLAG');
7350 END IF;
7351 --<R12 STYLES PHASE II START >
7352 l_document_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => l_item_type, itemkey => l_item_key, aname => 'DOCUMENT_ID');
7353 IF l_ga_flag = 'N' THEN
7354 l_orgid := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => l_item_type, itemkey => l_item_key, aname => 'ORG_ID');
7355 IF l_orgid IS NOT NULL THEN
7356 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
7357 END IF;
7358 END IF;
7359 /* if l_ga_flag = 'N' */
7360 IF (l_doc_type = 'PA' AND l_doc_subtype IN ('BLANKET','CONTRACT')) OR (l_doc_type = 'PO' AND l_doc_subtype = 'STANDARD') THEN
7361 l_doc_type_disp:= PO_DOC_STYLE_PVT.get_style_display_name(l_document_id);
7362 ELSE
7363 OPEN docDisp(l_doc_type, l_doc_subtype);
7364 FETCH docDisp INTO l_doc_type_disp;
7365
7366 CLOSE docDisp;
7367 END IF;
7368 --<R12 STYLES PHASE II END >
7369 l_doc_num := PO_WF_UTIL_PKG.GetItemAttrText ( itemtype => l_item_type, itemkey => l_item_key, aname => 'DOCUMENT_NUMBER');
7370 l_sys_error_msg := PO_WF_UTIL_PKG.GetItemAttrText ( itemtype => l_item_type, itemkey => l_item_key, aname => 'SYSADMIN_ERROR_MSG');
7371 l_release_num_dash := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => l_item_type, itemkey => l_item_key, aname => 'RELEASE_NUM_DASH');
7372 l_release_num := PO_WF_UTIL_PKG.GetItemAttrNumber(itemtype => l_item_type, itemkey => l_item_key, aname => 'RELEASE_NUM');
7373 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'PREPARER_USER_NAME' , avalue => l_name);
7374 /* Bug# 2655410: kagarwal
7375 ** Desc: We will only be using one display attribute for type and
7376 ** subtype - DOCUMENT_TYPE_DISP, hence commenting the code below
7377 */
7378 /* wf_engine.SetItemAttrText ( itemtype => itemType,
7379 itemkey => itemkey,
7380 aname => 'DOCUMENT_SUBTYPE_DISP' ,
7381 avalue => l_doc_subtype_disp);
7382 */
7383 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'DOCUMENT_TYPE_DISP' , avalue => l_doc_type_disp);
7384 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'DOCUMENT_NUMBER' , avalue => l_doc_num);
7385 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'RELEASE_NUM_DASH' , avalue => l_release_num_dash);
7386 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'RELEASE_NUM' , avalue => l_release_num);
7387 l_error_number := PO_REQAPPROVAL_ACTION.doc_mgr_err_num;
7388 /* bug 1942091. Set the Error attributes */
7389 l_sys_error_msg := PO_REQAPPROVAL_ACTION.sysadmin_err_msg;
7390 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => itemType, itemkey => itemkey, aname => 'DOC_MGR_ERROR_NUM', avalue => l_error_number);
7391 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemType, itemkey => itemkey, aname => 'SYSADMIN_ERROR_MSG' , avalue => l_sys_error_msg);
7392 /* Set the parents doc manager error number and sysadmin error mesg*/
7393 PO_WF_UTIL_PKG.SetItemAttrNumber ( itemtype => l_item_type, itemkey => l_item_key, aname => 'DOC_MGR_ERROR_NUM', avalue => l_error_number);
7394 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => l_item_type, itemkey => l_item_key, aname => 'SYSADMIN_ERROR_MSG' , avalue => l_sys_error_msg);
7395 END IF; --run mode
7396 EXCEPTION
7397 WHEN OTHERS THEN
7398 WF_CORE.context('PO_APPROVAL_LIST_WF1S' , 'Initialise_Error', itemtype, itemkey, l_progress);
7399 resultout:='COMPLETE:'||'N';
7400 END Initialise_Error;
7401 PROCEDURE acceptance_required
7402 (
7403 itemtype IN VARCHAR2,
7404 itemkey IN VARCHAR2,
7405 actid IN NUMBER,
7406 funcmode IN VARCHAR2,
7407 result OUT NOCOPY VARCHAR2 )
7408 IS
7409 l_acceptance_flag po_headers_all.acceptance_required_flag%TYPE;
7410 x_progress VARCHAR2(3) := '000';
7411 l_document_id NUMBER;
7412 l_document_type po_document_types.document_type_code%type;
7413 l_document_subtype po_document_types.document_subtype%type;
7414 l_when_to_archive po_document_types.archive_external_revision_code%type;
7415 l_archive_result VARCHAR2(1);
7416 l_revision_num NUMBER; -- <Bug 5501659> --
7417 l_responded_shipments NUMBER; -- <Bug 5501659> --
7418 BEGIN
7419 /*
7420 1. Bug#2742276: To find out if acceptance is required, older version used to check workflow
7421 attribute ACCEPTANCE_REQUIRED.
7422 This may not be correct since acceptance_requried_flag may be updated in the DB.
7423 Thus, we shall query acceptance_required_flag from po_headers/po_releases view.
7424 */
7425 x_progress := '001';
7426 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
7427 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
7428 l_document_subtype := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
7429 IF(l_document_type <> 'RELEASE') THEN
7430 SELECT acceptance_required_flag
7431 INTO l_acceptance_flag
7432 FROM po_headers_all --bug 4764963
7433 WHERE po_header_Id = l_document_id;
7434 ELSE
7435 SELECT acceptance_required_flag
7436 INTO l_acceptance_flag
7437 FROM po_releases_all --bug 4764963
7438 WHERE po_release_Id = l_document_id;
7439 END IF;
7440 /* BINDING FPJ START*/
7441 IF NVL(l_acceptance_flag,'N') <> 'N' THEN
7442 result := 'COMPLETE:' || 'Y';
7443 ELSE
7444 result := 'COMPLETE:' || 'N';
7445 END IF;
7446 /* BINDING FPJ END*/
7447 /*** Checking if at least one shipment has been responded to (Bug 5501659) */
7448 -- There should be no notification if there has been at least on reponse
7449 IF(l_document_type <> 'RELEASE') THEN
7450 SELECT revision_num
7451 INTO l_revision_num
7452 FROM po_headers_all
7453 WHERE po_header_id = l_document_id;
7454 SELECT COUNT(*)
7455 INTO l_responded_shipments
7456 FROM PO_ACCEPTANCES
7457 WHERE po_header_id = l_document_id
7458 AND revision_num = l_revision_num;
7459 ELSE
7460 SELECT revision_num
7461 INTO l_revision_num
7462 FROM po_releases_all
7463 WHERE po_release_id = l_document_id;
7464 SELECT COUNT(*)
7465 INTO l_responded_shipments
7466 FROM PO_ACCEPTANCES
7467 WHERE po_release_id = l_document_id
7468 AND revision_num = l_revision_num;
7469 END IF;
7470 IF(l_responded_shipments > 0) THEN
7471 result := 'COMPLETE:' || 'N';
7472 END IF;
7473 /*** (Bug 5501659) ***/
7474 EXCEPTION
7475 WHEN OTHERS THEN
7476 wf_core.context('PO_REQAPPROVAL_INIT1','acceptance_required',x_progress);
7477 raise;
7478 END;
7479 --
7480 PROCEDURE Register_acceptance
7481 (
7482 itemtype IN VARCHAR2,
7483 itemkey IN VARCHAR2,
7484 actid IN NUMBER,
7485 funcmode IN VARCHAR2,
7486 result OUT NOCOPY VARCHAR2 )
7487 IS
7488 x_progress VARCHAR2(3) := '000';
7489 x_acceptance_result fnd_new_messages.message_text%type := NULL; -- Bug 2821341
7490 x_org_id NUMBER;
7491 x_user_id NUMBER;
7492 x_document_id NUMBER;
7493 x_document_type_code VARCHAR2(30);
7494 x_po_header_id po_headers_all.po_header_id%TYPE;
7495 x_vendor po_vendors.vendor_name%TYPE;
7496 /* Bug 7172641 Changing the size as equal to the column size of vendor_name in po_vendors table */
7497 x_supp_user_name VARCHAR2(100);
7498 x_supplier_displayname VARCHAR2(100);
7499 x_revision_num NUMBER; -- RDP
7500 -- x_accp_type varchar2(100);
7501 l_nid NUMBER;
7502 l_ntf_role_name VARCHAR2(320);
7503 BEGIN
7504 -- set the org context
7505 x_org_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
7506 PO_MOAC_UTILS_PVT.set_org_context(x_org_id) ; -- <R12 MOAC>
7507 x_document_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
7508 x_document_type_code := wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
7509 -- commented out the usage of accptance_type (FPI)
7510 /* x_accp_type := PO_WF_UTIL_PKG.GetItemAttrText(itemtype => itemtype,
7511 itemkey => itemkey,
7512 aname => 'ACCEPTANCE_TYPE'); */
7513 x_acceptance_result := PO_WF_UTIL_PKG.GetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'ACCEPTANCE_RESULT');
7514 IF x_document_type_code <> 'RELEASE' THEN
7515 SELECT pov.vendor_name,
7516 poh.revision_num
7517 INTO x_vendor,
7518 x_revision_num -- RDP
7519 FROM po_vendors pov,
7520 po_headers poh
7521 WHERE pov.vendor_id = poh.vendor_id
7522 AND poh.po_header_id=x_document_id;
7523 ELSE
7524 SELECT pov.vendor_name,
7525 poh.po_header_id,
7526 por.revision_num --RDP
7527 INTO x_vendor,
7528 x_po_header_id,
7529 x_revision_num
7530 FROM po_releases por,
7531 po_headers_all poh, -- <R12 MOAC>
7532 po_vendors pov
7533 WHERE por.po_release_id = x_document_id
7534 AND por.po_header_id = poh.po_header_id
7535 AND poh.vendor_id = pov.vendor_id;
7536 END IF;
7537 IF (x_document_type_code <> 'RELEASE') THEN
7538 --dbms_output.put_line('For std pos');
7539 BEGIN
7540 SELECT a.notification_id,
7541 a.recipient_role
7542 INTO l_nid,
7543 l_ntf_role_name
7544 FROM wf_notifications a,
7545 wf_item_activity_statuses wa
7546 WHERE itemkey =wa.item_key
7547 AND itemtype =wa.item_type
7548 AND a.message_name IN ('PO_EMAIL_PO_WITH_RESPONSE', 'PO_EMAIL_PO_PDF_WITH_RESPONSE')
7549 AND a.notification_id=wa.notification_id
7550 AND a.status = 'CLOSED';
7551 EXCEPTION
7552 WHEN OTHERS THEN
7553 l_nid := NULL;
7554 END;
7555 ELSE
7556 BEGIN
7557 --dbms_output.put_line('For Releases');
7558 SELECT a.notification_id,
7559 a.recipient_role
7560 INTO l_nid,
7561 l_ntf_role_name
7562 FROM wf_notifications a,
7563 wf_item_activity_statuses wa
7564 WHERE itemkey =wa.item_key
7565 AND itemtype =wa.item_type
7566 AND a.message_name IN ('PO_EMAIL_PO_WITH_RESPONSE', 'PO_EMAIL_PO_PDF_WITH_RESPONSE')
7567 AND a.notification_id=wa.notification_id
7568 AND a.status = 'CLOSED';
7569 EXCEPTION
7570 WHEN OTHERS THEN
7571 l_nid := NULL;
7572 END;
7573 END IF;
7574 IF (l_nid IS NULL) THEN
7575 --we do not want to continue if the notification is not closed.
7576 RETURN;
7577 ELSE
7578 x_supp_user_name := wf_notification.responder(l_nid);
7579 END IF;
7580 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'SUPPLIER', avalue => x_vendor);
7581 -- commented out the usage of accptance_type (FPI)
7582 /* IF (x_accp_type is NULL) THEN
7583 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype,
7584 itemkey => itemkey,
7585 aname => 'ACCEPTANCE_TYPE',
7586 avalue => 'Accepted' );
7587 END IF; */
7588 IF (x_acceptance_result IS NULL) THEN
7589 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ACCEPTANCE_RESULT', avalue => fnd_message.get_string('PO','PO_WF_NOTIF_ACCEPTED') );
7590 END IF;
7591 IF (SUBSTR(x_supp_user_name, 1, 6) = 'email:') THEN
7592 --Get the username and store that in the supplier_user_name.
7593 x_supp_user_name := PO_ChangeOrderWF_PVT.getEmailResponderUserName(x_supp_user_name, l_ntf_role_name);
7594 END IF;
7595 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'SUPPLIER_USER_NAME', avalue => x_supp_user_name);
7596 x_user_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, -- RDP
7597 itemkey => itemkey, aname => 'BUYER_USER_ID');
7598 -- Default only when the profile option is set
7599 IF( g_default_promise_date = 'Y') THEN
7600 IF(x_document_type_code <> 'RELEASE') THEN -- RDP
7601 POS_ACK_PO.Acknowledge_promise_date(NULL,x_document_id,NULL,x_revision_num,x_user_id);
7602 ELSE
7603 POS_ACK_PO.Acknowledge_promise_date(NULL,x_po_header_id,x_document_id,x_revision_num,x_user_id);
7604 END IF;
7605 END IF;
7606 -- insert acceptance record.
7607 Insert_Acc_Rejection_Row(itemtype, itemkey, actid, 'Y');
7608 EXCEPTION
7609 WHEN OTHERS THEN
7610 wf_core.context('PO_REQAPPROVAL_INIT1','Register_acceptance',x_progress);
7611 raise;
7612 END;
7613 --
7614 PROCEDURE Register_rejection
7615 (
7616 itemtype IN VARCHAR2,
7617 itemkey IN VARCHAR2,
7618 actid IN NUMBER,
7619 funcmode IN VARCHAR2,
7620 result OUT NOCOPY VARCHAR2 )
7621 IS
7622 x_progress VARCHAR2(3) := '000';
7623 x_acceptance_result fnd_new_messages.message_text%type := NULL; -- Bug 2821341
7624 x_org_id NUMBER;
7625 x_document_id NUMBER;
7626 x_document_type_code VARCHAR2(30);
7627 x_vendor VARCHAR2(80);
7628 x_supp_user_name VARCHAR2(100);
7629 x_supplier_displayname VARCHAR2(100);
7630 --x_accp_type varchar2(100);
7631 l_revision_num NUMBER;
7632 l_is_hdr_rejected VARCHAR2(1);
7633 l_return_status VARCHAR2(1);
7634 l_role_name VARCHAR2(50);
7635 l_role_display_name VARCHAR2(50);
7636 l_nid NUMBER;
7637 l_ntf_role_name VARCHAR2(320);
7638 BEGIN
7639 -- set the org context
7640 x_org_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
7641 PO_MOAC_UTILS_PVT.set_org_context(x_org_id) ; -- <R12 MOAC>
7642 x_progress := '001';
7643 x_document_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
7644 x_document_type_code := wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
7645 -- commented out the usage of accptance_type (FPI)
7646 /* x_accp_type := PO_WF_UTIL_PKG.GetItemAttrText(itemtype => itemtype,
7647 itemkey => itemkey,
7648 aname => 'ACCEPTANCE_TYPE'); */
7649 x_acceptance_result := PO_WF_UTIL_PKG.GetItemAttrText(itemtype => itemtype, itemkey => itemkey, aname => 'ACCEPTANCE_RESULT');
7650 IF x_document_type_code <> 'RELEASE' THEN
7651 SELECT pov.vendor_name,
7652 poh.revision_num
7653 INTO x_vendor,
7654 l_revision_num
7655 FROM po_vendors pov,
7656 po_headers poh
7657 WHERE pov.vendor_id = poh.vendor_id
7658 AND poh.po_header_id=x_document_id;
7659
7660 x_progress := '002';
7661 PO_ChangeOrderWF_PVT.IsPOHeaderRejected( 1.0, l_return_status, x_document_id, NULL, l_revision_num, l_is_hdr_rejected);
7662 ELSE
7663 SELECT pov.vendor_name,
7664 por.revision_num
7665 INTO x_vendor,
7666 l_revision_num
7667 FROM po_releases por,
7668 po_headers_all poh, --<R12 MOAC>
7669 po_vendors pov
7670 WHERE por.po_release_id = x_document_id
7671 AND por.po_header_id = poh.po_header_id
7672 AND poh.vendor_id = pov.vendor_id;
7673
7674 x_progress := '003';
7675 PO_ChangeOrderWF_PVT.IsPOHeaderRejected( 1.0, l_return_status, NULL, x_document_id, l_revision_num, l_is_hdr_rejected);
7676 END IF;
7677 IF (x_document_type_code <> 'RELEASE') THEN
7678 --dbms_output.put_line('For std pos');
7679 BEGIN
7680 SELECT a.notification_id,
7681 a.recipient_role
7682 INTO l_nid,
7683 l_ntf_role_name
7684 FROM wf_notifications a,
7685 wf_item_activity_statuses wa
7686 WHERE itemkey =wa.item_key
7687 AND itemtype =wa.item_type
7688 AND a.message_name IN ('PO_EMAIL_PO_WITH_RESPONSE', 'PO_EMAIL_PO_PDF_WITH_RESPONSE')
7689 AND a.notification_id=wa.notification_id
7690 AND a.status = 'CLOSED';
7691 EXCEPTION
7692 WHEN OTHERS THEN
7693 l_nid := NULL;
7694 END;
7695 ELSE
7696 BEGIN
7697 --dbms_output.put_line('For Releases');
7698 SELECT a.notification_id,
7699 a.recipient_role
7700 INTO l_nid,
7701 l_ntf_role_name
7702 FROM wf_notifications a,
7703 wf_item_activity_statuses wa
7704 WHERE itemkey =wa.item_key
7705 AND itemtype =wa.item_type
7706 AND a.message_name IN ('PO_EMAIL_PO_WITH_RESPONSE', 'PO_EMAIL_PO_PDF_WITH_RESPONSE')
7707 AND a.notification_id=wa.notification_id
7708 AND a.status = 'CLOSED';
7709 EXCEPTION
7710 WHEN OTHERS THEN
7711 l_nid := NULL;
7712 END;
7713 END IF;
7714 IF (l_nid IS NULL) THEN
7715 --We do not want to continue if the notification is not closed.
7716 RETURN;
7717 ELSE
7718 x_supp_user_name := wf_notification.responder(l_nid);
7719 END IF;
7720 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'SUPPLIER', avalue => x_vendor);
7721 -- commented out the usage of accptance_type (FPI)
7722 /* IF (x_accp_type is NULL) THEN
7723 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype,
7724 itemkey => itemkey,
7725 aname => 'ACCEPTANCE_TYPE',
7726 avalue => 'Rejected' );
7727 END IF; */
7728 IF (x_acceptance_result IS NULL) THEN
7729 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'ACCEPTANCE_RESULT', avalue => 'Rejected' );
7730 END IF;
7731 IF (SUBSTR(x_supp_user_name, 1, 6) = 'email:') THEN
7732 --Get the username and store that in the supplier_user_name.
7733 x_supp_user_name := PO_ChangeOrderWF_PVT.getEmailResponderUserName(x_supp_user_name, l_ntf_role_name);
7734 END IF;
7735 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'SUPPLIER_USER_NAME', avalue => x_supp_user_name);
7736 -- insert rejection record.
7737 IF(l_is_hdr_rejected = 'Y') THEN
7738 x_progress := '004';
7739 Insert_Acc_Rejection_Row(itemtype, itemkey, actid, 'N');
7740 ELSE
7741 x_progress := '005';
7742 wf_directory.createadhocrole( l_role_name , l_role_display_name , NULL, NULL, NULL, 'MAILHTML', NULL, NULL, NULL, 'ACTIVE', sysdate+1);
7743 PO_WF_UTIL_PKG.SetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'BUYER_USER_NAME', avalue => l_role_name);
7744 END IF;
7745 EXCEPTION
7746 WHEN OTHERS THEN
7747 wf_core.context('PO_REQAPPROVAL_INIT1','Register_rejection',x_progress);
7748 raise;
7749 END;
7750 PROCEDURE Insert_Acc_Rejection_Row
7751 (
7752 itemtype IN VARCHAR2,
7753 itemkey IN VARCHAR2,
7754 actid IN NUMBER,
7755 flag IN VARCHAR2)
7756 IS
7757 PRAGMA AUTONOMOUS_TRANSACTION; --<BUG 10189933 Modified the call as AUTONOMOUS_TRANSACTION>
7758 x_row_id VARCHAR2(30);
7759 -- Bug 2850566
7760 -- x_Acceptance_id number;
7761 -- x_Last_Update_Date date := TRUNC(SYSDATE);
7762 -- x_Last_Updated_By number := fnd_global.user_id;
7763 -- End of Bug 2850566
7764 x_Creation_Date DATE := TRUNC(SYSDATE);
7765 x_Created_By NUMBER := fnd_global.user_id;
7766 x_Po_Header_Id NUMBER;
7767 x_Po_Release_Id NUMBER;
7768 x_Action VARCHAR2(240) := 'NEW';
7769 x_Action_Date DATE := TRUNC(SYSDATE);
7770 x_Employee_Id NUMBER;
7771 x_Revision_Num NUMBER;
7772 x_Accepted_Flag VARCHAR2(1) := flag;
7773 -- x_Acceptance_Lookup_Code varchar2(25);
7774 x_document_id NUMBER;
7775 x_document_type_code VARCHAR2(30);
7776 x_acceptance_note PO_ACCEPTANCES.note%TYPE; --bug 2178922
7777 -- Bug 2850566
7778 l_rowid ROWID;
7779 l_Last_Update_Login PO_ACCEPTANCES.last_update_login%TYPE;
7780 l_Last_Update_Date PO_ACCEPTANCES.last_update_date%TYPE;
7781 l_Last_Updated_By PO_ACCEPTANCES.last_updated_by%TYPE;
7782 l_acc_po_header_id PO_HEADERS_ALL.po_header_id%TYPE;
7783 l_acceptance_id PO_ACCEPTANCES.acceptance_id%TYPE;
7784 -- End of Bug 2850566
7785 l_rspndr_usr_name fnd_user.user_name%TYPE := '';
7786 l_accepting_party VARCHAR2(1);
7787 BEGIN
7788 -- Bug 2850566
7789 -- Commented out the select statement as it is handled in the PO_ACCEPTANCES rowhandler
7790 -- SELECT po_acceptances_s.nextval into x_Acceptance_id FROM sys.dual;
7791 -- commented out the usage of accptance_type (FPI)
7792 /* x_Acceptance_Lookup_Code := wf_engine.GetItemAttrText( itemtype => itemtype,
7793 itemkey => itemkey,
7794 aname => 'ACCEPTANCE_LOOKUP_CODE'); */
7795 x_acceptance_note := PO_WF_UTIL_PKG.GetItemAttrText( itemtype => itemtype, itemkey => itemkey, aname => 'ACCEPTANCE_COMMENTS');
7796 -- commented out the usage of accptance_type (FPI)
7797 /* if (x_Acceptance_Lookup_Code is NULL) then
7798 if flag = 'Y' then
7799 x_Acceptance_Lookup_Code := 'Accepted Terms';
7800 else
7801 x_Acceptance_Lookup_Code := 'Unacceptable Changes';
7802 end if;
7803 end if; */
7804 x_document_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
7805 x_document_type_code := wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
7806 -- abort any outstanding acceptance notifications for any previous revision of the document.
7807 IF x_document_type_code <> 'RELEASE' THEN
7808 x_Po_Header_Id := x_document_id;
7809 SELECT revision_num,
7810 agent_id
7811 INTO x_revision_num,
7812 x_employee_id
7813 FROM po_headers
7814 WHERE po_header_id = x_document_id;
7815 ELSE
7816 x_Po_Release_Id := x_document_id;
7817 SELECT po_header_id,
7818 revision_num,
7819 agent_id
7820 INTO x_Po_Header_Id,
7821 x_revision_num,
7822 x_employee_id
7823 FROM po_releases
7824 WHERE po_release_id = x_document_id;
7825 END IF;
7826 -- Bug 2850566 RBAIRRAJ
7827 -- Calling the Acceptances row handler to insert into the PO_ACCEPTANCES table
7828 -- instead of writing an Insert statement.
7829 IF x_po_release_id IS NULL THEN
7830 l_acc_po_header_id := x_po_header_id;
7831 ELSE
7832 l_acc_po_header_id := NULL;
7833 END IF;
7834 l_rspndr_usr_name := wf_engine.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'SUPPLIER_USER_NAME');
7835 BEGIN
7836 SELECT user_id
7837 INTO l_Last_Updated_By
7838 FROM fnd_user
7839 WHERE user_name = upper(l_rspndr_usr_name);
7840
7841 l_accepting_party := 'S';
7842 EXCEPTION
7843 WHEN OTHERS THEN
7844 --in case of non-isp users there wont be any suppliers
7845 l_Last_Updated_By := x_created_by;
7846 l_accepting_party := 'S'; --ack is always by supplier.
7847 END;
7848 l_Last_Update_Login := l_Last_Updated_By;
7849 PO_ACCEPTANCES_INS_PVT.insert_row( x_rowid => l_rowid, x_acceptance_id => l_acceptance_id,
7850 x_Last_Update_Date => l_Last_Update_Date, x_Last_Updated_By => l_Last_Updated_By,
7851 x_Last_Update_Login => l_Last_Update_Login, p_creation_date => x_Creation_Date,
7852 p_created_by => l_Last_Updated_By, p_po_header_id => l_acc_po_header_id, p_po_release_id => x_Po_Release_Id,
7853 p_action => x_Action, p_action_date => x_Action_Date, p_employee_id => NULL, p_revision_num => x_Revision_Num,
7854 p_accepted_flag => x_Accepted_Flag, p_note => x_acceptance_note, p_accepting_party => l_accepting_party );
7855 -- End of Bug 2850566 RBAIRRAJ
7856 -- Reset the Acceptance required Flag
7857 --Bug 6847039 - Start
7858 --Update the last update date when po_headers_all/po_releases_all tables are updated.
7859 IF x_po_release_id IS NOT NULL THEN
7860 UPDATE po_releases
7861 SET acceptance_required_flag = 'N',
7862 LAST_UPDATE_DATE = SYSDATE,
7863 acceptance_due_date = ''
7864 WHERE po_release_id = x_po_release_id;
7865 ELSE
7866 UPDATE po_headers
7867 SET acceptance_required_flag = 'N',
7868 LAST_UPDATE_DATE = SYSDATE,
7869 acceptance_due_date = ''
7870 WHERE po_header_id = x_po_header_id;
7871 END IF;
7872 COMMIT; --<BUG 10189933>
7873 EXCEPTION
7874 WHEN OTHERS THEN
7875 raise;
7876 END;
7877 /* Bug#2353153: kagarwal
7878 ** Added new PROCEDURE set_doc_mgr_context as a global procedure as this
7879 ** is being used by wf apis present in different packages.
7880 **
7881 ** Calling Set_doc_mgr_context to set the application context in procedures
7882 ** Set_Startup_Values() and Is_doc_preapproved() procedures for PO Approval
7883 ** to succeed when SLS SUB LEDGER SECURITY (IGI) is being used
7884 */
7885 PROCEDURE Set_doc_mgr_context
7886 (
7887 itemtype VARCHAR2,
7888 itemkey VARCHAR2)
7889 IS
7890 l_user_id NUMBER;
7891 l_responsibility_id NUMBER;
7892 l_application_id NUMBER;
7893 l_orgid NUMBER; --RETRO FPI
7894 x_progress VARCHAR2(200);
7895 -- Bug 4290541 Start
7896 X_User_Id NUMBER;
7897 X_Responsibility_Id NUMBER;
7898 X_Application_Id NUMBER;
7899 -- Bug 4290541 End
7900 BEGIN
7901 -- Bug 4290541 Start
7902 --Fnd_Profile.Get('USER_ID',X_User_Id);
7903 --Fnd_Profile.Get('RESP_ID',X_Responsibility_Id);
7904 --Fnd_Profile.Get('RESP_APPL_ID',X_Application_Id);
7905 -- Bug 4290541 End
7906 -- Context Setting Revamp
7907 X_User_Id := fnd_global.user_id;
7908 X_Responsibility_Id := fnd_global.resp_id;
7909 X_Application_Id := fnd_global.resp_appl_id;
7910 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_mgr_context.X_USER_ID= ' || TO_CHAR(x_user_id) || 'X_ APPLICATION_ID= ' || TO_CHAR(x_application_id) || 'X_RESPONSIBILITY_ID= ' || TO_CHAR(x_responsibility_id);
7911 IF (g_po_wf_debug = 'Y') THEN
7912 /* DEBUG */
7913 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7914 END IF;
7915 IF (X_User_Id = -1) THEN
7916 X_User_Id := NULL;
7917 END IF;
7918 IF (X_Responsibility_Id = -1) THEN
7919 X_Responsibility_Id := NULL;
7920 END IF;
7921 IF (X_Application_Id = -1) THEN
7922 X_Application_Id := NULL;
7923 END IF;
7924 l_user_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'USER_ID');
7925 --
7926 l_application_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'APPLICATION_ID');
7927 --
7928 l_responsibility_id := wf_engine.GetItemAttrNumber ( itemtype => itemtype, itemkey => itemkey, aname => 'RESPONSIBILITY_ID');
7929 x_progress := 'PO_REQAPPROVAL_INIT1.set_doc_mgr_context.L_USER_ID= ' || TO_CHAR(l_user_id) || ' L_APPLICATION_ID= ' || TO_CHAR(l_application_id) || 'L_RESPONSIBILITY_ID= ' || TO_CHAR(l_responsibility_id);
7930 IF (g_po_wf_debug = 'Y') THEN
7931 /* DEBUG */
7932 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,x_progress);
7933 END IF;
7934 -- bug 3543578
7935 -- Returning a Req from AutoCreate was nulling out the FND context.
7936 -- No particular context is required for sending the notification in
7937 -- the NOTIFY_RETURN_REQ process, so only change the context if
7938 -- a valid context has been explicitly set for the workflow process.
7939 -- Bug 4125251 Start
7940 -- Set the application context to the logged-in user
7941 -- if not null
7942 IF (NVL(X_USER_ID,-1) = -1 OR NVL(X_RESPONSIBILITY_ID,-1) = -1 OR NVL(X_APPLICATION_ID,-1) = -1)THEN
7943 IF X_USER_ID IS NOT NULL THEN
7944 FND_GLOBAL.APPS_INITIALIZE (X_USER_ID, L_RESPONSIBILITY_ID, L_APPLICATION_ID);
7945 ELSE
7946 -- Start fix for Bug 3543578
7947 IF ( L_USER_ID IS NOT NULL AND L_RESPONSIBILITY_ID IS NOT NULL AND L_APPLICATION_ID IS NOT NULL) THEN
7948 FND_GLOBAL.APPS_INITIALIZE (L_USER_ID, L_RESPONSIBILITY_ID, L_APPLICATION_ID);
7949 END IF;
7950 -- End fix for Bug 3543578
7951 END IF;
7952 END IF;
7953 -- Bug 4125251 End
7954 /* RETRO FPI START.
7955 * If we had set the org context for a different operating unit, the above
7956 * fnd_global.APPS_INITIALIZE resets it back to the operating unit of
7957 * the responsibility. So set the org context explicitly again.
7958 */
7959 l_orgid := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
7960 IF l_orgid IS NOT NULL THEN
7961 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
7962 END IF;
7963 /* RETRO FPI END. */
7964 -- Bug 3571038
7965 igi_sls_context_pkg.set_sls_context;
7966 EXCEPTION
7967 WHEN OTHERS THEN
7968 wf_core.context('PO_REQAPPROVAL_ACTION','set_doc_mgr_context',x_progress);
7969 raise;
7970 END Set_doc_mgr_context;
7971 /* RETROACTIVE FPI START */
7972 PROCEDURE MassUpdate_Releases_Yes_No
7973 (
7974 itemtype IN VARCHAR2,
7975 itemkey IN VARCHAR2,
7976 actid IN NUMBER,
7977 funcmode IN VARCHAR2,
7978 resultout OUT NOCOPY VARCHAR2 )
7979 IS
7980 l_orgid NUMBER;
7981 l_massupdate_releases VARCHAR2(2);
7982 l_progress VARCHAR2(300);
7983 l_doc_string VARCHAR2(200);
7984 l_preparer_user_name VARCHAR2(100);
7985 l_document_type PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE;
7986 l_document_subtype PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE;
7987 l_resp_id NUMBER;
7988 l_user_id NUMBER;
7989 l_appl_id NUMBER;
7990 BEGIN
7991 l_progress := 'PO_REQAPPROVAL_INIT1.MassUpdate_Releases_Yes_No: 01';
7992 IF (g_po_wf_debug = 'Y') THEN
7993 /* DEBUG */
7994 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
7995 END IF;
7996 -- Do nothing in cancel or timeout mode
7997 IF (funcmode <> wf_engine.eng_run) THEN
7998 resultout := wf_engine.eng_null;
7999 RETURN;
8000 END IF;
8001 l_orgid := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'ORG_ID');
8002 l_user_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'USER_ID');
8003 l_resp_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'RESPONSIBILITY_ID');
8004 l_appl_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'APPLICATION_ID');
8005 /* Since the call may be started from background engine (new seesion),
8006 * need to ensure the fnd context is correct
8007 */
8008 --Context Setting Revamp
8009 /* if (l_user_id is not null and
8010 l_resp_id is not null and
8011 l_appl_id is not null )then
8012 -- Bug 4125251,replaced apps init call with set doc mgr context call
8013 PO_REQAPPROVAL_INIT1.Set_doc_mgr_context(itemtype, itemkey); */
8014 IF l_orgid IS NOT NULL THEN
8015 PO_MOAC_UTILS_PVT.set_org_context(l_orgid) ; -- <R12 MOAC>
8016 END IF;
8017 -- end if;
8018 l_massupdate_releases := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'MASSUPDATE_RELEASES');
8019 l_document_type := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
8020 l_document_subtype := PO_WF_UTIL_PKG.GetItemAttrText (itemtype =>itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
8021 /* the value of CREATE_SOURCING_RULE should be Y or N */
8022 IF (NVL(l_massupdate_releases,'N') <> 'Y') THEN
8023 l_massupdate_releases := 'N';
8024 ELSE
8025 IF (l_document_type = 'PA' AND l_document_subtype = 'BLANKET') THEN
8026 l_massupdate_releases := 'Y';
8027 ELSE
8028 l_massupdate_releases := 'N';
8029 END IF;
8030 END IF;
8031 resultout := wf_engine.eng_completed || ':' || l_massupdate_releases;
8032 l_progress := 'PO_REQAPPROVAL_INIT1.MassUpdate_Releases_Yes_No: 02. Result= ' || l_massupdate_releases;
8033 IF (g_po_wf_debug = 'Y') THEN
8034 /* DEBUG */
8035 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8036 END IF;
8037 EXCEPTION
8038 WHEN OTHERS THEN
8039 l_massupdate_releases := 'N';
8040 resultout := wf_engine.eng_completed || ':' || l_massupdate_releases;
8041 END MassUpdate_Releases_Yes_No;
8042 PROCEDURE MassUpdate_Releases_Workflow
8043 (
8044 itemtype IN VARCHAR2,
8045 itemkey IN VARCHAR2,
8046 actid IN NUMBER,
8047 funcmode IN VARCHAR2,
8048 resultout OUT NOCOPY VARCHAR2 )
8049 IS
8050 l_document_id po_headers_all.po_header_id%type;
8051 l_vendor_id po_headers_all.vendor_id%type;
8052 l_vendor_site_id po_headers_all.vendor_site_id%type;
8053 l_progress VARCHAR2(300);
8054 l_update_releases VARCHAR2(1) := 'Y';
8055 l_return_status VARCHAR2(1) ;
8056 l_communicate_update VARCHAR2(30); -- Bug 3574895. Length same as that on the form field PO_APPROVE.COMMUNICATE_UPDATES
8057 l_category_struct_id mtl_category_sets_b.structure_id%type; -- Bug 3592705
8058 BEGIN
8059 l_progress := 'PO_REQAPPROVAL_INIT1.MassUpdate_Releases_Workflow: 01';
8060 /* Bug# 2846210
8061 ** Desc: Setting application context as this wf api will be executed
8062 ** after the background engine is run.
8063 */
8064 Set_doc_mgr_context(itemtype, itemkey);
8065 l_document_id := PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
8066 SELECT poh.vendor_id,
8067 poh.vendor_site_id
8068 INTO l_vendor_id,
8069 l_vendor_site_id
8070 FROM po_headers poh
8071 WHERE poh.po_header_id = l_document_id;
8072 --<Bug 3592705 Start> Retrieved the default structure for
8073 -- Purchasing from the view mtl_default_sets_view.
8074 BEGIN
8075 SELECT structure_id
8076 INTO l_category_struct_id
8077 FROM mtl_default_sets_view
8078 WHERE functional_area_id = 2 ;
8079 EXCEPTION
8080 WHEN OTHERS THEN
8081 l_progress := 'PO_REQAPPROVAL_INIT1.MassUpdate_Releases_Workflow: Could not find Category Structure Id';
8082 IF (g_po_wf_debug = 'Y') THEN
8083 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8084 END IF;
8085 raise;
8086 END;
8087 --<Bug 3592705 End>
8088 --Bug 3574895. Retroactively Repriced Releases/Std PO's are not getting
8089 -- communicated to supplier. Need to pick up the workflow
8090 -- attribute CO_H_RETROACTIVE_SUPPLIER_COMM here from the
8091 -- Blanket Approval Workflow and pass it in the procedure
8092 -- call below so that it may be set correctly for Release/
8093 -- Standard PO Approval as well.
8094 l_communicate_update := PO_WF_UTIL_PKG.GetItemAttrText ( itemtype => itemtype, itemkey => itemkey, aname => 'CO_H_RETROACTIVE_SUPPLIER_COMM');
8095 PO_RETROACTIVE_PRICING_PVT. MassUpdate_Releases
8096 ( p_api_version => 1.0, p_validation_level => 100, p_vendor_id => l_vendor_id,
8097 p_vendor_site_id => l_vendor_site_id , p_po_header_id => l_document_id,
8098 p_category_struct_id => l_category_struct_id, -- Bug 3592705
8099 p_category_from => NULL, p_category_to => NULL, p_item_from => NULL,
8100 p_item_to => NULL, p_date => NULL, p_communicate_update => l_communicate_update, --Bug 3574895
8101 x_return_status => l_return_status);
8102 IF (l_return_status <> 'S') THEN
8103 l_update_releases := 'N';
8104 END IF;
8105 l_progress := ': 02. Result= ' || l_update_releases;
8106 IF (g_po_wf_debug = 'Y') THEN
8107 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8108 END IF;
8109 resultout := wf_engine.eng_completed || ':' || l_update_releases;
8110 EXCEPTION
8111 WHEN OTHERS THEN
8112 l_update_releases := 'N';
8113 l_progress := 'PO_REQAPPROVAL_INIT1.MassUpdate_Releases_Workflow: 03.'|| ' Result= ' || l_update_releases;
8114 resultout := wf_engine.eng_completed || ':' || l_update_releases;
8115 IF (g_po_wf_debug = 'Y') THEN
8116 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8117 END IF;
8118 END MassUpdate_Releases_Workflow;
8119 PROCEDURE Send_Supplier_Comm_Yes_No
8120 (
8121 itemtype IN VARCHAR2,
8122 itemkey IN VARCHAR2,
8123 actid IN NUMBER,
8124 funcmode IN VARCHAR2,
8125 resultout OUT NOCOPY VARCHAR2 )
8126 IS
8127 l_retro_change VARCHAR2(1);
8128 l_supplier_comm VARCHAR2(1) := 'Y'; --default has to be Y
8129 l_progress VARCHAR2(300);
8130 l_document_type PO_DOCUMENT_TYPES_ALL.DOCUMENT_TYPE_CODE%TYPE;
8131 l_document_subtype PO_DOCUMENT_TYPES_ALL.DOCUMENT_SUBTYPE%TYPE;
8132 BEGIN
8133 l_progress := 'PO_REQAPPROVAL_INIT1.Send_Supplier_Comm_Yes_No: 01';
8134 l_retro_change := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CO_R_RETRO_CHANGE');
8135 -- Bug 3694128 : get the document type and subtype
8136 l_document_type := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
8137 l_document_subtype := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_SUBTYPE');
8138 -- Bug 3694128 : The communication depends on the WF attribute only
8139 -- for std PO's and blanket releases. For all other documents we
8140 -- always communicate.
8141 IF (l_retro_change = 'Y') AND ((l_document_type = 'RELEASE' AND l_document_subtype = 'BLANKET') OR (l_document_type = 'PO' AND l_document_subtype = 'STANDARD')) THEN
8142 l_supplier_comm := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CO_H_RETROACTIVE_SUPPLIER_COMM');
8143 ELSE
8144 l_supplier_comm := 'Y';
8145 END IF;
8146 -- Bug 3325520
8147 IF (l_supplier_comm IS NULL) THEN
8148 l_supplier_comm := 'N';
8149 END IF;
8150 /*IF (l_supplier_comm IS NULL)*/
8151 resultout := wf_engine.eng_completed || ':' || l_supplier_comm;
8152 l_progress := 'PO_REQAPPROVAL_INIT1.Send_Supplier_Comm_Yes_No: 02. Result= ' || l_supplier_comm;
8153 IF (g_po_wf_debug = 'Y') THEN
8154 /* DEBUG */
8155 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8156 END IF;
8157 EXCEPTION
8158 WHEN OTHERS THEN
8159 l_supplier_comm := 'Y';
8160 resultout := wf_engine.eng_completed || ':' || l_supplier_comm;
8161 END Send_Supplier_Comm_Yes_No;
8162 /* RETROACTIVE FPI END */
8163 /************************************************************************************
8164 * Added this procedure as part of Bug #: 2843760
8165 * This procedure basically checks if archive_on_print option is selected, and if yes
8166 * call procedure PO_ARCHIVE_PO_SV.ARCHIVE_PO to archive the PO
8167 *************************************************************************************/
8168 PROCEDURE archive_po
8169 (
8170 p_document_id IN NUMBER,
8171 p_document_type IN VARCHAR2,
8172 p_document_subtype IN VARCHAR2)
8173 IS
8174 -- <FPJ Refactor Archiving API>
8175 l_return_status VARCHAR2(1) ;
8176 l_msg_count NUMBER := 0;
8177 l_msg_data VARCHAR2(2000);
8178 BEGIN
8179 -- <FPJ Refactor Archiving API>
8180 PO_DOCUMENT_ARCHIVE_GRP.Archive_PO( p_api_version => 1.0, p_document_id => p_document_id,
8181 p_document_type => p_document_type, p_document_subtype => p_document_subtype,
8182 p_process => 'PRINT', x_return_status => l_return_status, x_msg_count =>
8183 l_msg_count, x_msg_data => l_msg_data);
8184 END ARCHIVE_PO;
8185 -- <FPJ Retroactive START>
8186 /**
8187 * Public Procedure: Retro_Invoice_Release_WF
8188 * Requires:
8189 * IN PARAMETERS:
8190 * Usual workflow attributes.
8191 * Modifies: PO_DISTRIBUTIONS_ALL.invoice_adjustment_flag
8192 * Effects: This procedure updates invoice adjustment flag, and calls Costing
8193 * and Inventory APIs.
8194 */
8195 PROCEDURE Retro_Invoice_Release_WF
8196 (
8197 itemtype IN VARCHAR2,
8198 itemkey IN VARCHAR2,
8199 actid IN NUMBER,
8200 funcmode IN VARCHAR2,
8201 resultout OUT NOCOPY VARCHAR2)
8202 IS
8203 l_retro_change VARCHAR2(1);
8204 l_document_id PO_HEADERS_ALL.po_header_id%TYPE;
8205 l_document_type PO_DOCUMENT_TYPES.document_type_code%TYPE;
8206 l_progress VARCHAR2(2000);
8207 l_update_releases VARCHAR2(1) := 'Y';
8208 l_return_status VARCHAR2(1) ;
8209 l_msg_count NUMBER := 0;
8210 l_msg_data VARCHAR2(2000);
8211 l_retroactive_update VARCHAR2(30) := 'NEVER';
8212 l_reset_retro_update BOOLEAN := FALSE;
8213 BEGIN
8214 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 01';
8215 IF (g_po_wf_debug = 'Y') THEN
8216 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8217 END IF;
8218 resultout := wf_engine.eng_completed || ':' || l_update_releases;
8219 /* Bug# 2846210
8220 ** Desc: Setting application context as this wf api will be executed
8221 ** after the background engine is run.
8222 */
8223 Set_doc_mgr_context(itemtype, itemkey);
8224 l_document_id := wf_engine.GetItemAttrNumber (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_ID');
8225 l_document_type := wf_engine.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'DOCUMENT_TYPE');
8226 l_retro_change := PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CO_R_RETRO_CHANGE');
8227 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 02. ' || 'l_document_id = ' || l_document_id || 'l_document_type = ' || l_document_type || 'l_retro_change = ' || l_retro_change ;
8228 IF (g_po_wf_debug = 'Y') THEN
8229 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8230 END IF;
8231 -- Only handle retroactive invoice change for PO or Release
8232 IF (l_document_type NOT IN ('PO', 'RELEASE')) THEN
8233 RETURN;
8234 END IF;
8235 -- Don't trust l_retro_change='N' because if user makes retro changes, instead
8236 -- of approving it immediately, he chooses to close the form and re-query
8237 -- the PO/Release, then approve it.
8238 -- In this case, d_globals.retroactive_change_flag is lost.
8239 -- Always trust l_retro_change='Y'
8240 IF (l_retro_change IS NULL OR l_retro_change = 'N') THEN
8241 l_retro_change := PO_RETROACTIVE_PRICING_PVT.Is_Retro_Update( p_document_id => l_document_id, p_document_type => l_document_type);
8242 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 03' || 'l_retro_change = ' || l_retro_change ;
8243 IF (g_po_wf_debug = 'Y') THEN
8244 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8245 END IF;
8246 END IF;
8247 /*IF (l_retro_change IS NULL OR l_retro_change = 'N')*/
8248 IF (l_retro_change = 'Y') THEN
8249 l_retroactive_update := PO_RETROACTIVE_PRICING_PVT.Get_Retro_Mode;
8250 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 04' || 'l_retroactive_update = ' || l_retroactive_update;
8251 IF (g_po_wf_debug = 'Y') THEN
8252 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8253 END IF;
8254 -- Need to reset retroactive_date afterwards
8255 l_reset_retro_update := TRUE;
8256 IF (l_retroactive_update = 'NEVER') THEN
8257 l_retro_change := 'N';
8258 END IF;
8259 /*IF (l_retroactive_update = 'NEVER')*/
8260 END IF;
8261 /*IF (l_retro_change = 'Y')*/
8262 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 05' || 'l_retroactive_update = ' || l_retroactive_update || 'l_retro_change = ' || l_retro_change ;
8263 IF (g_po_wf_debug = 'Y') THEN
8264 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8265 END IF;
8266 -- Set 'CO_R_RETRO_CHANGE' attribute so that later Workflow process can
8267 -- use this attribute safely
8268 PO_WF_UTIL_PKG.SetItemAttrText (itemtype => itemtype, itemkey => itemkey, aname => 'CO_R_RETRO_CHANGE', avalue => l_retro_change);
8269 IF (l_retro_change = 'Y' AND l_retroactive_update = 'ALL_RELEASES') THEN
8270 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 06. Calling ' || 'PO_RETROACTIVE_PRICING_PVT.Retro_Invoice_Release';
8271 IF (g_po_wf_debug = 'Y') THEN
8272 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8273 END IF;
8274 PO_RETROACTIVE_PRICING_PVT.Retro_Invoice_Release ( p_api_version => 1.0, p_document_id => l_document_id, p_document_type => l_document_type , x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data);
8275 IF (l_return_status <> 'S') THEN
8276 l_update_releases := 'N';
8277 END IF;
8278 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 07. Result= ' || l_update_releases;
8279 IF (g_po_wf_debug = 'Y') THEN
8280 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8281 END IF;
8282 END IF;
8283 /*IF (l_retro_change = 'Y' AND l_retroactive_update = 'ALL_RELEASES')*/
8284 IF (l_reset_retro_update) THEN
8285 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 08. Reset_Retro_Update';
8286 IF (g_po_wf_debug = 'Y') THEN
8287 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8288 END IF;
8289 PO_RETROACTIVE_PRICING_PVT.Reset_Retro_Update( p_document_id => l_document_id, p_document_type => l_document_type);
8290 END IF;
8291 /*IF (l_reset_retro_update)*/
8292 resultout := wf_engine.eng_completed || ':' || l_update_releases;
8293 EXCEPTION
8294 WHEN OTHERS THEN
8295 l_update_releases := 'N';
8296 l_progress := 'PO_REQAPPROVAL_INIT1.Retro_Invoice_Release_WF: 09.'|| ' Result= ' || l_update_releases;
8297 resultout := wf_engine.eng_completed || ':' || l_update_releases;
8298 IF (g_po_wf_debug = 'Y') THEN
8299 PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
8300 END IF;
8301 END Retro_Invoice_Release_WF;
8302 -- <FPJ Retroactive END>
8303 -------------------------------------------------------------------------------
8304 --Start of Comments : Bug 3845048
8305 --Name: UpdateActionHistory
8306 --Pre-reqs:
8307 -- None.
8308 --Modifies:
8309 -- None.
8310 --Locks:
8311 -- None.
8312 --Function:
8313 -- Updates the action history for the given doc with an action
8314 --Parameters:
8315 --IN:
8316 --p_doc_id
8317 -- Document id
8318 --p_doc_type
8319 -- Document type
8320 --p_doc_subtype
8321 -- Document Sub type
8322 --p_action
8323 -- Action to be inserted into the action history
8324 --Testing:
8325 -- None.
8326 --End of Comments
8327 -------------------------------------------------------------------------------
8328 -- <BUG 5691965 START>
8329 /*
8330 Update the Action History with a note ICX_POR_NOTIF_TIMEOUT in approvers
8331 language
8332 */
8333 PROCEDURE UpdateActionHistory
8334 (
8335 p_doc_id IN NUMBER,
8336 p_doc_type IN VARCHAR2,
8337 p_doc_subtype IN VARCHAR2,
8338 p_action IN VARCHAR2 )
8339 IS
8340 pragma AUTONOMOUS_TRANSACTION;
8341 l_emp_id NUMBER;
8342 l_rowid ROWID;
8343 l_name wf_local_roles.NAME%TYPE;
8344 l_display_name wf_local_roles.display_name%TYPE;
8345 l_email_address wf_local_roles.email_address%TYPE;
8346 l_notification_preference wf_local_roles.notification_preference%TYPE;
8347 l_language wf_local_roles.LANGUAGE%TYPE;
8348 l_territory wf_local_roles.territory%TYPE;
8349 l_note fnd_new_messages.message_text%TYPE;
8350 BEGIN
8351 -- SQL What : Get the employee_id corresponding to the last NULL action record.
8352 -- Sql Why : To get hold the language of the employee.
8353 BEGIN
8354 SELECT pah.employee_id,
8355 pah.ROWID
8356 INTO l_emp_id,
8357 l_rowid
8358 FROM po_action_history pah
8359 WHERE pah.object_id = p_doc_id
8360 AND pah.object_type_code = p_doc_type
8361 AND pah.object_sub_type_code = p_doc_subtype
8362 AND pah.sequence_num =
8363 (SELECT MAX(sequence_num)
8364 FROM po_action_history pah1
8365 WHERE pah1.object_id = p_doc_id
8366 AND pah1.object_type_code = p_doc_type
8367 AND pah1.object_sub_type_code = p_doc_subtype
8368 )
8369 AND pah.action_code IS NULL;
8370 EXCEPTION
8371 WHEN OTHERS THEN
8372 NULL;
8373 END;
8374 IF l_emp_id IS NOT NULL THEN
8375 wf_directory.GetUserName ( p_orig_system => 'PER', p_orig_system_id => l_emp_id, p_name => l_name, p_display_name => l_display_name );
8376 IF l_name IS NOT NULL THEN
8377 WF_DIRECTORY.GETROLEINFO ( ROLE => l_name, Display_Name => l_display_name, Email_Address => l_email_address, Notification_Preference => l_notification_preference, LANGUAGE => l_language, Territory => l_territory );
8378 IF l_language IS NOT NULL THEN
8379 BEGIN
8380 -- SQL What : Get the message in the approvers language.
8381 -- Sql Why : To maintain the NO ACTION message in approver language.
8382 SELECT message_text
8383 INTO l_note
8384 FROM fnd_new_messages fm,
8385 fnd_languages fl
8386 WHERE fm.message_name = 'ICX_POR_NOTIF_TIMEOUT'
8387 AND fm.language_code = fl.language_code
8388 AND fl.nls_language = l_language;
8389 EXCEPTION
8390 WHEN OTHERS THEN
8391 NULL;
8392 END;
8393 END IF;
8394 END IF;
8395 END IF;
8396 IF l_note IS NULL THEN
8397 l_note := fnd_message.get_string('ICX', 'ICX_POR_NOTIF_TIMEOUT');
8398 END IF;
8399 IF l_rowid IS NOT NULL THEN
8400 -- SQL What : Update the No action in the action history.
8401 -- Sql Why : To maintain the NO ACTION message in approver language.
8402 UPDATE po_action_history pah
8403 SET pah.action_code = p_action,
8404 pah.action_date = SYSDATE,
8405 pah.Note = l_note,
8406 pah.last_updated_by = fnd_global.user_id,
8407 pah.last_update_login = fnd_global.login_id,
8408 pah.last_update_date = SYSDATE
8409 WHERE ROWID = l_rowid;
8410 END IF;
8411 COMMIT;
8412 EXCEPTION
8413 WHEN OTHERS THEN
8414 NULL;
8415 END;
8416 -- <BUG 5691965 END>
8417 -------------------------------------------------------------------------------
8418 --Start of Comments : R12 Online authoring Notifications
8419 --Name: should_notify_cat_admin
8420 --Pre-reqs:
8421 -- None.
8422 --Modifies:
8423 -- None.
8424 --Locks:
8425 -- None.
8426 --Function:
8427 -- Determines if the Catalog admin has to be notified of the
8428 -- PO approval. The catalog admin will be notified if the changes
8429 -- were initiated by admin. In this scenario, the notification will be
8430 -- sent to both the catalog admin (in addition to the buyer+supplier, which is
8431 -- an existing logic)
8432 --Parameters:
8433 --IN:
8434 --p_item_type
8435 -- WF item type
8436 --p_item_key
8437 -- WF Item key
8438 --p_act_id
8439 -- ActionId
8440 --p_func_mode
8441 -- Function mode
8442 --OUT
8443 --x_result_out
8444 -- Y/N: Whether to send notification to catalog admin or not
8445 --Testing:
8446 -- None.
8447 --End of Comments
8448 -------------------------------------------------------------------------------
8449 PROCEDURE should_notify_cat_admin
8450 (
8451 p_item_type IN VARCHAR2,
8452 p_item_key IN VARCHAR2,
8453 p_act_id IN NUMBER,
8454 p_func_mode IN VARCHAR2,
8455 x_result_out OUT NOCOPY VARCHAR2 )
8456 IS
8457 l_progress VARCHAR2(200);
8458 l_doc_id NUMBER;
8459 l_doc_type PO_HEADERS_ALL.TYPE_LOOKUP_CODE%type;
8460 l_cat_admin_user_name FND_USER.USER_NAME%type;
8461 BEGIN
8462 l_progress := '100';
8463 IF (g_po_wf_debug = 'Y') THEN
8464 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,l_progress);
8465 END IF;
8466 l_progress := '110';
8467 -- Get the Catalog Admin User Name
8468 l_cat_admin_user_name := wf_engine.GetItemAttrText ( itemtype => p_item_type, itemkey => p_item_key, aname => 'CATALOG_ADMIN_USER_NAME');
8469 l_progress := '130';
8470 IF (g_po_wf_debug = 'Y') THEN
8471 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,'Item Attribute value for CATALOG_ADMIN_USER_NAME='|| l_cat_admin_user_name);
8472 END IF;
8473 IF l_cat_admin_user_name IS NOT NULL THEN
8474 l_progress := '150';
8475 x_result_out := wf_engine.eng_completed || ':' || 'Y' ;
8476 ELSE
8477 l_progress := '190';
8478 x_result_out := wf_engine.eng_completed || ':' || 'N' ;
8479 END IF;
8480 l_progress := '200';
8481 EXCEPTION
8482 WHEN OTHERS THEN
8483 wf_core.context('PO_REQAPPROVAL_INIT1','should_notify_cat_admin',l_progress||' DocumentId='||TO_CHAR(l_doc_id));
8484 raise;
8485 END should_notify_cat_admin;
8486 -------------------------------------------------------------------------------
8487 --Start of Comments : R12 Online authoring Notifications
8488 --Name: should_notify_cat_admin
8489 --Pre-reqs:
8490 -- None.
8491 --Modifies:
8492 -- None.
8493 --Locks:
8494 -- None.
8495 --Function:
8496 -- If this is an agreement that has been locked by the catalog admin (change
8497 -- initiator, then set the item attribute CATALOG_ADMIN_USER_NAME so that
8498 -- the catalog admin can be notified later in the workflow process.
8499 -- The reason why we are setting the attribute here instead of checking later
8500 -- in the wf process is because, the lock_owner_role/lock_owner_id will be
8501 -- cleared from po_headers_all later. So first capture the item attribute
8502 -- use it later in the workflow to decide whether a notification has to be
8503 -- sent. See Node "SHOULD_NOTIFY_CAT_ADMIN" function in the PO Approval and
8504 -- PO Approval Top Process(Also see function should_notify_cat_admin() in
8505 -- this file).
8506 --Parameters:
8507 --IN:
8508 --p_item_type
8509 -- WF item type
8510 --p_item_key
8511 -- WF Item key
8512 --p_doc_id
8513 -- Document Id(PO Header Id)
8514 --p_doc_type
8515 -- Document type (PO/PA)
8516 --Testing:
8517 -- None.
8518 --End of Comments
8519 -------------------------------------------------------------------------------
8520 PROCEDURE set_catalog_admin_user_name
8521 (
8522 p_item_type IN VARCHAR2,
8523 p_item_key IN VARCHAR2,
8524 p_doc_id IN NUMBER,
8525 p_doc_type IN VARCHAR2)
8526 IS
8527 l_progress VARCHAR2(255);
8528 l_user_name FND_USER.USER_NAME%type;
8529 l_lock_owner_role PO_HEADERS_ALL.lock_owner_role%type;
8530 l_lock_owner_user_id PO_HEADERS_ALL.lock_owner_user_id%type;
8531 BEGIN
8532 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 100' || 'Document Id='|| TO_CHAR(p_doc_id) || 'Document Type='|| p_doc_type;
8533 IF (g_po_wf_debug = 'Y') THEN
8534 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,l_progress);
8535 END IF;
8536 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 110';
8537 -- Proceed only if this is an agreement
8538 IF (g_po_wf_debug = 'Y') THEN
8539 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,l_progress);
8540 END IF;
8541 IF p_doc_type = 'PA' THEN
8542 -- Get the locking user role and user id information
8543 SELECT lock_owner_user_id,
8544 lock_owner_role
8545 INTO l_lock_owner_user_id,
8546 l_lock_owner_role
8547 FROM po_headers_all
8548 WHERE po_header_id = p_doc_id;
8549
8550 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 140' || 'l_lock_owner_user_id ='|| TO_CHAR(l_lock_owner_user_id) || 'l_lock_owner_role Type='|| l_lock_owner_role;
8551 IF (g_po_wf_debug = 'Y') THEN
8552 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,l_progress);
8553 END IF;
8554 IF l_lock_owner_role = 'CAT ADMIN' THEN
8555 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 150';
8556 -- The performer attribute holds the user name, get the user name
8557 -- associated with the user id
8558 SELECT user_name
8559 INTO l_user_name
8560 FROM fnd_user
8561 WHERE user_id = l_lock_owner_user_id;
8562
8563 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 155' || 'UserName='|| l_user_name;
8564 IF (g_po_wf_debug = 'Y') THEN
8565 PO_WF_DEBUG_PKG.insert_debug(p_item_type,p_item_key,l_progress);
8566 END IF;
8567 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 160';
8568 -- Set the item attribute tied to the performer of the
8569 -- approval notification
8570 wf_engine.SetItemAttrText ( itemtype => p_item_type , itemkey => p_item_key , aname => 'CATALOG_ADMIN_USER_NAME', avalue => l_user_name);
8571 l_progress := 'PO_REQAPPROVAL_INIT1.set_catalog_admin_user_name: 170';
8572 END IF; -- End of check for "CAT ADMIN"
8573 END IF; -- End of Check for "PA" (Agreement check)
8574 l_progress := '200';
8575 EXCEPTION
8576 WHEN OTHERS THEN
8577 wf_core.context('PO_REQAPPROVAL_INIT1','set_catalog_admin_user_name',l_progress||' DocumentId='||TO_CHAR(p_doc_id));
8578 raise;
8579 END set_catalog_admin_user_name;
8580 -------------------------------------------------------------------------------
8581 --Start of Comments : HTML Orders R12
8582 --Name: get_po_url
8583 --Pre-reqs:
8584 -- None.
8585 --Modifies:
8586 -- None.
8587 --Locks:
8588 -- None.
8589 --Function:
8590 -- Constructs the PO view/Update page URLs based on the document
8591 -- type and mode
8592 --Parameters:
8593 --IN:
8594 --p_po_header_id
8595 -- Document Id
8596 --p_doc_subtype
8597 -- Document subtype
8598 --p_mode
8599 -- ViewOnly or Update mode
8600 --Testing:
8601 -- None.
8602 --End of Comments
8603 -------------------------------------------------------------------------------
8604 FUNCTION get_po_url
8605 (
8606 p_po_header_id IN NUMBER,
8607 p_doc_subtype IN VARCHAR2,
8608 p_mode IN VARCHAR2)
8609 RETURN VARCHAR2
8610 IS
8611 l_url VARCHAR2(1000);
8612 l_page_function VARCHAR2(25);
8613 BEGIN
8614 IF p_doc_subtype = 'STANDARD' THEN
8615 l_page_function := 'PO_ORDER';
8616 ELSIF p_doc_subtype = 'BLANKET' THEN
8617 l_page_function := 'PO_BLANKET';
8618 ELSIF p_doc_subtype = 'CONTRACT' THEN
8619 l_page_function := 'PO_CONTRACT';
8620 END IF;
8621 IF p_mode = 'viewOnly' THEN
8622 /* Bug 7307832
8623 Added JSP:/OA_HTML/ before OA.jsp?OAFunc= */
8624 l_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=' || l_page_function || '&' || 'poHeaderId=' ||
8625 p_po_header_id || '&' || 'poMode=' || p_mode || '&' || 'poCallingModule=notification'||
8626 '&' || 'poHideUpdate=Y'|| '&' || 'poCallingNotifId=-NID-'|| '&' || 'retainAM=Y' || '&' || 'addBreadCrumb=Y' ;
8627 ELSE
8628 /* Bug 7307832
8629 Added JSP:/OA_HTML/ before OA.jsp?OAFunc= */
8630 l_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=' || l_page_function || '&' || 'poHeaderId=' ||
8631 p_po_header_id || '&' || 'poMode=' || p_mode || '&' || 'poCallingModule=notification'|| '&' ||
8632 'poCallingNotifId=-NID-'|| '&' || 'retainAM=Y' || '&' || 'addBreadCrumb=Y' ;
8633 END IF;
8634 RETURN l_url;
8635 END;
8636 -------------------------------------------------------------------------------
8637 --Start of Comments : CLM Apprvl
8638 --Name: get_mod_url
8639 --Pre-reqs:
8640 -- None.
8641 --Modifies:
8642 -- None.
8643 --Locks:
8644 -- None.
8645 --Function:
8646 -- Constructs the Modification view/Update page URLs based on the document
8647 -- type and mode
8648 --Parameters:
8649 --IN:
8650 --p_po_header_id
8651 -- Document Id
8652 --p_draft_id
8653 -- Draft Id
8654 --p_doc_subtype
8655 -- Document subtype
8656 --p_mode
8657 -- ViewOnly or Update mode
8658 --Testing:
8659 -- None.
8660 --End of Comments
8661 -------------------------------------------------------------------------------
8662 FUNCTION get_mod_url
8663 (
8664 p_po_header_id IN NUMBER,
8665 p_draft_id IN NUMBER,
8666 p_doc_subtype IN VARCHAR2,
8667 p_mode IN VARCHAR2)
8668 RETURN VARCHAR2
8669 IS
8670 l_url VARCHAR2(1000);
8671 l_page_function VARCHAR2(25);
8672 BEGIN
8673 IF p_doc_subtype = 'STANDARD' THEN
8674 l_page_function := 'PO_ORDER';
8675 ELSIF p_doc_subtype = 'BLANKET' THEN
8676 l_page_function := 'PO_BLANKET';
8677 ELSIF p_doc_subtype = 'CONTRACT' THEN
8678 l_page_function := 'PO_CONTRACT';
8679 END IF;
8680 IF p_mode = 'viewOnly' THEN
8681 /* Bug 7307832
8682 Added JSP:/OA_HTML/ before OA.jsp?OAFunc= */
8683 l_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=' || l_page_function || '&' || 'poHeaderId=' || p_po_header_id || '&' ||
8684 'poDraftId=' || p_draft_id || '&' || 'poMode=' || p_mode || '&' || 'poCallingModule=notification'|| '&' ||
8685 'poHideUpdate=Y'|| '&' || 'poCallingNotifId=-NID-'|| '&' || 'retainAM=Y' || '&' || 'addBreadCrumb=Y' ;
8686 ELSE
8687 /* Bug 7307832
8688 Added JSP:/OA_HTML/ before OA.jsp?OAFunc= */
8689 l_url := 'JSP:/OA_HTML/OA.jsp?OAFunc=' || l_page_function || '&' || 'poHeaderId=' || p_po_header_id || '&' ||
8690 'poDraftId=' || p_draft_id || '&' || 'poMode=' || p_mode || '&' || 'poCallingModule=notification'|| '&' ||
8691 'poCallingNotifId=-NID-'|| '&' || 'retainAM=Y' || '&' || 'addBreadCrumb=Y' ;
8692 END IF;
8693 RETURN l_url;
8694 END;
8695 -- <HTML Agreement R12 START>
8696 -------------------------------------------------------------------------------
8697 --Start of Comments
8698 --Name: unlock_document
8699 --Function:
8700 -- Clear Lock owner information autonomously
8701 --Parameters:
8702 --IN:
8703 --p_po_header_id
8704 -- Document Id
8705 --End of Comments
8706 -------------------------------------------------------------------------------
8707 PROCEDURE unlock_document
8708 (
8709 p_po_header_id IN NUMBER )
8710 IS
8711 PRAGMA AUTONOMOUS_TRANSACTION;
8712 BEGIN
8713 PO_DRAFTS_PVT.unlock_document ( p_po_header_id => p_po_header_id );
8714 COMMIT;
8715 END unlock_document;
8716 -- <HTML Agreement R12 END>
8717 -- <Bug 5059002 Begin>
8718 /**
8719 * Public Procedure: set_is_supplier_context_y
8720 * Sets the workflow attribute IS_SUPPLIER_CONTEXT to Y to let
8721 * the POREQ_SELECTOR know we should be in the supplier's context
8722 * and not reset to the buyer's context
8723 * Requires:
8724 * IN PARAMETERS:
8725 * Usual workflow attributes.
8726 * Modifies: Sets the workflow attribute IS_SUPPLIER_CONTEXT to Y
8727 */
8728 -- Commenting this code. Most likely will not be required with our context Setting fix.
8729 /* procedure set_is_supplier_context_y(p_item_type in varchar2,
8730 p_item_key in varchar2,
8731 p_act_id in number,
8732 p_func_mode in varchar2,
8733 x_result_out out NOCOPY varchar2) is
8734 l_progress VARCHAR2(300);
8735 begin
8736 l_progress := 'PO_REQAPPROVAL_INIT1.set_is_supplier_context_y: ';
8737 IF (g_po_wf_debug = 'Y') THEN
8738 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Begin');
8739 END IF;
8740 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => p_item_type,
8741 itemkey => p_item_key,
8742 aname => 'IS_SUPPLIER_CONTEXT',
8743 avalue => 'Y');
8744 IF (g_po_wf_debug = 'Y') THEN
8745 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'End');
8746 END IF;
8747 EXCEPTION
8748 WHEN OTHERS THEN
8749 IF (g_po_wf_debug = 'Y') THEN
8750 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Unexpected error');
8751 END IF;
8752 RAISE;
8753 end set_is_supplier_context_y; */
8754 /**
8755 * Public Procedure: set_is_supplier_context_n
8756 * Sets the workflow attribute IS_SUPPLIER_CONTEXT to N to let
8757 * the POREQ_SELECTOR know we are no longer in the suppliers
8758 * context.
8759 * Requires:
8760 * IN PARAMETERS:
8761 * Usual workflow attributes.
8762 * Modifies: Sets the workflow attribute IS_SUPPLIER_CONTEXT to N
8763 */
8764 /* procedure set_is_supplier_context_n(p_item_type in varchar2,
8765 p_item_key in varchar2,
8766 p_act_id in number,
8767 p_func_mode in varchar2,
8768 x_result_out out NOCOPY varchar2) is
8769 l_progress VARCHAR2(300);
8770 begin
8771 l_progress := 'PO_REQAPPROVAL_INIT1.set_is_supplier_context_n: ';
8772 IF (g_po_wf_debug = 'Y') THEN
8773 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Begin');
8774 END IF;
8775 -- Set the IS_SUPPLIER_CONTEXT value to 'N'
8776 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => p_item_type,
8777 itemkey => p_item_key,
8778 aname => 'IS_SUPPLIER_CONTEXT',
8779 avalue => 'N');
8780 IF (g_po_wf_debug = 'Y') THEN
8781 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'End');
8782 END IF;
8783 EXCEPTION
8784 WHEN OTHERS THEN
8785 IF (g_po_wf_debug = 'Y') THEN
8786 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Unexpected error');
8787 END IF;
8788 RAISE;
8789 end set_is_supplier_context_n; */
8790 -- <Bug 5059002 End>
8791 -- <Bug 4950854 Begin>
8792 -- added the following proc to update the print count
8793
8794 --<Bug 14254141 :Cancel Refactoring Project>
8795 -- Made the procedure non-autonomous
8796 -- There was deadlock error occurring when the communication was invoked
8797 -- from Cancel as the Cancel code also updates the po_headers_all/po_releases_all tables
8798 -- and the Commit/Rollback will not happen when the communication is invoked.
8799 PROCEDURE update_print_count( p_doc_id NUMBER,
8800 p_doc_type VARCHAR2 )
8801 IS
8802
8803 BEGIN
8804 IF (p_doc_type = 'RELEASE') THEN
8805 UPDATE po_releases_all pr
8806 SET pr.printed_date = sysdate,
8807 pr.print_count = NVL(pr.print_count,0) + 1
8808 WHERE pr.po_release_id = p_doc_id ;
8809 ELSIF (p_doc_type IN ('PO','PA')) THEN
8810 UPDATE po_headers_all ph
8811 SET ph.printed_date = sysdate,
8812 ph.print_count = NVL(ph.print_count,0) + 1
8813 WHERE ph.po_header_id = p_doc_id ;
8814 END IF;
8815
8816 END;
8817 -- <Bug 4950854 End>
8818 -- <BUG 5691965 START>
8819 /*
8820 ** Public Procedure: Update_Action_History_TimeOut
8821 ** Requires:
8822 ** IN PARAMETERS:
8823 ** Usual workflow attributes.
8824 ** Modifies: Action History
8825 ** Effects: Actoin History is updated with No Action if the approval
8826 ** notification is TimedOut.
8827 */
8828 PROCEDURE Update_Action_History_Timeout
8829 (
8830 Itemtype IN VARCHAR2,
8831 Itemkey IN VARCHAR2,
8832 Actid IN NUMBER,
8833 Funcmode IN VARCHAR2,
8834 Resultout OUT NOCOPY VARCHAR2)
8835 IS
8836 L_Doc_Id NUMBER;
8837 L_Doc_Type Po_Action_History.Object_Type_Code%TYPE;
8838 L_Doc_Subtype Po_Action_History.Object_Sub_Type_Code%TYPE;
8839 BEGIN
8840 L_Doc_Type := Wf_Engine.Getitemattrtext (Itemtype => Itemtype, Itemkey => Itemkey, Aname => 'DOCUMENT_TYPE');
8841 L_Doc_Subtype := Wf_Engine.Getitemattrtext(Itemtype => Itemtype, Itemkey => Itemkey, Aname => 'DOCUMENT_SUBTYPE');
8842 L_Doc_Id := Wf_Engine.Getitemattrnumber (Itemtype => Itemtype, Itemkey => Itemkey, Aname => 'DOCUMENT_ID');
8843 UpdateActionHistory ( p_doc_id => L_Doc_Id, p_doc_type => L_Doc_Type, p_doc_subtype => L_Doc_Subtype, p_action => 'NO ACTION' );
8844 END Update_Action_History_Timeout;
8845 -- <BUG 5691965 END>
8846 -- <Bug 6144768 Begin>
8847 -- When Supplier responds from iSP then the responder should show
8848 -- as supplier and also supplier acknowledgement notifications
8849 -- should be available in the To-Do Notification full list.
8850 /**
8851 * Public Procedure: set_is_supplier_context_y
8852 * Sets the workflow attribute IS_SUPPLIER_CONTEXT to Y to let
8853 * the POREQ_SELECTOR know we should be in the supplier's context
8854 * and not reset to the buyer's context
8855 * Requires:
8856 * IN PARAMETERS:
8857 * Usual workflow attributes.
8858 * Modifies: Sets the workflow attribute IS_SUPPLIER_CONTEXT to Y
8859 */
8860 PROCEDURE set_is_supplier_context_y
8861 (
8862 p_item_type IN VARCHAR2,
8863 p_item_key IN VARCHAR2,
8864 p_act_id IN NUMBER,
8865 p_func_mode IN VARCHAR2,
8866 x_result_out OUT NOCOPY VARCHAR2)
8867 IS
8868 l_progress VARCHAR2(300);
8869 BEGIN
8870 l_progress := 'PO_REQAPPROVAL_INIT1.set_is_supplier_context_y: ';
8871 IF (g_po_wf_debug = 'Y') THEN
8872 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Begin');
8873 END IF;
8874 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => p_item_type, itemkey => p_item_key, aname => 'IS_SUPPLIER_CONTEXT', avalue => 'Y');
8875 IF (g_po_wf_debug = 'Y') THEN
8876 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'End');
8877 END IF;
8878 EXCEPTION
8879 WHEN OTHERS THEN
8880 IF (g_po_wf_debug = 'Y') THEN
8881 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Unexpected error');
8882 END IF;
8883 RAISE;
8884 END set_is_supplier_context_y;
8885 /**
8886 * Public Procedure: set_is_supplier_context_n
8887 * Sets the workflow attribute IS_SUPPLIER_CONTEXT to N to let
8888 * the POREQ_SELECTOR know we are no longer in the suppliers
8889 * context.
8890 * Requires:
8891 * IN PARAMETERS:
8892 * Usual workflow attributes.
8893 * Modifies: Sets the workflow attribute IS_SUPPLIER_CONTEXT to N
8894 */
8895 PROCEDURE set_is_supplier_context_n
8896 (
8897 p_item_type IN VARCHAR2,
8898 p_item_key IN VARCHAR2,
8899 p_act_id IN NUMBER,
8900 p_func_mode IN VARCHAR2,
8901 x_result_out OUT NOCOPY VARCHAR2)
8902 IS
8903 l_progress VARCHAR2(300);
8904 BEGIN
8905 l_progress := 'PO_REQAPPROVAL_INIT1.set_is_supplier_context_n: ';
8906 IF (g_po_wf_debug = 'Y') THEN
8907 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Begin');
8908 END IF;
8909 -- Set the IS_SUPPLIER_CONTEXT value to 'N'
8910 PO_WF_UTIL_PKG.SetItemAttrText(itemtype => p_item_type, itemkey => p_item_key, aname => 'IS_SUPPLIER_CONTEXT', avalue => 'N');
8911 IF (g_po_wf_debug = 'Y') THEN
8912 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'End');
8913 END IF;
8914 EXCEPTION
8915 WHEN OTHERS THEN
8916 IF (g_po_wf_debug = 'Y') THEN
8917 PO_WF_DEBUG_PKG.insert_debug(p_item_type, p_item_key, l_progress || 'Unexpected error');
8918 END IF;
8919 RAISE;
8920 END set_is_supplier_context_n;
8921 PROCEDURE get_wf_attrs_from_docstyle
8922 (
8923 DocumentId NUMBER,
8924 DraftId NUMBER,
8925 l_itemtype OUT NOCOPY VARCHAR2,
8926 l_workflow_process OUT NOCOPY VARCHAR2,
8927 l_ame_transaction_type OUT NOCOPY VARCHAR2)
8928 IS
8929 l_draft_type PO_DRAFTS.DRAFT_TYPE%TYPE;
8930 l_progress VARCHAR2(1000);
8931 BEGIN
8932 l_progress := 'PO_REQAPPROVAL_INIT1.get_wf_attrs_from_docstyle DocumentId ' || DocumentId || ' and DraftId ' || DraftId;
8933
8934 IF DraftId <> -1 THEN
8935 SELECT draft_type
8936 INTO l_draft_type
8937 FROM po_drafts
8938 WHERE document_id = DocumentId
8939 AND draft_id = DraftId;
8940 ELSE
8941 l_draft_type := NULL;
8942 END IF;
8943
8944 l_progress := 'PO_REQAPPROVAL_INIT1.get_wf_attrs_from_docstyle l_draft_type' || l_draft_type;
8945
8946 SELECT ds.wf_approval_itemtype,
8947 ds.wf_approval_process,
8948 DECODE(l_draft_type,
8949 'MOD', ds.mod_ame_transaction_type,
8950 'PAR', ds.par_ame_transaction_type,
8951 ds.ame_transaction_type)
8952 INTO l_itemtype,
8953 l_workflow_process,
8954 l_ame_transaction_type
8955 FROM po_doc_style_headers ds,
8956 po_headers_merge_v phm
8957 WHERE phm.po_header_id = DocumentId
8958 AND NVL(phm.draft_id, -1) = DraftId
8959 AND phm.style_id = ds.style_id
8960 AND ds.wf_approval_itemtype IS NOT NULL
8961 AND ds.wf_approval_process IS NOT NULL;
8962
8963 l_progress := 'PO_REQAPPROVAL_INIT1.get_wf_attrs_from_docstyle l_itemtype ' || l_itemtype ||
8964 ' l_workflow_process ' || l_workflow_process || ' l_ame_transaction_type ' || l_ame_transaction_type;
8965
8966 EXCEPTION
8967 WHEN OTHERS THEN
8968 IF DraftId = -1 THEN
8969 l_ame_transaction_type := 'PURCHASE_ORDER';
8970 ELSE
8971 IF l_draft_type = 'MOD' THEN
8972 l_ame_transaction_type := 'PURCHASE_MOD';
8973 ELSIF l_draft_type = 'PAR' THEN
8974 l_ame_transaction_type := 'PURCHASE_PAR';
8975 END IF;
8976 END IF;
8977 l_progress := 'PO_REQAPPROVAL_INIT1.get_wf_attrs_from_docstyle in exception l_itemtype ' || l_itemtype ||
8978 ' l_workflow_process ' || l_workflow_process || ' l_ame_transaction_type ' || l_ame_transaction_type;
8979 END;
8980 -- <Bug 6144768 End>
8981 -- This procedure is used to set the modupdated_aftercdgenerated to 'Y', if the
8982 -- modification document is updated after generating the change description
8983 -- set the value to N, if the mod document is not updated after generating
8984 -- the change description
8985 PROCEDURE SetModUpdateAfterCDGenFlag
8986 (
8987 p_draft_id IN NUMBER) -- SGD Project
8988 IS
8989 pragma AUTONOMOUS_TRANSACTION;
8990 x_progress VARCHAR2(3):= '000';
8991 mod_last_update_date PO_DRAFTS.last_update_date%type;
8992 changedesc_gen_date PO_DRAFTS.cd_generated_date%type;
8993 BEGIN
8994 x_progress := '001';
8995 --fetch the change description generation date and edit by user flag value
8996 SELECT cd_generated_date
8997 INTO changedesc_gen_date
8998 FROM po_drafts
8999 WHERE draft_id = p_draft_id;
9000
9001 x_progress := '002';
9002 --find the latest date of the modification document
9003 mod_last_update_date := PO_CORE_S.get_last_update_date_for_mod(p_draft_id);
9004 x_progress := '003';
9005 IF( mod_last_update_date > changedesc_gen_date) THEN
9006 UPDATE po_drafts
9007 SET modupdated_aftercdgenerated = 'Y'
9008 WHERE draft_id = p_draft_id;
9009 ELSE
9010 UPDATE po_drafts
9011 SET modupdated_aftercdgenerated = 'N'
9012 WHERE draft_id = p_draft_id;
9013 END IF;
9014 COMMIT;
9015 EXCEPTION
9016 WHEN OTHERS THEN
9017 wf_core.context('PO_REQAPPROVAL_INIT1','SetModUpdateAfterCDGenFlag',x_progress);
9018 raise;
9019 END SetModUpdateAfterCDGenFlag;
9020
9021 -- code added for bug 8291565 FP
9022 -- to avoid sending repetitive FYI notifications to supplier users for the same revision number of a Purchase Order.
9023
9024 PROCEDURE check_rev_num_supplier_notif(itemtype IN VARCHAR2,
9025 itemkey IN VARCHAR2,
9026 actid IN VARCHAR2,
9027 funcmode IN VARCHAR2,
9028 resultout OUT NOCOPY VARCHAR2) IS
9029
9030 l_revision_num_flag varchar2(2);
9031 l_progress varchar2(255);
9032
9033 BEGIN
9034
9035 l_revision_num_flag := wf_engine.GetItemAttrText(itemtype => itemtype,
9036 itemkey => itemkey,
9037 aname => 'HAS_REVISION_NUM_INCREMENTED');
9038
9039 l_progress := 'PO_REQAPPROVAL_INIT1.check_rev_num_supplier_notif: HAS_REVISION_NUM_INCREMENTED = '||l_revision_num_flag;
9040
9041 resultout := wf_engine.eng_completed || ':' || l_revision_num_flag ;
9042
9043 EXCEPTION
9044 WHEN OTHERS THEN
9045 IF (g_po_wf_debug = 'Y') THEN
9046 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, l_progress || 'Unexpected error');
9047 END IF;
9048 RAISE;
9049
9050 END check_rev_num_supplier_notif;
9051
9052 PROCEDURE update_supplier_com_rev_num(itemtype IN VARCHAR2,
9053 itemkey IN VARCHAR2,
9054 actid IN VARCHAR2,
9055 funcmode IN VARCHAR2,
9056 resultout OUT NOCOPY VARCHAR2) IS
9057
9058 l_po_header_id NUMBER;
9059 l_po_revision_num_curr NUMBER;
9060 l_progress varchar2(255);
9061 l_doc_type varchar2(10);
9062
9063 BEGIN
9064
9065 l_po_header_id := wf_engine.GetItemAttrNumber( itemtype => itemtype,
9066 itemkey => itemkey,
9067 aname => 'DOCUMENT_ID');
9068
9069 l_po_revision_num_curr := wf_engine.GetItemAttrText( itemtype => itemtype,
9070 itemkey => itemkey,
9071 aname => 'NEW_PO_REVISION_NUM');
9072
9073 l_doc_type := wf_engine.GetItemAttrText (itemtype => itemtype,
9074 itemkey => itemkey,
9075 aname => 'DOCUMENT_TYPE');
9076
9077 IF l_doc_type IN ('PO', 'PA') THEN
9078
9079 UPDATE po_headers_all
9080 SET comm_rev_num = l_po_revision_num_curr
9081 WHERE po_header_id = l_po_header_id;
9082
9083 -- added for bug 9072034 (to update revision number for releases.)
9084 ELSIF l_doc_type in ('RELEASE') THEN
9085
9086 UPDATE po_releases_all
9087 SET comm_rev_num = l_po_revision_num_curr
9088 WHERE po_release_id = l_po_header_id;
9089
9090 END IF;
9091
9092 l_progress := 'PO_REQAPPROVAL_INIT1.update_supplier_com_rev_num: Current PO Rev Number = '||l_po_revision_num_curr;
9093
9094 EXCEPTION
9095 WHEN OTHERS THEN
9096 IF (g_po_wf_debug = 'Y') THEN
9097 PO_WF_DEBUG_PKG.insert_debug(itemtype, itemkey, l_progress || 'Unexpected error');
9098 END IF;
9099 RAISE;
9100
9101 END update_supplier_com_rev_num;
9102
9103 -- end of code added for bug 8291565
9104 -- to avoid sending repetitive FYI notifications to supplier users for the same revision number of a Purchase Order.
9105 --
9106
9107 END PO_REQAPPROVAL_INIT1;