1 PACKAGE BODY HR_WORKFLOW_PKG AS
2 /* $Header: pewkflow.pkb 115.4 2004/01/30 07:16:32 bsubrama ship $ */
3 -----------------------------------------------------------------------------
4 -----------------------------------------------------------------------------
5 --
6 procedure initiate_workflow(
7 p_param_workflow_name IN OUT nocopy varchar2,
8 p_workflow_id IN OUT nocopy number,
9 p_current_form varchar2,
10 p_current_block varchar2,
11 p_passed_nav_node_usage_id number,
12 p_dest_form IN OUT nocopy varchar2,
13 p_dest_block IN OUT nocopy varchar2,
14 p_nav_node_usage_id IN OUT nocopy number,
15 p_top_workflow_node IN OUT nocopy varchar2,
16 p_cust_rest_id IN OUT nocopy number,
17 p_cust_appl_id IN OUT nocopy number,
18 p_cust_query_title IN OUT nocopy varchar2,
19 p_cust_std_title IN OUT nocopy varchar2,
20 p_default_found IN OUT nocopy varchar2) is
21 --
22 l_enabled varchar2(1);
23 --
24 cursor default_workflow is
25 select w.workflow_id,
26 u.form_name,
27 u.block_name,
28 nu.nav_node_usage_id
29 from hr_workflows w,
30 hr_navigation_node_usages nu,
31 hr_navigation_nodes n,
32 hr_navigation_units u
33 where w.workflow_id = nu.workflow_id
34 and nu.top_node = 'Y'
35 and nu.nav_node_id = n.nav_node_id
36 and n.nav_unit_id = u.nav_unit_id
37 and u.default_workflow_id + 0 = w.workflow_id -- Bug 3390412
38 and u.form_name = P_CURRENT_FORM;
39 --
40 cursor new_workflow is
41 select w.workflow_id,
42 u.form_name,
43 u.block_name,
44 nu.nav_node_usage_id
45 from hr_workflows w,
46 hr_navigation_node_usages nu,
47 hr_navigation_nodes n,
48 hr_navigation_units u
49 where w.workflow_name = P_PARAM_WORKFLOW_NAME
50 and w.workflow_id = nu.workflow_id
51 and nu.top_node = 'Y'
52 and nu.nav_node_id = n.nav_node_id
53 and n.nav_unit_id = u.nav_unit_id;
54 --
55 cursor customization is
56 select r.customized_restriction_id,
57 r.application_id,
58 r.query_form_title,
59 r.standard_form_title,
60 r.enabled_flag
61 from hr_navigation_nodes n,
62 hr_navigation_node_usages us,
63 pay_custom_restrictions_vl r
64 where us.workflow_id = P_WORKFLOW_ID
65 and us.nav_node_usage_id = P_NAV_NODE_USAGE_ID
66 and us.nav_node_id = n.nav_node_id
67 and n.customized_restriction_id = r.customized_restriction_id;
68 --
69 begin
70 --
71 -- Called from PRE-FORM of all workflow forms. Gets node details - i.e. the
72 -- customization if there is one and the workflow details.
73 -- Note all workflow forms will have the WORKFLOW_NAME parameter. It will
74 -- contain the actual workflow name when passed from a menu but when passed
75 -- from form to form, it will begin with '**'. This is so that we can work out
76 -- if we are entering a new workflow or not.
77 --
78 --
79 if p_param_workflow_name is null then
80 --
81 -- Not in workflow as no workflow name was specified. Try to
82 -- get default workflow for this unit. If none exists then
83 -- simply no buttons will be displayed for navigation.
84 -- When searching for default:
85 -- Obviously in top node here. Only one default_workflow_id
86 -- should exist per form in the units table. Furthermore, only
87 -- one node in the default workflow (corresponding to only one
88 -- unit) will be the top node. Therefore only 1 row returned.
89 --
90 open default_workflow;
91 fetch default_workflow
92 into p_workflow_id,
93 p_dest_form,
94 p_dest_block,
95 p_nav_node_usage_id;
96 --
97 if default_workflow%found then
98 --
99 p_top_workflow_node := 'Y';
100 p_default_found := 'Y';
101 else
102 p_top_workflow_node := 'N';
103 p_default_found := 'N';
104
105 p_workflow_id := null ;
106 p_nav_node_usage_id := null ;
107 end if;
108 --
109 close default_workflow;
110 --
111 elsif p_param_workflow_name like '**%' then
112 --
113 -- Not top workflow form but in workflow.
114 -- Get workflow name and this form and block name (that which
115 -- workflow knows about).
116 --
117 p_top_workflow_node := 'N';
118 p_dest_form := p_current_form;
119 p_dest_block := p_current_block;
120 p_nav_node_usage_id := p_passed_nav_node_usage_id;
121 else
122 --
123 -- Entering new workflow; get workflow name from parameter
124 -- and also top node form/block name for use in navigation SQL.
125 --
126 open new_workflow;
127 fetch new_workflow
128 into p_workflow_id,
129 p_dest_form,
130 p_dest_block,
131 p_nav_node_usage_id;
132 if new_workflow%notfound then
133 close new_workflow;
134 fnd_message.set_name('PAY',
135 'HR_7068_WFLOW_NAME_NOT_FOUND');
136 fnd_message.raise_error;
137 end if;
138 --
139 close new_workflow;
140 p_top_workflow_node := 'Y';
141 end if;
142 --
143 -- Now get customization details. If this node does not have an enabled
144 -- customization then this SQL will simply fail (gracefully).
145 --
146
147 if ( p_workflow_id is not null ) then
148
149 open customization;
150 fetch customization
151 into p_cust_rest_id,
152 p_cust_appl_id,
153 p_cust_query_title,
154 p_cust_std_title,
155 l_enabled;
156 --
157 -- If not enabled then give warning message otherwise write
158 -- customization details.
159 --
160 if customization%found and l_enabled <> 'Y' then
161 close customization ;
162 fnd_message.set_name('PAY', 'HR_CUST_NOT_ENABLED');
163 fnd_message.raise_error;
164 end if;
165
166 close customization ;
167
168 end if;
169 --
170 end initiate_workflow;
171 ----------------------------------------------------------------------------
172 END HR_WORKFLOW_PKG;