DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ERRORS_API

Source


4 -- ----------------------------------------------------------------------------
1 package body hr_errors_api as
2 /* $Header: hrerrapi.pkb 115.15 2002/12/06 15:37:26 hjonnala ship $ */
3 --
5 -- |--< errorExists >---------------------------------------------------------|
6 -- ----------------------------------------------------------------------------
7 function errorExists return boolean is
8 --
9 begin
10    if nvl(noOfErrorRecords, 0) > 0 then
11       return true;
12    else
13       return false;
14    end if;
15 end;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |--< warningExists >-------------------------------------------------------|
19 -- ----------------------------------------------------------------------------
20 function warningExists return boolean is
21 --
22 l_counter     number := null;
23 --
24 begin
25    -- we need to scan through the error records to see if there are any
26    -- with the warning flag set.
27 -- bug # 1641590
28    l_counter := g_errorTable.First;
29 /*
30    if g_errorTable.count <> 0 then
31      l_counter := 1;
32    else
33      l_counter := null;
34    end if;
35 */
36    while l_counter is not null loop
37       IF g_errorTable(l_counter).warningFlag THEN
38          RETURN TRUE;
39       END IF;
40      l_counter := g_errorTable.Next(l_counter);
41    end loop;
42 
43    -- If we have reached here then no warnings have been found
44    RETURN FALSE;
45 end;
46 --
47 -- ----------------------------------------------------------------------------
48 -- |--< fieldLevelErrorsExist >-----------------------------------------------|
49 -- ----------------------------------------------------------------------------
50 function fieldLevelErrorsExist return boolean is
51 --
52 l_counter     number := null;
53 --
54 begin
55    -- loop through the error table and if we find a field level error return
56    -- true - otherwise return false
57 -- bug # 1641590
58    l_counter := g_errorTable.First;
59 /*
60    if g_errorTable.count <> 0 then
61      l_counter := 1;
62    else
63      l_counter := null;
64    end if;
65 */
66    while l_counter is not null loop
67       if    ( g_errorTable(l_counter).ErrorField IS NOT NULL OR
68               g_errorTable(l_counter).RowNumber > 0 )
69         AND NOT g_errorTable(l_counter).warningFlag
70       then
71          return TRUE;
72       end if;
73      l_counter := g_errorTable.Next(l_counter);
74    end loop;
75 
76    -- if we have reached here then no field level errors exist
77    return FALSE;
78 end;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |--< addErrorToTable >-----------------------------------------------------|
82 -- ----------------------------------------------------------------------------
83 procedure addErrorToTable(p_errorField    varchar2    default null
84                          ,p_errorCode     varchar2    default null
85                          ,p_errorMsg      varchar2
86                          ,p_warningFlag   boolean     default false
87                          ,p_rowNumber     number      default null
88                          ,p_email_id      varchar2    default null
89                          ,p_email_msg     varchar2    default null
90                          ) is
91 --
92 begin
93 --
94    -- increment the error count
95    -- g_count := g_count + 1;
96 -- bug # 1641590
97    g_count := g_errorTable.Last;
98    if g_count is not null then
99       g_count := g_count + 1;
100    else
101       g_count := 1;
102    end if;
103    --
104    -- set the values in the pl/sql table to the stuff thats been passed in!
105    --
106    g_errorTable(g_count).ErrorField   := p_errorField;
107    g_errorTable(g_count).ErrorCode    := p_errorCode;
108    g_errorTable(g_count).ErrorMsg     := p_errorMsg;
109    g_errorTable(g_count).WarningFlag  := p_warningFlag;
110    g_errorTable(g_count).RowNumber    := NVL(p_rowNumber, 0);
111    g_errorTable(g_count).EmailId      := p_email_id;
112    g_errorTable(g_count).EmailMsg     := p_email_msg;
113 
114 --
115 end;
116 --
117 -- ----------------------------------------------------------------------------
118 -- |--< noOfErrorRecords >----------------------------------------------------|
119 -- ----------------------------------------------------------------------------
120 function noOfErrorRecords return number is
121 --
122 l_error_count    NUMBER;
123 l_counter        NUMBER := 0;
124 --
125 begin
126    l_error_count := 0;
127 
128    -- loop through the error table counting the errors (ie. not warnings)
129 -- bug # 1641590
130    l_counter := g_errorTable.First;
131 /*
132    if g_errorTable.count <> 0 then
133      l_counter := 1;
134    else
135      l_counter := null;
136    end if;
137 */
138 
139    while l_counter is not null loop
140       if NOT g_errorTable(l_counter).warningFlag then
141          l_error_count := l_error_count + 1;
142       end if;
146    return nvl(l_error_count, 0);
143      l_counter := g_errorTable.Next(l_counter);
144    end loop;
145 
147 end;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |--< noOfWarnings >--------------------------------------------------------|
151 -- ----------------------------------------------------------------------------
152 function noOfWarnings return number is
153 --
154 l_warning_count    NUMBER;
155 l_counter        NUMBER := 0;
156 --
157 begin
158    l_warning_count := 0;
159 
160    -- loop through the error table counting the warnings
161 -- bug # 1641590
162    l_counter := g_errorTable.First;
163 /*
164    if g_errorTable.count <> 0 then
165      l_counter := 1;
166    else
167      l_counter := null;
168    end if;
169 */
170 
171    while l_counter is not null loop
172       if g_errorTable(l_counter).warningFlag then
173          l_warning_count := l_warning_count + 1;
174       end if;
175      l_counter := g_errorTable.Next(l_counter);
176    end loop;
177 
178    return nvl(l_warning_count, 0);
179 end;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |--< getPageLevelErrors >--------------------------------------------------|
183 -- ----------------------------------------------------------------------------
184 function getPageLevelErrors return ErrorRecTable is
185 --
186 l_text         varchar2 (32000);
187 l_errorArray   ErrorRecTable;
188 l_count        number := 0;
189 
190 Counter        number := 0;
191 --
192 begin
193 -- bug 1690449
194      Counter := g_errorTable.First;
195 
196      -- return the text of any errors that do not have a field name
197 -- bug 1690449
198      while Counter is not null
199      loop
200 
201          if   g_errorTable(Counter).ErrorField is null
202           OR  g_errorTable(Counter).ErrorField = ''
203           OR  g_errorTable(Counter).warningFlag then
204             --
205             -- this is a page level error message or a warning (all warnings
206             -- are page level)
207             --
208             -- check if this is not  a row level error
209             -- if not then this is a page level or warning
210             IF g_errorTable(counter).rownumber = 0 THEN
211             l_count := l_count + 1;
212 
213             -- add it to the array of errors to return
214             l_errorArray(l_count).ErrorField
215                                           := g_errorTable(Counter).ErrorField;
216             l_errorArray(l_count).ErrorCode
217                                           := g_errorTable(Counter).ErrorCode;
218             l_errorArray(l_count).ErrorMsg
219                                           := g_errorTable(Counter).ErrorMsg;
220             l_errorArray(l_count).WarningFlag
221                                           := g_errorTable(Counter).WarningFlag;
222             l_errorArray(l_count).RowNumber
223                                           := g_errorTable(Counter).RowNumber;
224             l_errorArray(l_count).EmailId
225                                           := g_errorTable(Counter).EmailId;
226             l_errorArray(l_count).EmailMsg
227                                           := g_errorTable(Counter).EmailMsg;
228 -- bug # 1641590
229             g_errorTable.delete(Counter);
230             END IF ;
231          end if;
232 -- bug 1690449
233         Counter := g_errorTable.Next(Counter);
234      end loop;
235    return l_errorArray;
236 end;
237 -- ----------------------------------------------------------------------------
238 -- |--< getRowLevelErrors >---------------------------------------------------|
239 -- ----------------------------------------------------------------------------
240 function getRowLevelErrors (p_row_number   varchar2
241                             ,p_error_loc     OUT NOCOPY ErrorRecLocTable
242                            ) return ErrorTextTable is
243 --
244 l_textTable   ErrorTextTable;
245 l_count       number := 0;
246 l_row_number  number := null;
247 l_counter     number := null;
248 
249 l_err_loc_count number := 0;
250 --
251 begin
252    if p_row_number is not null then
253       l_row_number := to_number(p_row_number);
254 
255       -- return the text of any errors that do not have a field name
256 -- bug # 1641590
257       l_counter := g_errorTable.First;
258   /*
259       if g_errorTable.count <> 0 then
260        l_counter := 1;
261       else
262        l_counter := null;
263       end if;
264   */
265 
266       while l_counter is not null loop
267           if (   g_errorTable(l_counter).ErrorField is null
268               or g_errorTable(l_counter).ErrorField = '' )
269              and NOT g_errorTable(l_counter).warningFlag
270              and g_errorTable(l_counter).RowNumber = l_row_number then
271              --
272              l_count := l_count + 1;
273 
274              IF g_errorTable(l_counter).ErrorCode IS NOT NULL THEN
275                 l_textTable(l_count) := g_errorTable(l_counter).ErrorMsg ||
276                                         ' (' ||
277                                         g_errorTable(l_counter).ErrorCode ||
278                                         ')';
279              ELSE
280                 l_textTable(l_count) := g_errorTable(l_counter).ErrorMsg;
281              END IF;
282 -- bug # 1641590 1690449
283              --g_errorTable.delete(l_counter);
284              l_err_loc_count := l_err_loc_count + 1;
285              p_error_loc(l_err_loc_count) := l_counter;
286           end if;
290    end if;
287           l_counter := g_errorTable.Next(l_counter);
288       end loop;
289       --
291    --
292    return l_textTable;
293    Exception
294    when others then
295    p_error_loc.delete;
296    raise;
297 end;
298 --
299 -- ----------------------------------------------------------------------------
300 -- |--< getFieldLevelErrors >-------------------------------------------------|
301 -- ----------------------------------------------------------------------------
302 function getFieldLevelErrors(p_field_name    varchar2
303                             ,p_row_number    varchar2     default null
304                             ,p_error_loc     OUT NOCOPY ErrorRecLocTable
305                             ) return ErrorTextTable is
306 --
307 l_textTable   ErrorTextTable;
308 l_count       number := 0;
309 l_row_number  number := null;
310 l_counter     number := null;
311 
312 l_err_loc_count number := 0;
313 --
314 begin
315    if p_row_number is not null then
316       l_row_number := to_number(p_row_number);
317    end if;
318 
319    -- scan the pl/sql table to see if there are matches with the field name
320    -- passed in
321 -- bug # 1641590
322    l_counter := g_errorTable.First;
323 /*
324    if g_errorTable.count <> 0 then
325      l_counter := 1;
326    else
327      l_counter := null;
328    end if;
329 */
330 
331    while l_counter is not null loop
332        if upper(g_errorTable(l_counter).ErrorField) = upper(p_field_name)
333            AND NOT g_errorTable(l_counter).warningFlag
334            AND (     (g_errorTable(l_counter).RowNumber = p_row_number)
335                  OR  p_row_number is null) then
336           --
337           l_count := l_count + 1;
338           --
339           IF g_errorTable(l_counter).ErrorCode IS NOT NULL THEN
340              l_textTable(l_count) := g_errorTable(l_counter).ErrorMsg ||
341                                      ' (' ||
342                                      g_errorTable(l_counter).ErrorCode ||
343                                      ')';
344           ELSE
345              l_textTable(l_count) := g_errorTable(l_counter).ErrorMsg;
346           END IF;
347 -- bug # 1641590 1690449
348           --g_errorTable.delete(l_counter);
349           l_err_loc_count := l_err_loc_count + 1;
350           p_error_loc(l_err_loc_count) := l_counter;
351        end if;
352       l_counter := g_errorTable.Next(l_counter);
353    end loop;
354 
355    return l_textTable;
356    Exception
357    when others then
358    p_error_loc.delete;
359    raise;
360 end;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |--< encryptErrorTable >---------------------------------------------------|
364 -- ----------------------------------------------------------------------------
365 function encryptErrorTable return varchar2 is
366 --
367 l_string    varchar2 (32000);
368 l_id        varchar2 (2000) default '';
369 l_tmpflag   varchar2 (1);
370 
371 Counter     number := 0;
372 --
373 begin
374   if g_errorTable.count > 0 then
375      l_string := hr_general_utilities.Add_Separators
376                   ( p_instring => to_char(g_errorTable.count)
377                   , p_start => TRUE
378                   );
379      --
380      Counter := g_errorTable.First;
381      while Counter is not null
382      loop
383          if g_errorTable(Counter).WarningFlag = true then
384             l_tmpflag := 'Y';
385          else
386             l_tmpflag := 'N';
387          end if;
388 
389          l_string := l_string
390                      || hr_general_utilities.Add_Separators
391                            ( p_instring => g_errorTable(Counter).ErrorField)
392                      || hr_general_utilities.Add_Separators
393                            ( p_instring => g_errorTable(Counter).ErrorCode)
394                      || hr_general_utilities.Add_Separators
395                            ( p_instring => g_errorTable(Counter).ErrorMsg)
396                      || hr_general_utilities.Add_Separators
397                            ( p_instring => l_tmpflag)
398                      || hr_general_utilities.Add_Separators
399                        (p_instring => to_char(g_errorTable(Counter).RowNumber))
400                      || hr_general_utilities.Add_Separators
401                       ( p_instring => g_errorTable(Counter).EmailId)
402                      || hr_general_utilities.Add_Separators
403                       ( p_instring => g_errorTable(Counter).EmailMsg);
404      Counter := g_errorTable.Next(Counter);
405      end loop;
406    end if;
407    --
408    if l_string is not null then
409       -- encrypt the string
410       l_id := hr_general_utilitieS.EPFS
411               ( p_string => l_string
412               , p_type => 'G'
413               );
414    else
415       l_id := '';
416    end if;
417 
418    return l_id;
419 end;
420 --
421 -- ----------------------------------------------------------------------------
422 -- |--< decryptErrorTable >---------------------------------------------------|
423 -- ----------------------------------------------------------------------------
424 procedure decryptErrorTable(p_encrypt varchar2
425                           ) is
426 --
427 l_index    number;
428 l_tmpflag  varchar2(1);
429 l_tmpstring varchar2(32000);
430 --
431 begin
432 -- bug # 1615428
433    hr_general_utilities.reset_g_cache;
434 
435 --
436    if p_encrypt is not null then
437       -- decrypt the string
438 
439 -- bug # 1615428
440 -- cache initialization is moved up and made us the first call in this procedure
441 --
442 --
443       hr_general_utilities.DEXL (i => p_encrypt);
444 
445       l_tmpString := hr_general_utilities.REGS (p_index => 1);
446       -- extract the record count
447       g_count := to_number
448                      (hr_general_utilities.Find_Item_In_String
449                         ( p_item    => 1
450                         , p_string  => l_tmpString
451                         ));
452       --
453       -- loop through the string reassigning the record values
454       --
455       if g_count >= 1 then
456          FOR Counter IN 1 .. g_count
457          LOOP
458             l_index := ((Counter - 1) * 7) + 1;
459 
460             g_errorTable(Counter).ErrorField :=
461              hr_general_utilities.Find_Item_In_String
462                 ( p_item                => l_index + 1
463                 , p_string              => l_tmpString
464                 ) ;
465 
466             g_errorTable(Counter).ErrorCode :=
467               hr_general_utilities.Find_Item_In_String
468                 ( p_item                => l_index + 2
469                 , p_string              => l_tmpString
470                 ) ;
471 
472             g_errorTable(Counter).ErrorMsg :=
473               hr_general_utilities.Find_Item_In_String
474                 ( p_item                => l_index + 3
475                 , p_string              => l_tmpString
476                 ) ;
477 
478             l_tmpflag :=
479                hr_general_utilities.Find_Item_In_String
480                 ( p_item                => l_index + 4
481                 , p_string              => l_tmpString
482                 );
483 
484             if l_tmpflag = 'Y' then
485                g_errorTable(Counter).WarningFlag := true;
486             else
487                g_errorTable(Counter).WarningFlag := false;
488             end if;
489 
490             g_errorTable(Counter).RowNumber :=
491               to_number
492                 ( hr_general_utilities.Find_Item_In_String
493                     ( p_item            => l_index + 5
494                     , p_string          => l_tmpString
495                     )
496                 );
497 
498          g_errorTable(Counter).EmailId :=
499                 hr_general_utilities.Find_Item_In_String
500                     ( p_item            => l_index + 6
501                     , p_string          => l_tmpString
502                     );
503          g_errorTable(Counter).EmailMsg :=
504                 hr_general_utilities.Find_Item_In_String
505                     ( p_item            => l_index + 7
506                     , p_string          => l_tmpString
507                     );
508 
509          end loop;
510       end if;
511    end if;
512 end;
513 --
514 -- bug 1690449
515 -- ----------------------------------------------------------------------------
516 -- |--< deleteErrorRec >---------------------------------------------------|
517 -- ----------------------------------------------------------------------------
518 procedure deleteErrorRec(p_error_loc ErrorRecLocTable
519                           ) is
520 --
521 Begin
522      for Counter in 1 .. p_error_loc.count
523      loop
524         g_errorTable.delete(p_error_loc(Counter));
525      end loop;
526 end;
527 
528 --
529 end hr_errors_api;