[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.4.12000000.4 2007/05/07 08:51:10 ttagawa noship $ */
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 ,p_payroll_id
81 ,param('PAYROLL_ID', p_payroll_id)
82 ,p_itax_organization_id
83 ,param('ITAX_ORGANIZATION_ID', p_itax_organization_id)
84 ,p_include_terminated_flag
85 ,param('INCLUDE_TERMINATED_FLAG', p_include_terminated_flag)
86 ,p_termination_date_from
87 ,param('TERMINATION_DATE_FROM', p_termination_date_from, true, p_include_terminated_flag = 'Y')
88 ,p_termination_date_to
89 ,param('TERMINATION_DATE_TO', p_termination_date_to, true, p_include_terminated_flag = 'Y')
90 ,p_rearchive_flag
91 ,param('REARCHIVE_FLAG', p_rearchive_flag)
92 ,p_inherit_archive_flag
93 ,param('INHERIT_ARCHIVE_FLAG', p_inherit_archive_flag)
94 ,p_publication_period_status
95 ,param('PUBLICATION_PERIOD_STATUS', p_publication_period_status)
96 ,p_publication_start_date
97 ,param('PUBLICATION_START_DATE', p_publication_start_date, true)
98 ,p_publication_end_date
99 ,param('PUBLICATION_END_DATE', p_publication_end_date, true)
100 ,chr(0));
101 end submit_payjpitw_archive;
102 begin
103 hr_utility.set_location('Entering: ' || c_proc, 10);
104 --
105 retcode := 0;
106 --
107 -- Read the value from REQUEST_DATA. If this is the
108 -- first run of the program, then this value will be null.
109 -- Otherwise, this will be the value that we passed to
110 -- SET_REQ_GLOBALS on the previous run.
111 --
112 l_request_id := fnd_number.number_to_canonical(fnd_conc_global.request_data);
113 --
114 -- Exit when REQUEST_DATA was set to "-1" in previous procedure call.
115 --
116 if l_request_id = -1 then
117 return;
118 end if;
119 --
120 hr_utility.set_location(c_proc, 20);
121 --
122 if p_run_pre_tax_archive = 'Y' then
123 if l_request_id is NULL THEN
124 hr_utility.set_location(c_proc, 30);
125 --
126 -- Submit PAYJPPRT_ARCHIVE
127 --
128 l_request_id := fnd_request.submit_request
129 ('PAY'
130 ,'PAYJPPRT_ARCHIVE'
131 ,NULL
132 ,NULL
133 ,TRUE -- Sub Request
134 ,'ARCHIVE'
135 ,'PRT'
136 ,'JP'
137 ,fnd_date.date_to_canonical(fnd_date.displaydate_to_date(p_start_date))
138 ,fnd_date.date_to_canonical(fnd_date.displaydate_to_date(p_end_date))
139 ,'ARCHIVE'
140 ,p_business_group_id
141 ,null
142 ,null
143 ,null
144 ,null
145 ,p_consolidation_set_id
146 ,param('CONSOLIDATION_SET_ID', p_consolidation_set_id)
147 ,chr(0));
148 --
149 if (l_request_id = 0) then
150 errbuf := fnd_message.get;
151 retcode := 2;
152 return;
153 else
154 hr_utility.trace('Child request PAYJPPRT_ARCHIVE submitted, request_id: ' || l_request_id);
155 --
156 -- Set PAYJPPRT_ARCHIVE request_id as request data.
157 --
158 fnd_conc_global.set_req_globals
159 (conc_status => 'PAUSED'
160 ,request_data => fnd_number.number_to_canonical(l_request_id));
161 end if;
162 else
163 hr_utility.set_location(c_proc, 40);
164 hr_utility.trace('PAYJPPRT_ARCHIVE request_id: ' || l_request_id);
165 --
166 l_req_status := FND_CONCURRENT.GET_REQUEST_STATUS
167 (request_id => l_request_id
168 ,phase => l_rphase
169 ,status => l_rstatus
170 ,dev_phase => l_dphase
171 ,dev_status => l_dstatus
172 ,message => l_message
173 );
174 --
175 if (l_req_status = FALSE) then
176 errbuf := fnd_message.get;
177 retcode := 2;
178 return;
179 end if;
180 --
181 hr_utility.trace('Developer Phase = ' || l_dphase);
182 hr_utility.trace('Developer Status = ' || l_dstatus);
183 --
184 if (l_dphase = 'COMPLETE' and l_dstatus = 'NORMAL') then
185 hr_utility.set_location(c_proc, 50);
186 --
187 select COUNT(1)
188 into l_count
189 from pay_payroll_actions ppa,
190 pay_assignment_actions paa
191 where ppa.request_id = l_request_id
192 and ppa.action_type = 'X'
193 and paa.payroll_action_id = ppa.payroll_action_id
194 and paa.action_status <> 'C';
195 --
196 if (l_count = 0) then
197 hr_utility.set_location(c_proc, 60);
198 --
199 l_request_id := submit_payjpitw_archive;
200 --
201 if (l_request_id = 0) then
202 errbuf := fnd_message.get;
203 retcode := 2;
204 return;
205 else
206 hr_utility.trace('Child request PAYJPITW_ARCHIVE submitted: ' || l_request_id);
207 --
208 fnd_conc_global.set_req_globals
209 (conc_status => 'PAUSED'
210 ,request_data => fnd_number.number_to_canonical(-1)
211 );
212 end if;
213 else
214 fnd_message.set_name('PAY', 'PAY_JP_ITW_ARCH_NOT_SUBMITTED');
215 errbuf := fnd_message.get;
216 retcode := 1;
217 return;
218 end if;
219 else
220 fnd_message.set_name('PAY', 'PAY_JP_ITW_ARCH_NOT_SUBMITTED2');
221 errbuf := fnd_message.get;
222 retcode := 1;
223 return;
224 end if;
225 end if;
226 else
227 hr_utility.set_location(c_proc, 70);
228 --
229 l_request_id := submit_payjpitw_archive;
230 --
231 if (l_request_id = 0) then
232 errbuf := fnd_message.get;
233 retcode := 2;
234 return;
235 else
236 hr_utility.trace('Child request PAYJPITW_ARCHIVE submitted: ' || l_request_id);
237 --
238 fnd_conc_global.set_req_globals
239 (conc_status => 'PAUSED'
240 ,request_data => fnd_number.number_to_canonical(-1)
241 );
242 end if;
243 end if;
244 --
245 hr_utility.set_location('Leaving: ' || c_proc, 80);
246 end submit_request;
247 --
248 END PAY_JP_ITW_REPORT_ARCHIVE;