DBA Data[Home] [Help]

PACKAGE BODY: APPS.HRI_OPL_WRKFC_TRNSFR_EVENTS

Source


1 PACKAGE BODY hri_opl_wrkfc_trnsfr_events AS
2 /* $Header: hriowevttrn.pkb 120.1.12000000.2 2007/04/12 13:24:20 smohapat noship $ */
3 
4 TYPE g_chain_rec_type IS RECORD
5  (node_from_sk        NUMBER,
6   node_to_sk          NUMBER,
7   node_from_exists    BOOLEAN,
8   node_to_exists      BOOLEAN,
9   direct_node_before  NUMBER,
10   direct_node_after   NUMBER);
11 
12 TYPE g_chain_cache_type IS TABLE OF g_chain_rec_type INDEX BY BINARY_INTEGER;
13 
14 -- Simple table types
15 TYPE g_date_tab_type IS TABLE OF DATE INDEX BY BINARY_INTEGER;
16 TYPE g_number_tab_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
17 TYPE g_varchar2_tab_type IS TABLE OF VARCHAR2(40) INDEX BY BINARY_INTEGER;
18 
19 -- PLSQL table of tables representing database table
20 g_mgrh_sup_psn_id          g_number_tab_type;
21 g_mgrh_sup_sc_fk           g_number_tab_type;
22 g_mgrh_psn_id              g_number_tab_type;
23 g_mgrh_trn_id              g_number_tab_type;
24 g_mgrh_asg_id              g_number_tab_type;
25 g_mgrh_wty_fk              g_varchar2_tab_type;
26 g_mgrh_date                g_date_tab_type;
27 g_mgrh_in_ind              g_number_tab_type;
28 g_mgrh_out_ind             g_number_tab_type;
29 g_mgrh_dir_ind             g_number_tab_type;
30 g_mgrh_dir_rec             g_number_tab_type;
31 g_mgrh_row_count           PLS_INTEGER;
32 
33 -- PLSQL table of tables representing database table
34 g_orgh_sup_org_id          g_number_tab_type;
35 g_orgh_psn_id              g_number_tab_type;
36 g_orgh_asg_id              g_number_tab_type;
37 g_orgh_wty_fk              g_varchar2_tab_type;
38 g_orgh_date                g_date_tab_type;
39 g_orgh_in_ind              g_number_tab_type;
40 g_orgh_out_ind             g_number_tab_type;
41 g_orgh_dir_ind             g_number_tab_type;
42 g_orgh_hdc_trn             g_number_tab_type;
43 g_orgh_fte_trn             g_number_tab_type;
44 g_orgh_row_count           PLS_INTEGER;
45 
46 
47 -- ----------------------------------------------------------------------------
48 -- Resets globals
49 -- ----------------------------------------------------------------------------
50 PROCEDURE initialize_globals IS
51 
52 BEGIN
53 
54   g_mgrh_row_count := 0;
55   g_orgh_row_count := 0;
56 
57 END initialize_globals;
58 
59 
60 -- ----------------------------------------------------------------------------
61 -- Deletes manager hierarchy transfers to be maintained incrementally
62 -- ----------------------------------------------------------------------------
63 PROCEDURE delete_transfers_mgrh(p_start_object_id   IN NUMBER,
64                                 p_end_object_id     IN NUMBER) IS
65 
66 BEGIN
67 
68   -- Delete primary assignment changes
69   DELETE FROM hri_mdp_mgrh_transfers_ct  mgrh_trn
70   WHERE mgrh_trn.rowid IN
71    (SELECT mgrh_trn2.rowid
72     FROM
73      hri_mdp_mgrh_transfers_ct  mgrh_trn2
74     ,hri_eq_sprvsr_hrchy_chgs   eq
75     WHERE mgrh_trn2.asg_assgnmnt_fk = eq.assignment_id
76     AND eq.person_id BETWEEN p_start_object_id AND p_end_object_id
77     AND mgrh_trn2.time_day_evt_fk >= eq.erlst_evnt_effective_date);
78 
79   -- Delete inherited secondary assignment changes
80   DELETE FROM hri_mdp_mgrh_transfers_ct  mgrh_trn
81   WHERE mgrh_trn.rowid IN
82    (SELECT mgrh_trn2.rowid
83     FROM
84      hri_mdp_mgrh_transfers_ct  mgrh_trn2
85     ,hri_eq_sprvsr_hrchy_chgs   eq
86     WHERE mgrh_trn2.per_person_trn_fk = eq.person_id
87     AND eq.person_id BETWEEN p_start_object_id AND p_end_object_id
88     AND mgrh_trn2.time_day_evt_fk >= eq.erlst_evnt_effective_date);
89 
90 END delete_transfers_mgrh;
91 
92 -- ----------------------------------------------------------------------------
93 -- Deletes transfers to be maintained incrementally
94 -- ----------------------------------------------------------------------------
95 PROCEDURE delete_transfers(p_start_object_id   IN NUMBER,
96                            p_end_object_id     IN NUMBER) IS
97 
98 BEGIN
99 
100   DELETE FROM hri_mdp_mgrh_transfers_ct  mgrh_trn
101   WHERE mgrh_trn.rowid IN
102    (SELECT mgrh_trn2.rowid
103     FROM
104      hri_mdp_mgrh_transfers_ct  mgrh_trn2
105     ,hri_eq_asgn_evnts          eq
106     WHERE mgrh_trn2.asg_assgnmnt_fk = eq.assignment_id
107     AND eq.assignment_id BETWEEN p_start_object_id AND p_end_object_id
108     AND mgrh_trn2.time_day_evt_fk >= eq.erlst_evnt_effective_date
109     AND mgrh_trn2.sec_asg_ind IS NULL);
110 
111   DELETE FROM hri_mdp_orgh_transfers_ct  orgh_trn
112   WHERE orgh_trn.rowid IN
113    (SELECT orgh_trn2.rowid
114     FROM
115      hri_mdp_orgh_transfers_ct  orgh_trn2
116     ,hri_eq_asgn_evnts          eq
117     WHERE orgh_trn2.asg_assgnmnt_fk = eq.assignment_id
118     AND eq.assignment_id BETWEEN p_start_object_id AND p_end_object_id
119     AND orgh_trn2.time_day_evt_fk >= eq.erlst_evnt_effective_date);
120 
121 END delete_transfers;
122 
123 
124 -- ----------------------------------------------------------------------------
125 -- Bulk inserts stored rows for all transfers
126 -- ----------------------------------------------------------------------------
127 PROCEDURE bulk_insert_transfers IS
128 
129   l_user_id        NUMBER;
130   l_current_time   DATE;
131 
132 BEGIN
133 
134   -- Insert manager hierarchy transfers
135   IF (g_mgrh_row_count > 0) THEN
136 
137     l_user_id := fnd_global.user_id;
138     l_current_time := SYSDATE;
139 
140     -- Insert rows all at once
141     -- Exception may occur if unique index is violated - it is possible
142     -- for a transfer to be picked up twice if it is part of two simultaneous
143     -- "team transfers" e.g. if 2 managers in a chain are simultaneously promoted,
144     -- the lower promotion occurring "within" the higher level one.
145     BEGIN
146 
147       FORALL i IN 1..g_mgrh_row_count
148         INSERT INTO hri_mdp_mgrh_transfers_ct
149          (mgr_sup_person_fk
150          ,mgr_sup_mngrsc_fk
151          ,per_person_fk
152          ,per_person_trn_fk
153          ,asg_assgnmnt_fk
154          ,ptyp_wrktyp_fk
155          ,time_day_evt_fk
156          ,transfer_in_ind
157          ,transfer_out_ind
158          ,direct_ind
159          ,direct_record_ind
160          ,last_update_date
161          ,last_update_login
162          ,last_updated_by
163          ,created_by
164          ,creation_date)
165           VALUES
166            (g_mgrh_sup_psn_id(i)
167            ,g_mgrh_sup_sc_fk(i)
168            ,g_mgrh_psn_id(i)
169            ,g_mgrh_trn_id(i)
170            ,g_mgrh_asg_id(i)
171            ,g_mgrh_wty_fk(i)
172            ,g_mgrh_date(i)
173            ,g_mgrh_in_ind(i)
174            ,g_mgrh_out_ind(i)
175            ,g_mgrh_dir_ind(i)
176            ,g_mgrh_dir_rec(i)
177            ,l_current_time
178            ,l_user_id
179            ,l_user_id
180            ,l_user_id
181            ,l_current_time);
182 
183     EXCEPTION WHEN OTHERS THEN
184 
185       -- Loop through inserting rows 1 at a time
186       -- Skip any exceptions that occur
187       FOR i IN 1..g_mgrh_row_count LOOP
188         BEGIN
189           INSERT INTO hri_mdp_mgrh_transfers_ct
190            (mgr_sup_person_fk
191            ,mgr_sup_mngrsc_fk
192            ,per_person_fk
193            ,per_person_trn_fk
194            ,asg_assgnmnt_fk
195            ,ptyp_wrktyp_fk
196            ,time_day_evt_fk
197            ,transfer_in_ind
198            ,transfer_out_ind
199            ,direct_ind
200            ,direct_record_ind
201            ,last_update_date
202            ,last_update_login
203            ,last_updated_by
204            ,created_by
205            ,creation_date)
206             VALUES
207              (g_mgrh_sup_psn_id(i)
208              ,g_mgrh_sup_sc_fk(i)
209              ,g_mgrh_psn_id(i)
210              ,g_mgrh_trn_id(i)
211              ,g_mgrh_asg_id(i)
212              ,g_mgrh_wty_fk(i)
213              ,g_mgrh_date(i)
214              ,g_mgrh_in_ind(i)
215              ,g_mgrh_out_ind(i)
216              ,g_mgrh_dir_ind(i)
217              ,g_mgrh_dir_rec(i)
218              ,l_current_time
219              ,l_user_id
220              ,l_user_id
221              ,l_user_id
222              ,l_current_time);
223         EXCEPTION WHEN OTHERS THEN
224           null;
225         END;
226       END LOOP;
227 
228     END;
229 
230     g_mgrh_row_count := 0;
231 
232   END IF;
233 
234   -- Insert organization hierarchy transfers
235   IF (g_orgh_row_count > 0) THEN
236 
237     l_user_id := fnd_global.user_id;
238     l_current_time := SYSDATE;
239 
240     FORALL i IN 1..g_orgh_row_count
241       INSERT INTO hri_mdp_orgh_transfers_ct
242        (org_sup_organztn_fk
243        ,per_person_fk
244        ,asg_assgnmnt_fk
245        ,ptyp_wrktyp_fk
246        ,time_day_evt_fk
247        ,transfer_in_ind
248        ,transfer_out_ind
249        ,direct_ind
250        ,headcount_trn
251        ,fte_trn
252        ,last_update_date
253        ,last_update_login
254        ,last_updated_by
255        ,created_by
256        ,creation_date)
257         VALUES
258          (g_orgh_sup_org_id(i)
259          ,g_orgh_psn_id(i)
260          ,g_orgh_asg_id(i)
261          ,g_orgh_wty_fk(i)
262          ,g_orgh_date(i)
263          ,g_orgh_in_ind(i)
264          ,g_orgh_out_ind(i)
265          ,g_orgh_dir_ind(i)
266          ,g_orgh_hdc_trn(i)
267          ,g_orgh_fte_trn(i)
268          ,l_current_time
269          ,l_user_id
270          ,l_user_id
271          ,l_user_id
272          ,l_current_time);
273 
274     g_orgh_row_count := 0;
275 
276   END IF;
277 
278 END bulk_insert_transfers;
279 
280 
281 -- ----------------------------------------------------------------------------
282 -- Inserts row into global pl/sql table
283 -- ----------------------------------------------------------------------------
284 PROCEDURE insert_mgrh_transfer_row(p_sup_person_id     IN NUMBER
285                                   ,p_sup_mngrsc_fk     IN NUMBER
286                                   ,p_trn_person_id     IN NUMBER
287                                   ,p_transferee_id     IN NUMBER
288                                   ,p_trn_assignment_id IN NUMBER
289                                   ,p_trn_wrktyp_fk     IN VARCHAR2
290                                   ,p_transfer_date     IN DATE
291                                   ,p_transfer_in_ind   IN NUMBER
292                                   ,p_transfer_out_ind  IN NUMBER
293                                   ,p_direct_ind        IN NUMBER
294                                   ,p_direct_rec        IN NUMBER) IS
295 
296 BEGIN
297 
298   -- Add row
299   g_mgrh_row_count := g_mgrh_row_count + 1;
300   g_mgrh_sup_psn_id(g_mgrh_row_count) := p_sup_person_id;
301   g_mgrh_sup_sc_fk(g_mgrh_row_count)  := p_sup_mngrsc_fk;
302   g_mgrh_psn_id(g_mgrh_row_count)     := p_trn_person_id;
303   g_mgrh_trn_id(g_mgrh_row_count)     := p_transferee_id;
304   g_mgrh_asg_id(g_mgrh_row_count)     := p_trn_assignment_id;
305   g_mgrh_wty_fk(g_mgrh_row_count)     := p_trn_wrktyp_fk;
306   g_mgrh_date(g_mgrh_row_count)       := p_transfer_date;
307   g_mgrh_in_ind(g_mgrh_row_count)     := p_transfer_in_ind;
308   g_mgrh_out_ind(g_mgrh_row_count)    := p_transfer_out_ind;
309   g_mgrh_dir_ind(g_mgrh_row_count)    := p_direct_ind;
310   g_mgrh_dir_rec(g_mgrh_row_count)    := p_direct_rec;
311 
312 END insert_mgrh_transfer_row;
313 
314 
315 -- ----------------------------------------------------------------------------
316 -- Inserts row into global pl/sql table
317 -- ----------------------------------------------------------------------------
318 PROCEDURE insert_orgh_transfer_row(p_sup_organization_id  IN NUMBER
319                                   ,p_trn_person_id        IN NUMBER
320                                   ,p_trn_assignment_id    IN NUMBER
321                                   ,p_trn_wrktyp_fk        IN VARCHAR2
322                                   ,p_transfer_date        IN DATE
323                                   ,p_transfer_in_ind      IN NUMBER
324                                   ,p_transfer_out_ind     IN NUMBER
325                                   ,p_direct_ind           IN NUMBER
326                                   ,p_hdc_trn              IN NUMBER
327                                   ,p_fte_trn              IN NUMBER) IS
328 
329 BEGIN
330 
331   -- Add row
332   g_orgh_row_count := g_orgh_row_count + 1;
333   g_orgh_sup_org_id(g_orgh_row_count) := p_sup_organization_id;
334   g_orgh_psn_id(g_orgh_row_count)     := p_trn_person_id;
335   g_orgh_asg_id(g_orgh_row_count)     := p_trn_assignment_id;
336   g_orgh_wty_fk(g_orgh_row_count)     := p_trn_wrktyp_fk;
337   g_orgh_date(g_orgh_row_count)       := p_transfer_date;
338   g_orgh_in_ind(g_orgh_row_count)     := p_transfer_in_ind;
342   g_orgh_fte_trn(g_orgh_row_count)    := p_fte_trn;
339   g_orgh_out_ind(g_orgh_row_count)    := p_transfer_out_ind;
340   g_orgh_dir_ind(g_orgh_row_count)    := p_direct_ind;
341   g_orgh_hdc_trn(g_orgh_row_count)    := p_hdc_trn;
343 
344 END insert_orgh_transfer_row;
345 
346 
347 -- ----------------------------------------------------------------------------
348 -- Processes supervisor change event to determine manager hierarchy transfers
349 -- ----------------------------------------------------------------------------
350 PROCEDURE process_mgrh_transfer(p_manager_from_id   IN NUMBER,
351                                 p_manager_to_id     IN NUMBER,
352                                 p_transfer_psn_id   IN NUMBER,
353                                 p_transfer_asg_id   IN NUMBER,
354                                 p_transfer_wty_fk   IN VARCHAR2,
355                                 p_transfer_date     IN DATE,
356                                 p_transfer_hdc      IN NUMBER,
357                                 p_transfer_fte      IN NUMBER) IS
358 
359   CURSOR chain_csr(v_person_id  IN NUMBER,
360                    v_date       IN DATE) IS
361   SELECT
362    suph.sup_person_id
363   ,chn.mgrs_mngrsc_pk
364   FROM
365    hri_cs_suph       suph
366   ,hri_cs_mngrsc_ct  chn
367   WHERE suph.sub_person_id = v_person_id
368   AND suph.sub_person_id = chn.mgrs_person_fk
369   AND v_date BETWEEN suph.effective_start_date
370              AND suph.effective_end_date
371   AND v_date BETWEEN chn.mgrs_date_start
372              AND chn.mgrs_date_end;
373 
374   l_chain_cache        g_chain_cache_type;
375   l_index              NUMBER;
376   l_transfer_in_ind    NUMBER;
377   l_transfer_out_ind   NUMBER;
378   l_node_sk            NUMBER;
379   l_direct_ind         NUMBER;
380 
381 BEGIN
382 
383   -- Populate cache with chain nodes before transfer
384   FOR mgr_from_rec IN chain_csr(p_manager_from_id, p_transfer_date - 1) LOOP
385     l_chain_cache(mgr_from_rec.sup_person_id).node_from_exists := TRUE;
386     l_chain_cache(mgr_from_rec.sup_person_id).node_from_sk := mgr_from_rec.mgrs_mngrsc_pk;
387     IF mgr_from_rec.sup_person_id = p_manager_from_id THEN
388       l_chain_cache(mgr_from_rec.sup_person_id).direct_node_before := 1;
389     ELSE
390       l_chain_cache(mgr_from_rec.sup_person_id).direct_node_before := 0;
391     END IF;
392   END LOOP;
393 
394   -- Populate cache with chain nodes after transfer
395   FOR mgr_to_rec IN chain_csr(p_manager_to_id, p_transfer_date) LOOP
396 
397     l_chain_cache(mgr_to_rec.sup_person_id).node_to_exists := TRUE;
398     l_chain_cache(mgr_to_rec.sup_person_id).node_to_sk := mgr_to_rec.mgrs_mngrsc_pk;
399     IF mgr_to_rec.sup_person_id = p_manager_to_id THEN
400       l_chain_cache(mgr_to_rec.sup_person_id).direct_node_after := 1;
401     ELSE
402       l_chain_cache(mgr_to_rec.sup_person_id).direct_node_after := 0;
403     END IF;
404   END LOOP;
405 
406   BEGIN
407     l_index := l_chain_cache.FIRST;
408   EXCEPTION WHEN OTHERS THEN
409     l_index := to_number(null);
410   END;
411 
412   WHILE l_index IS NOT NULL LOOP
413 
414     -- If node exists before and after transfer it is a transfer within
415     -- the hierarchy, so do not do anything
416     IF (l_chain_cache(l_index).node_from_exists AND
417         l_chain_cache(l_index).node_to_exists) THEN
418       null;
419 
420     ELSE
421 
422       -- If node exists before (but not after) then it is a transfer out
423       IF (l_chain_cache(l_index).node_from_exists) THEN
424 
425         l_transfer_in_ind  := 0;
426         l_transfer_out_ind := 1;
427         l_node_sk          := l_chain_cache(l_index).node_from_sk;
428         l_direct_ind       := l_chain_cache(l_index).direct_node_before;
429 
430       -- If node exists after (but not before) then it is a transfer in
431       ELSE
432 
433         l_transfer_in_ind  := 1;
434         l_transfer_out_ind := 0;
435         l_node_sk          := l_chain_cache(l_index).node_to_sk;
436         l_direct_ind       := l_chain_cache(l_index).direct_node_after;
437 
438       END IF;
439 
440       -- Insert records for transfer person
441       insert_mgrh_transfer_row
442        (p_sup_person_id     => l_index
443        ,p_sup_mngrsc_fk     => l_node_sk
444        ,p_trn_person_id     => p_transfer_psn_id
445        ,p_transferee_id     => p_transfer_psn_id
446        ,p_trn_assignment_id => p_transfer_asg_id
447        ,p_trn_wrktyp_fk     => p_transfer_wty_fk
448        ,p_transfer_date     => p_transfer_date
449        ,p_transfer_in_ind   => l_transfer_in_ind
450        ,p_transfer_out_ind  => l_transfer_out_ind
451        ,p_direct_ind        => l_direct_ind
452        ,p_direct_rec        => 0);
453 
454     END IF;
455 
456     -- Filter out direct record transfers within
457     IF (l_chain_cache(l_index).direct_node_before = 1 AND
458         l_chain_cache(l_index).direct_node_after = 1) THEN
459 
460       null;
461 
462     ELSE
463 
464       -- If node is a direct manager before but not after it is a direct record transfer out
465       IF (l_chain_cache(l_index).direct_node_before = 1) THEN
466 
467         insert_mgrh_transfer_row
471          ,p_transferee_id     => p_transfer_psn_id
468          (p_sup_person_id     => l_index
469          ,p_sup_mngrsc_fk     => l_node_sk
470          ,p_trn_person_id     => p_transfer_psn_id
472          ,p_trn_assignment_id => p_transfer_asg_id
473          ,p_trn_wrktyp_fk     => p_transfer_wty_fk
474          ,p_transfer_date     => p_transfer_date
475          ,p_transfer_in_ind   => 0
476          ,p_transfer_out_ind  => 1
477          ,p_direct_ind        => 1
478          ,p_direct_rec        => 1);
479 
480       -- If node is a direct manager after but not before it is a direct record transfer in
481       ELSIF (l_chain_cache(l_index).direct_node_after = 1) THEN
482 
483         insert_mgrh_transfer_row
484          (p_sup_person_id     => l_index
485          ,p_sup_mngrsc_fk     => l_node_sk
486          ,p_trn_person_id     => p_transfer_psn_id
487          ,p_transferee_id     => p_transfer_psn_id
488          ,p_trn_assignment_id => p_transfer_asg_id
489          ,p_trn_wrktyp_fk     => p_transfer_wty_fk
490          ,p_transfer_date     => p_transfer_date
491          ,p_transfer_in_ind   => 1
492          ,p_transfer_out_ind  => 0
493          ,p_direct_ind        => 1
494          ,p_direct_rec        => 1);
495 
496       END IF;
497 
498     END IF;
499 
500     l_index := l_chain_cache.NEXT(l_index);
501 
502   END LOOP;
503 
504 END process_mgrh_transfer;
505 
506 
507 -- ----------------------------------------------------------------------------
508 -- Processes organization change event to determine org hierarchy transfers
509 -- ----------------------------------------------------------------------------
510 PROCEDURE process_orgh_transfer(p_organization_from_id  IN NUMBER,
511                                 p_organization_to_id    IN NUMBER,
512                                 p_transfer_psn_id       IN NUMBER,
513                                 p_transfer_asg_id       IN NUMBER,
514                                 p_transfer_wty_fk       IN VARCHAR2,
515                                 p_transfer_date         IN DATE,
516                                 p_transfer_hdc          IN NUMBER,
517                                 p_transfer_fte          IN NUMBER) IS
518 
519   CURSOR chain_csr(v_organization_id  IN NUMBER) IS
520   SELECT
521    orgh_sup_organztn_fk
522   ,orgh_relative_level
523   FROM hri_cs_orgh_ct
524   WHERE orgh_organztn_fk = v_organization_id;
525 
526   l_chain_cache    g_chain_cache_type;
527   l_index          NUMBER;
528 
529 BEGIN
530 
531   -- Populate cache with chain nodes before transfer
532   FOR org_from_rec IN chain_csr(p_organization_from_id) LOOP
533     l_chain_cache(org_from_rec.orgh_sup_organztn_fk).node_from_exists := TRUE;
534     IF org_from_rec.orgh_relative_level = 1 THEN
535       l_chain_cache(org_from_rec.orgh_sup_organztn_fk).direct_node_before := 1;
536     ELSE
537       l_chain_cache(org_from_rec.orgh_sup_organztn_fk).direct_node_before := 0;
538     END IF;
539   END LOOP;
540 
541   -- Populate cache with chain nodes after transfer
542   FOR org_to_rec IN chain_csr(p_organization_to_id) LOOP
543     l_chain_cache(org_to_rec.orgh_sup_organztn_fk).node_to_exists := TRUE;
544     IF org_to_rec.orgh_relative_level = 1 THEN
545       l_chain_cache(org_to_rec.orgh_sup_organztn_fk).direct_node_after := 1;
546     ELSE
547       l_chain_cache(org_to_rec.orgh_sup_organztn_fk).direct_node_after := 0;
548     END IF;
549   END LOOP;
550 
551   l_index := l_chain_cache.FIRST;
552 
553   WHILE l_index IS NOT NULL LOOP
554 
555     -- If node exists before and after transfer it is a transfer within
556     -- the hierarchy, so do not do anything
557     IF (l_chain_cache(l_index).node_from_exists AND
558         l_chain_cache(l_index).node_to_exists) THEN
559       null;
560 
561     -- If node exists before (but not after) then it is a transfer out
562     ELSIF (l_chain_cache(l_index).node_from_exists) THEN
563 
564       insert_orgh_transfer_row
565        (p_sup_organization_id => l_index
566        ,p_trn_person_id       => p_transfer_psn_id
567        ,p_trn_assignment_id   => p_transfer_asg_id
568        ,p_trn_wrktyp_fk       => p_transfer_wty_fk
569        ,p_transfer_date       => p_transfer_date
570        ,p_transfer_in_ind     => 0
571        ,p_transfer_out_ind    => 1
572        ,p_direct_ind          => l_chain_cache(l_index).direct_node_before
573        ,p_hdc_trn             => p_transfer_hdc
574        ,p_fte_trn             => p_transfer_fte);
575 
576     -- If node exists after (but not before) then it is a transfer in
577     ELSE
578 
579       insert_orgh_transfer_row
580        (p_sup_organization_id => l_index
581        ,p_trn_person_id       => p_transfer_psn_id
582        ,p_trn_assignment_id   => p_transfer_asg_id
583        ,p_trn_wrktyp_fk       => p_transfer_wty_fk
584        ,p_transfer_date       => p_transfer_date
585        ,p_transfer_in_ind     => 1
586        ,p_transfer_out_ind    => 0
587        ,p_direct_ind          => l_chain_cache(l_index).direct_node_after
588        ,p_hdc_trn             => p_transfer_hdc
589        ,p_fte_trn             => p_transfer_fte);
590 
591     END IF;
592 
593     l_index := l_chain_cache.NEXT(l_index);
594 
595   END LOOP;
596 
597 EXCEPTION WHEN OTHERS THEN
598 
599   null;
600 
601 END process_orgh_transfer;
602 
603 END hri_opl_wrkfc_trnsfr_events;