[Home] [Help]
PACKAGE BODY: APPS.PAY_JP_ITW_REPORT_ARCHIVE
Source
1 PACKAGE BODY PAY_JP_ITW_REPORT_ARCHIVE AS
2 /* $Header: pyjpitwreparch.pkb 120.9 2011/05/10 02:02:29 keyazawa ship $ */
3 --
4 -- Constants
5 --
6 c_package constant varchar2(31) := 'pay_jp_itw_report_archive.';
7 --
8 PROCEDURE submit_request
9 (errbuf OUT NOCOPY VARCHAR2
10 ,retcode OUT NOCOPY NUMBER
11 ,p_run_pre_tax_archive IN VARCHAR2
12 --
13 ,p_effective_date IN VARCHAR2
14 ,p_business_group_id IN VARCHAR2
15 ,p_payroll_id IN VARCHAR2 DEFAULT NULL
16 ,p_itax_organization_id IN VARCHAR2 DEFAULT NULL
17 ,p_include_terminated_flag IN VARCHAR2
18 ,p_termination_date_from IN VARCHAR2 DEFAULT NULL
19 ,p_termination_date_to IN VARCHAR2 DEFAULT NULL
20 ,p_rearchive_flag IN VARCHAR2
21 ,p_inherit_archive_flag IN VARCHAR2
22 ,p_publication_period_status IN VARCHAR2
23 ,p_publication_start_date IN VARCHAR2 DEFAULT NULL
24 ,p_publication_end_date IN VARCHAR2 DEFAULT NULL
25 --
26 ,p_enable_flag IN VARCHAR2 DEFAULT NULL
27 ,p_start_date IN VARCHAR2 DEFAULT NULL
28 ,p_end_date IN VARCHAR2 DEFAULT NULL
29 ,p_consolidation_set_id IN VARCHAR2 DEFAULT NULL
30 )
31 IS
32 c_proc constant varchar2(61) := c_package || 'submit_request';
33 l_request_id NUMBER;
34 l_rphase VARCHAR2(80);
35 l_rstatus VARCHAR2(80);
36 l_dphase VARCHAR2(30);
37 l_dstatus VARCHAR2(30);
38 l_message VARCHAR2(240);
39 l_req_status BOOLEAN;
40 l_count NUMBER;
41 --
42 function param
43 (p_parameter_name in varchar2
44 ,p_parameter_value in varchar2
45 ,p_pipe in boolean default false
46 ,p_condition in boolean default true) return varchar2
47 is
48 begin
49 if p_parameter_name is not null
50 and p_parameter_value is not null
51 and p_condition then
52 if p_pipe then
53 return p_parameter_name || '=|' || p_parameter_value || '|';
54 else
55 return p_parameter_name || '=' || p_parameter_value;
56 end if;
57 end if;
58 --
59 return null;
60 end param;
61 --
62 function submit_payjpitw_archive return number
63 is
64 begin
65 return fnd_request.submit_request
66 ('PAY'
67 ,'PAYJPITW_ARCHIVE'
68 ,NULL
69 ,NULL
70 ,TRUE -- Sub Request
71 ,'ARCHIVE'
72 ,'JPTW'
73 ,'JP'
74 ,p_effective_date
75 ,p_effective_date
76 ,'ARCHIVE'
77 ,p_business_group_id
78 ,null
79 ,null
80 ,null
81 ,p_payroll_id
82 ,param('PAYROLL_ID', p_payroll_id)
83 ,p_itax_organization_id
84 ,param('ITAX_ORGANIZATION_ID', p_itax_organization_id)
85 ,p_include_terminated_flag
86 ,param('INCLUDE_TERMINATED_FLAG', p_include_terminated_flag)
87 ,p_termination_date_from
88 ,param('TERMINATION_DATE_FROM', p_termination_date_from, true, p_include_terminated_flag = 'Y')
89 ,p_termination_date_to
90 ,param('TERMINATION_DATE_TO', p_termination_date_to, true, p_include_terminated_flag = 'Y')
91 ,p_rearchive_flag
92 ,param('REARCHIVE_FLAG', p_rearchive_flag)
93 ,p_inherit_archive_flag
94 ,param('INHERIT_ARCHIVE_FLAG', p_inherit_archive_flag)
95 ,p_publication_period_status
96 ,param('PUBLICATION_PERIOD_STATUS', p_publication_period_status)
97 ,p_publication_start_date
98 ,param('PUBLICATION_START_DATE', p_publication_start_date, true)
99 ,p_publication_end_date
100 ,param('PUBLICATION_END_DATE', p_publication_end_date, true)
101 ,chr(0));
102 end submit_payjpitw_archive;
103 begin
104 hr_utility.set_location('Entering: ' || c_proc, 10);
105 --
106 retcode := 0;
107 --
108 -- Read the value from REQUEST_DATA. If this is the
109 -- first run of the program, then this value will be null.
110 -- Otherwise, this will be the value that we passed to
111 -- SET_REQ_GLOBALS on the previous run.
112 --
113 l_request_id := fnd_number.number_to_canonical(fnd_conc_global.request_data);
114 --
115 -- Exit when REQUEST_DATA was set to "-1" in previous procedure call.
116 --
117 if l_request_id = -1 then
118 return;
119 end if;
120 --
121 hr_utility.set_location(c_proc, 20);
122 --
123 if p_run_pre_tax_archive = 'Y' then
124 if l_request_id is NULL THEN
125 hr_utility.set_location(c_proc, 30);
126 --
127 -- Submit PAYJPPRT_ARCHIVE
128 --
129 l_request_id := fnd_request.submit_request
130 ('PAY'
131 ,'PAYJPPRT_ARCHIVE'
132 ,NULL
133 ,NULL
134 ,TRUE -- Sub Request
135 ,'ARCHIVE'
136 ,'PRT'
137 ,'JP'
138 ,p_start_date
139 ,nvl(p_end_date,greatest(nvl(p_start_date,p_effective_date),p_effective_date))
140 ,'ARCHIVE'
141 ,p_business_group_id
142 ,null
143 ,null
144 ,null
145 ,null
146 ,null
147 ,p_consolidation_set_id
148 ,param('CONSOLIDATION_SET_ID', p_consolidation_set_id)
149 ,chr(0));
150 --
151 if (l_request_id = 0) then
152 errbuf := fnd_message.get;
153 retcode := 2;
154 return;
155 else
156 hr_utility.trace('Child request PAYJPPRT_ARCHIVE submitted, request_id: ' || l_request_id);
157 --
158 -- Set PAYJPPRT_ARCHIVE request_id as request data.
159 --
160 fnd_conc_global.set_req_globals
161 (conc_status => 'PAUSED'
162 ,request_data => fnd_number.number_to_canonical(l_request_id));
163 end if;
164 else
165 hr_utility.set_location(c_proc, 40);
166 hr_utility.trace('PAYJPPRT_ARCHIVE request_id: ' || l_request_id);
167 --
168 l_req_status := FND_CONCURRENT.GET_REQUEST_STATUS
169 (request_id => l_request_id
170 ,phase => l_rphase
171 ,status => l_rstatus
172 ,dev_phase => l_dphase
173 ,dev_status => l_dstatus
174 ,message => l_message
175 );
176 --
177 if (l_req_status = FALSE) then
178 errbuf := fnd_message.get;
179 retcode := 2;
180 return;
181 end if;
182 --
183 hr_utility.trace('Developer Phase = ' || l_dphase);
184 hr_utility.trace('Developer Status = ' || l_dstatus);
185 --
186 if (l_dphase = 'COMPLETE' and l_dstatus = 'NORMAL') then
187 hr_utility.set_location(c_proc, 50);
188 --
189 select COUNT(1)
190 into l_count
191 from pay_payroll_actions ppa,
192 pay_assignment_actions paa
193 where ppa.request_id = l_request_id
194 and ppa.action_type = 'X'
195 and paa.payroll_action_id = ppa.payroll_action_id
196 and paa.action_status <> 'C';
197 --
198 if (l_count = 0) then
199 hr_utility.set_location(c_proc, 60);
200 --
201 l_request_id := submit_payjpitw_archive;
202 --
203 if (l_request_id = 0) then
204 errbuf := fnd_message.get;
205 retcode := 2;
206 return;
207 else
208 hr_utility.trace('Child request PAYJPITW_ARCHIVE submitted: ' || l_request_id);
209 --
210 fnd_conc_global.set_req_globals
211 (conc_status => 'PAUSED'
212 ,request_data => fnd_number.number_to_canonical(-1)
213 );
214 end if;
215 else
216 fnd_message.set_name('PAY', 'PAY_JP_ITW_ARCH_NOT_SUBMITTED');
217 errbuf := fnd_message.get;
218 retcode := 1;
219 return;
220 end if;
221 else
222 fnd_message.set_name('PAY', 'PAY_JP_ITW_ARCH_NOT_SUBMITTED2');
223 errbuf := fnd_message.get;
224 retcode := 1;
225 return;
226 end if;
227 end if;
228 else
229 hr_utility.set_location(c_proc, 70);
230 --
231 l_request_id := submit_payjpitw_archive;
232 --
233 if (l_request_id = 0) then
234 errbuf := fnd_message.get;
235 retcode := 2;
236 return;
237 else
238 hr_utility.trace('Child request PAYJPITW_ARCHIVE submitted: ' || l_request_id);
239 --
240 fnd_conc_global.set_req_globals
241 (conc_status => 'PAUSED'
242 ,request_data => fnd_number.number_to_canonical(-1)
243 );
244 end if;
245 end if;
246 --
247 hr_utility.set_location('Leaving: ' || c_proc, 80);
248 end submit_request;
249 --
250 END PAY_JP_ITW_REPORT_ARCHIVE;