DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_JP_IWHT_REPORT_ARCH_PKG

Source


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