DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGS_HE_EXTRACT2_PKG

Source


1 PACKAGE BODY IGS_HE_EXTRACT2_PKG AS
2 /* $Header: IGSHE9BB.pls 120.15 2006/09/21 23:56:26 jbaber noship $ */
3 
4    -- Variables that will be accessed by any or all the procedures
5    -- Extract related records
6    g_he_ext_run_dtls                      igs_he_ext_run_dtls%ROWTYPE;
7    g_he_ext_run_except                    igs_he_ext_run_excp%ROWTYPE;
8    g_he_submsn_return                     igs_he_submsn_return%ROWTYPE;
9    g_he_submsn_header                     igs_he_submsn_header%ROWTYPE;
10 
11    -- Student / Module related records.
12    g_en_stdnt_ps_att                      igs_en_stdnt_ps_att%ROWTYPE;
13    g_he_st_spa                            igs_he_st_spa%ROWTYPE;
14    g_as_su_setatmpt                       igs_as_su_setatmpt%ROWTYPE;
15    g_he_en_susa                           igs_he_en_susa%ROWTYPE;
16    g_he_st_prog                           igs_he_st_prog%ROWTYPE;
17    g_ps_ver                               igs_ps_ver%ROWTYPE;
18    g_ps_type                              igs_ps_type_all%ROWTYPE;
19    g_ps_ofr_opt                           igs_ps_ofr_opt%ROWTYPE;
20    g_he_poous                             igs_he_poous%ROWTYPE;
21    g_pe_person                            igs_pe_person%ROWTYPE;
22    g_pe_stat_v                            igs_pe_stat_v%ROWTYPE;
23    g_he_ad_dtl                            igs_he_ad_dtl%ROWTYPE;
24    g_he_st_unt_vs                         igs_he_st_unt_vs%ROWTYPE;
25    g_ps_unit_ver_v                        igs_ps_unit_ver_v%ROWTYPE;
26    g_default_pro                          VARCHAR2(1);
27    g_he_stdnt_dlhe                        igs_he_stdnt_dlhe%ROWTYPE ;
28    l_hesa_method      igs_he_ex_rn_dat_fd.value%TYPE;
29    l_hesa_empcir      igs_he_ex_rn_dat_fd.value%TYPE;
30    l_hesa_modstudy    igs_he_ex_rn_dat_fd.value%TYPE;
31    l_hesa_natstudy    igs_he_ex_rn_dat_fd.value%TYPE;
32    l_hesa_empcrse     igs_he_ex_rn_dat_fd.value%TYPE;
33    l_hesa_prevemp     igs_he_ex_rn_dat_fd.value%TYPE;
34    l_hesa_tchemp      igs_he_ex_rn_dat_fd.value%TYPE;
35    g_field_exists       BOOLEAN;
36    g_prog_rec_flag      BOOLEAN; -- used as a flag to check whether to search igs_he_submsn_awd table
37    g_prog_type_rec_flag BOOLEAN; -- used as a flag to check whether to search igs_he_submsn_awd table
38    l_awd_conf_start_dt DATE;
39    l_awd_conf_end_dt DATE;
40    -- PL/SQL table to hold award conferral dates for a submission
41    g_awd_table        igs_he_extract_fields_pkg.awd_table;
42 
43    -- Index Table to hold the field definitions.
44    TYPE fldnum IS TABLE OF igs_he_usr_rt_cl_fld.field_number%TYPE
45         INDEX BY binary_integer;
46    TYPE constval IS TABLE OF igs_he_usr_rt_cl_fld.constant_val%TYPE
47         INDEX BY binary_integer;
48    TYPE defval IS TABLE OF igs_he_usr_rt_cl_fld.default_val%TYPE
49         INDEX BY binary_integer;
50    TYPE reportnullflag IS TABLE OF igs_he_usr_rt_cl_fld.report_null_flag%TYPE
51         INDEX BY binary_integer;
52    TYPE value IS TABLE OF igs_he_ex_rn_dat_fd.value%TYPE
53         INDEX BY binary_integer;
54 
55    TYPE field_defn IS RECORD
56       (field_number             fldnum,
57        constant_val             constval,
58        default_val              defval,
59        report_null_flag         reportnullflag,
60        hesa_value               value,
61        oss_value                value);
62 
63    g_field_defn        field_defn;
64 
65    g_msg_ext_fld_val_null VARCHAR2(2000);
66 
67    -- Structure to hold cost centres
68    g_cc_rec           igs_he_extract_fields_pkg.cc_rec;
69    g_total_ccs        NUMBER;
70 
71    -- Structure to hold Modules
72    g_mod_rec          igs_he_extract_fields_pkg.mod_rec;
73    g_total_mod        NUMBER;
74 
75    /*----------------------------------------------------------------------
76    This procedures writes onto the log file
77    ----------------------------------------------------------------------*/
78    PROCEDURE write_to_log(p_message    IN VARCHAR2)
79    IS
80    BEGIN
81 
82       Fnd_File.Put_Line(Fnd_File.Log, p_message);
83 
84    END write_to_log;
85 
86    --smaddali added this new local procedure for bug 2452592 to calculte field 76
87   PROCEDURE get_pgce_subj
88           (p_person_id             IN  igs_pe_person.person_id%TYPE,
89            p_pgce_subj             OUT NOCOPY VARCHAR2) IS
90  /***************************************************************
91    Created By           :       bayadav
92    Date Created By      :       25-Mar-2002
93    Purpose              :This procedure gets the subject of the previous qualification which
94       is also defined as the 1t qualification in igs_he_code_values for code_type 'OSS_QUAL_1ST_DEGREE'
95         The govt field of study for the subject is returned
96    Known Limitations,Enhancements or Remarks:
97    Change History       :
98    Who                  When            What
99    smaddali 19-jul-02  Included new procedure get_pgce_subj as a part  of bug 2452592
100   smaddali modified cursor c_subject for bug 2730388
101  ***************************************************************/
102 
103    --Cursor to  get the subject of the previous qualification which is defined as OSS_QUAL_1ST_DEGREE
104    -- smaddali modified cursor to get only open code_values ,bug 2730388
105    CURSOR c_subject IS
106    SELECT  a.subject_code
107    FROM   igs_uc_qual_dets a
108    WHERE  a.person_id = p_person_id
109    AND    EXISTS (SELECT 'X'
110                   FROM   igs_he_code_values b
111                   WHERE  b.value = a.exam_level
112                   AND    b.code_type = 'OSS_QUAL_1ST_DEGREE'
113                   AND    NVL(b.closed_ind,'N') = 'N' )
114    ORDER BY a.year DESC;
115 
116     -- get the govt field of study for the subject
117    CURSOR c_field_of_study(p_subject  igs_he_poous_ou_cc.subject%TYPE) IS
118    SELECT govt_field_of_study
119    FROM   IGS_PS_FLD_OF_STUDY PFS
120    WHERE  field_of_study = p_subject;
121 
122    l_subject igs_uc_qual_dets.subject_code%TYPE  ;
123 
124   BEGIN
125 l_subject := NULL;
126           OPEN c_subject ;
127           FETCH c_subject INTO l_subject ;
128           IF c_subject%FOUND THEN
129                OPEN c_field_of_study(l_subject) ;
130                FETCH c_field_of_study INTO p_pgce_subj ;
131                CLOSE c_field_of_study ;
132           ELSE
133               p_pgce_subj := NULL ;
134           END IF ;
135           CLOSE c_subject ;
136 
137   EXCEPTION
138       WHEN OTHERS
139       THEN
140           write_to_log (SQLERRM);
141           -- close open cursors
142           IF c_subject%ISOPEN THEN
143               CLOSE c_subject ;
144           END IF ;
145           IF c_field_of_study%ISOPEN THEN
146               CLOSE c_field_of_study ;
147           END IF ;
148 
149           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
150           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT_FIELDS_PKG.get_pgce_subj');
151           IGS_GE_MSG_STACK.ADD;
152           App_Exception.Raise_Exception;
153 
154   END get_pgce_subj ;
155 
156 
157 
158    /*----------------------------------------------------------------------
159    This procedure is called to fetch the data from the HESA mapping
160    table. It is used to either get a HESA equivalent value for an OSS
161    value or to derive one OSS value dependent on another.
162 
163    Parameters :
164    p_he_code_map_val   IN     Record containing the association codes
165                               and any other value from which the new value
166                               needs to be derived
167    p_value_from        IN     Column name of what to select from
168                               E.g 'map1' or 'map2' etc.
169    p_return_value      OUT NOCOPY Return Value
170 
171    Change History :
172    Who                  When            What
173    jchakrab        05-FEB-2005        Modified for 4006205 - SQL queries using literals have been
174                                       modified to use bind variables.
175                                       Added new internal procedure - get_map_values_from_SQL()
176    ----------------------------------------------------------------------*/
177    PROCEDURE get_map_values
178                  (p_he_code_map_val   IN     igs_he_code_map_val%ROWTYPE,
179                   p_value_from        IN     VARCHAR2,
180                   p_return_value      OUT NOCOPY igs_he_code_map_val.map1%TYPE)
181    IS
182 
183    CURSOR cur_map1 (p_assoc igs_he_code_map_val.association_code%TYPE ,
184                      p_map2 igs_he_code_map_val.map2%TYPE ) IS
185      SELECT  map1
186      FROM    igs_he_code_map_val
187      WHERE   association_code = p_assoc
188      AND     map2  = p_map2;
189 
190    CURSOR cur_map2 (p_assoc igs_he_code_map_val.association_code%TYPE ,
191                      p_map1 igs_he_code_map_val.map1%TYPE ) IS
192      SELECT  map2
193      FROM    igs_he_code_map_val
194      WHERE   association_code = p_assoc
195      AND     map1  = p_map1;
196 
197    CURSOR cur_map3 (p_assoc igs_he_code_map_val.association_code%TYPE ,
198                      p_map2 igs_he_code_map_val.map2%TYPE ) IS
199      SELECT  map3
200      FROM    igs_he_code_map_val
201      WHERE   association_code = p_assoc
202      AND     map2  = p_map2;
203 
204    CURSOR cur_map4 (p_assoc igs_he_code_map_val.association_code%TYPE ,
205                      p_map2 igs_he_code_map_val.map2%TYPE,
206                      p_map3 igs_he_code_map_val.map3%TYPE ) IS
207      SELECT  map1
208      FROM    igs_he_code_map_val
209      WHERE   association_code = p_assoc
210      AND     map2  = p_map2
211      AND     map3  = p_map3;
212 
213    CURSOR cur_map5 (p_assoc igs_he_code_map_val.association_code%TYPE ,
214                      p_map2 igs_he_code_map_val.map2%TYPE,
215                      p_map3 igs_he_code_map_val.map3%TYPE,
216                      p_map4 igs_he_code_map_val.map5%TYPE ) IS
217      SELECT  map1
218      FROM    igs_he_code_map_val
219      WHERE   association_code = p_assoc
220      AND     map2  = p_map2
221      AND     map3  = p_map3
222      AND     map4  = p_map4;
223 
224 
225    l_found_map                 BOOLEAN;
226 
227 
228    PROCEDURE get_map_values_from_sql(p_he_code_map_val   IN   igs_he_code_map_val%ROWTYPE,
229                                     p_value_from        IN   VARCHAR2,
230                                     p_return_value      OUT  NOCOPY igs_he_code_map_val.map1%TYPE)
231    IS
232 
233   /******************************************************************************
234     Created By      : JCHAKRAB
235     Date Created By : 09-FEB-2005
236     Purpose         : Created for 4006205 - HESA performance enhs.
237 
238                       As part of 4006205, the get_map_values() procedure was modified
239                       to prevent the use of literals in the SQL queries used for lookups.
240                       The modified procedure makes use of cursors to make use of
241                       bind variables for lookup queries. But the cursors added are limited
242                       to the various combinations of lookup queries being performed
243                       in the current HESA extraction code.
244 
245                       This procedure was added to make the modified get_map_values()
246                       procedure to be compatible with any kind of lookup performed.
247                       This procedure would only be called when none of the cursors
248                       defined in the get_map_values() procedure can be used to get
249                       a mapped value.
250 
251     Parameters :
252     p_he_code_map_val   IN     Record containing the association codes
253                                     and any other value from which the new value
254                                     needs to be derived
255     p_value_from        IN     Column name of what to select from
256                                     E.g 'map1' or 'map2' etc.
257     p_return_value      OUT NOCOPY Return Value
258 
259     Known limitations,enhancements,remarks:
260 
261     CHANGE HISTORY:
262      WHO        WHEN         WHAT
263 
264   ******************************************************************************/
265 
266   TYPE cur_mapval  IS REF CURSOR;
267       c_mapval                   cur_mapval;
268       l_sql_stmt                 VARCHAR2(2000);
269 
270 
271   BEGIN
272 
273         l_sql_stmt := ' SELECT '||p_value_from ||
274                            ' FROM igs_he_code_map_val '||
275                       ' WHERE association_code = '''||p_he_code_map_val.association_code ||'''';
276 
277         If p_he_code_map_val.map1 IS NOT NULL
278         THEN
279            l_sql_stmt := l_sql_stmt ||
280                          ' AND map1 = '''||p_he_code_map_val.map1||'''';
281         END IF;
282 
283         If p_he_code_map_val.map2 IS NOT NULL
284         THEN
285            l_sql_stmt := l_sql_stmt ||
286                          ' AND map2 = '''||p_he_code_map_val.map2||'''';
287         END IF;
288 
289         If p_he_code_map_val.map3 IS NOT NULL
290         THEN
291            l_sql_stmt := l_sql_stmt ||
292                          ' AND map3 = '''||p_he_code_map_val.map3||'''';
293         END IF;
294 
295         If p_he_code_map_val.map4 IS NOT NULL
296         THEN
297            l_sql_stmt := l_sql_stmt ||
298                          ' AND map4 = '''||p_he_code_map_val.map4||'''';
299         END IF;
300 
301         If p_he_code_map_val.map5 IS NOT NULL
302         THEN
303            l_sql_stmt := l_sql_stmt ||
304                          ' AND map5 = '''||p_he_code_map_val.map5||'''';
305         END IF;
306 
307         If p_he_code_map_val.map6 IS NOT NULL
308         THEN
309            l_sql_stmt := l_sql_stmt ||
310                          ' AND map6 = '''||p_he_code_map_val.map6||'''';
311         END IF;
312 
313         If p_he_code_map_val.map7 IS NOT NULL
314         THEN
315            l_sql_stmt := l_sql_stmt ||
316                          ' AND map7 = '''||p_he_code_map_val.map7||'''';
317         END IF;
318 
319         If p_he_code_map_val.map8 IS NOT NULL
320         THEN
321            l_sql_stmt := l_sql_stmt ||
322                          ' AND map8 = '''||p_he_code_map_val.map8||'''';
323         END IF;
324 
325         If p_he_code_map_val.map9 IS NOT NULL
326         THEN
327            l_sql_stmt := l_sql_stmt ||
328                          ' AND map9 = '''||p_he_code_map_val.map9||'''';
329         END IF;
330 
331         If p_he_code_map_val.map10 IS NOT NULL
332         THEN
333            l_sql_stmt := l_sql_stmt ||
334                          ' AND map10 = '''||p_he_code_map_val.map10||'''';
335         END IF;
336 
337             OPEN c_mapval FOR l_sql_stmt;
338             FETCH c_mapval INTO p_return_value;
339             CLOSE c_mapval;
340 
341         EXCEPTION
342         WHEN OTHERS
343         THEN
344             write_to_log(SQLERRM);
345 
346             -- Close cursor
347             IF c_mapval%ISOPEN
348             THEN
349                 CLOSE c_mapval;
350             END IF;
351 
352             Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
353             Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.get_map_values_from_sql');
354             IGS_GE_MSG_STACK.ADD;
355             App_Exception.Raise_Exception;
356 
357    END get_map_values_from_sql;
358 
359    BEGIN
360        l_found_map := FALSE;
361        IF p_value_from = 'MAP1' THEN
362            IF p_he_code_map_val.map2 IS NOT NULL and
363                p_he_code_map_val.map3 IS NOT NULL and
364                p_he_code_map_val.map4 IS NOT NULL THEN
365 
366                -- use cur_map5
367                OPEN cur_map5(p_he_code_map_val.association_code,
368                             p_he_code_map_val.map2,
369                             p_he_code_map_val.map3,
370                             p_he_code_map_val.map4);
371                FETCH cur_map5 INTO p_return_value;
372                CLOSE cur_map5;
373                l_found_map := TRUE;
374             ELSIF p_he_code_map_val.map2 IS NOT NULL and
375                p_he_code_map_val.map3 IS NOT NULL THEN
376 
377                -- use cur_map4
378                OPEN cur_map4(p_he_code_map_val.association_code,
379                             p_he_code_map_val.map2,
380                             p_he_code_map_val.map3);
381                FETCH cur_map4 INTO p_return_value;
382                CLOSE cur_map4;
383                l_found_map := TRUE;
384             ELSIF p_he_code_map_val.map2 IS NOT NULL THEN
385 
386                -- use cur_map1
387                OPEN cur_map1(p_he_code_map_val.association_code,
388                             p_he_code_map_val.map2);
389                FETCH cur_map1 INTO p_return_value;
390                CLOSE cur_map1;
391                l_found_map := TRUE;
392             END IF;
393        ELSIF p_value_from = 'MAP2' THEN
394            IF    p_he_code_map_val.map1 IS NOT NULL THEN
395                -- use cur_map2
396                OPEN cur_map2(p_he_code_map_val.association_code,
397                             p_he_code_map_val.map1);
398                FETCH cur_map2 INTO p_return_value;
399                CLOSE cur_map2;
400                l_found_map := TRUE;
401            END IF;
402       ELSIF p_value_from = 'MAP3' THEN
403            IF    p_he_code_map_val.map2 IS NOT NULL THEN
404                -- use cur_map3
405                OPEN cur_map3(p_he_code_map_val.association_code,
406                           p_he_code_map_val.map2);
407                FETCH cur_map3 INTO p_return_value;
408                CLOSE cur_map3;
409                l_found_map := TRUE;
410            END IF;
411        END IF;
412 
413        IF NOT l_found_map THEN
414            --use get_map_values_from_sql() to construct the map lookup query
415            get_map_values_from_sql(p_he_code_map_val, p_value_from, p_return_value);
416        END IF;
417 
418 
419    EXCEPTION
420       WHEN OTHERS
421       THEN
422           write_to_log(SQLERRM);
423 
424           -- Close cursors
425           IF cur_map1%ISOPEN
426           THEN
427               CLOSE cur_map1;
428           END IF;
429 
430           IF cur_map2%ISOPEN
431           THEN
432               CLOSE cur_map2;
433           END IF;
434 
435           IF cur_map3%ISOPEN
436           THEN
437               CLOSE cur_map3;
438           END IF;
439 
440           IF cur_map4%ISOPEN
441           THEN
442               CLOSE cur_map4;
443           END IF;
444 
445           IF cur_map5%ISOPEN
446           THEN
447               CLOSE cur_map5;
448           END IF;
449 
450           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
451           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.get_map_values');
452           IGS_GE_MSG_STACK.ADD;
453           App_Exception.Raise_Exception;
454 
455    END get_map_values;
456 
457    /*----------------------------------------------------------------------
458    This procedure is called to insert errors into the exception run
459    table. The Exception Run Report is run after the Generate Extract
460    process completes which reads the data from this table and prints the
461    report
462    The processing should not stop if any error is encountered unless it
463    is fatal.
464 
465    Parameters :
466    p_he_ext_run_exceptions     IN     Record which contains the values that
467                                       need to be inserted into the exception
468                                       table.
469                                       The field Exception_Reason should
470                                       contain the message text not the
471                                       message code.
472 
473    Change History :
474    Who                  When            What
475    jchakrab        05-FEB-2005        Modified for 4006205 - Removed Autonomous Transaction.
476                                       Replaced TBH call to insert_row() with direct DML.
477    ----------------------------------------------------------------------*/
478    PROCEDURE log_error
479              (p_he_ext_run_exceptions  IN OUT NOCOPY igs_he_ext_run_excp%ROWTYPE)
480    IS
481 
482    l_rowid VARCHAR2(30) ;
483    l_last_update_date           DATE;
484    l_last_updated_by            NUMBER;
485    l_last_update_login          NUMBER;
486 
487 
488    BEGIN
489 
490       l_rowid := NULL;
491 
492       l_last_update_date := SYSDATE;
493       l_last_updated_by := NVL(fnd_global.user_id, -1);
494       l_last_update_login := NVL(fnd_global.login_id, -1);
495 
496       --jchakrab - 4006205 - replace TBH with direct DML call
497       INSERT INTO igs_he_ext_run_excp (
498                           ext_exception_id,
499                           extract_run_id,
500                           person_id,
501                           person_number,
502                           course_cd,
503                           crv_version_number,
504                           unit_cd,
505                           uv_version_number,
506                           line_number,
507                           field_number,
508                           exception_reason,
509                           creation_date,
510                           created_by,
511                           last_update_date,
512                           last_updated_by,
513                           last_update_login
514                 ) VALUES (
515                           igs_he_ext_run_excp_s.NEXTVAL,
516                           p_he_ext_run_exceptions.Extract_Run_Id,
517                           p_he_ext_run_exceptions.Person_Id,
518                           p_he_ext_run_exceptions.Person_Number,
519                           p_he_ext_run_exceptions.Course_Cd,
520                           p_he_ext_run_exceptions.Crv_Version_Number,
521                           p_he_ext_run_exceptions.Unit_Cd,
522                           p_he_ext_run_exceptions.Uv_Version_Number,
523                           p_he_ext_run_exceptions.Line_Number,
524                           p_he_ext_run_exceptions.Field_Number,
525                           p_he_ext_run_exceptions.Exception_Reason,
526                           l_last_update_date,
527                           l_last_updated_by,
528                           l_last_update_date,
529                           l_last_updated_by,
530                           l_last_update_login
531                 );
532 
533 
534       EXCEPTION
535       WHEN OTHERS
536       THEN
537           write_to_log(SQLERRM);
538           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
539           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.log_error');
540           IGS_GE_MSG_STACK.ADD;
541           App_Exception.Raise_Exception;
542 
543    END log_error;
544 
545    /*----------------------------------------------------------------------
546    This procedure gets the field definitions and stores them into
547    a global array to be used when deriving the fields.
548 
549    Parameters :
550    p_extract_run_id     IN     The Extract Run Id
551 
552    Name       Date         Comments                                                                                                |
553    sjlaport   31 May 2005  Modified cursor c_fld_defn to select the mandatory_flag
554                            field from the system return class definition and to
555                            exclude fields not included in the user return class
556    jbaber     15 Mar 2006  Modified c_fld_defn to use report_null_flag instead of
557                            mandatory_flag as per HE365 - Extract Rerun
558    ----------------------------------------------------------------------*/
559    PROCEDURE get_field_defn
560           (p_extract_run_id IN igs_he_ext_run_dtls.extract_run_id%TYPE)
561    IS
562 
563    CURSOR c_ext_dtl IS
564    SELECT a.submission_name,
565           a.user_return_subclass,
566           a.return_name ,
567           a.extract_phase,
568           a.student_ext_run_id,
569           b.lrr_start_date,
570           b.lrr_end_date,
571           b.record_id,
572           c.enrolment_start_date,
573           c.enrolment_end_date,
574           c.offset_days ,
575           c.validation_country,
576           c.apply_to_atmpt_st_dt,
577           c.apply_to_inst_st_dt
578    FROM   igs_he_ext_run_dtls  a,
579           igs_he_submsn_return b,
580           igs_he_submsn_header c
581    WHERE  a.extract_run_id       = p_extract_run_id
582    AND    a.submission_name      = b.submission_name
583    AND    a.return_name          = b.return_name
584    AND    a.User_Return_Subclass = b.user_return_subclass
585    AND    a.submission_name      = c.submission_name;
586 
587    CURSOR c_fld_defn
588           (p_usr_return_subclass   igs_he_usr_rt_cl_fld.user_return_subclass%TYPE) IS
589    SELECT hefld.field_number,
590           hefld.constant_val,
591           hefld.default_val,
592           hefld.report_null_flag
593    FROM   igs_he_usr_rt_cl_fld hefld,
594           igs_he_usr_rtn_clas hecls
595    WHERE  hefld.user_return_subclass = p_usr_return_subclass
596    AND    hefld.user_return_subclass = hecls.user_return_subclass
597    AND    hefld.include_flag = 'Y';
598 
599 
600    l_message               VARCHAR2(2000);
601 
602    BEGIN
603 
604       -- Get the HESA Extract Details
605       OPEN c_ext_dtl;
606       FETCH c_ext_dtl INTO g_he_ext_run_dtls.submission_name,
607                            g_he_ext_run_dtls.user_return_subclass,
608                            g_he_ext_run_dtls.return_name ,
609                            g_he_ext_run_dtls.extract_phase,
610                            g_he_ext_run_dtls.student_ext_run_id,
611                            g_he_submsn_return.lrr_start_date,
612                            g_he_submsn_return.lrr_end_date,
613                            g_he_submsn_return.record_id,
614                            g_he_submsn_header.enrolment_start_date,
615                            g_he_submsn_header.enrolment_end_date,
616                            g_he_submsn_header.offset_days ,
617                            g_he_submsn_header.validation_country,
618                            g_he_submsn_header.apply_to_atmpt_st_dt,
619                            g_he_submsn_header.apply_to_inst_st_dt;
620       CLOSE c_ext_dtl;
621 
622       -- Now get the Fields for which extraction needs to be performed.
623       FOR l_fld_defn IN c_fld_defn (g_he_ext_run_dtls.user_return_subclass)
624       LOOP
625           -- Store the values in an array , where the index is the
626           -- field number
627           g_field_defn.field_number(l_fld_defn.field_number)     := l_fld_defn.field_number;
628           g_field_defn.constant_val(l_fld_defn.field_number)     := l_fld_defn.constant_val;
629           g_field_defn.default_val(l_fld_defn.field_number)      := l_fld_defn.default_val;
630           g_field_defn.report_null_flag(l_fld_defn.field_number) := l_fld_defn.report_null_flag;
631 
632       END LOOP;
633 
634       IF g_field_defn.field_number.COUNT = 0
635       THEN
636           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_FLDS_NOT_FOUND');
637           l_message := Fnd_Message.Get;
638           write_to_log(l_message);
639           -- Initialize Record to Null.
640           g_he_ext_run_except := NULL;
641 
642           -- Populate the required fields.
643           g_he_ext_run_except.extract_run_id   := p_extract_run_id;
644           g_he_ext_run_except.exception_reason := l_message;
645 
646           -- Call procedure to log error
647           log_error (g_he_ext_run_except);
648       END IF;
649 
650       EXCEPTION
651       WHEN OTHERS
652       THEN
653           write_to_log(SQLERRM);
654 
655           IF c_ext_dtl%ISOPEN
656           THEN
657               CLOSE c_ext_dtl;
658           END IF;
659 
660           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
661           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.get_field_defn');
662           IGS_GE_MSG_STACK.ADD;
663           App_Exception.Raise_Exception;
664 
665    END get_field_defn;
666 
667 
668    /*----------------------------------------------------------------------
669    This procedure gets values for the individual fields to be
670    submitted in the HESA COMBINED and STUDENT returns
671 
672    Parameters :
673    p_person_id              Person_id for the student
674    p_course_cd              Course Code that the student is attempting
675    p_crv_version_number     Version Number of the course code
676    p_student_inst_number    Student Instance Number
677    p_field_number           Field Number currently being processed.
678    p_value                  Calculated Value of the field.
679 
680       --changed the code for field 26  as a  part of HECR002.
681       --If IGS_HE_ST_SPA_ALL.commencement date is NOT NULL then  assign  IGS_HE_ST_SPA_ALL.commencement date to p_value
682       --elsif IGS_HE_ST_SPA_ALL.commencement date IS  NULL then  check if program transfer has taken palce
683       --If program transfer has taken place then assign get the value of first program in chain for that person
684       --(For the person having the same student instance number for the different program transfer are said to be in same chain)
685       --and assign the corresponding IGS_EN_STDNT_PS_ATT.commencement_dt value to it
686       --else if the program transfer has  not taken palce then get the IGS_EN_STDNT_PS_ATT.commencement_dt value
687       --of course in context and assign it to field
688    ----------------------------------------------------------------------*/
689    PROCEDURE process_comb_fields
690              (p_person_id           IN  igs_he_ex_rn_dat_ln.person_id%TYPE,
691               p_course_cd           IN   igs_he_ex_rn_dat_ln.course_cd%TYPE,
692               p_crv_version_number  IN   igs_he_ex_rn_dat_ln.crv_version_number%TYPE,
693               p_student_inst_number IN   igs_he_ex_rn_dat_ln.student_inst_number%TYPE,
694               p_field_number        IN   NUMBER,
695               p_value               IN OUT NOCOPY   igs_he_ex_rn_dat_fd.value%TYPE)
696 
697    IS
698   /***************************************************************
699    Created By           :
700    Date Created By      :
701    Purpose              :This procedure gets the value of combined fields
702    Known Limitations,Enhancements or Remarks:
703    Change History       :
704    Who                   When                   What
705    Bayadav   25-MAR-2002     Changed the code for field 26  as a  part of HECR002.
706    Bayadav   26-Mar-2002     Changed the code for field 74  as a  part of HECR001.
707    Bayadav   26-Mar-2002     Changed the code for field 101,104,107,113,116,119,122,125,128,131,137,140,143 and 146 as a part of HECR004 .
708    Bayadav   19-JUL-2002     Changed the call for IGS_HE_EXTRACT_FIELDS_PKG.get_year_of_student proc for fields 27 and 30 as per bug 2449010
709    smaddali  23-jul-02       modified field 76 to call new procedure for bug 2452592
710    Bayadav   24-OCt-02       modified the logic for field 148,4,33,43,44,45,46,49,50,153,6,14,17,27,29,
711                              34,36,42,83,84,85,54,55,56,57,58,59,60,61,62,63,78,155,156,161 as a part of HEFD101(2636897)
712 
713    Bayadav    02-DEC-02    Included 'WALES' also in the counrty list for field 155 as a part fo bug 2685091.Also made the default processing TRUE for other countries
714    smaddali   3-dec-2002   Modified field 169 to remove dependency on field 148 for bug 2663717
715    Bayadav    09-DEC-02    Modified code logic field 29 as a part of bug 2685091
716    Bayadav    12-DEC-02    Included exists clause field 148 as a part of bug 2706787
717    Bayadav    16-DEC-02    Changed the code for default Processing for field 83 and 161 as a part of bug 2710907
718    Bayadav    16-DEC-02    Included 2 new parameters in procedure get_rsn_inst_left for field combined/student field 33 as a part of bug 2702100
719    Bayadav    16-DEC-02    Included 2 new parameters in procedure get_qual_obtained  for field combined/student field 37 and 38,39  as a part of bug 2702117
720    Bayadav    17-DEC-02    Changed the defualt value processing for combined field 155 and student field 140 as a part of bug 2713527
721    Bayadav    17-DEC-02    Changed the default value processing for combined field  34,36,42,83,84,85 and student field 34,36,42,83,84,191 as a part of bug 2714418
722    smaddali  18-dec-2002   modified field 85 to give format mask 00000 ,bug 2714010
723    smaddali  25-aug-03     modified get_funding_src call to pass funding_source field for hefd208 - bug#2717751
724    rbezawad  17-Sep-03     Modified the derivation of field 19 logic w.r.t. UCFD210 Build, Bug 2893542
725    smaddali  13-oct-03     Modified calls to get_year_of_student to add 1 new parameter , for bug#3224246
726    uudayapr  02-nov-03     Modified get_inst_last_attended procedure by adding two new parameter.
727    smaddali  14-jan-04     Modified logic for field 19 for bug#3370979
728    jbaber    20-Sep-04     Modified as per HEFD350 - Statutory changes for 2004/05 Reporting
729                            Modified fields: 27, 30, 96, 97, 98, 99, 100
730                            Created fields:  206-226
731    jtmathew  01-Feb-05     Modified get_funding_src call to pass funding_source field at spa level -  bug#3962575
732  ***************************************************************/
733 
734 
735 
736      l_inst_id          igs_or_institution.govt_institution_cd%TYPE;
737      l_index            NUMBER;
738      l_dummy            VARCHAR2(50);
739      l_prop_not_taught  NUMBER ;
740      l_dummy1  igs_ps_fld_of_study.govt_field_of_study%TYPE;
741      l_dummy2  igs_ps_fld_of_study.govt_field_of_study%TYPE;
742      l_dummy3  igs_ps_fld_of_study.govt_field_of_study%TYPE;
743      l_fundlev igs_he_ex_rn_dat_fd.value%TYPE;
744      l_spcstu  igs_he_ex_rn_dat_fd.value%TYPE;
745      l_notact  igs_he_ex_rn_dat_fd.value%TYPE;
746      l_mode    igs_he_ex_rn_dat_fd.value%TYPE;
747      l_typeyr  igs_he_ex_rn_dat_fd.value%TYPE;
748      l_fmly_name igs_pe_person.surname%TYPE;
749      l_disadv_uplift_factor igs_he_st_spa.disadv_uplift_factor%TYPE;
750 
751      CURSOR c_subj(cp_field_of_study igs_ps_fld_of_study.field_of_study%TYPE)
752      IS
753      SELECT govt_field_of_study
754      FROM igs_ps_fld_of_study
755      WHERE field_of_study = cp_field_of_study;
756 
757 
758    BEGIN
759 
760       p_value := NULL;
761       g_default_pro := 'Y';
762       l_prop_not_taught := NULL ;
763       l_disadv_uplift_factor := NULL;
764 
765       IF      p_field_number = 1
766       THEN
767           -- Record Type Identifier
768           p_value := g_he_submsn_return.record_id;
769 
770       ELSIF  p_field_number = 2
771       THEN
772           -- Hesa Institution Id
773           igs_he_extract_fields_pkg.get_hesa_inst_id
774               (p_hesa_inst_id => p_value);
775 
776       ELSIF  p_field_number = 3
777       THEN
778           -- Campus Id
779           igs_he_extract_fields_pkg.get_campus_id
780               (p_location_cd => g_en_stdnt_ps_att.location_cd,
781                p_campus_id   => p_value);
782 
783       ELSIF  p_field_number = 4
784       THEN
785           -- Student Identifier
786           -- Pass in the Institution Id
787           IF g_field_defn.hesa_value.EXISTS(2)
788           THEN
789               l_inst_id := g_field_defn.hesa_value(2);
790           ELSE
791               l_inst_id := 0;
792           END IF;
793 
794           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
795           igs_he_extract_fields_pkg.get_stdnt_id
796               (p_person_id              => p_person_id,
797                p_inst_id                => l_inst_id,
798                p_stdnt_id               => p_value,
799                p_enrl_start_dt          =>  g_he_submsn_header.enrolment_start_date,
800                p_enrl_end_dt            =>  g_he_submsn_header.enrolment_end_date);
801 
802       ELSIF  p_field_number = 5
803       THEN
804           -- Scottish Candidate Number
805           IF g_he_st_spa.associate_scott_cand = 'Y'
806           THEN
807           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
808               igs_he_extract_fields_pkg.get_alt_pers_id
809                  (p_person_id           => p_person_id,
810                   p_id_type             => 'UCASREGNO',
811                   p_api_id              => p_value,
812                   p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
813                   p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date);
814           END IF;
815 
816       ELSIF  p_field_number = 6
817       THEN
818           -- FE Student Marker
819           -- First get the Funding Source
820           -- smaddali modified this call to pass funding_source field for hefd208 - bug#2717751
821           -- jtmathew modified this call to pass funding source from spa level - bug#3962575
822           igs_he_extract_fields_pkg.get_funding_src
823               (p_course_cd             => p_course_cd,
824                p_version_number        => p_crv_version_number,
825                p_spa_fund_src          => g_en_stdnt_ps_att.funding_source,
826                p_poous_fund_src        => g_he_poous.funding_source,
827                p_oss_fund_src          => g_field_defn.oss_value(64),
828                p_hesa_fund_src         => g_field_defn.hesa_value(64));
829 
830           -- Next get the Fundability Code
831           IF  g_field_defn.oss_value.EXISTS(64) THEN
832             -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
833             igs_he_extract_fields_pkg.get_fundability_cd
834               (p_person_id             => p_person_id,
835                p_susa_fund_cd          => g_he_en_susa.fundability_code,
836                p_spa_funding_source    => g_en_stdnt_ps_att.funding_source,
837                p_poous_fund_cd         => g_he_poous.fundability_cd,
838                p_prg_fund_cd           => g_he_st_prog.fundability,
839                p_prg_funding_source    => g_field_defn.oss_value(64),
840                p_oss_fund_cd           => g_field_defn.oss_value(65),
841                p_hesa_fund_cd          => g_field_defn.hesa_value(65),
842                p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
843                p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
844 
845           END IF;
846 
847           -- Now get the FE Student Marker
848           --Included new param validation_country as a part of HEFD101
849 
850           IF  g_he_submsn_header.validation_country IN  ('ENGLAND','WALES') AND g_field_defn.oss_value.EXISTS(64) AND g_field_defn.oss_value.EXISTS(65) THEN
851              igs_he_extract_fields_pkg.get_fe_stdnt_mrker
852               (p_spa_fe_stdnt_mrker    =>  g_he_st_spa.fe_student_marker,
853                p_fe_program_marker     =>  g_he_st_prog.fe_program_marker,
854                p_funding_src           =>  g_field_defn.oss_value(64),
855                p_fundability_cd        =>  g_field_defn.oss_value(65),
856                p_oss_fe_stdnt_mrker    =>  g_field_defn.oss_value(6),
857                p_hesa_fe_stdnt_mrker   =>  p_value);
858 
859            ELSE
860              g_default_pro := 'N';
861            END IF;
862 
863       ELSIF  p_field_number = 7
864       THEN
865           -- Family Name
866           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
867           -- smaddali added translate for bug#3223991
868           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
869           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
870           IF g_pe_person.given_names IS NULL
871           THEN
872               p_value := TRANSLATE( substr(g_pe_person.full_name,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a');
873               -- Set value of forename = '9'
874               g_field_defn.hesa_value(8) := '9';
875           ELSE
876               p_value := TRANSLATE( substr(g_pe_person.surname,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a');
877           END IF;
878 
879       ELSIF  p_field_number = 8
880       THEN
881           -- Forename
882           -- If value set earlier in field 7, use that
883           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
884           -- smaddali added translate for bug#3223991
885           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
886           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
887           IF g_field_defn.hesa_value.EXISTS(8)
888           THEN
889               IF g_field_defn.hesa_value(8) = '9'
890               THEN
891                    p_value := g_field_defn.hesa_value(8);
892               ELSE
893                    p_value := TRANSLATE( substr(g_pe_person.given_names,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a');
894               END IF;
895           ELSE
896               p_value := TRANSLATE( substr(g_pe_person.given_names,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a');
897           END IF;
898 
899 
900       ELSIF  p_field_number = 9
901       THEN
902           -- Family Name on 16th Birthday
903           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
904           l_fmly_name := NULL;
905           igs_he_extract_fields_pkg.get_fmly_name_on_16_bday
906               (p_person_id      => p_person_id,
907                p_fmly_name      => l_fmly_name,
908                p_enrl_start_dt  =>  g_he_submsn_header.enrolment_start_date,
909                p_enrl_end_dt    =>  g_he_submsn_header.enrolment_end_date);
910           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
911           -- smaddali added translate for bug#3223991
912           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
913           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
914           p_value := TRANSLATE( substr(l_fmly_name,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
915 
916       ELSIF  p_field_number = 10
917       THEN
918           -- Date of Birth
919           p_value := To_Char(g_pe_person.birth_dt, 'DD/MM/YYYY');
920 
921       ELSIF  p_field_number = 11
922       THEN
923           -- Gender
924           igs_he_extract_fields_pkg.get_gender
925               (p_gender           => g_pe_person.sex,
926                p_hesa_gender      => p_value);
927 
928       ELSIF  p_field_number = 12
929       THEN
930           -- Domicile
931           igs_he_extract_fields_pkg.get_domicile
932               (p_ad_domicile       => g_he_ad_dtl.domicile_cd,
933                p_spa_domicile      => g_he_st_spa.domicile_cd,
934                p_hesa_domicile     => p_value);
935 
936       ELSIF  p_field_number = 13
937       THEN
938           -- Nationality
939           -- smaddali 11-dec-03   Modified for bug#3235753 , added 1 new parameter
940           igs_he_extract_fields_pkg.get_nationality
941               (p_person_id         => p_person_id,
942                p_nationality       => p_value,
943                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date);
944 
945       -- Modified the field derivation to remove the reference of DOMICILE field (12)
946       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
947       ELSIF  p_field_number = 14
948       THEN
949          -- Ethnicity
950          igs_he_extract_fields_pkg.get_ethnicity (
951            p_person_id         => p_person_id,
952            p_oss_eth           => g_pe_stat_v.ethnic_origin_id,
953            p_hesa_eth          => p_value);
954 
955       ELSIF  p_field_number = 15
956       THEN
957           -- Disability Allowance
958           igs_he_extract_fields_pkg.get_disablity_allow
959               (p_oss_dis_allow     => g_he_en_susa.disability_allow,
960                p_hesa_dis_allow    => p_value);
961 
962       ELSIF  p_field_number = 16
963       THEN
964           -- Diability
965           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
966           igs_he_extract_fields_pkg.get_disablity
967               (p_person_id         => p_person_id,
968                p_disability        => p_value,
969                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
970                p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date);
971 
972       ELSIF  p_field_number = 17
973       THEN
974 
975          -- Additional Support Band
976          IF  ((g_field_defn.hesa_value.EXISTS(6) AND g_field_defn.hesa_value(6) IN (1,3))
977                AND   g_he_submsn_header.validation_country = 'ENGLAND') THEN
978 
979                igs_he_extract_fields_pkg.get_addnl_supp_band
980               (p_oss_supp_band     =>  g_he_en_susa.additional_sup_band,
981                p_hesa_supp_band    =>  p_value);
982           ELSE
983               p_value := NULL;
984               g_default_pro := 'N';
985           END IF;
986 
987       ELSIF  p_field_number = 18
988       THEN
989            -- Not Used
990            p_value := NULL;
991 
992       ELSIF  p_field_number = 19
993       THEN
994 
995           --Get the field 41 value - Qualification Aim
996           -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
997           igs_he_extract_fields_pkg.get_gen_qual_aim
998               (p_person_id           =>  p_person_id,
999                p_course_cd           =>  p_course_cd,
1000                p_version_number      =>  p_crv_version_number,
1001                p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
1002                p_hesa_gen_qaim       =>  g_field_defn.hesa_value(41),
1003                p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
1004                p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
1005                p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
1006 
1007           -- Get the field 70 value - Mode of Study
1008           igs_he_extract_fields_pkg.get_mode_of_study
1009               (p_person_id         =>  p_person_id,
1010                p_course_cd         =>  p_course_cd,
1011                p_version_number    =>  p_crv_version_number,
1012                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
1013                p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
1014                p_susa_study_mode   =>  g_he_en_susa.study_mode,
1015                p_poous_study_mode  =>  g_he_poous.mode_of_study,
1016                p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
1017                p_mode_of_study     =>  g_field_defn.hesa_value(70));
1018 
1019           -- Modified the derivation of this field to derive regardless of the value of the HESA MODE field (70)
1020           -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
1021 
1022           -- Get the field 148 value - UCAS NUM
1023           IF g_he_st_spa.associate_ucas_number = 'Y' THEN
1024             -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1025             igs_he_extract_fields_pkg.get_ucasnum
1026                (p_person_id             => p_person_id,
1027                 p_ucasnum               => g_field_defn.hesa_value(148),
1028                 p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
1029                 p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
1030             -- smaddali added else logic to create the table index for hesa_value(148), for bug#3370979
1031           ELSE
1032              g_field_defn.hesa_value(148) := NULL;
1033           END IF;
1034 
1035           IF  g_field_defn.hesa_value.EXISTS(148) AND g_field_defn.hesa_value.EXISTS(41) THEN
1036              -- Calculate the field 19 value - Year left last institution
1037              igs_he_extract_fields_pkg.get_yr_left_last_inst
1038               (p_person_id      => p_person_id,
1039                p_com_dt         => g_en_stdnt_ps_att.commencement_dt,
1040                p_hesa_gen_qaim  => g_field_defn.hesa_value(41),
1041                p_ucasnum        => g_field_defn.hesa_value(148),
1042                p_year           => p_value);
1043           END IF ;
1044 
1045       ELSIF  p_field_number = 20
1046       THEN
1047            -- Not Used
1048            p_value := NULL;
1049 
1050       ELSIF  p_field_number = 21
1051       THEN
1052           -- Highest Qualification on Entry
1053           p_value := g_he_st_spa.highest_qual_on_entry;
1054 
1055       ELSIF  p_field_number = 22
1056       THEN
1057            -- Not Used
1058            p_value := NULL;
1059 
1060       ELSIF  p_field_number = 23
1061       THEN
1062            -- Not Used
1063            p_value := NULL;
1064 
1065       ELSIF  p_field_number = 24
1066       THEN
1067            -- Not Used
1068            p_value := NULL;
1069 
1070       ELSIF  p_field_number = 25
1071       THEN
1072 
1073           -- Get the field 148 value - UCAS NUM
1074           IF NOT g_field_defn.hesa_value.EXISTS(148) THEN
1075              IF  g_he_st_spa.associate_ucas_number = 'Y' THEN
1076                igs_he_extract_fields_pkg.get_ucasnum
1077                   (p_person_id             => p_person_id,
1078                    p_ucasnum               => g_field_defn.hesa_value(148),
1079                    p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
1080                    p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
1081              ELSE
1082                g_field_defn.hesa_value(148) := NULL;
1083              END IF;
1084           END IF;
1085 
1086           -- sjlaporte use date comparison rather than text bug 3933715
1087           -- Occupation Code
1088           IF g_en_stdnt_ps_att.commencement_dt  <= TO_DATE('31/07/2002', 'DD/MM/YYYY')
1089              OR (g_field_defn.hesa_value(148) IS NOT NULL AND g_field_defn.hesa_value(148) BETWEEN '000000010' AND '019999999')
1090           THEN
1091               p_value := g_he_st_spa.occcode;
1092           ELSE
1093              p_value := NULL;
1094           END IF;
1095 
1096       ELSIF  p_field_number = 26
1097       THEN
1098          -- Commencement Date
1099          igs_he_extract_fields_pkg.get_commencement_dt( p_hesa_commdate         => g_he_st_spa.commencement_dt,
1100                                                         p_enstdnt_commdate      => g_en_stdnt_ps_att.commencement_dt,
1101                                                         p_person_id             => p_person_id ,
1102                                                         p_course_cd             => p_course_cd  ,
1103                                                         p_version_number        => p_crv_version_number,
1104                                                         p_student_inst_number   => p_student_inst_number,
1105                                                         p_final_commdate        => p_value );
1106 
1107       ELSIF  p_field_number = 27
1108       THEN
1109           -- New Entrant to HE
1110           -- smaddali removed the call to field 72 and added call to field30 for bug 2452551
1111           -- First get field 30, Year of student
1112 
1113          -- jbaber added p_susa_year_of_student for HEFD350
1114           igs_he_extract_fields_pkg.get_year_of_student
1115               (p_person_id            => p_person_id ,
1116                p_course_cd            => p_course_cd ,
1117                p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
1118                p_sequence_number      => g_as_su_setatmpt.sequence_number,
1119                p_year_of_student      => g_field_defn.hesa_value(30),
1120                p_enrl_end_dt          => g_he_submsn_header.enrolment_end_date,
1121                p_susa_year_of_student => g_he_en_susa.year_stu);
1122 
1123           --get field 41 value also first as it is required for  this calculation
1124                     -- Qualification Aim
1125           IF NOT g_field_defn.hesa_value.EXISTS(41) THEN
1126             -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
1127             igs_he_extract_fields_pkg.get_gen_qual_aim
1128               (p_person_id           =>  p_person_id,
1129                p_course_cd           =>  p_course_cd,
1130                p_version_number      =>  p_crv_version_number,
1131                p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
1132                p_hesa_gen_qaim       =>  g_field_defn.hesa_value(41),
1133                p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
1134                p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
1135                p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
1136           END IF ;
1137 
1138 
1139 
1140           -- Now calculate New Entrant to HE
1141           -- smaddali replaced the dependency on field 72 with field 30 for bug 2452551
1142           IF  g_field_defn.hesa_value.EXISTS(6)
1143           AND g_field_defn.hesa_value.EXISTS(21)
1144           AND g_field_defn.hesa_value.EXISTS(30)
1145           AND g_field_defn.hesa_value.EXISTS(12)
1146           AND
1147           (g_field_defn.hesa_value.EXISTS(41) and (
1148                                                     (g_field_defn.hesa_value(41) >= 02 and g_field_defn.hesa_value(41) <= 52)
1149                                                                                     OR
1150                                                      (g_field_defn.hesa_value(41) IN (61,62,97,98))
1151                                                    )
1152            )
1153           THEN
1154               igs_he_extract_fields_pkg.get_new_ent_to_he
1155                   (p_fe_stdnt_mrker        => g_field_defn.hesa_value(6),
1156                    p_susa_new_ent_to_he    => g_he_en_susa.new_he_entrant_cd,
1157                    p_yop                   => g_field_defn.hesa_value(30),
1158                    p_high_qual_on_ent      => g_field_defn.hesa_value(21),
1159                    p_domicile              => g_field_defn.hesa_value(12),
1160                    p_hesa_new_ent_to_he    => p_value);
1161 
1162 
1163             END IF;
1164 
1165             IF   (g_field_defn.hesa_value.EXISTS(41) and (
1166                                                     (g_field_defn.hesa_value(41) >= 02 and g_field_defn.hesa_value(41) <= 52)
1167                                                                                     OR
1168                                                      (g_field_defn.hesa_value(41) IN (61,62,97,98))
1169                                                    )  ) THEN
1170                   g_default_pro := 'Y' ;
1171              ELSE
1172                     -- The default value should not be calculated for  any other condition
1173                      g_default_pro := 'N' ;
1174              END IF;
1175 
1176       ELSIF  p_field_number = 28      THEN
1177           -- Special students
1178           igs_he_extract_fields_pkg.get_special_student
1179               (p_ad_special_student    => g_he_ad_dtl.special_student_cd,
1180                p_spa_special_student   => g_he_st_spa.special_student,
1181                p_oss_special_student   => g_field_defn.oss_value(28),
1182                p_hesa_special_student  => p_value);
1183 
1184       ELSIF  p_field_number = 29 THEN
1185          --get the quail1 field 37  and 38 value required in calculating field 29 value
1186          igs_he_extract_fields_pkg.get_qual_obtained
1187               (p_person_id        => p_person_id,
1188                p_course_cd        => p_course_cd,
1189                p_enrl_start_dt    => l_awd_conf_start_dt,
1190                p_enrl_end_dt      => l_awd_conf_end_dt,
1191                p_oss_qual_obt1    => g_field_defn.oss_value(37),
1192                p_oss_qual_obt2    => g_field_defn.oss_value(38),
1193                p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
1194                p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
1195                p_classification   => g_field_defn.hesa_value(39));
1196 
1197          --Calcualting field 53 fierst reuqured fro field 161 calcualtion
1198          -- Teacher Training Course Identifier
1199           igs_he_extract_fields_pkg.get_teach_train_crs_id
1200           (p_prg_ttcid            =>  g_he_st_prog.teacher_train_prog_id,
1201            p_spa_ttcid            =>  g_he_st_spa.teacher_train_prog_id,
1202            p_hesa_ttcid           =>  g_field_defn.hesa_value(53));
1203 
1204 
1205         --Calculating field 161 first required for field 29
1206         -- Outcome of ITT Program
1207 
1208        IF g_he_submsn_header.validation_country  IN   ('ENGLAND','WALES') THEN
1209                    igs_he_extract_fields_pkg.get_itt_outcome
1210                    (p_oss_itt_outcome     =>  g_he_st_spa.itt_prog_outcome,
1211                     p_teach_train_prg     =>  g_field_defn.hesa_value(53),
1212                     p_hesa_itt_outcome    =>  g_field_defn.hesa_value(161));
1213        END IF;
1214 
1215        --Set the default value of g_deafult_pro flag as N here as the default processing has to be done only in one case
1216        --for which it is done as written down
1217        g_default_pro := 'N' ;
1218 
1219      IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES','SCOTLAND') THEN
1220           -- Get the value
1221           IF g_he_st_spa.associate_teach_ref_num = 'Y'
1222           THEN
1223           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1224               igs_he_extract_fields_pkg.get_alt_pers_id
1225                   (p_person_id            => p_person_id,
1226                    p_id_type              => 'TEACH REF',
1227                    p_api_id               => p_value,
1228                    p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
1229                    p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date);
1230           END IF;
1231            --In case the value calculated above is NULL then calculate the defualt value
1232            IF p_value IS NULL THEN
1233              IF
1234               ( (g_field_defn.hesa_value.EXISTS(161)  AND   g_field_defn.hesa_value(161) = '1') OR
1235                 ((g_field_defn.hesa_value.EXISTS(53)  AND g_field_defn.hesa_value(53) IN (1,6,7)) AND
1236                   ((g_field_defn.hesa_value.EXISTS(37)  AND g_field_defn.hesa_value(37) = 20) OR
1237                    (g_field_defn.hesa_value.EXISTS(38)  AND g_field_defn.hesa_value(38) = 20))))  THEN
1238                       g_default_pro := 'Y' ;
1239              END IF;
1240            END IF;
1241        END IF;
1242 
1243 
1244 
1245 
1246       ELSIF  p_field_number = 30
1247       THEN
1248           -- Year of Student
1249           --smaddali added this check to see if it already is calculated
1250           -- because of bug 2452551 where field 30 is being calculated for field 27
1251           IF  g_field_defn.hesa_value.EXISTS(30)
1252           THEN
1253               -- Calculated earlier, for field 27
1254               p_value :=   g_field_defn.hesa_value(30);
1255 
1256           ELSE
1257 
1258             -- jbaber added p_susa_year_of_student for HEFD350
1259             igs_he_extract_fields_pkg.get_year_of_student
1260               (p_person_id            => p_person_id,
1261                p_course_cd            => p_course_cd,
1262                p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
1263                p_sequence_number      => g_as_su_setatmpt.sequence_number,
1264                p_year_of_student      => p_value,
1265                p_enrl_end_dt          => g_he_submsn_header.enrolment_end_date,
1266                p_susa_year_of_student => g_he_en_susa.year_stu);
1267 
1268           END IF ;
1269 
1270            --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
1271              p_value := LPAD(p_value, 2,'0') ;
1272 
1273 
1274 
1275 
1276       ELSIF  p_field_number = 31
1277       THEN
1278           -- Term Time Accomodation
1279           -- Calculate field 71, location of study first
1280           igs_he_extract_fields_pkg.get_study_location
1281               (p_susa_study_location    => g_he_en_susa.study_location,
1282                p_poous_study_location   => g_he_poous.location_of_study,
1283                p_prg_study_location     => g_he_st_prog.location_of_study,
1284                p_oss_study_location     => g_field_defn.oss_value(71),
1285                p_hesa_study_location    => g_field_defn.hesa_value(71));
1286 
1287           -- Next calcualte TTA
1288           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1289           igs_he_extract_fields_pkg.get_term_time_acc
1290               (p_person_id            =>  p_person_id,
1291                p_susa_term_time_acc   =>  g_he_en_susa.term_time_accom,
1292                p_study_location       =>  g_field_defn.oss_value(71),
1293                p_hesa_term_time_acc   =>  p_value,
1294                p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
1295                p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date);
1296 
1297       ELSIF  p_field_number = 32
1298       THEN
1299            -- Not Used
1300            p_value := NULL;
1301       ELSIF  p_field_number = 33
1302       THEN
1303 
1304           -- Reason for leaving institution
1305           igs_he_extract_fields_pkg.get_rsn_inst_left
1306               (p_person_id            => p_person_id,
1307                p_course_cd            => p_course_cd ,
1308                p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
1309                p_crs_req_comp_dt      => g_en_stdnt_ps_att.course_rqrmnts_complete_dt,
1310                p_disc_reason_cd       => g_en_stdnt_ps_att.discontinuation_reason_cd,
1311                p_disc_dt              => g_en_stdnt_ps_att.discontinued_dt,
1312                p_enrl_start_dt        => l_awd_conf_start_dt,
1313                p_enrl_end_dt          => l_awd_conf_end_dt,
1314                p_rsn_inst_left        => p_value);
1315 
1316       ELSIF  p_field_number = 34
1317       THEN
1318           --Defualt value processing to be done only if field 6 value is in 1,3,4
1319           g_default_pro:= 'N';
1320           -- Completion Status
1321           -- Need Field 6, FE Student Marker to be completed
1322            --smaddali added new parameter p_course_cd to this call for bug 2396174
1323           IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
1324           THEN
1325               -- Calculate Completion Status
1326               igs_he_extract_fields_pkg.get_completion_status
1327                   (p_person_id            => p_person_id,
1328                    p_course_cd            => p_course_cd ,
1329                    p_susa_comp_status     => g_he_en_susa.completion_status,
1330                    p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
1331                    p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
1332                    p_discont_date         => g_en_stdnt_ps_att.discontinued_dt,
1333                    p_hesa_comp_status     => p_value);
1334 
1335                g_default_pro:= 'Y';
1336           END IF;
1337 
1338       ELSIF  p_field_number = 35
1339       THEN -- DATELEFT - only report this field if SPA completed within current reporting period
1340 
1341           IF g_en_stdnt_ps_att.course_rqrmnt_complete_ind = 'Y'
1342           AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt <= g_he_submsn_header.enrolment_end_date
1343           THEN -- report Completion Date
1344               p_value := To_Char(g_en_stdnt_ps_att.course_rqrmnts_complete_dt, 'DD/MM/YYYY');
1345           ELSIF g_en_stdnt_ps_att.discontinued_dt IS NOT NULL
1346             AND g_en_stdnt_ps_att.discontinued_dt <= g_he_submsn_header.enrolment_end_date
1347           THEN -- report Discontinuation Date
1348               p_value := To_Char(g_en_stdnt_ps_att.discontinued_dt, 'DD/MM/YYYY');
1349           END IF;
1350 
1351       ELSIF  p_field_number = 36
1352       THEN
1353           --Defualt value processing to be done only if field 6 value is in 1,3,4
1354           g_default_pro:= 'N';
1355 
1356           -- Good Standing Marker
1357           IF g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
1358           THEN
1359               igs_he_extract_fields_pkg.get_good_stand_mrkr
1360                    (p_susa_good_st_mk      => g_he_en_susa.good_stand_marker,
1361                     p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
1362                     p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
1363                     p_discont_date         => g_en_stdnt_ps_att.discontinued_dt,
1364                     p_hesa_good_st_mk      => p_value);
1365               g_default_pro:= 'Y';
1366           END IF;
1367 
1368 
1369       ELSIF  p_field_number = 37
1370       THEN
1371           -- Qualification Obtained 1
1372           -- Get fields 37, 38 and 39 together.
1373           IF  g_field_defn.hesa_value.EXISTS(37)
1374           THEN
1375               p_value :=  g_field_defn.hesa_value(37);
1376           ELSE
1377             igs_he_extract_fields_pkg.get_qual_obtained
1378               (p_person_id        => p_person_id,
1379                p_course_cd        => p_course_cd,
1380                p_enrl_start_dt    => l_awd_conf_start_dt,
1381                p_enrl_end_dt      => l_awd_conf_end_dt,
1382                p_oss_qual_obt1    => g_field_defn.oss_value(37),
1383                p_oss_qual_obt2    => g_field_defn.oss_value(38),
1384                p_hesa_qual_obt1   => p_value,
1385                p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
1386                p_classification   => g_field_defn.hesa_value(39));
1387           END IF ;
1388 
1389       ELSIF  p_field_number = 38
1390       THEN
1391           -- Qualification Obtained 2
1392           -- If not calculated earlier, calculate now.
1393           IF  g_field_defn.hesa_value.EXISTS(38)
1394           THEN
1395               p_value :=  g_field_defn.hesa_value(38);
1396           ELSE
1397               igs_he_extract_fields_pkg.get_qual_obtained
1398                   (p_person_id        => p_person_id,
1399                    p_course_cd        => p_course_cd,
1400                  p_enrl_start_dt    => l_awd_conf_start_dt,
1401                  p_enrl_end_dt      => l_awd_conf_end_dt,
1402                    p_oss_qual_obt1    => g_field_defn.oss_value(37),
1403                    p_oss_qual_obt2    => g_field_defn.oss_value(38),
1404                    p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
1405                    p_hesa_qual_obt2   => p_value,
1406                    p_classification   => g_field_defn.hesa_value(39));
1407 
1408           END IF;
1409 
1410       ELSIF  p_field_number = 39
1411       THEN
1412           -- HESA Classification
1413           -- If not calculated earlier, calculate now.
1414           IF  g_field_defn.hesa_value.EXISTS(39)
1415           THEN
1416               p_value :=  g_field_defn.hesa_value(39);
1417           ELSE
1418               igs_he_extract_fields_pkg.get_qual_obtained
1419                   (p_person_id        => p_person_id,
1420                    p_course_cd        => p_course_cd,
1421                  p_enrl_start_dt    => l_awd_conf_start_dt,
1422                  p_enrl_end_dt      => l_awd_conf_end_dt,
1423                    p_oss_qual_obt1    => g_field_defn.oss_value(37),
1424                    p_oss_qual_obt2    => g_field_defn.oss_value(38),
1425                    p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
1426                    p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
1427                    p_classification   => p_value);
1428 
1429           END IF;
1430 
1431       ELSIF  p_field_number = 40
1432       THEN
1433           -- Program of Study Title
1434           p_value := g_ps_ver.title;
1435 
1436       ELSIF  p_field_number = 41
1437       THEN
1438 
1439           IF  g_field_defn.hesa_value.EXISTS(41)
1440           THEN
1441               -- Calculated earlier, for field 27
1442               p_value :=   g_field_defn.hesa_value(41);
1443 
1444           ELSE
1445 
1446           -- Qualification Aim
1447           -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
1448               igs_he_extract_fields_pkg.get_gen_qual_aim
1449                (p_person_id           =>  p_person_id,
1450                 p_course_cd           =>  p_course_cd,
1451                 p_version_number      =>  p_crv_version_number,
1452                 p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
1453                 p_hesa_gen_qaim       =>  p_value,
1454                 p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
1455                 p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
1456                 p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
1457 
1458           END IF;
1459 
1460       ELSIF  p_field_number = 42
1461       THEN
1462           --Defualt value processing to be done only if field 6 value is in 1,3,4
1463           g_default_pro:= 'N';
1464 
1465 
1466           -- FE General Qualification Aim
1467          IF g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
1468           THEN
1469               igs_he_extract_fields_pkg.get_fe_qual_aim
1470                    (p_spa_fe_qual_aim      => g_he_st_spa.student_fe_qual_aim,
1471                     p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
1472                     p_course_cd            => p_course_cd,
1473                     p_version_number       => p_crv_version_number,
1474                     p_hesa_fe_qual_aim     => p_value);
1475 
1476               g_default_pro:= 'Y';
1477          END IF;
1478 
1479 
1480       ELSIF  p_field_number = 43
1481       THEN
1482 
1483            -- Check for details at the SPA HESA Details level
1484            IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
1485                  OPEN c_subj(g_he_st_spa.qual_aim_subj1);
1486                  FETCH c_subj INTO p_value;
1487                  CLOSE c_subj;
1488            ELSE
1489              -- Qualification Aim, Subject 1
1490              igs_he_extract_fields_pkg.get_qual_aim_sbj
1491                (p_course_cd            => p_course_cd,
1492                 p_version_number       => p_crv_version_number,
1493                 p_subject1             => p_value,
1494                 p_subject2             => g_field_defn.hesa_value(44),
1495                 p_subject3             => g_field_defn.hesa_value(45),
1496                 p_prop_ind             => g_field_defn.hesa_value(46));
1497            END IF;
1498 
1499 
1500 
1501       ELSIF  p_field_number = 44
1502       THEN
1503 
1504             -- Check for details at the SPA HESA Details level
1505             IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
1506 
1507                 IF g_he_st_spa.qual_aim_subj2 IS NOT NULL THEN
1508                      OPEN c_subj(g_he_st_spa.qual_aim_subj2);
1509                      FETCH c_subj INTO p_value;
1510                      CLOSE c_subj;
1511                 ELSE
1512                     -- derive NULL as there is no value for subj2
1513                     p_value := NULL;
1514                 END IF;
1515 
1516            ELSE
1517 
1518               -- Qualification Aim, Subject 2
1519               IF g_field_defn.hesa_value.EXISTS(44)
1520               THEN
1521                  -- Calculated earlier..
1522                  p_value := g_field_defn.hesa_value(44);
1523               ELSE
1524                  -- Not calculated earlier, calculate now
1525                  igs_he_extract_fields_pkg.get_qual_aim_sbj
1526                   (p_course_cd         => p_course_cd,
1527                    p_version_number    => p_crv_version_number,
1528                    p_subject1          => l_dummy1,
1529                    p_subject2          => p_value,
1530                    p_subject3          => g_field_defn.hesa_value(45),
1531                    p_prop_ind          => g_field_defn.hesa_value(46));
1532               END IF;
1533 
1534            END IF;
1535 
1536 
1537       ELSIF  p_field_number = 45
1538       THEN
1539 
1540            -- Check for details at the SPA HESA Details level
1541            IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
1542 
1543                 IF g_he_st_spa.qual_aim_subj3 IS NOT NULL THEN
1544                     OPEN c_subj(g_he_st_spa.qual_aim_subj3);
1545                     FETCH c_subj INTO p_value;
1546                     CLOSE c_subj;
1547                 ELSE
1548                     -- derive NULL as there is no value for subj3
1549                     p_value := NULL;
1550                 END IF;
1551 
1552            ELSE
1553              -- Qualification Aim, Subject 3
1554              IF g_field_defn.hesa_value.EXISTS(45)
1555              THEN
1556                  -- Calculated earlier..
1557                  p_value := g_field_defn.hesa_value(45);
1558              ELSE
1559                  -- Not calculated earlier, calculate now
1560                  igs_he_extract_fields_pkg.get_qual_aim_sbj
1561                   (p_course_cd         => p_course_cd,
1562                    p_version_number    => p_crv_version_number,
1563                    p_subject1          => l_dummy1,
1564                    p_subject2          => l_dummy2,
1565                    p_subject3          => p_value,
1566                    p_prop_ind          => g_field_defn.hesa_value(46));
1567              END IF;
1568            END IF;
1569 
1570       ELSIF  p_field_number = 46
1571       THEN
1572 
1573           IF g_he_st_spa.qual_aim_subj1 IS NOT NULL OR
1574              g_he_st_spa.qual_aim_proportion IS NOT NULL OR
1575              g_he_st_spa.qual_aim_subj2 IS NOT NULL OR
1576              g_he_st_spa.qual_aim_subj3 IS NOT NULL
1577           THEN
1578 
1579               igs_he_extract_fields_pkg.get_qual_aim_sbj1(
1580                      p_qual_aim_subj1    => g_he_st_spa.qual_aim_subj1,
1581                      p_qual_aim_subj2    => g_he_st_spa.qual_aim_subj2,
1582                      p_qual_aim_subj3    => g_he_st_spa.qual_aim_subj3,
1583                      p_oss_qualaim_sbj   => g_he_st_spa.qual_aim_proportion,
1584                      p_hesa_qualaim_sbj  => p_value);
1585 
1586           ELSE
1587                   -- Proportion Indicator
1588                   IF g_field_defn.hesa_value.EXISTS(46)
1589                   THEN
1590                       -- Calculated earlier..
1591                       p_value := g_field_defn.hesa_value(46);
1592                   ELSE
1593                       -- Not calculated earlier, calculate now
1594                       igs_he_extract_fields_pkg.get_qual_aim_sbj
1595                           (p_course_cd         => p_course_cd,
1596                            p_version_number    => p_crv_version_number,
1597                            p_subject1          => l_dummy1,
1598                            p_subject2          => l_dummy2,
1599                            p_subject3          => l_dummy3,
1600                            p_prop_ind          => p_value);
1601                   END IF;
1602           END IF;
1603 
1604       ELSIF  p_field_number = 47
1605       THEN
1606           -- Awarding Body 1
1607           IF  g_field_defn.oss_value.EXISTS(37)
1608           AND g_field_defn.oss_value.EXISTS(38)
1609           THEN
1610               igs_he_extract_fields_pkg.get_awd_body_12
1611                   (p_course_cd         =>  p_course_cd,
1612                    p_version_number    =>  p_crv_version_number,
1613                    p_awd1              =>  g_field_defn.oss_value(37),
1614                    p_awd2              =>  g_field_defn.oss_value(38),
1615                    p_awd_body1         =>  p_value,
1616                    p_awd_body2         =>  g_field_defn.hesa_value(48));
1617 
1618           END IF;
1619 
1620       ELSIF  p_field_number = 48
1621       THEN
1622           -- Awarding Body 2
1623           IF g_field_defn.hesa_value.EXISTS(48)
1624           THEN
1625               -- Calculated earlier for field 47..
1626               p_value := g_field_defn.hesa_value(48);
1627           ELSIF  g_field_defn.oss_value.EXISTS(37)
1628           AND    g_field_defn.oss_value.EXISTS(38)
1629           THEN
1630               -- Not calculated therefore calculate.
1631               igs_he_extract_fields_pkg.get_awd_body_12
1632                   (p_course_cd         =>  p_course_cd,
1633                    p_version_number    =>  p_crv_version_number,
1634                    p_awd1              =>  g_field_defn.oss_value(37),
1635                    p_awd2              =>  g_field_defn.oss_value(38),
1636                    p_awd_body1         =>  g_field_defn.hesa_value(47),
1637                    p_awd_body2         =>  p_value);
1638 
1639           END IF;
1640 
1641       ELSIF  p_field_number = 49
1642       THEN
1643           -- Length of Program
1644           igs_he_extract_fields_pkg.get_new_prog_length
1645           (p_spa_attendance_type           =>  g_en_stdnt_ps_att.attendance_type,
1646            p_program_length                => g_ps_ofr_opt.program_length,
1647            p_program_length_measurement    => g_ps_ofr_opt.program_length_measurement,
1648            p_length                        =>  p_value,
1649            p_units                         =>  g_field_defn.hesa_value(50));
1650 
1651 
1652             --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
1653             p_value := LPAD(p_value, 2,'0') ;
1654 
1655       ELSIF  p_field_number = 50
1656       THEN
1657 
1658           -- Units of length of Program
1659         IF g_field_defn.hesa_value.EXISTS(50)
1660         THEN
1661            -- Calculated Earlier ..
1662            p_value := g_field_defn.hesa_value(50);
1663         ELSE
1664            -- Not calculated earlier ..
1665            igs_he_extract_fields_pkg.get_new_prog_length
1666           (p_spa_attendance_type           =>  g_en_stdnt_ps_att.attendance_type,
1667            p_program_length                => g_ps_ofr_opt.program_length,
1668            p_program_length_measurement    => g_ps_ofr_opt.program_length_measurement,
1669            p_length                        =>  g_field_defn.hesa_value(49),
1670            p_units                         => p_value);
1671 
1672         END IF;
1673 
1674       -- This field is classified as 'Not Used' by HESA
1675       -- Removed the call to the procedure, get_voc_lvl
1676       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
1677       ELSIF  p_field_number = 51
1678       THEN
1679 
1680          -- Not Used
1681          p_value := NULL;
1682 
1683       ELSIF  p_field_number = 52
1684       THEN
1685           -- Spcial Programmes
1686           p_value := g_ps_ver.govt_special_course_type;
1687 
1688       ELSIF  p_field_number = 53
1689       THEN
1690           IF g_field_defn.hesa_value.EXISTS(53)
1691           THEN
1692               -- Calculated Earlier ..
1693               p_value := g_field_defn.hesa_value(53);
1694           ELSE
1695               -- Not calculated earlier ..
1696               -- Teacher Training Course Identifier
1697               igs_he_extract_fields_pkg.get_teach_train_crs_id
1698                (p_prg_ttcid            =>  g_he_st_prog.teacher_train_prog_id,
1699                 p_spa_ttcid            =>  g_he_st_spa.teacher_train_prog_id,
1700                 p_hesa_ttcid           =>  p_value);
1701           END IF;
1702 
1703       ELSIF  p_field_number = 54
1704       THEN
1705 
1706              IF (g_he_submsn_header.validation_country  in ('ENGLAND','WALES')  AND ( g_field_defn.hesa_value.EXISTS(53)   and g_field_defn.hesa_value(53)  IN(1,2,6,7) ))   THEN
1707                   -- ITT Phase / Scope
1708                   igs_he_extract_fields_pkg.get_itt_phsc
1709                       (p_prg_itt_phsc        =>  g_he_st_prog.itt_phase,
1710                        p_spa_itt_phsc        =>  g_he_st_spa.itt_phase,
1711                        p_hesa_itt_phsc       =>  p_value);
1712 
1713              ELSE
1714                   g_default_pro:= 'N';
1715              END IF;
1716 
1717       ELSIF  p_field_number = 55
1718       THEN
1719 
1720                IF (g_he_submsn_header.validation_country  in ('SCOTLAND','WALES','NORTHERN IRELAND')   AND ( g_field_defn.hesa_value.EXISTS(53) AND g_field_defn.hesa_value(53)  IN(1,2)) )   THEN
1721                   -- Bilingual ITT Marker
1722                   igs_he_extract_fields_pkg.get_itt_mrker
1723                       (p_prg_itt_mrker       =>  g_he_st_prog.bilingual_itt_marker,
1724                        p_spa_itt_mrker       =>  g_he_st_spa.bilingual_itt_marker,
1725                        p_hesa_itt_mrker      =>  p_value);
1726 
1727 
1728                 ELSE
1729                   g_default_pro:= 'N';
1730                END IF;
1731 
1732       ELSIF  p_field_number = 56
1733       THEN
1734 
1735                 IF ( g_he_submsn_header.validation_country IN ('SCOTLAND','NORTHERN IRELAND')  AND ( g_field_defn.hesa_value.EXISTS(53) and g_field_defn.hesa_value(53)  IN(1,2) ) )   THEN
1736                   -- Teaching Qualification Sought Sector
1737                   igs_he_extract_fields_pkg.get_teach_qual_sect
1738                       (p_oss_teach_qual_sect   => g_he_st_prog.teaching_qual_sought_sector,
1739                        p_hesa_teach_qual_sect  => p_value);
1740 
1741                 ELSE
1742                   g_default_pro:= 'N';
1743                END IF;
1744 
1745       ELSIF  p_field_number = 57
1746       THEN
1747                IF ( g_he_submsn_header.validation_country = 'SCOTLAND'  AND ( g_field_defn.hesa_value.EXISTS(56)  AND g_field_defn.hesa_value(56)  =2  ) )  THEN
1748                   -- Teaching Qualification Sought Subject 1
1749                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1750                       (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj1,
1751                        p_hesa_teach_qual_sbj    =>  p_value);
1752 
1753 
1754               ELSE
1755                   g_default_pro:= 'N';
1756               END IF;
1757 
1758 
1759       ELSIF  p_field_number = 58
1760       THEN
1761               IF ( g_he_submsn_header.validation_country = 'SCOTLAND'  AND ( g_field_defn.hesa_value.EXISTS(56)  AND g_field_defn.hesa_value(56)  =2 ))   THEN
1762                   -- Teaching Qualification Sought Subject 2
1763                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1764                       (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj2,
1765                        p_hesa_teach_qual_sbj    =>  p_value);
1766                ELSE
1767                   g_default_pro:= 'N';
1768               END IF;
1769 
1770       ELSIF  p_field_number = 59
1771       THEN
1772               IF ( g_he_submsn_header.validation_country = 'SCOTLAND'  AND ( g_field_defn.hesa_value.EXISTS(56) AND g_field_defn.hesa_value(56)  =2  ))   THEN
1773                   -- Teaching Qualification Sought Subject 3
1774                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1775                       (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj3,
1776                        p_hesa_teach_qual_sbj    =>  p_value);
1777               ELSE
1778                   g_default_pro:= 'N';
1779               END IF;
1780 
1781       ELSIF  p_field_number = 60
1782       THEN
1783 
1784               IF ( g_he_submsn_header.validation_country IN ('SCOTLAND' , 'NORTHERN IRELAND' )  AND ( g_field_defn.hesa_value.EXISTS(53) AND g_field_defn.hesa_value(53)  in (1,2)) )   THEN
1785                   -- Teaching Qualification Gained Sector
1786                   igs_he_extract_fields_pkg.get_teach_qual_sect
1787                       (p_oss_teach_qual_sect   => g_he_st_spa.teaching_qual_gain_sector,
1788                        p_hesa_teach_qual_sect  => p_value);
1789 
1790                   IF p_value IS NULL
1791                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
1792                   AND g_field_defn.hesa_value.EXISTS(56)
1793                   THEN
1794                       p_value := g_field_defn.hesa_value(56);
1795                   END IF;
1796               ELSE
1797                   g_default_pro:= 'N';
1798               END IF;
1799 
1800       ELSIF  p_field_number = 61
1801       THEN
1802 
1803               IF        (g_he_submsn_header.validation_country = 'SCOTLAND'    AND ( g_field_defn.hesa_value.EXISTS(60)  AND g_field_defn.hesa_value(60) = 2 ) ) THEN
1804                   -- Teaching Qualification Gained Subject 1
1805                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1806                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj1,
1807                        p_hesa_teach_qual_sbj    =>  p_value);
1808 
1809                   IF p_value IS NULL
1810                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
1811                   AND g_field_defn.hesa_value.EXISTS(57)
1812                   THEN
1813                       p_value := g_field_defn.hesa_value(57);
1814                   END IF;
1815               ELSE
1816                   g_default_pro:= 'N';
1817               END IF;
1818 
1819       ELSIF  p_field_number = 62
1820       THEN
1821               IF       (g_he_submsn_header.validation_country = 'SCOTLAND'   AND ( g_field_defn.hesa_value.EXISTS(60) AND g_field_defn.hesa_value(60) = 2 ) ) THEN
1822                   -- Teaching Qualification Gained Subject 2
1823                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1824                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj2,
1825                        p_hesa_teach_qual_sbj    =>  p_value);
1826 
1827                   IF p_value IS NULL
1828                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
1829                   AND g_field_defn.hesa_value.EXISTS(58)
1830                   THEN
1831                       p_value := g_field_defn.hesa_value(58);
1832                   END IF;
1833 
1834               ELSE
1835                   g_default_pro:= 'N';
1836               END IF;
1837 
1838       ELSIF  p_field_number = 63
1839       THEN
1840 
1841               IF        (g_he_submsn_header.validation_country = 'SCOTLAND'  AND ( g_field_defn.hesa_value.EXISTS(60) AND g_field_defn.hesa_value(60) = 2 ) ) THEN
1842                   -- Teaching Qualification Gained Subject 3
1843                   igs_he_extract_fields_pkg.get_teach_qual_sbj
1844                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj3,
1845                        p_hesa_teach_qual_sbj    =>  p_value);
1846 
1847                   IF p_value IS NULL
1848                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
1849                   AND g_field_defn.hesa_value.EXISTS(59)
1850                   THEN
1851                       p_value := g_field_defn.hesa_value(59);
1852                   END IF;
1853 
1854 
1855               ELSE
1856                   g_default_pro:= 'N';
1857               END IF;
1858 
1859 
1860       ELSIF  p_field_number = 64
1861       THEN
1862           -- Major Source of Funding
1863           IF  g_field_defn.hesa_value.EXISTS(64)
1864           THEN
1865               -- Calculated earlier, for field 6
1866               p_value :=   g_field_defn.hesa_value(64);
1867           ELSE
1868               -- Not calculated earlier.
1869               -- smaddali modified this call to pass funding_source field for hefd208 - bug#2717751
1870               -- jtmathew modified this call to pass funding_source at spa level - bug#3962575
1871               igs_he_extract_fields_pkg.get_funding_src
1872                   (p_course_cd             => p_course_cd,
1873                    p_version_number        => p_crv_version_number,
1874                    p_spa_fund_src          => g_en_stdnt_ps_att.funding_source,
1875                    p_poous_fund_src        => g_he_poous.funding_source,
1876                    p_oss_fund_src          => g_field_defn.oss_value(64),
1877                    p_hesa_fund_src         => p_value);
1878           END IF;
1879 
1880       ELSIF  p_field_number = 65
1881       THEN
1882           -- Fundability Code
1883           IF  g_field_defn.hesa_value.EXISTS(65)
1884           THEN
1885               -- Calculated earlier, for field 6
1886               p_value :=   g_field_defn.hesa_value(65);
1887           ELSE
1888               -- Not calculated earlier, hence derive
1889               IF  g_field_defn.oss_value.EXISTS(64)
1890               THEN
1891                   -- Next get the Fundability Code
1892                   -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1893                   igs_he_extract_fields_pkg.get_fundability_cd
1894                       (p_person_id             => p_person_id,
1895                        p_susa_fund_cd          => g_he_en_susa.fundability_code,
1896                        p_spa_funding_source    => g_en_stdnt_ps_att.funding_source,
1897                        p_poous_fund_cd         => g_he_poous.fundability_cd,
1898                        p_prg_fund_cd           => g_he_st_prog.fundability,
1899                        p_prg_funding_source    => g_field_defn.oss_value(64),
1900                        p_oss_fund_cd           => g_field_defn.oss_value(65),
1901                        p_hesa_fund_cd          => p_value,
1902                        p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
1903                        p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
1904               ELSE
1905                   p_value := NULL;
1906               END IF;
1907 
1908           END IF; -- Not calculated earlier
1909 
1910       ELSIF  p_field_number = 66
1911       THEN
1912           -- smaddali modified value passed to p_study_mode for bug 2367167
1913           -- Fee Eligibility
1914           IF   g_field_defn.oss_value.EXISTS(6)
1915           AND  g_field_defn.oss_value.EXISTS(28)
1916           THEN
1917           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1918               igs_he_extract_fields_pkg.get_fee_elig
1919                   (p_person_id          =>  p_person_id,
1920                    p_susa_fee_elig      =>  g_he_en_susa.fee_eligibility,
1921                    p_fe_stdnt_mrker     =>  g_field_defn.oss_value(6),
1922                    p_study_mode         =>  NVL(g_he_en_susa.study_mode,NVL(g_he_poous.mode_of_study,g_en_stdnt_ps_att.attendance_type)) ,
1923                    p_special_student    =>  g_field_defn.oss_value(28),
1924                    p_hesa_fee_elig      =>  p_value,
1925                    p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
1926                    p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
1927           ELSE
1928           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
1929               igs_he_extract_fields_pkg.get_fee_elig
1930                   (p_person_id          =>  p_person_id,
1931                    p_susa_fee_elig      =>  g_he_en_susa.fee_eligibility,
1932                    p_fe_stdnt_mrker     =>  NULL,
1933                    p_study_mode         =>  NVL(g_he_en_susa.study_mode,NVL(g_he_poous.mode_of_study,g_en_stdnt_ps_att.attendance_type)),
1934                    p_special_student    =>  NULL,
1935                    p_hesa_fee_elig      =>  p_value,
1936                    p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
1937                    p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
1938           END IF;
1939 
1940       ELSIF  p_field_number = 67
1941       THEN
1942           -- Fee Band
1943           IF   g_field_defn.hesa_value.EXISTS(66) THEN
1944               igs_he_extract_fields_pkg.get_fee_band
1945                   (p_hesa_fee_elig     =>  g_field_defn.hesa_value(66),
1946                    p_susa_fee_band     =>  g_he_en_susa.fee_band,
1947                    p_poous_fee_band    =>  g_he_poous.fee_band,
1948                    p_prg_fee_band      =>  g_he_st_prog.fee_band,
1949                    p_hesa_fee_band     =>  p_value);
1950           ELSE
1951 
1952               igs_he_extract_fields_pkg.get_fee_band
1953                   (p_hesa_fee_elig     =>  NULL,
1954                    p_susa_fee_band     =>  g_he_en_susa.fee_band,
1955                    p_poous_fee_band    =>  g_he_poous.fee_band,
1956                    p_prg_fee_band      =>  g_he_st_prog.fee_band,
1957                    p_hesa_fee_band     =>  p_value);
1958 
1959           END IF;
1960 
1961       ELSIF  p_field_number = 68
1962       THEN
1963           -- Major Source of Tuition Fees
1964           -- Calculate amount of tuition Fees first
1965           IF   NOT g_field_defn.hesa_value.EXISTS(6)
1966           THEN
1967               g_field_defn.hesa_value(6) := NULL;
1968           END IF;
1969 
1970           -- smaddali 14-oct-03 added 2 new parameters to the procedure get_amt_tuition_fees, for bug#3179544
1971           IF   g_field_defn.hesa_value.EXISTS(6)
1972           AND  g_field_defn.hesa_value.EXISTS(28)
1973           THEN
1974               igs_he_extract_fields_pkg.get_amt_tuition_fees
1975                   (p_person_id         =>  p_person_id,
1976                    p_course_cd         =>  p_course_cd,
1977                    p_cal_type          =>  g_en_stdnt_ps_att.cal_type,
1978                    p_fe_prg_mrker      =>  g_he_st_prog.fe_program_marker,
1979                    p_fe_stdnt_mrker    =>  g_field_defn.hesa_value(6),
1980                    p_oss_amt           =>  g_field_defn.oss_value(83),
1981                    p_hesa_amt          =>  g_field_defn.hesa_value(83),
1982                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
1983                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date
1984                    );
1985 
1986               -- Calculate Mode of Study
1987               IF NOT g_field_defn.hesa_value.EXISTS(70) THEN
1988                  igs_he_extract_fields_pkg.get_mode_of_study
1989                   (p_person_id         =>  p_person_id,
1990                    p_course_cd         =>  p_course_cd,
1991                    p_version_number    =>  p_crv_version_number,
1992                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
1993                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
1994                    p_susa_study_mode   =>  g_he_en_susa.study_mode,
1995                    p_poous_study_mode  =>  g_he_poous.mode_of_study,
1996                    p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
1997                    p_mode_of_study     =>  g_field_defn.hesa_value(70));
1998               END IF ;
1999 
2000               -- Now calculate the major source of tuition fees
2001               igs_he_extract_fields_pkg.get_maj_src_tu_fee
2002                   (p_person_id         =>  p_person_id,
2003                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
2004                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
2005                    p_special_stdnt     =>  g_field_defn.hesa_value(28),
2006                    p_study_mode        =>  g_field_defn.hesa_value(70),
2007                    p_amt_tu_fee        =>  g_field_defn.oss_value(83),
2008                    p_susa_mstufee      =>  g_he_en_susa.student_fee,
2009                    p_hesa_mstufee      =>  p_value);
2010           END IF;
2011 
2012 
2013       ELSIF  p_field_number = 69
2014       THEN
2015           -- Not Used
2016           p_value := NULL;
2017 
2018       ELSIF  p_field_number = 70
2019       THEN
2020           -- Mode of Studying
2021           IF  g_field_defn.hesa_value.EXISTS(70)
2022           THEN
2023               -- Calculated earlier, for field 68
2024               p_value :=   g_field_defn.hesa_value(70);
2025           ELSE
2026               igs_he_extract_fields_pkg.get_mode_of_study
2027                   (p_person_id         =>  p_person_id,
2028                    p_course_cd         =>  p_course_cd,
2029                    p_version_number    =>  p_crv_version_number,
2030                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
2031                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
2032                    p_susa_study_mode   =>  g_he_en_susa.study_mode,
2033                    p_poous_study_mode  =>  g_he_poous.mode_of_study,
2034                    p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
2035                    p_mode_of_study     =>  p_value);
2036 
2037           END IF;
2038 
2039       ELSIF  p_field_number = 71
2040       THEN
2041           -- Location of Study
2042           IF  g_field_defn.hesa_value.EXISTS(71)
2043           THEN
2044               -- Calculated earlier, for field 31
2045               p_value :=   g_field_defn.hesa_value(71);
2046           ELSE
2047               -- Not calculated earlier, hence derive
2048               igs_he_extract_fields_pkg.get_study_location
2049                   (p_susa_study_location    => g_he_en_susa.study_location,
2050                    p_poous_study_location   => g_he_poous.location_of_study,
2051                    p_prg_study_location     => g_he_st_prog.location_of_study,
2052                    p_oss_study_location     => g_field_defn.oss_value(71),
2053                    p_hesa_study_location    => p_value);
2054           END IF;
2055 
2056       ELSIF  p_field_number = 72
2057       THEN
2058            -- Year of Program
2059           IF  g_field_defn.hesa_value.EXISTS(72)
2060           THEN
2061               p_value :=   g_field_defn.hesa_value(72);
2062           ELSE
2063               -- Not calculated earlier, hence derive
2064               igs_he_extract_fields_pkg.get_year_of_prog
2065                   (p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
2066                    p_year_of_prog         => p_value);
2067 
2068           END IF;
2069 
2070           -- To send to HESA Lpad with 0
2071           p_value := LPAD(p_value,2,'0');
2072 
2073       ELSIF  p_field_number = 73
2074       THEN
2075           -- Length of current year of program
2076           --smaddali adding LPAD '0' for bug 2437081
2077           p_value := LPAD(g_he_poous.leng_current_year,2,'0');
2078 
2079       ELSIF  p_field_number = 74
2080       THEN
2081           -- Included the below code as a part of HECR001(bug number 2278825)
2082           -- smaddali added the ltrim and changed format mask from 999.9 to 000.0 for bug 2431845
2083           -- jtmathew added the check for whether SUSA finishes before the start of reporting period
2084 
2085           IF g_he_en_susa.fte_perc_override  IS NOT NULL THEN
2086                   p_value := Ltrim(To_Char(g_he_en_susa.fte_perc_override,'000.0'));
2087           ELSE
2088               IF g_as_su_setatmpt.rqrmnts_complete_dt IS NOT NULL AND
2089                  g_as_su_setatmpt.rqrmnts_complete_dt <  g_he_submsn_header.enrolment_start_date
2090               THEN -- Report FTE of 000.0 as the unit set does not fit within the reporting period
2091                   p_value := Ltrim(To_Char(0,'000.0'));
2092               ELSE
2093                   p_value := Ltrim(To_Char(g_he_en_susa.calculated_fte,'000.0'));
2094               END IF;
2095           END IF;
2096 
2097       ELSIF  p_field_number = 75
2098       THEN
2099 
2100           IF g_field_defn.hesa_value.EXISTS(12) AND  g_field_defn.hesa_value(12) IN ('8826','5826','6826','7826','2826','3826','4826')
2101           THEN
2102                   p_value := g_he_st_spa.postcode;
2103 
2104           ELSE
2105                   g_default_pro:= 'N';
2106 
2107           END IF;
2108 
2109       ELSIF  p_field_number = 76
2110       THEN
2111           -- PGCE - Subject of Undergraduate Degree
2112           -- smaddali added call to the new local procedure for bug 2452592
2113           IF g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN ('12','13')
2114           THEN
2115               igs_he_extract2_pkg.get_pgce_subj
2116               (p_person_id         =>  p_person_id,
2117                p_pgce_subj        =>  p_value);
2118           ELSE
2119               p_value := NULL ;
2120           END IF ;
2121 
2122       ELSIF  p_field_number = 77
2123       THEN
2124           -- PGCE - Classification  of Undergraduate Degree
2125           --smaddali added the dependency on field41 for bug 2436924
2126           IF g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN ('12','13')
2127           THEN
2128               igs_he_extract_fields_pkg.get_pgce_class
2129               (p_person_id         =>  p_person_id,
2130                p_pgce_class        =>  p_value);
2131           ELSE
2132               p_value := NULL ;
2133           END IF ;
2134 
2135       ELSIF  p_field_number = 78
2136       THEN
2137 
2138         IF (g_he_submsn_header.validation_country  = 'NORTHERN IRELAND'  AND ( g_field_defn.hesa_value.EXISTS(12) AND  g_field_defn.hesa_value(12) = '8826')) THEN
2139           -- Religion
2140           igs_he_extract_fields_pkg.get_religion
2141           (p_oss_religion     =>  g_pe_stat_v.religion,
2142            p_hesa_religion    =>  p_value);
2143 
2144         ELSE
2145           g_default_pro := 'N';
2146         END IF;
2147 
2148 
2149       ELSIF  p_field_number = 79
2150       THEN
2151           -- Not used
2152           p_value := NULL;
2153 
2154       ELSIF  p_field_number = 80
2155       THEN
2156           -- Not used
2157           p_value := NULL;
2158 
2159       ELSIF  p_field_number = 81
2160       THEN
2161           -- SLDD Discrete Provision
2162           IF g_field_defn.hesa_value.EXISTS(6)
2163           THEN
2164               igs_he_extract_fields_pkg.get_sldd_disc_prv
2165                   (p_oss_sldd_disc_prv     =>  g_he_en_susa.sldd_discrete_prov,
2166                    p_fe_stdnt_mrker        =>  g_field_defn.hesa_value(6),
2167                    p_hesa_sldd_disc_prv    =>  p_value);
2168           END IF;
2169 
2170       ELSIF  p_field_number = 82
2171       THEN
2172           -- Not used
2173           p_value := NULL;
2174 
2175       ELSIF  p_field_number = 83
2176       THEN
2177         -- The default value processng to be done only if field 6 is in 1,3,4
2178          g_default_pro:= 'N';
2179 
2180          IF g_field_defn.hesa_value.EXISTS(6) AND g_field_defn.hesa_value(6) IN (1,3,4)     THEN
2181 
2182           -- Amount of Tuition fees expected
2183           IF g_field_defn.hesa_value.EXISTS(83)
2184           THEN
2185               -- Calculated earlier. No need to derive
2186               p_value := g_field_defn.hesa_value(83);
2187           ELSE
2188 
2189               -- Not calculated earlier. Derive now.
2190               -- smaddali 14-oct-03 added 2 new parameters to the procedure get_amt_tuition_fees, for bug#3179544
2191               igs_he_extract_fields_pkg.get_amt_tuition_fees
2192                   (p_person_id         =>  p_person_id,
2193                    p_course_cd         =>  p_course_cd,
2194                    p_cal_type          =>  g_en_stdnt_ps_att.cal_type,
2195                    p_fe_prg_mrker      =>  g_he_st_prog.fe_program_marker,
2196                    p_fe_stdnt_mrker    =>  g_field_defn.hesa_value(6),
2197                    p_oss_amt           =>  g_field_defn.oss_value(83),
2198                    p_hesa_amt          =>  p_value ,
2199                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
2200                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date);
2201           END IF;
2202           g_default_pro:= 'Y';
2203          END IF;
2204 
2205       ELSIF  p_field_number = 84
2206       THEN
2207 
2208          -- The default value processng to be done only if field 6 is in 1,3,4
2209          g_default_pro:= 'N';
2210 
2211          IF g_field_defn.hesa_value.EXISTS(6) AND g_field_defn.hesa_value(6) IN (1,3,4)     THEN
2212             -- Non Payment Reason
2213             igs_he_extract_fields_pkg.get_non_payment_rsn
2214               (p_oss_non_payment_rsn   =>  g_he_en_susa.non_payment_reason,
2215                p_hesa_non_payment_rsn  =>  p_value,
2216                p_fe_stdnt_mrker    => g_field_defn.hesa_value(6));
2217 
2218             g_default_pro:= 'Y';
2219          END IF;
2220 
2221       ELSIF  p_field_number = 85
2222       THEN
2223          -- The default value processng to be done only if field 6 is in 1,3,4
2224          g_default_pro:= 'N';
2225 
2226          IF g_field_defn.hesa_value.EXISTS(6) AND g_field_defn.hesa_value(6) IN (1,3,4)     THEN
2227             -- Guided Learning Hours
2228             p_value := To_char(g_ps_ver.contact_hours,'00000');
2229             g_default_pro:= 'Y';
2230          END IF;
2231 
2232       ELSIF  p_field_number = 86
2233       THEN
2234           -- Other Insitutions Providing Teaching 1
2235           igs_he_extract_fields_pkg.get_oth_teach_inst
2236               (p_person_id          =>  p_person_id,
2237                p_course_cd          =>  p_course_cd,
2238                p_program_calc       =>  g_he_st_prog.program_calc,
2239                p_susa_inst1         =>  g_he_en_susa.teaching_inst1,
2240                p_poous_inst1        =>  g_he_poous.other_instit_teach1,
2241                p_prog_inst1         =>  g_he_st_prog.other_inst_prov_teaching1,
2242                p_susa_inst2         =>  g_he_en_susa.teaching_inst2,
2243                p_poous_inst2        =>  g_he_poous.other_instit_teach2,
2244                p_prog_inst2         =>  g_he_st_prog.other_inst_prov_teaching2,
2245                p_hesa_inst1         =>  p_value,
2246                p_hesa_inst2         =>  g_field_defn.hesa_value(87),
2247                p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2248                p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
2249 
2250       ELSIF  p_field_number = 87
2251       THEN
2252           -- Other Insitutions Providing Teaching 2
2253           IF  g_field_defn.hesa_value.EXISTS(87)
2254           THEN
2255               -- Calculated earlier in field 86
2256               p_value :=  g_field_defn.hesa_value(87);
2257           ELSE
2258               -- Not calculated earlier
2259               igs_he_extract_fields_pkg.get_oth_teach_inst
2260                   (p_person_id          =>  p_person_id,
2261                    p_course_cd          =>  p_course_cd,
2262                    p_program_calc       =>  g_he_st_prog.program_calc,
2263                    p_susa_inst1         =>  g_he_en_susa.teaching_inst1,
2264                    p_poous_inst1        =>  g_he_poous.other_instit_teach1,
2265                    p_prog_inst1         =>  g_he_st_prog.other_inst_prov_teaching1,
2266                    p_susa_inst2         =>  g_he_en_susa.teaching_inst2,
2267                    p_poous_inst2        =>  g_he_poous.other_instit_teach2,
2268                    p_prog_inst2         =>  g_he_st_prog.other_inst_prov_teaching2,
2269                    p_hesa_inst1         =>  g_field_defn.hesa_value(86),
2270                    p_hesa_inst2         =>  p_value,
2271                    p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2272                    p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
2273 
2274           END IF;
2275 
2276       ELSIF  p_field_number = 88
2277       THEN
2278           -- Proportion of teaching in Welsh
2279            --smaddali adding format mask '000.0' for bug 2437081
2280           p_value := Ltrim(To_Char( g_he_st_prog.prop_teaching_in_welsh,'000.0') );
2281 
2282       ELSIF  p_field_number = 89
2283       THEN
2284           -- Not used
2285           p_value := NULL;
2286 
2287       ELSIF  p_field_number = 90
2288       THEN
2289           --smaddali added 2 new parameters p_enrl_start_dt and p_enrl_end_dt for bug 2437081
2290           -- Proportion Not taught by this institution
2291           igs_he_extract_fields_pkg.get_prop_not_taught
2292               (p_person_id          =>  p_person_id,
2293                p_course_cd          =>  p_course_cd,
2294                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
2295                p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date ,
2296                p_program_calc       =>  g_he_st_prog.program_calc,
2297                p_susa_prop          =>  g_he_en_susa.pro_not_taught,
2298                p_poous_prop         =>  g_he_poous.prop_not_taught,
2299                p_prog_prop          =>  g_he_st_prog.prop_not_taught,
2300                p_hesa_prop          =>  l_prop_not_taught);
2301 
2302            --smaddali adding format mask '000.0' for bug 2437081
2303            p_value := ltrim( to_char(l_prop_not_taught,'000.0')) ;
2304 
2305 
2306       ELSIF  p_field_number = 91
2307       THEN
2308           -- Credit Transfer Scheme
2309           igs_he_extract_fields_pkg.get_credit_trans_sch
2310           (p_oss_credit_trans_sch   =>  g_he_st_prog.credit_transfer_scheme,
2311            p_hesa_credit_trans_sch  =>  p_value);
2312 
2313       ELSIF  p_field_number = 92
2314       THEN
2315           -- smaddali removed the validation to check for g_he_st_prog.program_calc for bug 2419875
2316           -- Credit value for Year of Program , 1
2317               p_value := NVL(g_he_en_susa.credit_value_yop1,g_he_poous.credit_value_yop1 ) ;
2318 
2319           --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
2320           p_value := LPAD(p_value, 3,'0') ;
2321 
2322 
2323       ELSIF  p_field_number = 93
2324       THEN
2325           -- smaddali removed the validation to check for g_he_st_prog.program_calc for bug 2419875
2326           -- Credit value for Year of Program , 2
2327           -- smaddali added nvl of susa value for bug 2415879
2328           p_value := NVL(g_he_en_susa.credit_value_yop2,g_he_poous.credit_value_yop2 );
2329 
2330           --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
2331           p_value := LPAD(p_value, 3,'0') ;
2332 
2333 
2334       ELSIF  p_field_number = 94
2335       THEN
2336           -- smaddali removed the validation to check for g_he_st_prog.program_calc for bug 2419875
2337           -- Level of Credit, 1
2338               igs_he_extract_fields_pkg.get_credit_level
2339                  (p_susa_credit_level     => g_he_en_susa.credit_level1,
2340                   p_poous_credit_level     =>  g_he_poous.level_credit1,
2341                   p_hesa_credit_level    =>  p_value);
2342 
2343       ELSIF  p_field_number = 95
2344       THEN
2345           -- smaddali removed the validation to check for g_he_st_prog.program_calc for bug 2419875
2346           -- Level of Credit, 2
2347               igs_he_extract_fields_pkg.get_credit_level
2348                  (p_susa_credit_level    => g_he_en_susa.credit_level2 ,
2349                   p_poous_credit_level     =>  g_he_poous.level_credit2,
2350                   p_hesa_credit_level    =>  p_value);
2351 
2352       ELSIF  p_field_number = 96
2353       THEN
2354 
2355            -- Number of Credit Points Obtained 1
2356            -- jbaber added crd_pt3-4, lvl_crd_pt3-4 for HEFD350
2357            igs_he_extract_fields_pkg.get_credit_obtained
2358                (p_person_id          =>  p_person_id,
2359                 p_course_cd          =>  p_course_cd,
2360                 p_prog_calc          =>  g_he_st_prog.program_calc,
2361                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
2362                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
2363                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
2364                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
2365                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
2366                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
2367                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
2368                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
2369                 p_no_crd_pt1         =>  p_value,
2370                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
2371                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
2372                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
2373                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
2374                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
2375                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
2376                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
2377                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2378                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
2379 
2380             --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
2381             p_value := LPAD(p_value, 3,'0') ;
2382 
2383       ELSIF  p_field_number = 97
2384       THEN
2385            -- Number of Credit Points Obtained 2
2386            -- jbaber added crd_pt3-4, lvl_crd_pt3-4 for HEFD350
2387            IF g_field_defn.hesa_value.EXISTS(97)
2388            THEN
2389                p_value :=  g_field_defn.hesa_value(97);
2390            ELSE
2391                igs_he_extract_fields_pkg.get_credit_obtained
2392                (p_person_id          =>  p_person_id,
2393                 p_course_cd          =>  p_course_cd,
2394                 p_prog_calc          =>  g_he_st_prog.program_calc,
2395                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
2396                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
2397                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
2398                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
2399                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
2400                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
2401                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
2402                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
2403                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
2404                 p_no_crd_pt2         =>  p_value,
2405                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
2406                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
2407                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
2408                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
2409                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
2410                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
2411                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2412                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
2413 
2414 
2415            END IF;
2416            --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
2417            p_value := LPAD(p_value, 3,'0') ;
2418 
2419       ELSIF  p_field_number = 98
2420       THEN
2421            -- Level of Credit Points Obtained 1
2422            -- jbaber added crd_pt3-4, lvl_crd_pt3-4 for HEFD350
2423            IF g_field_defn.hesa_value.EXISTS(98)
2424            THEN
2425                p_value :=  g_field_defn.hesa_value(98);
2426            ELSE
2427                igs_he_extract_fields_pkg.get_credit_obtained
2428                (p_person_id          =>  p_person_id,
2429                 p_course_cd          =>  p_course_cd,
2430                 p_prog_calc          =>  g_he_st_prog.program_calc,
2431                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
2432                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
2433                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
2434                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
2435                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
2436                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
2437                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
2438                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
2439                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
2440                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
2441                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
2442                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
2443                 p_lvl_crd_pt1        =>  p_value,
2444                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
2445                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
2446                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
2447                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2448                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
2449            END IF;
2450 
2451       ELSIF  p_field_number = 99
2452       THEN
2453            -- Level of Credit Points Obtained 2
2454            -- jbaber added crd_pt3-4, lvl_crd_pt3-4 for HEFD350
2455            IF g_field_defn.hesa_value.EXISTS(99)
2456            THEN
2457                p_value :=  g_field_defn.hesa_value(99);
2458            ELSE
2459                igs_he_extract_fields_pkg.get_credit_obtained
2460                (p_person_id          =>  p_person_id,
2461                 p_course_cd          =>  p_course_cd,
2462                 p_prog_calc          =>  g_he_st_prog.program_calc,
2463                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
2464                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
2465                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
2466                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
2467                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
2468                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
2469                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
2470                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
2471                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
2472                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
2473                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
2474                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
2475                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
2476                 p_lvl_crd_pt2        =>  p_value,
2477                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
2478                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
2479                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2480                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
2481            END IF;
2482 
2483       ELSIF  p_field_number = 100
2484       THEN
2485           -- Cost Centre1
2486           --smaddali added the initialisation of variable g_cc_rec for bug 2417370
2487           --jbaber added p_validation_country for HEFD350
2488           g_cc_rec := NULL ;
2489           g_total_ccs := 0;
2490           igs_he_extract_fields_pkg.get_cost_centres
2491           (p_person_id           =>  p_person_id,
2492            p_course_cd           =>  p_course_cd,
2493            p_version_number      =>  p_crv_version_number,
2494            p_unit_set_cd         =>  g_as_su_setatmpt.unit_set_cd,
2495            p_us_version_number   =>  g_as_su_setatmpt.us_version_number,
2496            p_cal_type            =>  g_en_stdnt_ps_att.cal_type,
2497            p_attendance_mode     =>  g_en_stdnt_ps_att.attendance_mode,
2498            p_attendance_type     =>  g_en_stdnt_ps_att.attendance_type,
2499            p_location_cd         =>  g_en_stdnt_ps_att.location_cd,
2500            p_program_calc        =>  g_he_st_prog.program_calc,
2501            p_unit_cd             =>  NULL,
2502            p_uv_version_number   =>  NULL,
2503            p_return_type         =>  'C',
2504            p_cost_ctr_rec        =>  g_cc_rec,
2505            p_total_recs          =>  g_total_ccs,
2506            p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
2507            p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
2508            p_sequence_number     =>  g_as_su_setatmpt.sequence_number,
2509            p_validation_country  =>  g_he_submsn_header.validation_country);
2510 
2511            IF g_total_ccs >= 1
2512            THEN
2513                p_value := g_cc_rec.cost_centre(1);
2514            END IF;
2515 
2516       ELSIF  p_field_number = 101
2517       THEN
2518           -- Subject 1
2519           IF g_total_ccs >= 1
2520           THEN
2521               -- smaddali removed the corsor getting govt field of study for bug 2417454
2522                   p_value := g_cc_rec.subject(1);
2523           END IF;
2524 
2525       ELSIF  p_field_number = 102
2526       THEN
2527           -- Proportion 1
2528           IF g_total_ccs >= 1
2529           THEN
2530                  --smaddali added format mask '000.0' to this field for bug 2437279
2531                  p_value := Ltrim(To_Char(g_cc_rec.proportion(1),'000.0') );
2532 
2533           END IF;
2534 
2535       ELSIF  p_field_number = 103
2536       THEN
2537            -- Cost Centre 2
2538            IF g_total_ccs >= 2
2539            THEN
2540                p_value := g_cc_rec.cost_centre(2);
2541            END IF;
2542 
2543       ELSIF  p_field_number = 104
2544       THEN
2545           -- Subject 2
2546           IF g_total_ccs >= 2
2547           THEN
2548               -- smaddali removed the corsor getting govt field of study for bug 2417454
2549                   p_value := g_cc_rec.subject(2) ;
2550           END IF;
2551 
2552       ELSIF  p_field_number = 105
2553       THEN
2554           -- Proportion 2
2555           IF g_total_ccs >= 2
2556           THEN
2557               --smaddali added format mask '000.0' to this field for bug 2437279
2558               p_value := Ltrim(To_Char(g_cc_rec.proportion(2),'000.0') );
2559           END IF;
2560 
2561       ELSIF  p_field_number = 106
2562       THEN
2563            -- Cost Centre 3
2564            IF g_total_ccs >= 3
2565            THEN
2566                p_value := g_cc_rec.cost_centre(3);
2567            END IF;
2568 
2569       ELSIF  p_field_number = 107
2570       THEN
2571           -- Subject 3
2572           IF g_total_ccs >= 3
2573           THEN
2574               -- smaddali removed the corsor getting govt field of study for bug 2417454
2575                   p_value := g_cc_rec.subject(3) ;
2576           END IF;
2577 
2578       ELSIF  p_field_number = 108
2579       THEN
2580           -- Proportion 3
2581           IF g_total_ccs >= 3
2582           THEN
2583           --smaddali added format mask '000.0' to this field for bug 2437279
2584               p_value := Ltrim(To_Char(g_cc_rec.proportion(3),'000.0') );
2585           END IF;
2586 
2587       ELSIF  p_field_number = 109
2588       THEN
2589            -- Cost Centre 4
2590            IF g_total_ccs >= 4
2591            THEN
2592                p_value := g_cc_rec.cost_centre(4);
2593            END IF;
2594 
2595       ELSIF  p_field_number = 110
2596       THEN
2597           -- Subject 4
2598           IF g_total_ccs >= 4
2599           THEN
2600               -- smaddali removed the corsor getting govt field of study for bug 2417454
2601                   p_value := g_cc_rec.subject(4);
2602           END IF;
2603 
2604       ELSIF  p_field_number = 111
2605       THEN
2606           -- Proportion 4
2607           IF g_total_ccs >= 4
2608           THEN
2609           --smaddali added format mask '000.0' to this field for bug 2437279
2610               p_value := Ltrim(To_Char(g_cc_rec.proportion(4),'000.0') );
2611           END IF;
2612 
2613       ELSIF  p_field_number = 112
2614       THEN
2615            -- Cost Centre 5
2616            IF g_total_ccs >= 5
2617            THEN
2618                p_value := g_cc_rec.cost_centre(5);
2619            END IF;
2620 
2621       ELSIF  p_field_number = 113
2622       THEN
2623           -- Subject 5
2624           IF g_total_ccs >= 5
2625           THEN
2626               -- smaddali removed the corsor getting govt field of study for bug 2417454
2627                   p_value := g_cc_rec.subject(5);
2628           END IF;
2629 
2630       ELSIF  p_field_number = 114
2631       THEN
2632           -- Proportion 5
2633           IF g_total_ccs >= 5
2634           THEN
2635           --smaddali added format mask '000.0' to this field for bug 2437279
2636               p_value := Ltrim(To_Char(g_cc_rec.proportion(5),'000.0') );
2637           END IF;
2638 
2639       ELSIF  p_field_number = 115
2640       THEN
2641            -- Cost Centre 6
2642            IF g_total_ccs >= 6
2643            THEN
2644                p_value := g_cc_rec.cost_centre(6);
2645            END IF;
2646 
2647       ELSIF  p_field_number = 116
2648       THEN
2649           -- Subject 6
2650           IF g_total_ccs >= 6
2651           THEN
2652               -- smaddali removed the corsor getting govt field of study for bug 2417454
2653                   p_value := g_cc_rec.subject(6);
2654           END IF;
2655 
2656       ELSIF  p_field_number = 117
2657       THEN
2658           -- Proportion 6
2659           IF g_total_ccs >= 6
2660           THEN
2661           --smaddali added format mask '000.0' to this field for bug 2437279
2662               p_value := Ltrim(To_Char(g_cc_rec.proportion(6),'000.0') );
2663           END IF;
2664 
2665       ELSIF  p_field_number = 118
2666       THEN
2667            -- Cost Centre 7
2668            IF g_total_ccs >= 7
2669            THEN
2670                p_value := g_cc_rec.cost_centre(7);
2671            END IF;
2672 
2673       ELSIF  p_field_number = 119
2674       THEN
2675           -- Subject 7
2676           IF g_total_ccs >= 7
2677           THEN
2678               -- smaddali removed the corsor getting govt field of study for bug 2417454
2679                   p_value := g_cc_rec.subject(7);
2680           END IF;
2681 
2682       ELSIF  p_field_number = 120
2683       THEN
2684           -- Proportion 7
2685           IF g_total_ccs >= 7
2686           THEN
2687           --smaddali added format mask '000.0' to this field for bug 2437279
2688               p_value := Ltrim(To_Char(g_cc_rec.proportion(7),'000.0') );
2689           END IF;
2690 
2691       ELSIF  p_field_number = 121
2692       THEN
2693            -- Cost Centre 8
2694            IF g_total_ccs >= 8
2695            THEN
2696                p_value := g_cc_rec.cost_centre(8);
2697            END IF;
2698 
2699       ELSIF  p_field_number = 122
2700       THEN
2701           -- Subject 8
2702           IF g_total_ccs >= 8
2703           THEN
2704               -- smaddali removed the corsor getting govt field of study for bug 2417454
2705                   p_value := g_cc_rec.subject(8);
2706           END IF;
2707 
2708       ELSIF  p_field_number = 123
2709       THEN
2710           -- Proportion 8
2711           IF g_total_ccs >= 8
2712           THEN
2713           --smaddali added format mask '000.0' to this field for bug 2437279
2714               p_value := Ltrim(To_Char(g_cc_rec.proportion(8),'000.0') );
2715           END IF;
2716 
2717       ELSIF  p_field_number = 124
2718       THEN
2719            -- Cost Centre 9
2720            IF g_total_ccs >= 9
2721            THEN
2722                p_value := g_cc_rec.cost_centre(9);
2723            END IF;
2724 
2725       ELSIF  p_field_number = 125
2726       THEN
2727           -- Subject 9
2728           IF g_total_ccs >= 9
2729           THEN
2730               -- smaddali removed the corsor getting govt field of study for bug 2417454
2731                   p_value := g_cc_rec.subject(9);
2732           END IF;
2733 
2734       ELSIF  p_field_number = 126
2735       THEN
2736           -- Proportion 9
2737           IF g_total_ccs >= 9
2738           THEN
2739           --smaddali added format mask '000.0' to this field for bug 2437279
2740               p_value := Ltrim(To_Char(g_cc_rec.proportion(9),'000.0') );
2741           END IF;
2742 
2743       ELSIF  p_field_number = 127
2744       THEN
2745            -- Cost Centre 10
2746            IF g_total_ccs >= 10
2747            THEN
2748                p_value := g_cc_rec.cost_centre(10);
2749            END IF;
2750 
2751       ELSIF  p_field_number = 128
2752       THEN
2753           -- Subject 10
2754           IF g_total_ccs >= 10
2755           THEN
2756               -- smaddali removed the corsor getting govt field of study for bug 2417454
2757                   p_value := g_cc_rec.subject(10);
2758           END IF;
2759 
2760       ELSIF  p_field_number = 129
2761       THEN
2762           -- Proportion 10
2763           IF g_total_ccs >= 10
2764           THEN
2765           --smaddali added format mask '000.0' to this field for bug 2437279
2766               p_value := Ltrim(To_Char(g_cc_rec.proportion(10),'000.0') );
2767           END IF;
2768 
2769       ELSIF  p_field_number = 130
2770       THEN
2771            -- Cost Centre 11
2772            IF g_total_ccs >= 11
2773            THEN
2774                p_value := g_cc_rec.cost_centre(11);
2775            END IF;
2776 
2777       ELSIF  p_field_number = 131
2778       THEN
2779           -- Subject 11
2780           IF g_total_ccs >= 11
2781           THEN
2782               -- smaddali removed the corsor getting govt field of study for bug 2417454
2783                   p_value := g_cc_rec.subject(11);
2784           END IF;
2785 
2786       ELSIF  p_field_number = 132
2787       THEN
2788           -- Proportion 11
2789           IF g_total_ccs >= 11
2790           THEN
2791           --smaddali added format mask '000.0' to this field for bug 2437279
2792               p_value := Ltrim(To_Char(g_cc_rec.proportion(11),'000.0') );
2793           END IF;
2794 
2795       ELSIF  p_field_number = 133
2796       THEN
2797            -- Cost Centre 12
2798            IF g_total_ccs >= 12
2799            THEN
2800                p_value := g_cc_rec.cost_centre(12);
2801            END IF;
2802 
2803       ELSIF  p_field_number = 134
2804       THEN
2805           -- Subject 12
2806           IF g_total_ccs >= 12
2807           THEN
2808               -- smaddali removed the corsor getting govt field of study for bug 2417454
2809                   p_value := g_cc_rec.subject(12);
2810           END IF;
2811 
2812       ELSIF  p_field_number = 135
2813       THEN
2814           -- Proportion 12
2815           IF g_total_ccs >= 12
2816           THEN
2817           --smaddali added format mask '000.0' to this field for bug 2437279
2818               p_value := Ltrim(To_Char(g_cc_rec.proportion(12),'000.0') );
2819           END IF;
2820 
2821       ELSIF  p_field_number = 136
2822       THEN
2823            -- Cost Centre 13
2824            IF g_total_ccs >= 13
2825            THEN
2826                p_value := g_cc_rec.cost_centre(13);
2827            END IF;
2828 
2829       ELSIF  p_field_number = 137
2830       THEN
2831           -- Subject 13
2832           IF g_total_ccs >= 13
2833           THEN
2834               -- smaddali removed the corsor getting govt field of study for bug 2417454
2835                   p_value := g_cc_rec.subject(13);
2836            END IF;
2837 
2838       ELSIF  p_field_number = 138
2839       THEN
2840           -- Proportion 13
2841           IF g_total_ccs >= 13
2842           THEN
2843           --smaddali added format mask '000.0' to this field for bug 2437279
2844               p_value := Ltrim(To_Char(g_cc_rec.proportion(13),'000.0') );
2845           END IF;
2846 
2847       ELSIF  p_field_number = 139
2848       THEN
2849            -- Cost Centre 14
2850            IF g_total_ccs >= 14
2851            THEN
2852                p_value := g_cc_rec.cost_centre(14);
2853            END IF;
2854 
2855       ELSIF  p_field_number = 140
2856       THEN
2857           -- Subject 14
2858           IF g_total_ccs >= 14
2859           THEN
2860               -- smaddali removed the corsor getting govt field of study for bug 2417454
2861                  p_value := g_cc_rec.subject(14) ;
2862           END IF;
2863 
2864       ELSIF  p_field_number = 141
2865       THEN
2866           -- Proportion 14
2867           IF g_total_ccs >= 14
2868           THEN
2869           --smaddali added format mask '000.0' to this field for bug 2437279
2870               p_value := Ltrim(To_Char(g_cc_rec.proportion(14),'000.0') );
2871           END IF;
2872 
2873       ELSIF  p_field_number = 142
2874       THEN
2875            -- Cost Centre 15
2876            IF g_total_ccs >= 15
2877            THEN
2878                p_value := g_cc_rec.cost_centre(15);
2879            END IF;
2880 
2881       ELSIF  p_field_number = 143
2882       THEN
2883           -- Subject 15
2884           IF g_total_ccs >= 15
2885           THEN
2886               -- smaddali removed the corsor getting govt field of study for bug 2417454
2887                   p_value := g_cc_rec.subject(15);
2888           END IF;
2889 
2890       ELSIF  p_field_number = 144
2891       THEN
2892           -- Proportion 15
2893           IF g_total_ccs >= 15
2894           THEN
2895           --smaddali added format mask '000.0' to this field for bug 2437279
2896               p_value := Ltrim(To_Char(g_cc_rec.proportion(15),'000.0') );
2897           END IF;
2898 
2899       ELSIF  p_field_number = 145
2900       THEN
2901            -- Cost Centre 16
2902            IF g_total_ccs >= 16
2903            THEN
2904                p_value := g_cc_rec.cost_centre(16);
2905            END IF;
2906 
2907       ELSIF  p_field_number = 146
2908       THEN
2909           -- Subject 16
2910           IF g_total_ccs >= 16
2911           THEN
2912               -- smaddali removed the corsor getting govt field of study for bug 2417454
2913                   p_value := g_cc_rec.subject(16);
2914           END IF;
2915 
2916       ELSIF  p_field_number = 147
2917       THEN
2918           -- Proportion 16
2919           IF g_total_ccs >= 16
2920           THEN
2921           --smaddali added format mask '000.0' to this field for bug 2437279
2922               p_value := Ltrim(To_Char(g_cc_rec.proportion(16),'000.0') );
2923           END IF;
2924 
2925       -- Modified the derivation of this field to derive regardless of the value of the HESA MODE field (70)
2926       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
2927       ELSIF  p_field_number = 148
2928       THEN
2929 
2930          IF g_field_defn.hesa_value.EXISTS(148)
2931          THEN
2932              p_value :=  g_field_defn.hesa_value(148);
2933          ELSE
2934 
2935            IF  g_he_st_spa.associate_ucas_number = 'Y' THEN
2936               -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
2937               igs_he_extract_fields_pkg.get_ucasnum
2938               (p_person_id        => p_person_id,
2939                p_ucasnum          => p_value,
2940                p_enrl_start_dt    =>  g_he_submsn_header.enrolment_start_date,
2941                p_enrl_end_dt      =>  g_he_submsn_header.enrolment_end_date);
2942 
2943             END IF;
2944 
2945          END IF;
2946 
2947       ELSIF  p_field_number = 149
2948       THEN
2949           -- Institutions Own Id for Student
2950           p_value := g_pe_person.person_number;
2951 
2952       ELSIF  p_field_number = 150
2953       THEN
2954           -- Institutes program of study
2955           p_value := p_course_cd || '.' || To_Char(p_crv_version_number);
2956 
2957       ELSIF  p_field_number = 151
2958       THEN
2959           -- Student Instance Number
2960           p_value := g_he_st_spa.student_inst_number;
2961 
2962       ELSIF  p_field_number = 152
2963       THEN
2964           -- Suspension of Active studies
2965           igs_he_extract_fields_pkg.get_studies_susp
2966               (p_person_id          =>  p_person_id,
2967                p_course_cd          =>  p_course_cd,
2968                p_version_number     =>  p_crv_version_number,
2969                p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
2970                p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date,
2971                p_susp_act_std       =>  p_value);
2972 
2973       ELSIF  p_field_number = 153
2974       THEN
2975           -- Type of Program year
2976 
2977           igs_he_extract_fields_pkg.get_pyr_type
2978               (p_oss_pyr_type     =>  NVL(g_he_en_susa.type_of_year,g_he_poous.type_of_year),
2979                p_hesa_pyr_type    =>  p_value);
2980 
2981       ELSIF  p_field_number = 154
2982       THEN
2983           -- Level applicable for funding
2984           igs_he_extract_fields_pkg.get_lvl_appl_to_fund
2985               (p_poous_lvl_appl_fund   =>  g_he_poous.level_applicable_to_funding,
2986                p_prg_lvl_appl_fund     =>  g_he_st_prog.level_applicable_to_funding,
2987                p_hesa_lvl_appl_fund    =>  p_value);
2988 
2989       -- The derivation of this field has changed majorly to consider the new setup
2990       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
2991       ELSIF  p_field_number = 155
2992       THEN
2993 
2994          -- The default value not to be done for all the cuontries
2995          g_default_pro := 'N' ;
2996 
2997          IF g_he_submsn_header.validation_country IN ('ENGLAND','WALES','NORTHERN IRELAND')  THEN
2998 
2999             -- Check for the existence of the fields 154, 28, 152, 72 and 153. If not exists pass NULL value
3000             IF g_field_defn.hesa_value.EXISTS(154) THEN
3001               l_fundlev := g_field_defn.hesa_value(154);
3002             ELSE
3003               l_fundlev := NULL;
3004             END IF;
3005 
3006             IF g_field_defn.hesa_value.EXISTS(28) THEN
3007               l_spcstu := g_field_defn.hesa_value(28);
3008             ELSE
3009               l_spcstu := NULL;
3010             END IF;
3011 
3012             IF g_field_defn.hesa_value.EXISTS(152) THEN
3013               l_notact := g_field_defn.hesa_value(152);
3014             ELSE
3015               l_notact := NULL;
3016             END IF;
3017 
3018             IF g_field_defn.hesa_value.EXISTS(70) THEN
3019               l_mode := g_field_defn.hesa_value(70);
3020             ELSE
3021               l_mode := NULL;
3022             END IF;
3023             IF g_field_defn.hesa_value.EXISTS(153) THEN
3024               l_typeyr := g_field_defn.hesa_value(153);
3025             ELSE
3026               l_typeyr := NULL;
3027             END IF;
3028 
3029             -- Completion of Year of Program of study
3030             igs_he_extract_fields_pkg.get_comp_pyr_study (
3031               p_susa_comp_pyr_study  =>  g_he_en_susa.complete_pyr_study_cd,
3032               p_fundlev              =>  l_fundlev,
3033               p_spcstu               =>  l_spcstu,
3034               p_notact               =>  l_notact,
3035               p_mode                 =>  l_mode,
3036               p_typeyr               =>  l_typeyr,
3037               p_crse_rqr_complete_ind => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
3038               p_crse_req_complete_dt =>  g_en_stdnt_ps_att.course_rqrmnts_complete_dt,
3039               p_disc_reason_cd       =>  g_en_stdnt_ps_att.discontinuation_reason_cd,
3040               p_discont_dt           =>  g_en_stdnt_ps_att.discontinued_dt,
3041               p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
3042               p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date,
3043               p_person_id            =>  p_person_id,
3044               p_course_cd            =>  p_course_cd,
3045               p_hesa_comp_pyr_study  =>  p_value);
3046 
3047               g_default_pro := 'Y' ;
3048          END IF;
3049 
3050       ELSIF  p_field_number = 156
3051       THEN
3052 
3053          IF (g_he_submsn_header.validation_country =   'WALES'  AND ( g_field_defn.hesa_value.EXISTS(6) and  g_field_defn.hesa_value(6) IN (1,3,4))) THEN
3054             -- Get the value of Destination
3055             igs_he_extract_fields_pkg.get_destination
3056               (p_oss_destination     =>  g_he_st_spa.destination,
3057                p_hesa_destination    =>  p_value);
3058          ELSE
3059             -- The default value should not be calculated for  any other condition
3060             g_default_pro := 'N' ;
3061 
3062          END IF;
3063 
3064       ELSIF  p_field_number = 157
3065       THEN
3066           -- Not used
3067           p_value := NULL;
3068 
3069       ELSIF  p_field_number = 158
3070       THEN
3071           -- Not used
3072           p_value := NULL;
3073 
3074       ELSIF  p_field_number = 159
3075       THEN
3076           -- Not used
3077           p_value := NULL;
3078 
3079       ELSIF  p_field_number = 160
3080       THEN
3081           -- Not used
3082           p_value := NULL;
3083 
3084       ELSIF  p_field_number = 161
3085       THEN
3086 
3087         --Set the  default variable value as default value has to be calculated only for the down condition
3088         g_default_pro := 'N';
3089 
3090         IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES') THEN
3091               -- Get the value
3092               -- Outcome of ITT Program
3093           IF (g_field_defn.hesa_value.EXISTS(53)  AND g_field_defn.hesa_value(53) IN (1,6,7)) THEN
3094                 IF  g_field_defn.hesa_value.EXISTS(161)     THEN
3095                -- Calculated earlier, for field 29
3096                     p_value :=   g_field_defn.hesa_value(161);
3097 
3098                 ELSE
3099                    igs_he_extract_fields_pkg.get_itt_outcome
3100                     (p_oss_itt_outcome     =>  g_he_st_spa.itt_prog_outcome,
3101                      p_teach_train_prg     =>  g_field_defn.hesa_value(53),
3102                      p_hesa_itt_outcome    =>  p_value);
3103 
3104                 END IF;
3105                 --If the value is calculated as NULL above then do the default processing for this field
3106                 g_default_pro := 'Y' ;
3107           END IF;
3108         END IF;
3109 
3110       ELSIF  p_field_number = 162
3111       THEN
3112           -- Not used
3113           p_value := NULL;
3114 
3115       ELSIF  p_field_number = 163
3116       THEN
3117           -- Not used
3118           p_value := NULL;
3119 
3120       ELSIF  p_field_number = 164
3121       THEN
3122           -- UFI Place
3123           igs_he_extract_fields_pkg.get_ufi_place
3124               (p_oss_ufi_place     =>  NVL(g_he_st_spa.ufi_place,g_he_poous.ufi_place),
3125                p_hesa_ufi_place    =>  p_value);
3126 
3127       ELSIF  p_field_number = 165
3128       THEN
3129           --Franchising Activity
3130           igs_he_extract_fields_pkg.get_franchising_activity
3131               (p_susa_franch_activity   => g_he_en_susa.franchising_activity,
3132                p_poous_franch_activity  => g_he_poous.franchising_activity,
3133                p_prog_franch_activity   => g_he_st_prog.franchising_activity,
3134                p_hesa_franch_activity   =>  p_value);
3135 
3136       ELSIF  p_field_number = 166
3137       THEN
3138         -- Institutions own campus identifier
3139               igs_he_extract_fields_pkg.get_campus_id
3140               (p_location_cd => g_en_stdnt_ps_att.location_cd,
3141                p_campus_id   => p_value);
3142 
3143       ELSIF  p_field_number = 167
3144       THEN
3145           -- sjlaporte use date comparison rather than text bug 3933715
3146           -- Social Class Indicator
3147           IF g_en_stdnt_ps_att.commencement_dt  > TO_DATE('31/07/2002', 'DD/MM/YYYY')
3148           THEN
3149               igs_he_extract_fields_pkg.get_social_class_ind
3150                   (p_spa_social_class_ind   => g_he_st_spa.social_class_ind,
3151                    p_adm_social_class_ind   => g_he_ad_dtl.social_class_cd,
3152                    p_hesa_social_class_ind  => p_value);
3153           END IF;
3154 
3155       ELSIF  p_field_number = 168
3156       THEN
3157           -- sjlaporte use date comparison rather than text bug 3933715
3158           -- Occupation Code
3159           IF g_en_stdnt_ps_att.commencement_dt  > TO_DATE('31/07/2002', 'DD/MM/YYYY')
3160           THEN
3161               igs_he_extract_fields_pkg.get_occupation_code
3162                   (p_spa_occupation_code   => g_he_st_spa.occupation_code,
3163                    p_hesa_occupation_code  =>  p_value);
3164 
3165           END IF;
3166 
3167       ELSIF  p_field_number = 169
3168       THEN
3169 
3170           -- Insitute last attended
3171         -- smaddali modified this field to remove the dependency on field 148UCASNUM for bug 2663717
3172                   igs_he_extract_fields_pkg.get_inst_last_attended
3173                      (p_person_id         =>  p_person_id,
3174                       p_com_date          =>  g_en_stdnt_ps_att.commencement_dt,
3175                       p_inst_last_att     =>  p_value,
3176                       p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
3177                       p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date
3178                       );
3179 
3180       ELSIF  p_field_number = 170
3181       THEN
3182           -- Regulatory Body
3183           igs_he_extract_fields_pkg.get_regulatory_body
3184               (p_course_cd               =>  p_course_cd,
3185                p_version_number          =>  p_crv_version_number,
3186                p_hesa_regulatory_body    =>  p_value);
3187 
3188       -- Modified the field derivation to derive a default value based on field numbers 41 and 170
3189       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
3190       ELSIF  p_field_number = 171
3191       THEN
3192 
3193           -- Regulatory Body Registration Number
3194           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
3195           -- and adding validation to derive this field only if associate_nhs_reg_num=Y
3196           IF g_he_st_spa.associate_nhs_reg_num = 'Y' THEN
3197 
3198             -- Get alternate person id with type 'DH REG REF' which overlaps HESA reporting period
3199             igs_he_extract_fields_pkg.get_alt_pers_id
3200                 (p_person_id              => p_person_id,
3201                  p_id_type                => 'DH REG REF',
3202                  p_api_id                 => p_value,
3203                  p_enrl_start_dt          => g_he_submsn_header.enrolment_start_date,
3204                  p_enrl_end_dt            => g_he_submsn_header.enrolment_end_date);
3205 
3206           END IF ;
3207 
3208           -- If the field not derived and
3209           -- If field 41- QUALAIM  is 18 or 33 and Field 170 - Regulatory body for
3210           -- health and Social care students is 06 or 07 then use default value, 99999999
3211           IF p_value IS NULL AND g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN (18,33) AND
3212              g_field_defn.hesa_value.EXISTS(170)  AND g_field_defn.hesa_value(170) IN ('06', '07') THEN
3213 
3214             p_value := '99999999';
3215 
3216           END IF;
3217 
3218       ELSIF  p_field_number = 172
3219       THEN
3220           -- Source of NHS funding
3221           igs_he_extract_fields_pkg.get_nhs_fund_src
3222               (p_spa_nhs_fund_src    =>  g_he_st_spa.nhs_funding_source,
3223                p_prg_nhs_fund_src    =>  g_he_st_prog.nhs_funding_source,
3224                p_hesa_nhs_fund_src   =>  p_value);
3225 
3226       ELSIF  p_field_number = 173
3227       THEN
3228           -- NHS Employer
3229           igs_he_extract_fields_pkg.get_nhs_employer
3230               (p_spa_nhs_employer     => g_he_st_spa.nhs_employer,
3231                p_hesa_nhs_employer    => p_value);
3232 
3233       ELSIF  p_field_number = 174
3234       THEN
3235 
3236           g_default_pro := 'N';
3237 
3238           -- Number of GCE AS Levels
3239           igs_he_extract_fields_pkg.get_qual_dets
3240               (p_person_id            =>  p_person_id,
3241                p_course_cd            =>  p_course_cd,
3242                p_hesa_qual            =>  'GCSEAS',
3243                p_no_of_qual           =>  p_value,
3244                p_tariff_score         =>  g_field_defn.hesa_value(175));
3245 
3246           IF p_value IS NOT NULL THEN
3247             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3248                                                        p_person_number  => g_pe_person.person_number,
3249                                                        p_course_cd      => p_course_cd,
3250                                                        p_hesa_qual      => 'GCEASN',
3251                                                        p_no_of_qual     => p_value);
3252           ELSE
3253               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3254               IF g_field_defn.hesa_value.EXISTS(41)  AND
3255                  g_field_defn.hesa_value.EXISTS(26)  AND
3256                  g_field_defn.hesa_value.EXISTS(148) AND
3257                  igs_he_extract_fields_pkg.is_ucas_ftug
3258                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3259                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3260                       p_ucasnum           => g_field_defn.hesa_value(148),
3261                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3262               THEN
3263                   g_default_pro := 'Y';
3264               END IF;
3265 
3266           END IF;
3267 
3268       ELSIF  p_field_number = 175
3269       THEN
3270 
3271           g_default_pro := 'N';
3272 
3273           -- GCE AS level Tariff Score
3274           IF g_field_defn.hesa_value.EXISTS(175) AND g_field_defn.hesa_value(175) IS NOT NULL
3275           THEN
3276               p_value := g_field_defn.hesa_value(175);
3277 
3278               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3279                                                            p_person_number  => g_pe_person.person_number,
3280                                                            p_course_cd      => p_course_cd,
3281                                                            p_hesa_qual      => 'GCEASTS',
3282                                                            p_tariff_score   => p_value);
3283           END IF;
3284 
3285           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3286           IF p_value IS NULL AND
3287              g_field_defn.hesa_value.EXISTS(41)  AND
3288              g_field_defn.hesa_value.EXISTS(26)  AND
3289              g_field_defn.hesa_value.EXISTS(148) AND
3290              igs_he_extract_fields_pkg.is_ucas_ftug
3291                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3292                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3293                   p_ucasnum           => g_field_defn.hesa_value(148),
3294                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3295           THEN
3296               g_default_pro := 'Y';
3297           END IF;
3298 
3299       ELSIF  p_field_number = 176
3300       THEN
3301 
3302           g_default_pro := 'N';
3303 
3304           -- Number of VCE AS Levels
3305           igs_he_extract_fields_pkg.get_qual_dets
3306               (p_person_id            =>  p_person_id,
3307                p_course_cd            =>  p_course_cd,
3308                p_hesa_qual            =>  'VCSEAS',
3309                p_no_of_qual           =>  p_value,
3310                p_tariff_score         =>  g_field_defn.hesa_value(177));
3311 
3312           IF p_value IS NOT NULL THEN
3313             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3314                                                        p_person_number  => g_pe_person.person_number,
3315                                                        p_course_cd      => p_course_cd,
3316                                                        p_hesa_qual      => 'VCEASN',
3317                                                        p_no_of_qual     => p_value);
3318           END IF;
3319 
3320           IF g_field_defn.hesa_value.EXISTS(41)  AND
3321              g_field_defn.hesa_value.EXISTS(26)  AND
3322              g_field_defn.hesa_value.EXISTS(148) AND
3323              igs_he_extract_fields_pkg.is_ucas_ftug
3324                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3325                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3326                   p_ucasnum           => g_field_defn.hesa_value(148),
3327                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3328           THEN
3329               g_default_pro := 'Y';
3330           END IF;
3331 
3332 
3333       ELSIF  p_field_number = 177
3334       THEN
3335 
3336           g_default_pro := 'N';
3337 
3338           -- GCE AS level Tariff Score
3339           IF g_field_defn.hesa_value.EXISTS(177) AND g_field_defn.hesa_value(177) IS NOT NULL
3340           THEN
3341               p_value := g_field_defn.hesa_value(177);
3342 
3343               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3344                                                            p_person_number  => g_pe_person.person_number,
3345                                                            p_course_cd      => p_course_cd,
3346                                                            p_hesa_qual      => 'VCEASTS',
3347                                                            p_tariff_score   => p_value);
3348           END IF;
3349 
3350           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3351           IF p_value IS NULL AND
3352              g_field_defn.hesa_value.EXISTS(41)  AND
3353              g_field_defn.hesa_value.EXISTS(26)  AND
3354              g_field_defn.hesa_value.EXISTS(148) AND
3355              igs_he_extract_fields_pkg.is_ucas_ftug
3356                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3357                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3358                   p_ucasnum           => g_field_defn.hesa_value(148),
3359                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3360           THEN
3361               g_default_pro := 'Y';
3362           END IF;
3363 
3364       ELSIF  p_field_number = 178
3365       THEN
3366 
3367           g_default_pro := 'N';
3368 
3369           -- Number of GCE A Levels
3370           igs_he_extract_fields_pkg.get_qual_dets
3371               (p_person_id            =>  p_person_id,
3372                p_course_cd            =>  p_course_cd,
3373                p_hesa_qual            =>  'GCSEA',
3374                p_no_of_qual           =>  p_value,
3375                p_tariff_score         =>  g_field_defn.hesa_value(179));
3376 
3377           IF p_value IS NOT NULL THEN
3378             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3379                                                        p_person_number  => g_pe_person.person_number,
3380                                                        p_course_cd      => p_course_cd,
3381                                                        p_hesa_qual      => 'GCEAN',
3382                                                        p_no_of_qual     => p_value);
3383           END IF;
3384 
3385           IF g_field_defn.hesa_value.EXISTS(41)  AND
3386              g_field_defn.hesa_value.EXISTS(26)  AND
3387              g_field_defn.hesa_value.EXISTS(148) AND
3388              igs_he_extract_fields_pkg.is_ucas_ftug
3389                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3390                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3391                   p_ucasnum           => g_field_defn.hesa_value(148),
3392                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3393           THEN
3394               g_default_pro := 'Y';
3395           END IF;
3396 
3397       ELSIF  p_field_number = 179
3398       THEN
3399 
3400           g_default_pro := 'N';
3401 
3402           -- GCE A level Tariff Score
3403           IF g_field_defn.hesa_value.EXISTS(179) AND g_field_defn.hesa_value(179) IS NOT NULL
3404           THEN
3405               p_value := g_field_defn.hesa_value(179);
3406 
3407               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3408                                                            p_person_number  => g_pe_person.person_number,
3409                                                            p_course_cd      => p_course_cd,
3410                                                            p_hesa_qual      => 'GCEATS',
3411                                                            p_tariff_score   => p_value);
3412 
3413           END IF;
3414 
3415           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3416           IF p_value IS NULL AND
3417              g_field_defn.hesa_value.EXISTS(41)  AND
3418              g_field_defn.hesa_value.EXISTS(26)  AND
3419              g_field_defn.hesa_value.EXISTS(148) AND
3420              igs_he_extract_fields_pkg.is_ucas_ftug
3421                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3422                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3423                   p_ucasnum           => g_field_defn.hesa_value(148),
3424                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3425           THEN
3426               g_default_pro := 'Y';
3427           END IF;
3428 
3429 
3430       ELSIF  p_field_number = 180
3431       THEN
3432 
3433           g_default_pro := 'N';
3434 
3435           -- Number of VCE A Levels
3436           igs_he_extract_fields_pkg.get_qual_dets
3437               (p_person_id            =>  p_person_id,
3438                p_course_cd            =>  p_course_cd,
3439                p_hesa_qual            =>  'VCSEA',
3440                p_no_of_qual           =>  p_value,
3441                p_tariff_score         =>  g_field_defn.hesa_value(181));
3442 
3443           IF p_value IS NOT NULL THEN
3444             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3445                                                        p_person_number  => g_pe_person.person_number,
3446                                                        p_course_cd      => p_course_cd,
3447                                                        p_hesa_qual      => 'VCEAN',
3448                                                        p_no_of_qual     => p_value);
3449           ELSE
3450               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3451               IF g_field_defn.hesa_value.EXISTS(41)  AND
3452                  g_field_defn.hesa_value.EXISTS(26)  AND
3453                  g_field_defn.hesa_value.EXISTS(148) AND
3454                  igs_he_extract_fields_pkg.is_ucas_ftug
3455                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3456                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3457                       p_ucasnum           => g_field_defn.hesa_value(148),
3458                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3459               THEN
3460                 g_default_pro := 'Y';
3461               END IF;
3462 
3463           END IF;
3464 
3465 
3466       ELSIF  p_field_number = 181
3467       THEN
3468 
3469           g_default_pro := 'N';
3470 
3471           -- VCE A level Tariff Score
3472           IF g_field_defn.hesa_value.EXISTS(181) AND g_field_defn.hesa_value(181) IS NOT NULL
3473           THEN
3474               p_value := g_field_defn.hesa_value(181);
3475 
3476               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3477                                                            p_person_number  => g_pe_person.person_number,
3478                                                            p_course_cd      => p_course_cd,
3479                                                            p_hesa_qual      => 'VCEATS',
3480                                                            p_tariff_score   => p_value);
3481 
3482           END IF;
3483 
3484           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3485           IF p_value IS NULL AND
3486              g_field_defn.hesa_value.EXISTS(41)  AND
3487              g_field_defn.hesa_value.EXISTS(26)  AND
3488              g_field_defn.hesa_value.EXISTS(148) AND
3489              igs_he_extract_fields_pkg.is_ucas_ftug
3490                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3491                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3492                   p_ucasnum           => g_field_defn.hesa_value(148),
3493                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3494           THEN
3495               g_default_pro := 'Y';
3496           END IF;
3497 
3498       ELSIF  p_field_number = 182
3499       THEN
3500 
3501           g_default_pro := 'N';
3502 
3503           -- Number of Key Skill Qualifications
3504           igs_he_extract_fields_pkg.get_qual_dets
3505               (p_person_id            =>  p_person_id,
3506                p_course_cd            =>  p_course_cd,
3507                p_hesa_qual            =>  'KEYSKL',
3508                p_no_of_qual           =>  p_value,
3509                p_tariff_score         =>  g_field_defn.hesa_value(183));
3510 
3511           IF p_value IS NOT NULL THEN
3512             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3513                                                        p_person_number  => g_pe_person.person_number,
3514                                                        p_course_cd      => p_course_cd,
3515                                                        p_hesa_qual      => 'KSQN',
3516                                                        p_no_of_qual     => p_value);
3517           ELSE
3518               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3519               IF g_field_defn.hesa_value.EXISTS(41)  AND
3520                  g_field_defn.hesa_value.EXISTS(26)  AND
3521                  g_field_defn.hesa_value.EXISTS(148) AND
3522                  igs_he_extract_fields_pkg.is_ucas_ftug
3523                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3524                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3525                       p_ucasnum           => g_field_defn.hesa_value(148),
3526                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3527               THEN
3528                 g_default_pro := 'Y';
3529               END IF;
3530 
3531           END IF;
3532 
3533       ELSIF  p_field_number = 183
3534       THEN
3535 
3536           g_default_pro := 'N';
3537 
3538           -- Key Skills Tariff Score
3539           IF g_field_defn.hesa_value.EXISTS(183) AND g_field_defn.hesa_value(183) IS NOT NULL
3540           THEN
3541               p_value := g_field_defn.hesa_value(183);
3542 
3543               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3544                                                            p_person_number  => g_pe_person.person_number,
3545                                                            p_course_cd      => p_course_cd,
3546                                                            p_hesa_qual      => 'KSQTS',
3547                                                            p_tariff_score   => p_value);
3548 
3549           END IF;
3550 
3551           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3552           IF p_value IS NULL AND
3553              g_field_defn.hesa_value.EXISTS(41)  AND
3554              g_field_defn.hesa_value.EXISTS(26)  AND
3555              g_field_defn.hesa_value.EXISTS(148) AND
3556              igs_he_extract_fields_pkg.is_ucas_ftug
3557                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3558                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3559                   p_ucasnum           => g_field_defn.hesa_value(148),
3560                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3561           THEN
3562               g_default_pro := 'Y';
3563           END IF;
3564 
3565 
3566       ELSIF  p_field_number = 184
3567       THEN
3568 
3569           g_default_pro := 'N';
3570 
3571           -- Number of 1 unit key skill awards
3572           igs_he_extract_fields_pkg.get_qual_dets
3573               (p_person_id            =>  p_person_id,
3574                p_course_cd            =>  p_course_cd,
3575                p_hesa_qual            =>  '1UNKEYSKL',
3576                p_no_of_qual           =>  p_value,
3577                p_tariff_score         =>  g_field_defn.hesa_value(185));
3578 
3579           IF p_value IS NOT NULL THEN
3580             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3581                                                        p_person_number  => g_pe_person.person_number,
3582                                                        p_course_cd      => p_course_cd,
3583                                                        p_hesa_qual      => 'UKSAN',
3584                                                        p_no_of_qual     => p_value);
3585           ELSE
3586               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3587               IF g_field_defn.hesa_value.EXISTS(41)  AND
3588                  g_field_defn.hesa_value.EXISTS(26)  AND
3589                  g_field_defn.hesa_value.EXISTS(148) AND
3590                  igs_he_extract_fields_pkg.is_ucas_ftug
3591                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3592                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3593                       p_ucasnum           => g_field_defn.hesa_value(148),
3594                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3595               THEN
3596                 g_default_pro := 'Y';
3597               END IF;
3598 
3599           END IF;
3600 
3601       ELSIF  p_field_number = 185
3602       THEN
3603 
3604           g_default_pro := 'N';
3605 
3606           -- 1 Unit Key Skill Tariff Score
3607           IF g_field_defn.hesa_value.EXISTS(185) AND g_field_defn.hesa_value(185) IS NOT NULL
3608           THEN
3609               p_value := g_field_defn.hesa_value(185);
3610 
3611               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3612                                                            p_person_number  => g_pe_person.person_number,
3613                                                            p_course_cd      => p_course_cd,
3614                                                            p_hesa_qual      => 'UKSATS',
3615                                                            p_tariff_score   => p_value);
3616 
3617           END IF;
3618 
3619           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3620           IF p_value IS NULL AND
3621              g_field_defn.hesa_value.EXISTS(41)  AND
3622              g_field_defn.hesa_value.EXISTS(26)  AND
3623              g_field_defn.hesa_value.EXISTS(148) AND
3624              igs_he_extract_fields_pkg.is_ucas_ftug
3625                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3626                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3627                   p_ucasnum           => g_field_defn.hesa_value(148),
3628                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3629           THEN
3630               g_default_pro := 'Y';
3631           END IF;
3632 
3633       ELSIF  p_field_number = 186
3634       THEN
3635 
3636           g_default_pro := 'N';
3637 
3638           -- Number of Scottish Advanced Higher Levels
3639           igs_he_extract_fields_pkg.get_qual_dets
3640               (p_person_id            =>  p_person_id,
3641                p_course_cd            =>  p_course_cd,
3642                p_hesa_qual            =>  'SCOTADH',
3643                p_no_of_qual           =>  p_value,
3644                p_tariff_score         =>  g_field_defn.hesa_value(187));
3645 
3646           IF p_value IS NOT NULL THEN
3647             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3648                                                        p_person_number  => g_pe_person.person_number,
3649                                                        p_course_cd      => p_course_cd,
3650                                                        p_hesa_qual      => 'SAHN',
3651                                                        p_no_of_qual     => p_value);
3652           ELSE
3653               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3654               IF g_field_defn.hesa_value.EXISTS(41)  AND
3655                  g_field_defn.hesa_value.EXISTS(26)  AND
3656                  g_field_defn.hesa_value.EXISTS(148) AND
3657                  igs_he_extract_fields_pkg.is_ucas_ftug
3658                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3659                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3660                       p_ucasnum           => g_field_defn.hesa_value(148),
3661                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3662               THEN
3663                 g_default_pro := 'Y';
3664               END IF;
3665 
3666           END IF;
3667 
3668       ELSIF  p_field_number = 187
3669       THEN
3670 
3671           g_default_pro := 'N';
3672 
3673           -- Scottish Advanced Higher level Tariff Score
3674           IF g_field_defn.hesa_value.EXISTS(187) AND g_field_defn.hesa_value(187) IS NOT NULL
3675           THEN
3676               p_value := g_field_defn.hesa_value(187);
3677 
3678               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3679                                                            p_person_number  => g_pe_person.person_number,
3680                                                            p_course_cd      => p_course_cd,
3681                                                            p_hesa_qual      => 'SAHTS',
3682                                                            p_tariff_score   => p_value);
3683           END IF;
3684 
3685           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3686           IF p_value IS NULL AND
3687              g_field_defn.hesa_value.EXISTS(41)  AND
3688              g_field_defn.hesa_value.EXISTS(26)  AND
3689              g_field_defn.hesa_value.EXISTS(148) AND
3690              igs_he_extract_fields_pkg.is_ucas_ftug
3691                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3692                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3693                   p_ucasnum           => g_field_defn.hesa_value(148),
3694                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3695           THEN
3696               g_default_pro := 'Y';
3697           END IF;
3698 
3699       ELSIF  p_field_number = 188
3700       THEN
3701 
3702           g_default_pro := 'N';
3703 
3704           -- Number of Scottish Higher Levels
3705           igs_he_extract_fields_pkg.get_qual_dets
3706               (p_person_id            =>  p_person_id,
3707                p_course_cd            =>  p_course_cd,
3708                p_hesa_qual            =>  'SCOTH',
3709                p_no_of_qual           =>  p_value,
3710                p_tariff_score         =>  g_field_defn.hesa_value(189));
3711 
3712           IF p_value IS NOT NULL THEN
3713             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3714                                                        p_person_number  => g_pe_person.person_number,
3715                                                        p_course_cd      => p_course_cd,
3716                                                        p_hesa_qual      => 'SHN',
3717                                                        p_no_of_qual     => p_value);
3718           ELSE
3719               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3720               IF g_field_defn.hesa_value.EXISTS(41)  AND
3721                  g_field_defn.hesa_value.EXISTS(26)  AND
3722                  g_field_defn.hesa_value.EXISTS(148) AND
3723                  igs_he_extract_fields_pkg.is_ucas_ftug
3724                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3725                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3726                       p_ucasnum           => g_field_defn.hesa_value(148),
3727                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3728               THEN
3729                 g_default_pro := 'Y';
3730               END IF;
3731 
3732           END IF;
3733 
3734       ELSIF  p_field_number = 189
3735       THEN
3736 
3737           g_default_pro := 'N';
3738 
3739           -- Scottish Higher level Tariff Score
3740           IF g_field_defn.hesa_value.EXISTS(189) AND g_field_defn.hesa_value(189) IS NOT NULL
3741           THEN
3742               p_value := g_field_defn.hesa_value(189);
3743               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3744                                                            p_person_number  => g_pe_person.person_number,
3745                                                            p_course_cd      => p_course_cd,
3746                                                            p_hesa_qual      => 'SHTS',
3747                                                            p_tariff_score   => p_value);
3748 
3749           END IF;
3750 
3751           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3752           IF p_value IS NULL AND
3753              g_field_defn.hesa_value.EXISTS(41)  AND
3754              g_field_defn.hesa_value.EXISTS(26)  AND
3755              g_field_defn.hesa_value.EXISTS(148) AND
3756              igs_he_extract_fields_pkg.is_ucas_ftug
3757                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3758                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3759                   p_ucasnum           => g_field_defn.hesa_value(148),
3760                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3761           THEN
3762               g_default_pro := 'Y';
3763           END IF;
3764 
3765       ELSIF  p_field_number = 190
3766       THEN
3767 
3768           g_default_pro := 'N';
3769 
3770           -- Number of Scottish Intermediate Levels
3771           igs_he_extract_fields_pkg.get_qual_dets
3772               (p_person_id            =>  p_person_id,
3773                p_course_cd            =>  p_course_cd,
3774                p_hesa_qual            =>  'SCOTI2',
3775                p_no_of_qual           =>  p_value,
3776                p_tariff_score         =>  g_field_defn.hesa_value(191));
3777 
3778           IF p_value IS NOT NULL THEN
3779             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3780                                                        p_person_number  => g_pe_person.person_number,
3781                                                        p_course_cd      => p_course_cd,
3782                                                        p_hesa_qual      => 'SI2N',
3783                                                        p_no_of_qual     => p_value);
3784           ELSE
3785               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3786               IF g_field_defn.hesa_value.EXISTS(41)  AND
3787                  g_field_defn.hesa_value.EXISTS(26)  AND
3788                  g_field_defn.hesa_value.EXISTS(148) AND
3789                  igs_he_extract_fields_pkg.is_ucas_ftug
3790                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3791                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3792                       p_ucasnum           => g_field_defn.hesa_value(148),
3793                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3794               THEN
3795                 g_default_pro := 'Y';
3796               END IF;
3797 
3798           END IF;
3799 
3800       ELSIF  p_field_number = 191
3801       THEN
3802 
3803           g_default_pro := 'N';
3804 
3805           -- Scottish Intermediate level Tariff Score
3806           IF g_field_defn.hesa_value.EXISTS(191) AND g_field_defn.hesa_value(191) IS NOT NULL
3807           THEN
3808               p_value := g_field_defn.hesa_value(191);
3809               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3810                                                            p_person_number  => g_pe_person.person_number,
3811                                                            p_course_cd      => p_course_cd,
3812                                                            p_hesa_qual      => 'SI2TS',
3813                                                            p_tariff_score   => p_value);
3814 
3815           END IF;
3816 
3817           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3818           IF p_value IS NULL AND
3819              g_field_defn.hesa_value.EXISTS(41)  AND
3820              g_field_defn.hesa_value.EXISTS(26)  AND
3821              g_field_defn.hesa_value.EXISTS(148) AND
3822              igs_he_extract_fields_pkg.is_ucas_ftug
3823                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3824                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3825                   p_ucasnum           => g_field_defn.hesa_value(148),
3826                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3827           THEN
3828               g_default_pro := 'Y';
3829           END IF;
3830 
3831       ELSIF  p_field_number = 192
3832       THEN
3833 
3834           g_default_pro := 'N';
3835 
3836           -- Number of Scottish Standard Grade Credit Levels
3837           igs_he_extract_fields_pkg.get_qual_dets
3838               (p_person_id            =>  p_person_id,
3839                p_course_cd            =>  p_course_cd,
3840                p_hesa_qual            =>  'SCOTST',
3841                p_no_of_qual           =>  p_value,
3842                p_tariff_score         =>  g_field_defn.hesa_value(193));
3843 
3844           IF p_value IS NOT NULL THEN
3845             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3846                                                        p_person_number  => g_pe_person.person_number,
3847                                                        p_course_cd      => p_course_cd,
3848                                                        p_hesa_qual      => 'SSGCN',
3849                                                        p_no_of_qual     => p_value);
3850           ELSE
3851               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3852               IF g_field_defn.hesa_value.EXISTS(41)  AND
3853                  g_field_defn.hesa_value.EXISTS(26)  AND
3854                  g_field_defn.hesa_value.EXISTS(148) AND
3855                  igs_he_extract_fields_pkg.is_ucas_ftug
3856                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3857                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3858                       p_ucasnum           => g_field_defn.hesa_value(148),
3859                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3860               THEN
3861                 g_default_pro := 'Y';
3862               END IF;
3863 
3864           END IF;
3865 
3866       ELSIF  p_field_number = 193
3867       THEN
3868 
3869           g_default_pro := 'N';
3870 
3871           --  Scottish Standard Grade  level Tariff Score
3872           IF g_field_defn.hesa_value.EXISTS(193) AND g_field_defn.hesa_value(193) IS NOT NULL
3873           THEN
3874               p_value := g_field_defn.hesa_value(193);
3875 
3876               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3877                                                            p_person_number  => g_pe_person.person_number,
3878                                                            p_course_cd      => p_course_cd,
3879                                                            p_hesa_qual      => 'SSGCTS',
3880                                                            p_tariff_score   => p_value);
3881 
3882           END IF;
3883 
3884           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3885           IF p_value IS NULL AND
3886              g_field_defn.hesa_value.EXISTS(41)  AND
3887              g_field_defn.hesa_value.EXISTS(26)  AND
3888              g_field_defn.hesa_value.EXISTS(148) AND
3889              igs_he_extract_fields_pkg.is_ucas_ftug
3890                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3891                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3892                   p_ucasnum           => g_field_defn.hesa_value(148),
3893                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3894           THEN
3895               g_default_pro := 'Y';
3896           END IF;
3897 
3898       ELSIF  p_field_number = 194
3899       THEN
3900 
3901           g_default_pro := 'N';
3902 
3903           -- Number of Scottish Core Skills Levels
3904           igs_he_extract_fields_pkg.get_qual_dets
3905               (p_person_id            =>  p_person_id,
3906                p_course_cd            =>  p_course_cd,
3907                p_hesa_qual            =>  'SCOTCO',
3908                p_no_of_qual           =>  p_value,
3909                p_tariff_score         =>  g_field_defn.hesa_value(195));
3910 
3911           IF p_value IS NOT NULL THEN
3912             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3913                                                        p_person_number  => g_pe_person.person_number,
3914                                                        p_course_cd      => p_course_cd,
3915                                                        p_hesa_qual      => 'SCSN',
3916                                                        p_no_of_qual     => p_value);
3917           ELSE
3918               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3919               IF g_field_defn.hesa_value.EXISTS(41)  AND
3920                  g_field_defn.hesa_value.EXISTS(26)  AND
3921                  g_field_defn.hesa_value.EXISTS(148) AND
3922                  igs_he_extract_fields_pkg.is_ucas_ftug
3923                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3924                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3925                       p_ucasnum           => g_field_defn.hesa_value(148),
3926                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3927               THEN
3928                 g_default_pro := 'Y';
3929               END IF;
3930 
3931           END IF;
3932 
3933       ELSIF  p_field_number = 195
3934       THEN
3935 
3936           g_default_pro := 'N';
3937 
3938           -- Scottish Core Skills level Tariff Score
3939           IF g_field_defn.hesa_value.EXISTS(195) AND g_field_defn.hesa_value(195) IS NOT NULL
3940           THEN
3941               p_value := g_field_defn.hesa_value(195);
3942               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
3943                                                            p_person_number  => g_pe_person.person_number,
3944                                                            p_course_cd      => p_course_cd,
3945                                                            p_hesa_qual      => 'SCSTS',
3946                                                            p_tariff_score   => p_value);
3947 
3948           END IF;
3949 
3950           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
3951           IF p_value IS NULL AND
3952              g_field_defn.hesa_value.EXISTS(41)  AND
3953              g_field_defn.hesa_value.EXISTS(26)  AND
3954              g_field_defn.hesa_value.EXISTS(148) AND
3955              igs_he_extract_fields_pkg.is_ucas_ftug
3956                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3957                   p_hesa_commdate     => g_field_defn.hesa_value(26),
3958                   p_ucasnum           => g_field_defn.hesa_value(148),
3959                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
3960           THEN
3961               g_default_pro := 'Y';
3962           END IF;
3963 
3964       ELSIF  p_field_number = 196
3965       THEN
3966 
3967           g_default_pro := 'N';
3968 
3969           -- Number of Advanced Extension
3970           igs_he_extract_fields_pkg.get_qual_dets
3971               (p_person_id            =>  p_person_id,
3972                p_course_cd            =>  p_course_cd,
3973                p_hesa_qual            =>  'ADVEXT',
3974                p_no_of_qual           =>  p_value,
3975                p_tariff_score         =>  g_field_defn.hesa_value(197));
3976 
3977           IF p_value IS NOT NULL THEN
3978             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
3979                                                        p_person_number  => g_pe_person.person_number,
3980                                                        p_course_cd      => p_course_cd,
3981                                                        p_hesa_qual      => 'AEAN',
3982                                                        p_no_of_qual     => p_value);
3983           ELSE
3984               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
3985               IF g_field_defn.hesa_value.EXISTS(41)  AND
3986                  g_field_defn.hesa_value.EXISTS(26)  AND
3987                  g_field_defn.hesa_value.EXISTS(148) AND
3988                  igs_he_extract_fields_pkg.is_ucas_ftug
3989                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
3990                       p_hesa_commdate     => g_field_defn.hesa_value(26),
3991                       p_ucasnum           => g_field_defn.hesa_value(148),
3992                       p_min_commdate      => TO_DATE('31/07/2003', 'DD/MM/YYYY'))
3993               THEN
3994                 g_default_pro := 'Y';
3995               END IF;
3996 
3997           END IF;
3998 
3999       ELSIF  p_field_number = 197
4000       THEN
4001 
4002            g_default_pro := 'N';
4003 
4004           -- Advanced Extension Tariff Score
4005           IF g_field_defn.hesa_value.EXISTS(197) AND g_field_defn.hesa_value(197) IS NOT NULL
4006           THEN
4007               p_value := g_field_defn.hesa_value(197);
4008               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
4009                                                            p_person_number  => g_pe_person.person_number,
4010                                                            p_course_cd      => p_course_cd,
4011                                                            p_hesa_qual      => 'AENTS',
4012                                                            p_tariff_score   => p_value);
4013 
4014           END IF;
4015 
4016           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
4017           IF p_value IS NULL AND
4018              g_field_defn.hesa_value.EXISTS(41)  AND
4019              g_field_defn.hesa_value.EXISTS(26)  AND
4020              g_field_defn.hesa_value.EXISTS(148) AND
4021              igs_he_extract_fields_pkg.is_ucas_ftug
4022                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
4023                   p_hesa_commdate     => g_field_defn.hesa_value(26),
4024                   p_ucasnum           => g_field_defn.hesa_value(148),
4025                   p_min_commdate      => TO_DATE('31/07/2003', 'DD/MM/YYYY'))
4026           THEN
4027               g_default_pro := 'Y';
4028           END IF;
4029 
4030       ELSIF  p_field_number = 198
4031       THEN
4032 
4033           g_default_pro := 'N';
4034 
4035           -- Total Tariff Score
4036           p_value :=  g_he_st_spa.total_ucas_tariff;
4037 
4038           IF p_value IS NOT NULL
4039           THEN
4040               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
4041                                                            p_person_number  => g_pe_person.person_number,
4042                                                            p_course_cd      => p_course_cd,
4043                                                            p_hesa_qual      => 'TOTALTS',
4044                                                            p_tariff_score   => p_value);
4045           ELSE
4046               IF g_field_defn.hesa_value.EXISTS(41)  AND
4047                  g_field_defn.hesa_value.EXISTS(26)  AND
4048                  g_field_defn.hesa_value.EXISTS(148) AND
4049                  igs_he_extract_fields_pkg.is_ucas_ftug
4050                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
4051                       p_hesa_commdate     => g_field_defn.hesa_value(26),
4052                       p_ucasnum           => g_field_defn.hesa_value(148),
4053                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
4054               THEN
4055                   g_default_pro := 'Y';
4056               END IF;
4057           END IF;
4058 
4059       ELSIF  p_field_number = 199
4060       THEN
4061           -- Number of CACHE qualifications
4062           igs_he_extract_fields_pkg.get_qual_dets
4063               (p_person_id            =>  p_person_id,
4064                p_course_cd            =>  p_course_cd,
4065                p_hesa_qual            =>  'CACHE',
4066                p_no_of_qual           =>  p_value,
4067                p_tariff_score         =>  g_field_defn.hesa_value(200));
4068 
4069       ELSIF  p_field_number = 200
4070       THEN
4071           -- CACHE qualifications Tariff Score
4072           IF g_field_defn.hesa_value.EXISTS(200)
4073           THEN
4074               p_value := g_field_defn.hesa_value(200);
4075           END IF;
4076 
4077       ELSIF  p_field_number = 201
4078       THEN
4079           -- Number of BTEC
4080           igs_he_extract_fields_pkg.get_qual_dets
4081               (p_person_id            =>  p_person_id,
4082                p_course_cd            =>  p_course_cd,
4083                p_hesa_qual            =>  'BTEC',
4084                p_no_of_qual           =>  p_value,
4085                p_tariff_score         =>  g_field_defn.hesa_value(202));
4086 
4087       ELSIF  p_field_number = 202
4088       THEN
4089           -- BTEC Tariff Score
4090           IF g_field_defn.hesa_value.EXISTS(202)
4091           THEN
4092               p_value := g_field_defn.hesa_value(202);
4093           END IF;
4094 
4095       ELSIF  p_field_number = 203
4096       THEN
4097           -- International Baccalaureate Tariff Score
4098           igs_he_extract_fields_pkg.get_qual_dets
4099               (p_person_id            =>  p_person_id,
4100                p_course_cd            =>  p_course_cd,
4101                p_hesa_qual            =>  'INBA',
4102                p_no_of_qual           =>  l_dummy,
4103                p_tariff_score         =>  p_value);
4104 
4105       ELSIF  p_field_number = 204
4106       THEN
4107           -- Irish Leaving certificate tariff score
4108           igs_he_extract_fields_pkg.get_qual_dets
4109               (p_person_id            =>  p_person_id,
4110                p_course_cd            =>  p_course_cd,
4111                p_hesa_qual            =>  'ILC',
4112                p_no_of_qual           =>  l_dummy,
4113                p_tariff_score         =>  p_value);
4114 
4115       ELSIF  p_field_number = 205
4116       THEN
4117           -- Music, Drama and Performing Arts
4118           igs_he_extract_fields_pkg.get_qual_dets
4119               (p_person_id            =>  p_person_id,
4120                p_course_cd            =>  p_course_cd,
4121                p_hesa_qual            =>  'MUDRPA',
4122                p_no_of_qual           =>  l_dummy,
4123                p_tariff_score         =>  p_value);
4124 
4125       ELSIF  p_field_number = 206
4126       THEN
4127           -- Credit value for Year of Program , 3
4128           p_value := NVL(g_he_en_susa.credit_value_yop3,g_he_poous.credit_value_yop3 ) ;
4129 
4130           p_value := LPAD(p_value, 3,'0') ;
4131 
4132 
4133       ELSIF  p_field_number = 207
4134       THEN
4135           -- Credit value for Year of Program , 4
4136           p_value := NVL(g_he_en_susa.credit_value_yop4,g_he_poous.credit_value_yop4 );
4137 
4138           p_value := LPAD(p_value, 3,'0') ;
4139 
4140 
4141       ELSIF  p_field_number = 208
4142       THEN
4143           -- Level of Credit, 3
4144               igs_he_extract_fields_pkg.get_credit_level
4145                  (p_susa_credit_level     =>  g_he_en_susa.credit_level3,
4146                   p_poous_credit_level    =>  g_he_poous.level_credit3,
4147                   p_hesa_credit_level     =>  p_value);
4148 
4149       ELSIF  p_field_number = 209
4150       THEN
4151           -- Level of Credit, 4
4152               igs_he_extract_fields_pkg.get_credit_level
4153                  (p_susa_credit_level    =>  g_he_en_susa.credit_level4 ,
4154                   p_poous_credit_level   =>  g_he_poous.level_credit4,
4155                   p_hesa_credit_level    =>  p_value);
4156 
4157       ELSIF  p_field_number = 210
4158       THEN
4159            -- Number of Credit Points Obtained 3
4160            IF g_field_defn.hesa_value.EXISTS(210)
4161            THEN
4162                p_value :=  g_field_defn.hesa_value(210);
4163            ELSE
4164                igs_he_extract_fields_pkg.get_credit_obtained
4165                (p_person_id          =>  p_person_id,
4166                 p_course_cd          =>  p_course_cd,
4167                 p_prog_calc          =>  g_he_st_prog.program_calc,
4168                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
4169                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
4170                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
4171                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
4172                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
4173                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
4174                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
4175                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
4176                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
4177                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
4178                 p_no_crd_pt3         =>  p_value,
4179                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
4180                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
4181                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
4182                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
4183                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
4184                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
4185                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
4186            END IF;
4187 
4188            p_value := LPAD(p_value, 3,'0') ;
4189 
4190       ELSIF  p_field_number = 211
4191       THEN
4192            -- Number of Credit Points Obtained 4
4193            IF g_field_defn.hesa_value.EXISTS(211)
4194            THEN
4195                p_value :=  g_field_defn.hesa_value(211);
4196            ELSE
4197                igs_he_extract_fields_pkg.get_credit_obtained
4198                (p_person_id          =>  p_person_id,
4199                 p_course_cd          =>  p_course_cd,
4200                 p_prog_calc          =>  g_he_st_prog.program_calc,
4201                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
4202                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
4203                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
4204                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
4205                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
4206                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
4207                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
4208                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
4209                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
4210                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
4211                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
4212                 p_no_crd_pt4         =>  p_value,
4213                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
4214                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
4215                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
4216                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
4217                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
4218                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
4219            END IF;
4220 
4221            p_value := LPAD(p_value, 3,'0') ;
4222 
4223       ELSIF  p_field_number = 212
4224       THEN
4225            -- Level of Credit Points Obtained 3
4226            IF g_field_defn.hesa_value.EXISTS(212)
4227            THEN
4228                p_value :=  g_field_defn.hesa_value(212);
4229            ELSE
4230                igs_he_extract_fields_pkg.get_credit_obtained
4231                (p_person_id          =>  p_person_id,
4232                 p_course_cd          =>  p_course_cd,
4233                 p_prog_calc          =>  g_he_st_prog.program_calc,
4234                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
4235                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
4236                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
4237                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
4238                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
4239                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
4240                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
4241                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
4242                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
4243                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
4244                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
4245                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
4246                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
4247                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
4248                 p_lvl_crd_pt3        =>  p_value,
4249                 p_lvl_crd_pt4        =>  g_field_defn.hesa_value(213),
4250                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
4251                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
4252            END IF;
4253 
4254       ELSIF  p_field_number = 213
4255       THEN
4256            -- Level of Credit Points Obtained 4
4257            IF g_field_defn.hesa_value.EXISTS(213)
4258            THEN
4259                p_value :=  g_field_defn.hesa_value(213);
4260            ELSE
4261                igs_he_extract_fields_pkg.get_credit_obtained
4262                (p_person_id          =>  p_person_id,
4263                 p_course_cd          =>  p_course_cd,
4264                 p_prog_calc          =>  g_he_st_prog.program_calc,
4265                 p_susa_crd_pt1       =>  g_he_en_susa.credit_pt_achieved1,
4266                 p_susa_crd_pt2       =>  g_he_en_susa.credit_pt_achieved2,
4267                 p_susa_crd_pt3       =>  g_he_en_susa.credit_pt_achieved3,
4268                 p_susa_crd_pt4       =>  g_he_en_susa.credit_pt_achieved4,
4269                 p_susa_crd_lvl1      =>  g_he_en_susa.credit_level_achieved1,
4270                 p_susa_crd_lvl2      =>  g_he_en_susa.credit_level_achieved2,
4271                 p_susa_crd_lvl3      =>  g_he_en_susa.credit_level_achieved3,
4272                 p_susa_crd_lvl4      =>  g_he_en_susa.credit_level_achieved4,
4273                 p_no_crd_pt1         =>  g_field_defn.hesa_value(96),
4274                 p_no_crd_pt2         =>  g_field_defn.hesa_value(97),
4275                 p_no_crd_pt3         =>  g_field_defn.hesa_value(210),
4276                 p_no_crd_pt4         =>  g_field_defn.hesa_value(211),
4277                 p_lvl_crd_pt1        =>  g_field_defn.hesa_value(98),
4278                 p_lvl_crd_pt2        =>  g_field_defn.hesa_value(99),
4279                 p_lvl_crd_pt3        =>  g_field_defn.hesa_value(212),
4280                 p_lvl_crd_pt4        =>  p_value,
4281                 p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
4282                 p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date );
4283            END IF;
4284 
4285       ELSIF  p_field_number = 214
4286       THEN
4287           -- Marital Status
4288           igs_he_extract_fields_pkg.get_marital_status
4289               (p_oss_marital_status     =>  g_pe_stat_v.marital_status,
4290                p_hesa_marital_status    =>  p_value);
4291 
4292       ELSIF  p_field_number = 215
4293       THEN
4294           -- Dependants
4295           igs_he_extract_fields_pkg.get_dependants
4296               (p_oss_dependants     =>  g_he_st_spa.dependants_cd,
4297                p_hesa_dependants    =>  p_value);
4298 
4299       ELSIF  p_field_number = 216
4300       THEN
4301         -- Eligibility for enhanced funding
4302         --Set the  default variable value as default value has to be calculated only for the down condition
4303         g_default_pro := 'N';
4304 
4305         IF g_he_submsn_header.validation_country IN ('ENGLAND') THEN
4306 
4307           -- Student must be FE student
4308           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4309 
4310                 igs_he_extract_fields_pkg.get_enh_fund_elig
4311                  (p_susa_enh_fund_elig   => g_he_en_susa.enh_fund_elig_cd,
4312                   p_spa_enh_fund_elig    => g_he_st_spa.enh_fund_elig_cd,
4313                   p_hesa_enh_fund_elig   => p_value);
4314 
4315                 --If the value is calculated as NULL above then do the default processing for this field
4316                 g_default_pro := 'Y' ;
4317           END IF;
4318         END IF;
4319 
4320       ELSIF  p_field_number = 217
4321       THEN
4322         --Additional Support Cost
4323         --Set the  default variable value as default value has to be calculated only for the down condition
4324         g_default_pro := 'N';
4325 
4326         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4327 
4328           -- Student must be FE student
4329           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4330 
4331                 IF (g_he_en_susa.additional_sup_cost IS NOT NULL) THEN
4332                       -- LPad additional_sup_cost to 6 places
4333                       p_value := LPAD(g_he_en_susa.additional_sup_cost, 6,'0');
4334                 END IF;
4335 
4336                 --If the value is calculated as NULL above then do the default processing for this field
4337                 g_default_pro := 'Y' ;
4338           END IF;
4339         END IF;
4340 
4341       ELSIF  p_field_number = 218
4342       THEN
4343         -- Learning Difficulty
4344         --Set the  default variable value as default value has to be calculated only for the down condition
4345         g_default_pro := 'N';
4346 
4347         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4348 
4349           -- Student must be FE student
4350           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4351 
4352                 igs_he_extract_fields_pkg.get_learn_dif
4353                  (p_person_id            =>  p_person_id,
4354                   p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
4355                   p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date,
4356                   p_hesa_disability_type =>  p_value);
4357 
4358                 --If the value is calculated as NULL above then do the default processing for this field
4359                 g_default_pro := 'Y' ;
4360           END IF;
4361         END IF;
4362 
4363       ELSIF  p_field_number = 219
4364       THEN
4365         --Implied rate of council partial funding
4366         --Set the  default variable value as default value has to be calculated only for the down condition
4367         g_default_pro := 'N';
4368 
4369         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4370 
4371           -- Student must be FE student
4372           -- AND ESF funded
4373           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4))
4374              AND (g_field_defn.hesa_value.EXISTS(64)  AND g_field_defn.hesa_value(64) IN ('86','87','88','AA','AB','AC','AD'))
4375           THEN
4376 
4377                 p_value := NVL(g_he_st_spa.implied_fund_rate,g_he_st_prog.implied_fund_rate);
4378 
4379                 IF (p_value IS NOT NULL) THEN
4380                       p_value := LPAD(p_value, 3,'0');
4381                 END IF;
4382 
4383                 --If the value is calculated as NULL above then do the default processing for this field
4384                 g_default_pro := 'Y' ;
4385           END IF;
4386         END IF;
4387 
4388       ELSIF  p_field_number = 220
4389       THEN
4390         --Government initiatives
4391         --Set the  default variable value as default value has to be calculated only for the down condition
4392         g_default_pro := 'N';
4393 
4394         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4395 
4396           -- Student must be FE student
4397           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4398 
4399                 igs_he_extract_fields_pkg.get_gov_init
4400                  (p_spa_gov_initiatives_cd   => g_he_st_spa.gov_initiatives_cd,
4401                   p_prog_gov_initiatives_cd  => g_he_st_prog.gov_initiatives_cd,
4402                   p_hesa_gov_initiatives_cd  => p_value);
4403 
4404                 --If the value is calculated as NULL above then do the default processing for this field
4405                 g_default_pro := 'Y' ;
4406           END IF;
4407         END IF;
4408 
4409       ELSIF  p_field_number = 221
4410       THEN
4411         -- Number of units completed
4412         --Set the  default variable value as default value has to be calculated only for the down condition
4413         g_default_pro := 'N';
4414 
4415         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4416 
4417           -- Student must be FE student
4418           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4419 
4420                 igs_he_extract_fields_pkg.get_units_completed
4421                  (p_person_id                => p_person_id,
4422                   p_course_cd                => p_course_cd,
4423                   p_enrl_end_dt              => g_he_submsn_header.enrolment_end_date,
4424                   p_spa_units_completed      => g_he_st_spa.units_completed,
4425                   p_hesa_units_completed     => p_value);
4426 
4427                 IF (p_value IS NOT NULL) THEN
4428                       p_value := LPAD(p_value, 2,'0');
4429                 END IF;
4430 
4431                 --If the value is calculated as NULL above then do the default processing for this field
4432                 g_default_pro := 'Y' ;
4433           END IF;
4434         END IF;
4435 
4436       ELSIF  p_field_number = 222
4437       THEN
4438         --Number of units to achieve full qualification
4439         --Set the  default variable value as default value has to be calculated only for the down condition
4440         g_default_pro := 'N';
4441 
4442         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4443 
4444           -- Student must be FE student
4445           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4446 
4447                 p_value := NVL(g_he_st_spa.units_for_qual,g_he_st_prog.units_for_qual);
4448 
4449                 IF (p_value IS NOT NULL) THEN
4450                       p_value := LPAD(p_value, 2,'0');
4451                 END IF;
4452 
4453                 --If the value is calculated as NULL above then do the default processing for this field
4454                 g_default_pro := 'Y' ;
4455           END IF;
4456         END IF;
4457 
4458       ELSIF  p_field_number = 223
4459       THEN
4460         --Eligibility for disadvantage uplift
4461         --Set the  default variable value as default value has to be calculated only for the down condition
4462         g_default_pro := 'N';
4463 
4464         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4465 
4466           -- Student must be FE student
4467           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4468 
4469                 igs_he_extract_fields_pkg.get_disadv_uplift_elig
4470                  (p_spa_disadv_uplift_elig_cd   => g_he_st_spa.disadv_uplift_elig_cd,
4471                   p_prog_disadv_uplift_elig_cd  => g_he_st_prog.disadv_uplift_elig_cd,
4472                   p_hesa_disadv_uplift_elig_cd  => p_value);
4473 
4474                 --If the value is calculated as NULL above then do the default processing for this field
4475                 g_default_pro := 'Y' ;
4476           END IF;
4477         END IF;
4478 
4479       ELSIF  p_field_number = 224
4480       THEN
4481         --Disadvantage uplift factor
4482         --Set the  default variable value as default value has to be calculated only for the down condition
4483         g_default_pro := 'N';
4484 
4485         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4486 
4487           -- Student must be FE student
4488           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4489 
4490                 l_disadv_uplift_factor := NVL(g_he_en_susa.disadv_uplift_factor,g_he_st_spa.disadv_uplift_factor);
4491 
4492                 IF (l_disadv_uplift_factor IS NOT NULL) THEN
4493                       p_value := Ltrim(To_Char(l_disadv_uplift_factor,'0.0000'));
4494                 END IF;
4495 
4496                 --If the value is calculated as NULL above then do the default processing for this field
4497                 g_default_pro := 'Y' ;
4498           END IF;
4499         END IF;
4500 
4501       ELSIF  p_field_number = 225
4502       THEN
4503         --Franchised out arrangements
4504         --Set the  default variable value as default value has to be calculated only for the down condition
4505         g_default_pro := 'N';
4506 
4507         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
4508 
4509           -- Student must be FE student
4510           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4511 
4512                 igs_he_extract_fields_pkg.get_franch_out_arr
4513                  (p_spa_franch_out_arr_cd   => g_he_st_spa.franch_out_arr_cd,
4514                   p_prog_franch_out_arr_cd  => g_he_st_prog.franch_out_arr_cd,
4515                   p_hesa_franch_out_arr_cd  => p_value);
4516 
4517                 --If the value is calculated as NULL above then do the default processing for this field
4518                 g_default_pro := 'Y' ;
4519           END IF;
4520         END IF;
4521 
4522       ELSIF  p_field_number = 226
4523       THEN
4524         --Employer role
4525         --Set the  default variable value as default value has to be calculated only for the down condition
4526         g_default_pro := 'N';
4527 
4528         IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES') THEN
4529 
4530           -- Student must be FE student
4531           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
4532 
4533                 igs_he_extract_fields_pkg.get_employer_role
4534                  (p_spa_employer_role_cd   => g_he_st_spa.employer_role_cd,
4535                   p_hesa_employer_role_cd  => p_value);
4536 
4537                 --If the value is calculated as NULL above then do the default processing for this field
4538                 g_default_pro := 'Y' ;
4539           END IF;
4540         END IF;
4541 
4542       -- anwest 19-Dec-2005 (4731723) HE360 - HESA REQUIREMENTS FOR 2005/06 REPORTING
4543       ELSIF  p_field_number = 227 THEN
4544 
4545         IF p_value IS NULL THEN
4546 
4547           IF g_field_defn.hesa_value.EXISTS(12) AND
4548              g_field_defn.hesa_value(12) IN ('6826') THEN
4549 
4550             igs_he_extract_fields_pkg.get_welsh_bacc_qual(p_person_id  => p_person_id,
4551                                                           p_welsh_bacc => p_value);
4552 
4553             IF p_value = '3' THEN
4554 
4555               IF g_he_submsn_header.validation_country = 'WALES' AND
4556                  g_en_stdnt_ps_att.commencement_dt > TO_DATE('31/07/2005', 'DD/MM/YYYY') AND
4557                  g_field_defn.hesa_value.EXISTS(41) AND
4558                  ((g_field_defn.hesa_value(41) >= 18 AND g_field_defn.hesa_value(41) <= 52) OR
4559                    g_field_defn.hesa_value(41) IN ('61', '97')) THEN
4560 
4561                 null; -- Leave field value as '3'
4562 
4563               ELSE
4564 
4565                 p_value := NULL;
4566 
4567               END IF;
4568 
4569             END IF;
4570 
4571           ELSE
4572 
4573             g_default_pro := 'N';
4574             p_value := NULL;
4575 
4576           END IF;
4577 
4578         END IF;
4579 
4580       END IF; -- for each field from 1 to  227
4581 
4582       EXCEPTION
4583       WHEN OTHERS
4584       THEN
4585           write_to_log(SQLERRM);
4586           fnd_message.set_name('IGS','IGS_HE_FIELD_NUM');
4587           fnd_message.set_token('field_number',p_field_number);
4588           IGS_GE_MSG_STACK.ADD;
4589           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
4590           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_comb_fields');
4591           IGS_GE_MSG_STACK.ADD;
4592           App_Exception.Raise_Exception;
4593 
4594    END process_comb_fields;
4595 
4596 
4597    /*----------------------------------------------------------------------
4598    This procedure gets values for the individual fields to be
4599    submitted in the HESA STUDENT returns
4600 
4601    Parameters :
4602    p_person_id              Person_id for the student
4603    p_course_cd              Course Code that the student is attempting
4604    p_crv_version_number     Version Number of the course code
4605    p_student_inst_number    Student Instance Number
4606    p_field_number           Field Number currently being processed.
4607    p_value                  Calculated Value of the field.
4608 
4609       --changed the code for field 26  as a  part of HECR002.
4610       --If IGS_HE_ST_SPA_ALL.commencement date is NOT NULL then  assign  IGS_HE_ST_SPA_ALL.commencement date to p_value
4611       --elsif IGS_HE_ST_SPA_ALL.commencement date IS  NULL then  check if program transfer has taken palce
4612       --If program transfer has taken place then assign get the value of first program in chain for that person
4613       --(For the person having the same student instance number for the different program transfer are said to be in same chain)
4614       --and assign the corresponding IGS_EN_STDNT_PS_ATT.commencement_dt value to it
4615       --else if the program transfer has  not taken palce then get the IGS_EN_STDNT_PS_ATT.commencement_dt value
4616       --of course in context and assign it to field
4617    ----------------------------------------------------------------------*/
4618    PROCEDURE process_stdnt_fields
4619              (p_person_id           IN  igs_he_ex_rn_dat_ln.person_id%TYPE,
4620               p_course_cd           IN   igs_he_ex_rn_dat_ln.course_cd%TYPE,
4621               p_crv_version_number  IN   igs_he_ex_rn_dat_ln.crv_version_number%TYPE,
4622               p_student_inst_number IN   igs_he_ex_rn_dat_ln.student_inst_number%TYPE,
4623               p_field_number        IN   NUMBER,
4624               p_value               IN OUT NOCOPY   igs_he_ex_rn_dat_fd.value%TYPE)
4625 
4626    IS
4627    /***************************************************************
4628    Created By           :
4629    Date Created By      :
4630    Purpose              :This procedure gets the value of stduent related fields
4631    Known Limitations,Enhancements or Remarks:
4632    Change History       :
4633    Who                  When                    What
4634    bayadav   25-Mar-02  Changed the code for field 26  as a  part of HECR002.
4635    bayadav   26-Mar-02  Changed the code for field 74  as a  part of HECR001.
4636    bayadav   19-Jul-02  Changed the call for IGS_HE_EXTRACT_FIELDS_PKG.get_year_of_student proc for fields 27 and 30 as per bug 2449010
4637    smaddali  23-Jul-02  Modified field 76 to call new procedure for bug 2452592
4638    bayadav   24-Oct-02  Modified the logic for field 148,4,33,43,44,45,46,49,50,153,6,14,17,27,29,
4639                         34,36,42,83,84,85,54,55,56,57,58,59,60,61,62,63,78,140,141,146 as a part of HEFD101(2636897)
4640    bayadav   02-Dec-02  Included 'WALES' also in the counrty list for field 140 as a part fo bug 2685091.Also made the default processing TRUE for other countries
4641    smaddali  03-Dec-02  Modified field 169 to remove dependency on field 148 for bug 2663717
4642    bayadav   09-Dec-02  Modified code logic field 29 as a part of bug 2685091
4643    bayadav   12-Dec-02  Included exists clause field 133 as a part of bug 2706787
4644    bayadav   16-Dec-02  Changed the code for default Processing for field 83 and 146 as a part of bug 2710907
4645    bayadav   16-Dec-02  Included 2 new parameters in procedure get_rsn_inst_left for field combined/student field 33 as a part of bug 2702100
4646    bayadav   16-Dec-02  Included 2 new parameters in procedure get_qual_obtained  for field combined/student field 37 and 38,39  as a part of bug 2702117
4647    bayadav   17-Dec-02  Changed the defualt value processing for combined field 155 and student field 140 as a part of bug 2713527
4648    bayadav   17-Dec-02  Changed the default value processing for combined field  34,36,42,83,84,85 and student field 34,36,42,83,84,191 as a part of bug 2714418
4649    smaddali  18-Dec-02  Modified field 191 to give format mask 00000 ,bug 2714010
4650    smaddali  25-Aug-03  Modified get_funding_src call to pass funding_source field for hefd208 - bug#2717751
4651    rbezawad  17-Sep-03  Modified the derivation of field 19 logic w.r.t. UCFD210 Build, Bug 2893542
4652    smaddali  13-Oct-03  Modified student fields 101 to 116 for bug#3163324, to derive only for WELSH students.
4653    smaddali  13-Oct-03  Modified calls to get_year_of_student to add 1 new parameter , for bug#3224246
4654    uudayapr  02-Nov-03  Modified get_inst_last_attended procedure by adding two new parameter.
4655    smaddali  14-Jan-04  Modified logic for field 19 , for bug#3370979
4656    jbaber    20-Sep-04  Modified as per HEFD350 - Statutory changes for 2004/05 Reporting
4657                         Modified fields: 27, 30
4658                         Created fields:  192-208
4659    jtmathew  01-Feb-05  Modified get_funding_src call to pass funding_source field at spa level - bug#3962575
4660  ***************************************************************/
4661      l_inst_id          igs_or_institution.govt_institution_cd%TYPE;
4662      l_index            NUMBER;
4663      l_dummy            VARCHAR2(50);
4664      l_dummy1  igs_ps_fld_of_study.govt_field_of_study%TYPE;
4665      l_dummy2  igs_ps_fld_of_study.govt_field_of_study%TYPE;
4666      l_dummy3  igs_ps_fld_of_study.govt_field_of_study%TYPE;
4667      l_fundlev igs_he_ex_rn_dat_fd.value%TYPE;
4668      l_spcstu  igs_he_ex_rn_dat_fd.value%TYPE;
4669      l_notact  igs_he_ex_rn_dat_fd.value%TYPE;
4670      l_mode    igs_he_ex_rn_dat_fd.value%TYPE;
4671      l_typeyr  igs_he_ex_rn_dat_fd.value%TYPE;
4672      l_fmly_name igs_pe_person.surname%TYPE;
4673      l_disadv_uplift_factor igs_he_st_spa.disadv_uplift_factor%TYPE;
4674 
4675      CURSOR c_subj(cp_field_of_study igs_ps_fld_of_study.field_of_study%TYPE)
4676      IS
4677      SELECT govt_field_of_study
4678      FROM igs_ps_fld_of_study
4679      WHERE field_of_study = cp_field_of_study;
4680 
4681 
4682 
4683    BEGIN
4684 
4685       p_value := NULL;
4686       g_default_pro := 'Y';
4687       l_disadv_uplift_factor := NULL;
4688 
4689       IF      p_field_number = 1
4690       THEN
4691           -- Record Type Identifier
4692           p_value := g_he_submsn_return.record_id;
4693 
4694       ELSIF  p_field_number = 2
4695       THEN
4696           -- Hesa Institution Id
4697           igs_he_extract_fields_pkg.get_hesa_inst_id
4698               (p_hesa_inst_id => p_value);
4699 
4700       ELSIF  p_field_number = 3
4701       THEN
4702           -- Campus Id
4703           igs_he_extract_fields_pkg.get_campus_id
4704               (p_location_cd => g_en_stdnt_ps_att.location_cd,
4705                p_campus_id   => p_value);
4706 
4707       ELSIF  p_field_number = 4
4708       THEN
4709           -- Student Identifier
4710           -- Pass in the Institution Id
4711           IF g_field_defn.hesa_value.EXISTS(2)
4712           THEN
4713               l_inst_id := g_field_defn.hesa_value(2);
4714           ELSE
4715               l_inst_id := 0;
4716           END IF;
4717 
4718          -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4719           igs_he_extract_fields_pkg.get_stdnt_id
4720               (p_person_id              => p_person_id,
4721                p_inst_id                => l_inst_id,
4722                p_stdnt_id               => p_value,
4723                p_enrl_start_dt          =>  g_he_submsn_header.enrolment_start_date,
4724                p_enrl_end_dt            =>  g_he_submsn_header.enrolment_end_date);
4725 
4726       ELSIF  p_field_number = 5
4727       THEN
4728           -- Scottish Candidate Number
4729           IF g_he_st_spa.associate_scott_cand = 'Y'
4730           THEN
4731           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4732               igs_he_extract_fields_pkg.get_alt_pers_id
4733                  (p_person_id           => p_person_id,
4734                   p_id_type             => 'UCASREGNO',
4735                   p_api_id              => p_value,
4736                   p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
4737                   p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date);
4738           END IF;
4739 
4740       ELSIF  p_field_number = 6
4741       THEN
4742           -- FE Student Marker
4743           -- First get the Funding Source
4744           -- smaddali modified this call to pass funding_source field for hefd208 - bug#2717751
4745           -- jtmathew modified this call to pass funding_source field at spa level - bug#3962575
4746           igs_he_extract_fields_pkg.get_funding_src
4747               (p_course_cd             => p_course_cd,
4748                p_version_number        => p_crv_version_number,
4749                p_spa_fund_src          => g_en_stdnt_ps_att.funding_source,
4750                p_poous_fund_src        => g_he_poous.funding_source,
4751                p_oss_fund_src          => g_field_defn.oss_value(64),
4752                p_hesa_fund_src         => g_field_defn.hesa_value(64));
4753 
4754           -- Next get the Fundability Code
4755           IF g_field_defn.oss_value.EXISTS(64) THEN
4756           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4757            igs_he_extract_fields_pkg.get_fundability_cd
4758               (p_person_id             => p_person_id,
4759                p_susa_fund_cd          => g_he_en_susa.fundability_code,
4760                p_spa_funding_source    => g_en_stdnt_ps_att.funding_source,
4761                p_poous_fund_cd         => g_he_poous.fundability_cd,
4762                p_prg_fund_cd           => g_he_st_prog.fundability,
4763                p_prg_funding_source    => g_field_defn.oss_value(64),
4764                p_oss_fund_cd           => g_field_defn.oss_value(65),
4765                p_hesa_fund_cd          => g_field_defn.hesa_value(65),
4766                p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
4767                p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
4768            END IF;
4769 
4770           -- Now get the FE Student Marker
4771           IF  g_he_submsn_header.validation_country IN  ('ENGLAND','WALES') AND g_field_defn.oss_value.EXISTS(64) AND g_field_defn.oss_value.EXISTS(65) THEN
4772            igs_he_extract_fields_pkg.get_fe_stdnt_mrker
4773               (p_spa_fe_stdnt_mrker    =>  g_he_st_spa.fe_student_marker,
4774                p_fe_program_marker     =>  g_he_st_prog.fe_program_marker,
4775                p_funding_src           =>  g_field_defn.oss_value(64),
4776                p_fundability_cd        =>  g_field_defn.oss_value(65),
4777                p_oss_fe_stdnt_mrker    =>  g_field_defn.oss_value(6),
4778                p_hesa_fe_stdnt_mrker   =>  p_value);
4779            ELSE
4780 
4781               g_default_pro := 'N';
4782 
4783            END IF;
4784 
4785 
4786       ELSIF  p_field_number = 7
4787       THEN
4788           -- Family Name
4789           -- smaddali added translate for bug#3223991
4790           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
4791           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
4792           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
4793           IF g_pe_person.given_names IS NULL
4794           THEN
4795               p_value := TRANSLATE( substr(g_pe_person.full_name,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
4796               -- Set value of forename = '9'
4797               g_field_defn.hesa_value(8) := '9';
4798           ELSE
4799               p_value := TRANSLATE( substr(g_pe_person.surname,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
4800           END IF;
4801 
4802       ELSIF  p_field_number = 8
4803       THEN
4804           -- Forename
4805           -- smaddali added translate for bug#3223991
4806           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
4807           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
4808           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
4809           -- If value set earlier in field 7, use that
4810           IF g_field_defn.hesa_value.EXISTS(8)
4811           THEN
4812               IF g_field_defn.hesa_value(8) = '9'
4813               THEN
4814                    p_value := g_field_defn.hesa_value(8);
4815               ELSE
4816                    p_value := TRANSLATE( substr(g_pe_person.given_names,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
4817               END IF;
4818           ELSE
4819               p_value := TRANSLATE( substr(g_pe_person.given_names,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
4820           END IF;
4821 
4822 
4823       ELSIF  p_field_number = 9
4824       THEN
4825           -- Family Name on 16th Birthday
4826           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4827           l_fmly_name := NULL;
4828           igs_he_extract_fields_pkg.get_fmly_name_on_16_bday
4829               (p_person_id              => p_person_id,
4830                p_fmly_name              => l_fmly_name,
4831                p_enrl_start_dt          => g_he_submsn_header.enrolment_start_date,
4832                p_enrl_end_dt            => g_he_submsn_header.enrolment_end_date);
4833           -- smaddali added translate for bug#3223991
4834           -- modified the logic to remove the invalid characters /, @, \ for Bug# 3681149
4835           -- this trasnlate function translates a to a and all other characters in the FROM list to NULL
4836           -- so all the characters 1234567890~`!#$%^&*()_+={}[]|:;"<>? which are invalid will be removed from p_value
4837           p_value := TRANSLATE( substr(l_fmly_name,1,40),'a1234567890~`!#$%^&*()_+={}[]|:;"<>?,/@\','a') ;
4838 
4839 
4840       ELSIF  p_field_number = 10
4841       THEN
4842           -- Date of Birth
4843           p_value := To_Char(g_pe_person.birth_dt, 'DD/MM/YYYY');
4844 
4845       ELSIF  p_field_number = 11
4846       THEN
4847           -- Gender
4848           igs_he_extract_fields_pkg.get_gender
4849               (p_gender           => g_pe_person.sex,
4850                p_hesa_gender      => p_value);
4851 
4852       ELSIF  p_field_number = 12
4853       THEN
4854           -- Domicile
4855           igs_he_extract_fields_pkg.get_domicile
4856               (p_ad_domicile       => g_he_ad_dtl.domicile_cd,
4857                p_spa_domicile      => g_he_st_spa.domicile_cd,
4858                p_hesa_domicile     => p_value);
4859 
4860       ELSIF  p_field_number = 13
4861       THEN
4862           -- Nationality
4863           -- smaddali 11-dec-03   Modified for bug#3235753 , added 1 new parameter
4864           igs_he_extract_fields_pkg.get_nationality
4865               (p_person_id         => p_person_id,
4866                p_nationality       => p_value,
4867                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date);
4868 
4869       -- Modified the field derivation to remove the reference of DOMICILE field (12)
4870       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
4871       ELSIF  p_field_number = 14
4872       THEN
4873          -- Ethnicity
4874          igs_he_extract_fields_pkg.get_ethnicity (
4875            p_person_id         => p_person_id,
4876            p_oss_eth           => g_pe_stat_v.ethnic_origin_id,
4877            p_hesa_eth          => p_value);
4878 
4879       ELSIF  p_field_number = 15
4880       THEN
4881           -- Disability Allowance
4882           igs_he_extract_fields_pkg.get_disablity_allow
4883               (p_oss_dis_allow     => g_he_en_susa.disability_allow,
4884                p_hesa_dis_allow    => p_value);
4885 
4886       ELSIF  p_field_number = 16
4887       THEN
4888           -- Diability
4889           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4890           igs_he_extract_fields_pkg.get_disablity
4891               (p_person_id         => p_person_id,
4892                p_disability        => p_value,
4893                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
4894                p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date);
4895 
4896       ELSIF  p_field_number = 17
4897       THEN
4898 
4899 
4900         IF (( g_field_defn.hesa_value.EXISTS(6) AND g_field_defn.hesa_value(6) IN (1,3)) AND   g_he_submsn_header.validation_country = 'ENGLAND') THEN
4901           -- Additional Support Band
4902           igs_he_extract_fields_pkg.get_addnl_supp_band
4903               (p_oss_supp_band     =>  g_he_en_susa.additional_sup_band,
4904                p_hesa_supp_band    =>  p_value);
4905 
4906           ELSE
4907               p_value := NULL;
4908               g_default_pro := 'N';
4909           END IF;
4910 
4911 
4912       ELSIF  p_field_number = 18
4913       THEN
4914            -- Not Used
4915            p_value := NULL;
4916 
4917       ELSIF  p_field_number = 19
4918       THEN
4919 
4920           --Get the field 41 value - Qualification Aim
4921           -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
4922           igs_he_extract_fields_pkg.get_gen_qual_aim
4923               (p_person_id           =>  p_person_id,
4924                p_course_cd           =>  p_course_cd,
4925                p_version_number      =>  p_crv_version_number,
4926                p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
4927                p_hesa_gen_qaim       =>  g_field_defn.hesa_value(41),
4928                p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
4929                p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
4930                p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
4931 
4932           -- Get the field 70 value - Mode of Study
4933           igs_he_extract_fields_pkg.get_mode_of_study
4934               (p_person_id         =>  p_person_id,
4935                p_course_cd         =>  p_course_cd,
4936                p_version_number    =>  p_crv_version_number,
4937                p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
4938                p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
4939                p_susa_study_mode   =>  g_he_en_susa.study_mode,
4940                p_poous_study_mode  =>  g_he_poous.mode_of_study,
4941                p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
4942                p_mode_of_study     =>  g_field_defn.hesa_value(70));
4943 
4944           -- Modified the derivation of this field to derive regardless of the value of the HESA MODE field (70)
4945           -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
4946 
4947           -- Get the field 133 value - UCAS NUM
4948           IF g_he_st_spa.associate_ucas_number = 'Y' THEN
4949           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
4950             igs_he_extract_fields_pkg.get_ucasnum
4951                (p_person_id             => p_person_id,
4952                 p_ucasnum               => g_field_defn.hesa_value(133),
4953                 p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
4954                 p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
4955           -- smaddali added else logic to create the table index for hesa_value(133), for bug#3370979
4956           ELSE
4957              g_field_defn.hesa_value(133) := NULL;
4958           END IF;
4959 
4960           IF g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value.EXISTS(133) THEN
4961             -- Calculate the field 19 value - Year left last institution
4962             igs_he_extract_fields_pkg.get_yr_left_last_inst
4963               (p_person_id      => p_person_id,
4964                p_com_dt         => g_en_stdnt_ps_att.commencement_dt,
4965                p_hesa_gen_qaim  => g_field_defn.hesa_value(41),
4966                p_ucasnum        => g_field_defn.hesa_value(133),
4967                p_year           => p_value);
4968           END IF ;
4969 
4970       ELSIF  p_field_number = 20
4971       THEN
4972            -- Not Used
4973            p_value := NULL;
4974 
4975       ELSIF  p_field_number = 21
4976       THEN
4977           -- Highest Qualification on Entry
4978           p_value := g_he_st_spa.highest_qual_on_entry;
4979 
4980       ELSIF  p_field_number = 22
4981       THEN
4982            -- Not Used
4983            p_value := NULL;
4984 
4985       ELSIF  p_field_number = 23
4986       THEN
4987            -- Not Used
4988            p_value := NULL;
4989 
4990       ELSIF  p_field_number = 24
4991       THEN
4992            -- Not Used
4993            p_value := NULL;
4994 
4995       ELSIF  p_field_number = 25
4996       THEN
4997 
4998           -- Get the field 133 value - UCAS NUM
4999           IF NOT g_field_defn.hesa_value.EXISTS(133) THEN
5000              IF  g_he_st_spa.associate_ucas_number = 'Y' THEN
5001                igs_he_extract_fields_pkg.get_ucasnum
5002                   (p_person_id             => p_person_id,
5003                    p_ucasnum               => g_field_defn.hesa_value(133),
5004                    p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
5005                    p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
5006              ELSE
5007                g_field_defn.hesa_value(133) := NULL;
5008              END IF;
5009           END IF;
5010 
5011           -- sjlaporte use date comparison rather than text bug 3933715
5012           -- Occupation Code
5013           IF g_en_stdnt_ps_att.commencement_dt  <= TO_DATE('31/07/2002', 'DD/MM/YYYY')
5014              OR (g_field_defn.hesa_value(133) IS NOT NULL AND g_field_defn.hesa_value(133) BETWEEN '000000010' AND '019999999')
5015           THEN
5016               p_value := g_he_st_spa.occcode;
5017           ELSE
5018              p_value := NULL;
5019           END IF;
5020 
5021       ELSIF  p_field_number = 26
5022       THEN
5023 
5024        -- Commencement Date
5025          igs_he_extract_fields_pkg.get_commencement_dt( p_hesa_commdate         => g_he_st_spa.commencement_dt,
5026                                                         p_enstdnt_commdate      => g_en_stdnt_ps_att.commencement_dt,
5027                                                         p_person_id             => p_person_id ,
5028                                                         p_course_cd             => p_course_cd  ,
5029                                                         p_version_number        => p_crv_version_number,
5030                                                         p_student_inst_number   => p_student_inst_number,
5031                                                         p_final_commdate        => p_value );
5032 
5033 
5034       ELSIF  p_field_number = 27
5035       THEN
5036           -- New Entrant to HE
5037           -- smaddali removed the call to derive field 72 value and added the call to derive field 30
5038           -- because the dependency should be on field 30 not on 72 , bug 2452551
5039           -- First get field 30, Year of student
5040           -- jbaber added p_susa_year_of_student for HEFD350
5041           igs_he_extract_fields_pkg.get_year_of_student
5042               (p_person_id            => p_person_id ,
5043                p_course_cd            => p_course_cd ,
5044                p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
5045                p_sequence_number      => g_as_su_setatmpt.sequence_number,
5046                p_year_of_student      => g_field_defn.hesa_value(30),
5047                p_enrl_end_dt          => g_he_submsn_header.enrolment_end_date,
5048                p_susa_year_of_student => g_he_en_susa.year_stu);
5049 
5050            --get field 41 value also first as it is required for  this calculation
5051            -- Qualification Aim
5052            IF NOT g_field_defn.hesa_value.EXISTS(41) THEN
5053            -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
5054              igs_he_extract_fields_pkg.get_gen_qual_aim
5055               (p_person_id           =>  p_person_id,
5056                p_course_cd           =>  p_course_cd,
5057                p_version_number      =>  p_crv_version_number,
5058                p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
5059                p_hesa_gen_qaim       =>  g_field_defn.hesa_value(41),
5060                p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
5061                p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
5062                p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
5063            END IF ;
5064 
5065 
5066           -- Now calculate New Entrant to HE
5067           -- smaddali replaced dependency with field 72 to field 30 for bug 2452551
5068           IF  g_field_defn.hesa_value.EXISTS(6)
5069           AND g_field_defn.hesa_value.EXISTS(21)
5070           AND g_field_defn.hesa_value.EXISTS(30)
5071           AND g_field_defn.hesa_value.EXISTS(12)
5072           AND (g_field_defn.hesa_value.EXISTS(41) and (
5073                                                     (g_field_defn.hesa_value(41) >= 02 and g_field_defn.hesa_value(41) <= 52)
5074                                                                                     or
5075                                                      (g_field_defn.hesa_value(41) IN (61,62,97,98))
5076                                                    )  )           THEN
5077               igs_he_extract_fields_pkg.get_new_ent_to_he
5078                   (p_fe_stdnt_mrker        => g_field_defn.hesa_value(6),
5079                    p_susa_new_ent_to_he    => g_he_en_susa.new_he_entrant_cd,
5080                    p_yop                   => g_field_defn.hesa_value(30),
5081                    p_high_qual_on_ent      => g_field_defn.hesa_value(21),
5082                    p_domicile              => g_field_defn.hesa_value(12),
5083                    p_hesa_new_ent_to_he    => p_value);
5084 
5085           END IF;
5086 
5087 
5088 
5089           IF   (g_field_defn.hesa_value.EXISTS(41) and (
5090                                                     (g_field_defn.hesa_value(41) >= 02 and g_field_defn.hesa_value(41) <= 52)
5091                                                                                     or
5092                                                      (g_field_defn.hesa_value(41) IN (61,62,97,98))
5093                                                    )  ) THEN
5094                   g_default_pro := 'Y' ;
5095           ELSE
5096                   -- The default value should not be calculated for  any other condition
5097                   g_default_pro := 'N' ;
5098           END IF;
5099 
5100       ELSIF  p_field_number = 28
5101       THEN
5102           -- Special students
5103           igs_he_extract_fields_pkg.get_special_student
5104               (p_ad_special_student    => g_he_ad_dtl.special_student_cd,
5105                p_spa_special_student   => g_he_st_spa.special_student,
5106                p_oss_special_student   => g_field_defn.oss_value(28),
5107                p_hesa_special_student  => p_value);
5108 
5109       ELSIF  p_field_number = 29
5110       THEN
5111 
5112         --get the quail1 field 37 and 38 value required in calculating field 29 value
5113         igs_he_extract_fields_pkg.get_qual_obtained
5114               (p_person_id        => p_person_id,
5115                p_course_cd        => p_course_cd,
5116                p_enrl_start_dt    => l_awd_conf_start_dt,
5117                p_enrl_end_dt      => l_awd_conf_end_dt,
5118                p_oss_qual_obt1    => g_field_defn.oss_value(37),
5119                p_oss_qual_obt2    => g_field_defn.oss_value(38),
5120                p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
5121                p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
5122                p_classification   => g_field_defn.hesa_value(39));
5123 
5124 
5125         --Calculating field 53 first requred for field 146 calcualtion
5126         igs_he_extract_fields_pkg.get_teach_train_crs_id
5127           (p_prg_ttcid            =>  g_he_st_prog.teacher_train_prog_id,
5128            p_spa_ttcid            =>  g_he_st_spa.teacher_train_prog_id,
5129            p_hesa_ttcid           =>  g_field_defn.hesa_value(53));
5130 
5131 
5132         --Calculating field 146 first required for field 29
5133         -- Outcome of ITT Program
5134         IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES') THEN
5135               igs_he_extract_fields_pkg.get_itt_outcome
5136                   (p_oss_itt_outcome     =>  g_he_st_spa.itt_prog_outcome,
5137                    p_teach_train_prg     =>  g_field_defn.hesa_value(53),
5138                    p_hesa_itt_outcome    =>   g_field_defn.hesa_value(146));
5139         END IF;
5140 
5141         --Set the default value of g_default_pro as N here only as default processing has to be done only in one case which is written as below
5142         g_default_pro := 'N' ;
5143 
5144         --Start calculating value of field 29 as all the required fields have been calculated above
5145         IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES','SCOTLAND') THEN
5146           -- Get Teacher Reference Num
5147           IF g_he_st_spa.associate_teach_ref_num = 'Y'
5148           THEN
5149           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
5150               igs_he_extract_fields_pkg.get_alt_pers_id
5151                   (p_person_id            => p_person_id,
5152                    p_id_type              => 'TEACH REF',
5153                    p_api_id               => p_value,
5154                    p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
5155                    p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date);
5156 
5157           END IF;
5158            --In case the value calculated above is NULL then calculate the defualt value
5159           IF p_value IS NULL THEN
5160              IF (((g_field_defn.hesa_value.EXISTS(146)  AND g_field_defn.hesa_value(146) = '1') OR
5161                 ((g_field_defn.hesa_value.EXISTS(53)  AND g_field_defn.hesa_value(53) IN (1,6,7)) AND
5162                  ((g_field_defn.hesa_value.EXISTS(37) AND g_field_defn.hesa_value(37) = 20) OR
5163                   (g_field_defn.hesa_value.EXISTS(38) AND g_field_defn.hesa_value(38) = 20)))))  THEN
5164                      g_default_pro := 'Y' ;
5165               END IF;
5166           END IF;
5167         END IF;
5168 
5169      ELSIF  p_field_number = 30
5170       THEN
5171           -- Year of Student
5172           --smaddali added this check to see if it already is calculated
5173           -- because of bug 2452551 where field 30 is being calculated for field 27
5174           IF  g_field_defn.hesa_value.EXISTS(30)
5175           THEN
5176               -- Calculated earlier, for field 27
5177               p_value :=   g_field_defn.hesa_value(30);
5178           ELSE
5179 
5180              -- jbaber added p_susa_year_of_student for HEFD350
5181              igs_he_extract_fields_pkg.get_year_of_student
5182               (p_person_id            => p_person_id,
5183                p_course_cd            => p_course_cd,
5184                p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
5185                p_sequence_number      => g_as_su_setatmpt.sequence_number,
5186                p_year_of_student      => p_value,
5187                p_enrl_end_dt          => g_he_submsn_header.enrolment_end_date,
5188                p_susa_year_of_student => g_he_en_susa.year_stu);
5189 
5190            END IF ;
5191 
5192             --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
5193             p_value := LPAD(p_value, 2,'0') ;
5194 
5195       ELSIF  p_field_number = 31
5196       THEN
5197           -- Term Time Accomodation
5198           -- Calculate field 71, location of study first
5199           igs_he_extract_fields_pkg.get_study_location
5200               (p_susa_study_location    => g_he_en_susa.study_location,
5201                p_poous_study_location   => g_he_poous.location_of_study,
5202                p_prg_study_location     => g_he_st_prog.location_of_study,
5203                p_oss_study_location     => g_field_defn.oss_value(71),
5204                p_hesa_study_location    => g_field_defn.hesa_value(71));
5205 
5206           -- Next calcualte TTA
5207           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
5208           igs_he_extract_fields_pkg.get_term_time_acc
5209               (p_person_id            =>  p_person_id,
5210                p_susa_term_time_acc   =>  g_he_en_susa.term_time_accom,
5211                p_study_location       =>  g_field_defn.oss_value(71),
5212                p_hesa_term_time_acc   =>  p_value,
5213                p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
5214                p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date);
5215 
5216       ELSIF  p_field_number = 32
5217       THEN
5218            -- Not Used
5219            p_value := NULL;
5220 
5221       ELSIF  p_field_number = 33
5222       THEN
5223           -- Reason for leaving institution
5224           igs_he_extract_fields_pkg.get_rsn_inst_left
5225               (p_person_id            => p_person_id,
5226                p_course_cd            => p_course_cd ,
5227                p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
5228                p_crs_req_comp_dt      => g_en_stdnt_ps_att.course_rqrmnts_complete_dt,
5229                p_disc_reason_cd       => g_en_stdnt_ps_att.discontinuation_reason_cd,
5230                p_disc_dt              => g_en_stdnt_ps_att.discontinued_dt,
5231                p_enrl_start_dt        => l_awd_conf_start_dt,
5232                p_enrl_end_dt          => l_awd_conf_end_dt,
5233                p_rsn_inst_left        => p_value);
5234 
5235       ELSIF  p_field_number = 34
5236       THEN
5237          g_default_pro:= 'N';
5238 
5239           -- Completion Status
5240           -- Need Field 6, FE Student Marker to be completed
5241           IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
5242           THEN
5243               -- Calculate Completion Status
5244               --smaddali added new parameter p_course_cd to this call for bug 2396174
5245               igs_he_extract_fields_pkg.get_completion_status
5246                   (p_person_id            => p_person_id,
5247                    p_course_cd            => p_course_cd ,
5248                    p_susa_comp_status     => g_he_en_susa.completion_status,
5249                    p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
5250                    p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
5251                    p_discont_date         => g_en_stdnt_ps_att.discontinued_dt,
5252                    p_hesa_comp_status     => p_value);
5253               g_default_pro:= 'Y';
5254          END IF;
5255 
5256       ELSIF  p_field_number = 35
5257       THEN -- DATELEFT - only report this field if SPA completed within current reporting period
5258 
5259           IF g_en_stdnt_ps_att.course_rqrmnt_complete_ind = 'Y'
5260           AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt <= g_he_submsn_header.enrolment_end_date
5261           THEN -- report Completion Date
5262               p_value := To_Char(g_en_stdnt_ps_att.course_rqrmnts_complete_dt, 'DD/MM/YYYY');
5263           ELSIF g_en_stdnt_ps_att.discontinued_dt IS NOT NULL
5264             AND g_en_stdnt_ps_att.discontinued_dt <= g_he_submsn_header.enrolment_end_date
5265           THEN -- report Discontinuation Date
5266               p_value := To_Char(g_en_stdnt_ps_att.discontinued_dt, 'DD/MM/YYYY');
5267           END IF;
5268 
5269       ELSIF  p_field_number = 36
5270       THEN
5271           g_default_pro:= 'N';
5272           -- Good Standing Marker
5273           IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
5274           THEN
5275               igs_he_extract_fields_pkg.get_good_stand_mrkr
5276                    (p_susa_good_st_mk      => g_he_en_susa.good_stand_marker,
5277                     p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
5278                     p_crs_req_comp_ind     => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
5279                     p_discont_date         => g_en_stdnt_ps_att.discontinued_dt,
5280                     p_hesa_good_st_mk      => p_value);
5281           g_default_pro:= 'Y';
5282           END IF;
5283 
5284       ELSIF  p_field_number = 37
5285       THEN
5286           -- Qualificationa Obtained 1
5287           -- Get fields 37, 38 and 39 together.
5288           IF g_field_defn.hesa_value.EXISTS(37)  THEN
5289              p_value := g_field_defn.hesa_value(37) ;
5290           ELSE
5291             igs_he_extract_fields_pkg.get_qual_obtained
5292               (p_person_id        => p_person_id,
5293                p_course_cd        => p_course_cd,
5294                p_enrl_start_dt    => l_awd_conf_start_dt,
5295                p_enrl_end_dt      => l_awd_conf_end_dt,
5296                p_oss_qual_obt1    => g_field_defn.oss_value(37),
5297                p_oss_qual_obt2    => g_field_defn.oss_value(38),
5298                p_hesa_qual_obt1   => p_value,
5299                p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
5300                p_classification   => g_field_defn.hesa_value(39));
5301           END IF ;
5302 
5303       ELSIF  p_field_number = 38
5304       THEN
5305           -- Qualification Obtained 2
5306           -- If not calculated earlier, calculate now.
5307           IF  g_field_defn.hesa_value.EXISTS(38)
5308           THEN
5309               p_value :=  g_field_defn.hesa_value(38);
5310           ELSE
5311               igs_he_extract_fields_pkg.get_qual_obtained
5312                   (p_person_id        => p_person_id,
5313                    p_course_cd        => p_course_cd,
5314                    p_enrl_start_dt    => l_awd_conf_start_dt,
5315                    p_enrl_end_dt      => l_awd_conf_end_dt,
5316                    p_oss_qual_obt1    => g_field_defn.oss_value(37),
5317                    p_oss_qual_obt2    => g_field_defn.oss_value(38),
5318                    p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
5319                    p_hesa_qual_obt2   => p_value,
5320                    p_classification   => g_field_defn.hesa_value(39));
5321 
5322           END IF;
5323 
5324       ELSIF  p_field_number = 39
5325       THEN
5326           -- HESA Classification
5327           -- If not calculated earlier, calculate now.
5328           IF  g_field_defn.hesa_value.EXISTS(39)
5329           THEN
5330               p_value :=  g_field_defn.hesa_value(39);
5331           ELSE
5332               igs_he_extract_fields_pkg.get_qual_obtained
5333                   (p_person_id        => p_person_id,
5334                    p_course_cd        => p_course_cd,
5335                    p_enrl_start_dt    => l_awd_conf_start_dt,
5336                    p_enrl_end_dt      => l_awd_conf_end_dt,
5337                    p_oss_qual_obt1    => g_field_defn.oss_value(37),
5338                    p_oss_qual_obt2    => g_field_defn.oss_value(38),
5339                    p_hesa_qual_obt1   => g_field_defn.hesa_value(37),
5340                    p_hesa_qual_obt2   => g_field_defn.hesa_value(38),
5341                    p_classification   => p_value);
5342           END IF;
5343 
5344       ELSIF  p_field_number = 40
5345       THEN
5346           -- Program of Study Title
5347           p_value := g_ps_ver.title;
5348 
5349       ELSIF  p_field_number = 41
5350       THEN
5351 
5352 
5353                IF  g_field_defn.hesa_value.EXISTS(41)
5354                   THEN
5355                       -- Calculated earlier, for field 27
5356                       p_value :=   g_field_defn.hesa_value(41);
5357 
5358                ELSE
5359                   -- Qualification Aim
5360                   -- smaddali 21-jan-04  added 2 new parameters for bug#3360646
5361                   igs_he_extract_fields_pkg.get_gen_qual_aim
5362                       (p_person_id           =>  p_person_id,
5363                        p_course_cd           =>  p_course_cd,
5364                        p_version_number      =>  p_crv_version_number,
5365                        p_spa_gen_qaim        =>  g_he_st_spa.student_qual_aim,
5366                        p_hesa_gen_qaim       =>  p_value,
5367                        p_enrl_start_dt       =>  g_he_submsn_header.enrolment_start_date,
5368                        p_enrl_end_dt         =>  g_he_submsn_header.enrolment_end_date,
5369                        p_awd_conf_start_dt   =>  l_awd_conf_start_dt);
5370                 END IF;
5371 
5372 
5373       ELSIF  p_field_number = 42
5374       THEN
5375           g_default_pro:= 'N';
5376           -- FE General Qualification Aim
5377           IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)
5378           THEN
5379               igs_he_extract_fields_pkg.get_fe_qual_aim
5380                    (p_spa_fe_qual_aim      => g_he_st_spa.student_fe_qual_aim,
5381                     p_fe_stdnt_mrker       => g_field_defn.hesa_value(6),
5382                     p_course_cd            => p_course_cd,
5383                     p_version_number       => p_crv_version_number,
5384                     p_hesa_fe_qual_aim     => p_value);
5385              g_default_pro:= 'Y';
5386            END IF;
5387 
5388       ELSIF  p_field_number = 43
5389       THEN
5390 
5391            -- Check for details at the SPA HESA Details level
5392            IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
5393                  OPEN c_subj(g_he_st_spa.qual_aim_subj1);
5394                  FETCH c_subj INTO p_value;
5395                  CLOSE c_subj;
5396 
5397            ELSE
5398              -- Qualification Aim, Subject 1
5399              igs_he_extract_fields_pkg.get_qual_aim_sbj
5400               (p_course_cd            => p_course_cd,
5401                p_version_number       => p_crv_version_number,
5402                p_subject1             => p_value,
5403                p_subject2             => g_field_defn.hesa_value(44),
5404                p_subject3             => g_field_defn.hesa_value(45),
5405                p_prop_ind             => g_field_defn.hesa_value(46));
5406 
5407             END IF;
5408 
5409       ELSIF  p_field_number = 44
5410       THEN
5411 
5412            -- Check for details at the SPA HESA Details level
5413            IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
5414 
5415                 IF g_he_st_spa.qual_aim_subj2 IS NOT NULL THEN
5416                     OPEN c_subj(g_he_st_spa.qual_aim_subj2);
5417                     FETCH c_subj INTO p_value;
5418                     CLOSE c_subj;
5419                 ELSE
5420                     -- derive NULL as there is no value for subj2
5421                     p_value := NULL;
5422                 END IF;
5423 
5424            ELSE
5425                   -- Qualification Aim, Subject 2
5426                   IF g_field_defn.hesa_value.EXISTS(44)
5427                   THEN
5428                       -- Calculated earlier..
5429                       p_value := g_field_defn.hesa_value(44);
5430                   ELSE
5431                       -- Not calculated earlier, calculate now
5432                       igs_he_extract_fields_pkg.get_qual_aim_sbj
5433                           (p_course_cd         => p_course_cd,
5434                            p_version_number    => p_crv_version_number,
5435                            p_subject1          => l_dummy1,
5436                            p_subject2          => p_value,
5437                            p_subject3          => g_field_defn.hesa_value(45),
5438                            p_prop_ind          => g_field_defn.hesa_value(46));
5439                   END IF;
5440           END IF;
5441 
5442       ELSIF  p_field_number = 45
5443       THEN
5444 
5445            -- Check for details at the SPA HESA Details level
5446            IF g_he_st_spa.qual_aim_subj1 IS NOT NULL THEN
5447 
5448                 IF g_he_st_spa.qual_aim_subj3 IS NOT NULL THEN
5449                     OPEN c_subj(g_he_st_spa.qual_aim_subj3);
5450                     FETCH c_subj INTO p_value;
5451                     CLOSE c_subj;
5452                 ELSE
5453                     -- derive NULL as there is no value for subj3
5454                     p_value := NULL;
5455                 END IF;
5456 
5457            ELSE
5458                   -- Qualification Aim, Subject 3
5459                   IF g_field_defn.hesa_value.EXISTS(45)
5460                   THEN
5461                       -- Calculated earlier..
5462                       p_value := g_field_defn.hesa_value(45);
5463                   ELSE
5464                       -- Not calculated earlier, calculate now
5465                       igs_he_extract_fields_pkg.get_qual_aim_sbj
5466                           (p_course_cd         => p_course_cd,
5467                            p_version_number    => p_crv_version_number,
5468                            p_subject1          => l_dummy1,
5469                            p_subject2          => l_dummy2,
5470                            p_subject3          => p_value,
5471                            p_prop_ind          => g_field_defn.hesa_value(46));
5472                   END IF;
5473           END IF;
5474 
5475 
5476       ELSIF  p_field_number = 46
5477       THEN
5478 
5479           IF g_he_st_spa.qual_aim_subj1 IS NOT NULL OR
5480              g_he_st_spa.qual_aim_proportion IS NOT NULL OR
5481              g_he_st_spa.qual_aim_subj2 IS NOT NULL OR
5482              g_he_st_spa.qual_aim_subj3 IS NOT NULL
5483           THEN
5484 
5485               igs_he_extract_fields_pkg.get_qual_aim_sbj1(
5486                      p_qual_aim_subj1    => g_he_st_spa.qual_aim_subj1,
5487                      p_qual_aim_subj2    => g_he_st_spa.qual_aim_subj2,
5488                      p_qual_aim_subj3    => g_he_st_spa.qual_aim_subj3,
5489                      p_oss_qualaim_sbj   => g_he_st_spa.qual_aim_proportion,
5490                      p_hesa_qualaim_sbj  => p_value);
5491 
5492           ELSE
5493 
5494                   -- Proportion Indicator
5495                   IF g_field_defn.hesa_value.EXISTS(46)
5496                   THEN
5497                       -- Calculated earlier..
5498                       p_value := g_field_defn.hesa_value(46);
5499                   ELSE
5500                       -- Not calculated earlier, calculate now
5501                       igs_he_extract_fields_pkg.get_qual_aim_sbj
5502                           (p_course_cd         => p_course_cd,
5503                            p_version_number    => p_crv_version_number,
5504                            p_subject1          => l_dummy1,
5505                            p_subject2          => l_dummy2,
5506                            p_subject3          => l_dummy3,
5507                            p_prop_ind          => p_value);
5508                   END IF;
5509 
5510          END IF;
5511 
5512       ELSIF  p_field_number = 47
5513       THEN
5514           -- Awarding Body 1
5515           IF  g_field_defn.oss_value.EXISTS(37)
5516           AND g_field_defn.oss_value.EXISTS(38)
5517           THEN
5518               igs_he_extract_fields_pkg.get_awd_body_12
5519                   (p_course_cd         =>  p_course_cd,
5520                    p_version_number    =>  p_crv_version_number,
5521                    p_awd1              =>  g_field_defn.oss_value(37),
5522                    p_awd2              =>  g_field_defn.oss_value(38),
5523                    p_awd_body1         =>  p_value,
5524                    p_awd_body2         =>  g_field_defn.hesa_value(48));
5525 
5526           END IF;
5527       ELSIF  p_field_number = 48
5528       THEN
5529           -- Awarding Body 2
5530           IF g_field_defn.hesa_value.EXISTS(48)
5531           THEN
5532               -- Calculated earlier for field 47..
5533               p_value := g_field_defn.hesa_value(48);
5534           ELSIF  g_field_defn.oss_value.EXISTS(37)
5535           AND    g_field_defn.oss_value.EXISTS(38)
5536           THEN
5537               -- Not calculated therefore calculate.
5538               igs_he_extract_fields_pkg.get_awd_body_12
5539                   (p_course_cd         =>  p_course_cd,
5540                    p_version_number    =>  p_crv_version_number,
5541                    p_awd1              =>  g_field_defn.oss_value(37),
5542                    p_awd2              =>  g_field_defn.oss_value(38),
5543                    p_awd_body1         =>  g_field_defn.hesa_value(47),
5544                    p_awd_body2         =>  p_value);
5545 
5546           END IF;
5547       ELSIF  p_field_number = 49
5548       THEN
5549           -- Length of Program
5550           -- Length of Program
5551           igs_he_extract_fields_pkg.get_new_prog_length
5552           (p_spa_attendance_type           =>  g_en_stdnt_ps_att.attendance_type,
5553            p_program_length                => g_ps_ofr_opt.program_length,
5554            p_program_length_measurement    => g_ps_ofr_opt.program_length_measurement,
5555            p_length                        =>  p_value,
5556            p_units                         =>  g_field_defn.hesa_value(50));
5557 
5558               --smaddali 01-jul-2002 lpadding with 0  for bug 2436769
5559               p_value := LPAD(p_value, 2,'0') ;
5560 
5561 
5562       ELSIF  p_field_number = 50
5563       THEN
5564           -- Units of length of Program
5565           IF g_field_defn.hesa_value.EXISTS(50)
5566           THEN
5567               -- Calculated Earlier ..
5568               p_value := g_field_defn.hesa_value(50);
5569           ELSE
5570               -- Not calculated earlier ..
5571                   igs_he_extract_fields_pkg.get_new_prog_length
5572                   (p_spa_attendance_type           =>  g_en_stdnt_ps_att.attendance_type,
5573                    p_program_length                => g_ps_ofr_opt.program_length,
5574                    p_program_length_measurement    => g_ps_ofr_opt.program_length_measurement,
5575                    p_length                        =>  g_field_defn.hesa_value(49),
5576                    p_units                         =>  p_value);
5577           END IF;
5578 
5579       -- This field is classified as 'Not Used' by HESA
5580       -- Removed the call to the procedure, get_voc_lvl
5581       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
5582       ELSIF  p_field_number = 51
5583       THEN
5584 
5585          -- Not Used
5586          p_value := NULL;
5587 
5588       ELSIF  p_field_number = 52
5589       THEN
5590           -- Spcial Programmes
5591           p_value := g_ps_ver.govt_special_course_type;
5592 
5593       ELSIF  p_field_number = 53
5594       THEN
5595 
5596                   IF g_field_defn.hesa_value.EXISTS(53)
5597                   THEN
5598                       -- Calculated Earlier ..
5599                       p_value := g_field_defn.hesa_value(53);
5600                   ELSE
5601 
5602                   -- Teacher Training Course Identifier
5603                   igs_he_extract_fields_pkg.get_teach_train_crs_id
5604                   (p_prg_ttcid            =>  g_he_st_prog.teacher_train_prog_id,
5605                    p_spa_ttcid            =>  g_he_st_spa.teacher_train_prog_id,
5606                    p_hesa_ttcid           =>  p_value);
5607                  END IF;
5608 
5609       ELSIF  p_field_number = 54
5610       THEN
5611                IF (g_he_submsn_header.validation_country  in ('ENGLAND','WALES') AND ( g_field_defn.hesa_value.EXISTS(53)  AND g_field_defn.hesa_value(53)  IN(1,2,6,7) ))   THEN
5612                   -- ITT Phase / Scope
5613                   igs_he_extract_fields_pkg.get_itt_phsc
5614                       (p_prg_itt_phsc        =>  g_he_st_prog.itt_phase,
5615                        p_spa_itt_phsc        =>  g_he_st_spa.itt_phase,
5616                        p_hesa_itt_phsc       =>  p_value);
5617                ELSE
5618                   g_default_pro:= 'N';
5619                END IF;
5620 
5621       ELSIF  p_field_number = 55
5622       THEN
5623               IF (g_he_submsn_header.validation_country  in ('SCOTLAND','WALES','NORTHERN IRELAND')  AND ( g_field_defn.hesa_value.EXISTS(53) AND g_field_defn.hesa_value(53)  IN(1,2)) )   THEN
5624                   -- Bilingual ITT Marker
5625                   igs_he_extract_fields_pkg.get_itt_mrker
5626                       (p_prg_itt_mrker       =>  g_he_st_prog.bilingual_itt_marker,
5627                        p_spa_itt_mrker       =>  g_he_st_spa.bilingual_itt_marker,
5628                        p_hesa_itt_mrker      =>  p_value);
5629 
5630                ELSE
5631                   g_default_pro:= 'N';
5632                END IF;
5633 
5634       ELSIF  p_field_number = 56
5635       THEN
5636 
5637                IF ( g_he_submsn_header.validation_country IN ('SCOTLAND' ,'NORTHERN IRELAND')  AND ( g_field_defn.hesa_value.EXISTS(53) AND g_field_defn.hesa_value(53) IN(1, 2)))   THEN
5638                   -- Teaching Qualification Sought Sector
5639                   igs_he_extract_fields_pkg.get_teach_qual_sect
5640                       (p_oss_teach_qual_sect   => g_he_st_prog.teaching_qual_sought_sector,
5641                        p_hesa_teach_qual_sect  => p_value);
5642 
5643                ELSE
5644                   g_default_pro:= 'N';
5645                END IF;
5646 
5647       ELSIF  p_field_number = 57
5648       THEN
5649             IF ( g_he_submsn_header.validation_country = 'SCOTLAND'   AND ( g_field_defn.hesa_value.EXISTS(56)  and g_field_defn.hesa_value(56) = 2 ) )   THEN
5650                   -- Teaching Qualification Sought Subject 1
5651                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5652                     (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj1,
5653                      p_hesa_teach_qual_sbj    =>  p_value);
5654             ELSE
5655                   g_default_pro:= 'N';
5656             END IF;
5657 
5658 
5659       ELSIF  p_field_number = 58
5660       THEN
5661               IF ( g_he_submsn_header.validation_country = 'SCOTLAND' AND ( g_field_defn.hesa_value.EXISTS(56) AND g_field_defn.hesa_value(56) = 2 ))   THEN
5662                   -- Teaching Qualification Sought Subject 2
5663                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5664                       (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj2,
5665                        p_hesa_teach_qual_sbj    =>  p_value);
5666               ELSE
5667                   g_default_pro:= 'N';
5668                END IF;
5669 
5670       ELSIF  p_field_number = 59
5671       THEN
5672               IF ( g_he_submsn_header.validation_country = 'SCOTLAND' AND ( g_field_defn.hesa_value.EXISTS(56)   and g_field_defn.hesa_value(56) = 2 )  )   THEN
5673                   -- Teaching Qualification Sought Subject 3
5674                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5675                       (p_oss_teach_qual_sbj     =>  g_he_st_prog.teaching_qual_sought_subj3,
5676                        p_hesa_teach_qual_sbj    =>  p_value);
5677                ELSE
5678                   g_default_pro:= 'N';
5679                END IF;
5680 
5681       ELSIF  p_field_number = 60
5682       THEN
5683 
5684              IF ( g_he_submsn_header.validation_country IN ('SCOTLAND' , 'NORTHERN IRELAND' ) AND ( g_field_defn.hesa_value.EXISTS(53) AND g_field_defn.hesa_value(53)  in (1,2) ) )   THEN
5685                   -- Teaching Qualification Gained Sector
5686                   igs_he_extract_fields_pkg.get_teach_qual_sect
5687                       (p_oss_teach_qual_sect   => g_he_st_spa.teaching_qual_gain_sector,
5688                        p_hesa_teach_qual_sect  => p_value);
5689 
5690                   IF p_value IS NULL
5691                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
5692                   AND g_field_defn.hesa_value.EXISTS(56)
5693                   THEN
5694                       p_value := g_field_defn.hesa_value(56);
5695                   END IF;
5696 
5697                ELSE
5698                       g_default_pro:= 'N';
5699                END IF;
5700 
5701       ELSIF  p_field_number = 61
5702       THEN
5703 
5704                IF ( g_he_submsn_header.validation_country = 'SCOTLAND' AND ( g_field_defn.hesa_value.EXISTS(60) AND g_field_defn.hesa_value(60) = 2  ))   THEN
5705                   -- Teaching Qualification Gained Subject 1
5706                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5707                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj1,
5708                        p_hesa_teach_qual_sbj    =>  p_value);
5709 
5710                   IF p_value IS NULL
5711                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
5712                   AND g_field_defn.hesa_value.EXISTS(57)
5713                   THEN
5714                       p_value := g_field_defn.hesa_value(57);
5715                   END IF;
5716 
5717 
5718                ELSE
5719                       g_default_pro:= 'N';
5720                END IF;
5721 
5722       ELSIF  p_field_number = 62
5723       THEN
5724 
5725                IF ( g_he_submsn_header.validation_country = 'SCOTLAND' AND ( g_field_defn.hesa_value.EXISTS(60) and g_field_defn.hesa_value(60) = 2 ) )   THEN
5726                   -- Teaching Qualification Gained Subject 2
5727                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5728                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj2,
5729                        p_hesa_teach_qual_sbj    =>  p_value);
5730 
5731                   IF p_value IS NULL
5732                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
5733                   AND g_field_defn.hesa_value.EXISTS(58)
5734                   THEN
5735                       p_value := g_field_defn.hesa_value(58);
5736                   END IF;
5737                ELSE
5738                       g_default_pro:= 'N';
5739                END IF;
5740 
5741       ELSIF  p_field_number = 63
5742       THEN
5743                IF ( g_he_submsn_header.validation_country = 'SCOTLAND' AND ( g_field_defn.hesa_value.EXISTS(60) AND g_field_defn.hesa_value(60) = 2 ))   THEN
5744                   -- Teaching Qualification Gained Subject 3
5745                   igs_he_extract_fields_pkg.get_teach_qual_sbj
5746                       (p_oss_teach_qual_sbj     =>  g_he_st_spa.teaching_qual_gain_subj3,
5747                        p_hesa_teach_qual_sbj    =>  p_value);
5748 
5749                   IF p_value IS NULL
5750                   AND g_en_stdnt_ps_att.course_rqrmnts_complete_dt IS NOT NULL
5751                   AND g_field_defn.hesa_value.EXISTS(59)
5752                   THEN
5753                       p_value := g_field_defn.hesa_value(59);
5754                   END IF;
5755 
5756 
5757                ELSE
5758                       g_default_pro:= 'N';
5759                END IF;
5760 
5761       ELSIF  p_field_number = 64
5762       THEN
5763           -- Major Source of Funding
5764           IF  g_field_defn.hesa_value.EXISTS(64)
5765           THEN
5766               -- Calculated earlier, for field 6
5767               p_value :=   g_field_defn.hesa_value(64);
5768           ELSE
5769               -- Not calculated earlier.
5770               -- smaddali modified this call to pass funding_source field for hefd208 - bug#2717751
5771               -- jtmathew modified this call to pass funding_source field at spa level - bug#3962575
5772               igs_he_extract_fields_pkg.get_funding_src
5773                   (p_course_cd             => p_course_cd,
5774                    p_version_number        => p_crv_version_number,
5775                    p_spa_fund_src          => g_en_stdnt_ps_att.funding_source,
5776                    p_poous_fund_src        => g_he_poous.funding_source,
5777                    p_oss_fund_src          => g_field_defn.oss_value(64),
5778                    p_hesa_fund_src         => p_value);
5779           END IF;
5780 
5781       ELSIF  p_field_number = 65
5782       THEN
5783           -- Fundability Code
5784           IF  g_field_defn.hesa_value.EXISTS(65)
5785           THEN
5786               -- Calculated earlier, for field 6
5787               p_value :=   g_field_defn.hesa_value(65);
5788           ELSE
5789               -- Not calculated earlier, hence derive
5790               IF  g_field_defn.oss_value.EXISTS(64)
5791               THEN
5792                   -- Next get the Fundability Code
5793                   -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
5794                   igs_he_extract_fields_pkg.get_fundability_cd
5795                       (p_person_id             => p_person_id,
5796                        p_susa_fund_cd          => g_he_en_susa.fundability_code,
5797                        p_spa_funding_source    => g_en_stdnt_ps_att.funding_source,
5798                        p_poous_fund_cd         => g_he_poous.fundability_cd,
5799                        p_prg_fund_cd           => g_he_st_prog.fundability,
5800                        p_prg_funding_source    => g_field_defn.oss_value(64),
5801                        p_oss_fund_cd           => g_field_defn.oss_value(65),
5802                        p_hesa_fund_cd          => p_value,
5803                        p_enrl_start_dt         =>  g_he_submsn_header.enrolment_start_date,
5804                        p_enrl_end_dt           =>  g_he_submsn_header.enrolment_end_date);
5805               ELSE
5806                   p_value := NULL;
5807               END IF;
5808 
5809           END IF; -- Not calculated earlier
5810 
5811       ELSIF  p_field_number = 66
5812       THEN
5813           -- smaddali modified the value pased to p_study_mode for bug 2367167
5814           -- Fee Eligibility
5815           IF   g_field_defn.oss_value.EXISTS(6)
5816           AND  g_field_defn.oss_value.EXISTS(28)
5817           THEN
5818           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
5819               igs_he_extract_fields_pkg.get_fee_elig
5820                   (p_person_id          =>  p_person_id,
5821                    p_susa_fee_elig      =>  g_he_en_susa.fee_eligibility,
5822                    p_fe_stdnt_mrker     =>  g_field_defn.oss_value(6),
5823                    p_study_mode         =>  NVL(g_he_en_susa.study_mode,NVL(g_he_poous.mode_of_study,g_en_stdnt_ps_att.attendance_type)),
5824                    p_special_student    =>  g_field_defn.oss_value(28),
5825                    p_hesa_fee_elig      =>  p_value,
5826                    p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
5827                    p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
5828           ELSE
5829             -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
5830               igs_he_extract_fields_pkg.get_fee_elig
5831                   (p_person_id          =>  p_person_id,
5832                    p_susa_fee_elig      =>  g_he_en_susa.fee_eligibility,
5833                    p_fe_stdnt_mrker     =>  NULL,
5834                    p_study_mode         =>  NVL(g_he_en_susa.study_mode,NVL(g_he_poous.mode_of_study,g_en_stdnt_ps_att.attendance_type)),
5835                    p_special_student    =>  NULL,
5836                    p_hesa_fee_elig      =>  p_value,
5837                    p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
5838                    p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date);
5839           END IF;
5840 
5841       ELSIF  p_field_number = 67
5842       THEN
5843           -- Fee Band
5844           IF   g_field_defn.hesa_value.EXISTS(66) THEN
5845               igs_he_extract_fields_pkg.get_fee_band
5846                   (p_hesa_fee_elig     =>  g_field_defn.hesa_value(66),
5847                    p_susa_fee_band     =>  g_he_en_susa.fee_band,
5848                    p_poous_fee_band    =>  g_he_poous.fee_band,
5849                    p_prg_fee_band      =>  g_he_st_prog.fee_band,
5850                    p_hesa_fee_band     =>  p_value);
5851           ELSE
5852 
5853               igs_he_extract_fields_pkg.get_fee_band
5854                   (p_hesa_fee_elig     =>  NULL,
5855                    p_susa_fee_band     =>  g_he_en_susa.fee_band,
5856                    p_poous_fee_band    =>  g_he_poous.fee_band,
5857                    p_prg_fee_band      =>  g_he_st_prog.fee_band,
5858                    p_hesa_fee_band     =>  p_value);
5859 
5860           END IF;
5861 
5862       ELSIF  p_field_number = 68
5863       THEN
5864           -- Major Source of Tuition Fees
5865           -- Calculate amount of tuition Fees first
5866           IF   NOT g_field_defn.hesa_value.EXISTS(6)
5867           THEN
5868               g_field_defn.hesa_value(6) := NULL;
5869           END IF;
5870 
5871           -- smaddali 14-oct-03 added 2 new parameters to the procedure get_amt_tuition_fees, for bug#3179544
5872           IF   g_field_defn.hesa_value.EXISTS(6)
5873           AND  g_field_defn.hesa_value.EXISTS(28)
5874           THEN
5875               igs_he_extract_fields_pkg.get_amt_tuition_fees
5876                   (p_person_id         =>  p_person_id,
5877                    p_course_cd         =>  p_course_cd,
5878                    p_cal_type          =>  g_en_stdnt_ps_att.cal_type,
5879                    p_fe_prg_mrker      =>  g_he_st_prog.fe_program_marker,
5880                    p_fe_stdnt_mrker    =>  g_field_defn.hesa_value(6),
5881                    p_oss_amt           =>  g_field_defn.oss_value(83),
5882                    p_hesa_amt          =>  g_field_defn.hesa_value(83),
5883                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
5884                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date);
5885 
5886               -- Calculate Mode of Study
5887               IF NOT g_field_defn.hesa_value.EXISTS(70) THEN
5888                 igs_he_extract_fields_pkg.get_mode_of_study
5889                   (p_person_id         =>  p_person_id,
5890                    p_course_cd         =>  p_course_cd,
5891                    p_version_number    =>  p_crv_version_number,
5892                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
5893                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
5894                    p_susa_study_mode   =>  g_he_en_susa.study_mode,
5895                    p_poous_study_mode  =>  g_he_poous.mode_of_study,
5896                    p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
5897                    p_mode_of_study     =>  g_field_defn.hesa_value(70));
5898               END IF ;
5899 
5900               -- Now calculate the major source of tuition fees
5901               igs_he_extract_fields_pkg.get_maj_src_tu_fee
5902                   (p_person_id         =>  p_person_id,
5903                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
5904                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
5905                    p_special_stdnt     =>  g_field_defn.hesa_value(28),
5906                    p_study_mode        =>  g_field_defn.hesa_value(70),
5907                    p_amt_tu_fee        =>  g_field_defn.oss_value(83),
5908                    p_susa_mstufee      =>  g_he_en_susa.student_fee,
5909                    p_hesa_mstufee      =>  p_value);
5910           END IF;
5911 
5912       ELSIF  p_field_number = 69
5913       THEN
5914           -- Not Used
5915           p_value := NULL;
5916 
5917       ELSIF  p_field_number = 70
5918       THEN
5919           -- Mode of Studying
5920           IF  g_field_defn.hesa_value.EXISTS(70)
5921           THEN
5922               -- Calculated earlier, for field 68
5923               p_value :=   g_field_defn.hesa_value(70);
5924           ELSE
5925               igs_he_extract_fields_pkg.get_mode_of_study
5926                   (p_person_id         =>  p_person_id,
5927                    p_course_cd         =>  p_course_cd,
5928                    p_version_number    =>  p_crv_version_number,
5929                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
5930                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date,
5931                    p_susa_study_mode   =>  g_he_en_susa.study_mode,
5932                    p_poous_study_mode  =>  g_he_poous.mode_of_study,
5933                    p_attendance_type   =>  g_en_stdnt_ps_att.attendance_type,
5934                    p_mode_of_study     =>  p_value);
5935 
5936           END IF;
5937 
5938       ELSIF  p_field_number = 71
5939       THEN
5940           -- Location of Study
5941           IF  g_field_defn.hesa_value.EXISTS(71)
5942           THEN
5943               -- Calculated earlier, for field 31
5944               p_value :=   g_field_defn.hesa_value(71);
5945           ELSE
5946               -- Not calculated earlier, hence derive
5947               igs_he_extract_fields_pkg.get_study_location
5948                   (p_susa_study_location    => g_he_en_susa.study_location,
5949                    p_poous_study_location   => g_he_poous.location_of_study,
5950                    p_prg_study_location     => g_he_st_prog.location_of_study,
5951                    p_oss_study_location     => g_field_defn.oss_value(71),
5952                    p_hesa_study_location    => p_value);
5953           END IF;
5954 
5955       ELSIF  p_field_number = 72
5956       THEN
5957            -- Year of Program
5958           IF  g_field_defn.hesa_value.EXISTS(72)
5959           THEN
5960               p_value :=   g_field_defn.hesa_value(72);
5961           ELSE
5962               -- Not calculated earlier, hence derive
5963               igs_he_extract_fields_pkg.get_year_of_prog
5964                   (p_unit_set_cd          => g_as_su_setatmpt.unit_set_cd,
5965                    p_year_of_prog         => p_value);
5966 
5967           END IF;
5968 
5969           -- To send to HESA Lpad with 0
5970           p_value := LPAD(p_value,2,'0');
5971 
5972       ELSIF  p_field_number = 73
5973       THEN
5974           -- Length of current year of program
5975           --smaddali adding LPAD '0' for bug 2437081
5976           p_value := LPAD(g_he_poous.leng_current_year,2,'0') ;
5977 
5978       ELSIF  p_field_number = 74
5979       THEN
5980           -- Included the below code as a part of HECR001(bug number 2278825)
5981           -- smaddali added the ltrim and changed format mask from 999.9 to 000.0 for bug 2431845
5982           -- jtmathew added the check for whether SUSA finishes before the start of reporting period
5983 
5984           IF g_he_en_susa.fte_perc_override  IS NOT NULL THEN
5985                   p_value := Ltrim(To_Char(g_he_en_susa.fte_perc_override,'000.0'));
5986           ELSE
5987               IF g_as_su_setatmpt.rqrmnts_complete_dt IS NOT NULL AND
5988                  g_as_su_setatmpt.rqrmnts_complete_dt <  g_he_submsn_header.enrolment_start_date
5989               THEN -- Report FTE of 000.0 as the unit set does not fit within the reporting period
5990                   p_value := Ltrim(To_Char(0,'000.0'));
5991               ELSE
5992                   p_value := Ltrim(To_Char(g_he_en_susa.calculated_fte,'000.0'));
5993               END IF;
5994           END IF;
5995 
5996       ELSIF  p_field_number = 75
5997       THEN
5998           -- Postcode
5999           IF g_field_defn.hesa_value.EXISTS(12) AND  g_field_defn.hesa_value(12) IN ('8826','5826','6826','7826','2826','3826','4826') THEN
6000                   p_value := g_he_st_spa.postcode;
6001           ELSE
6002              g_default_pro:= 'N';
6003           END IF;
6004 
6005       ELSIF  p_field_number = 76
6006       THEN
6007           -- PGCE - Subject of Undergraduate Degree
6008           -- smaddali added call to the new local procedure for bug 2452592
6009           IF g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN ('12','13')
6010           THEN
6011               igs_he_extract2_pkg.get_pgce_subj
6012               (p_person_id         =>  p_person_id,
6013                p_pgce_subj        =>  p_value);
6014           ELSE
6015               p_value := NULL ;
6016           END IF ;
6017 
6018       ELSIF  p_field_number = 77
6019       THEN
6020           -- PGCE - Classification  of Undergraduate Degree
6021           --smaddali added the whole code instead of NULL statement for bug 2436924
6022           IF g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN ('12','13')
6023           THEN
6024              igs_he_extract_fields_pkg.get_pgce_class
6025               (p_person_id         =>  p_person_id,
6026                p_pgce_class        =>  p_value);
6027           ELSE
6028               p_value := NULL ;
6029           END IF ;
6030 
6031       ELSIF  p_field_number = 78
6032       THEN
6033               IF (g_he_submsn_header.validation_country  = 'NORTHERN IRELAND' AND ( g_field_defn.hesa_value.EXISTS(12)  and g_field_defn.hesa_value(12) = '8826'))THEN
6034                   -- Religion
6035                   igs_he_extract_fields_pkg.get_religion
6036                   (p_oss_religion     =>  g_pe_stat_v.religion,
6037                    p_hesa_religion    =>  p_value);
6038 
6039               ELSE
6040                  g_default_pro := 'N';
6041               END IF;
6042 
6043       ELSIF  p_field_number = 79
6044       THEN
6045           -- Not used
6046           p_value := NULL;
6047 
6048       ELSIF  p_field_number = 80
6049       THEN
6050           -- Not used
6051           p_value := NULL;
6052 
6053       ELSIF  p_field_number = 81
6054       THEN
6055           -- SLDD Discrete Provision
6056           IF g_field_defn.hesa_value.EXISTS(6)
6057           THEN
6058               igs_he_extract_fields_pkg.get_sldd_disc_prv
6059                   (p_oss_sldd_disc_prv     =>  g_he_en_susa.sldd_discrete_prov,
6060                    p_fe_stdnt_mrker        =>  g_field_defn.hesa_value(6),
6061                    p_hesa_sldd_disc_prv    =>  p_value);
6062           END IF;
6063 
6064       ELSIF  p_field_number = 82
6065       THEN
6066           -- Not used
6067           p_value := NULL;
6068 
6069       ELSIF  p_field_number = 83
6070       THEN
6071          --Set the default processing as N for all the conditions as it is set to Y for the below condition
6072          g_default_pro:= 'N';
6073 
6074          IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)  THEN
6075 
6076            -- Amount of Tuition fees expected
6077            IF g_field_defn.hesa_value.EXISTS(83)
6078            THEN
6079               -- Calculated earlier. No need to derive
6080               p_value := g_field_defn.hesa_value(83);
6081            ELSE
6082 
6083               -- Not calculated earlier. Derive now.
6084               -- smaddali 14-oct-03 added 2 new parameters to the procedure get_amt_tuition_fees, for bug#3179544
6085               igs_he_extract_fields_pkg.get_amt_tuition_fees
6086                   (p_person_id         =>  p_person_id,
6087                    p_course_cd         =>  p_course_cd,
6088                    p_cal_type          =>  g_en_stdnt_ps_att.cal_type,
6089                    p_fe_prg_mrker      =>  g_he_st_prog.fe_program_marker,
6090                    p_fe_stdnt_mrker    =>  g_field_defn.hesa_value(6),
6091                    p_oss_amt           =>  g_field_defn.oss_value(83),
6092                    p_hesa_amt          =>  p_value,
6093                    p_enrl_start_dt     =>  g_he_submsn_header.enrolment_start_date,
6094                    p_enrl_end_dt       =>  g_he_submsn_header.enrolment_end_date);
6095            END IF;
6096            --Set the default Processing for this condition
6097            g_default_pro:= 'Y';
6098          END IF;
6099 
6100       ELSIF  p_field_number = 84
6101       THEN
6102          g_default_pro:= 'N';
6103 
6104          IF  g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4) THEN
6105           -- Non Payment Reason
6106              igs_he_extract_fields_pkg.get_non_payment_rsn
6107               (p_oss_non_payment_rsn   =>  g_he_en_susa.non_payment_reason,
6108                p_hesa_non_payment_rsn  =>  p_value,
6109                p_fe_stdnt_mrker    => g_field_defn.hesa_value(6));
6110 
6111              g_default_pro:= 'Y';
6112          END IF;
6113 
6114       ELSIF  p_field_number = 85
6115       THEN
6116           -- Module Identifier 1
6117           --smaddali added the initialisation of variable g_mod_rec for bug 2417370
6118           g_mod_rec := NULL ;
6119           g_total_mod := 0;
6120 
6121           IF g_he_st_prog.program_calc = 'N'
6122           THEN
6123               igs_he_extract_fields_pkg.get_module_dets
6124                  (p_person_id            =>  p_person_id,
6125                   p_course_cd            =>  p_course_cd,
6126                   p_version_number       =>  p_crv_version_number,
6127                   p_student_inst_number  =>  g_he_st_spa.student_inst_number,
6128                   p_cal_type             =>  g_en_stdnt_ps_att.cal_type,
6129                   p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
6130                   p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date,
6131                   p_offset_days          =>  g_he_submsn_header.offset_days,
6132                   p_module_rec           =>  g_mod_rec,
6133                   p_total_recs           =>  g_total_mod);
6134 
6135               IF g_total_mod >= 1
6136               THEN
6137                   p_value := g_mod_rec.module_id(1);
6138               END IF;
6139           END IF;
6140 
6141 
6142       ELSIF  p_field_number = 86
6143       THEN
6144           -- Module Identifier 2
6145           IF g_he_st_prog.program_calc = 'N'
6146           AND g_total_mod >= 2
6147           THEN
6148               p_value := g_mod_rec.module_id(2);
6149           END IF;
6150 
6151       ELSIF  p_field_number = 87
6152       THEN
6153           -- Module Identifier 3
6154           IF g_he_st_prog.program_calc = 'N'
6155           AND g_total_mod >= 3
6156           THEN
6157               p_value := g_mod_rec.module_id(3);
6158           END IF;
6159 
6160 
6161       ELSIF  p_field_number = 88
6162       THEN
6163           -- Module Identifier 4
6164           IF g_he_st_prog.program_calc = 'N'
6165           AND g_total_mod >= 4
6166           THEN
6167               p_value := g_mod_rec.module_id(4);
6168           END IF;
6169 
6170 
6171       ELSIF  p_field_number = 89
6172       THEN
6173           -- Module Identifier 5
6174           IF g_he_st_prog.program_calc = 'N'
6175           AND g_total_mod >= 5
6176           THEN
6177               p_value := g_mod_rec.module_id(5);
6178           END IF;
6179 
6180 
6181       ELSIF  p_field_number = 90
6182       THEN
6183           -- Module Identifier 6
6184           IF g_he_st_prog.program_calc = 'N'
6185           AND g_total_mod >= 6
6186           THEN
6187               p_value := g_mod_rec.module_id(6);
6188           END IF;
6189 
6190       ELSIF  p_field_number = 91
6191       THEN
6192           -- Module Identifier 7
6193           IF g_he_st_prog.program_calc = 'N'
6194           AND g_total_mod >= 7
6195           THEN
6196               p_value := g_mod_rec.module_id(7);
6197           END IF;
6198 
6199 
6200       ELSIF  p_field_number = 92
6201       THEN
6202           -- Module Identifier 8
6203           IF g_he_st_prog.program_calc = 'N'
6204           AND g_total_mod >= 8
6205           THEN
6206               p_value := g_mod_rec.module_id(8);
6207           END IF;
6208 
6209 
6210       ELSIF  p_field_number = 93
6211       THEN
6212           -- Module Identifier 9
6213           IF g_he_st_prog.program_calc = 'N'
6214           AND g_total_mod >= 9
6215           THEN
6216               p_value := g_mod_rec.module_id(9);
6217           END IF;
6218 
6219 
6220       ELSIF  p_field_number = 94
6221       THEN
6222           -- Module Identifier 10
6223           IF g_he_st_prog.program_calc = 'N'
6224           AND g_total_mod >= 10
6225           THEN
6226               p_value := g_mod_rec.module_id(10);
6227           END IF;
6228 
6229 
6230       ELSIF  p_field_number = 95
6231       THEN
6232           -- Module Identifier 11
6233           IF g_he_st_prog.program_calc = 'N'
6234           AND g_total_mod >= 11
6235           THEN
6236               p_value := g_mod_rec.module_id(11);
6237           END IF;
6238 
6239 
6240       ELSIF  p_field_number = 96
6241       THEN
6242           -- Module Identifier 12
6243           IF g_he_st_prog.program_calc = 'N'
6244           AND g_total_mod >= 12
6245           THEN
6246               p_value := g_mod_rec.module_id(12);
6247           END IF;
6248 
6249 
6250       ELSIF  p_field_number = 97
6251       THEN
6252           -- Module Identifier 13
6253           IF g_he_st_prog.program_calc = 'N'
6254           AND g_total_mod >= 13
6255           THEN
6256               p_value := g_mod_rec.module_id(13);
6257           END IF;
6258 
6259 
6260       ELSIF  p_field_number = 98
6261       THEN
6262           -- Module Identifier 14
6263           IF g_he_st_prog.program_calc = 'N'
6264           AND g_total_mod >= 14
6265           THEN
6266               p_value := g_mod_rec.module_id(14);
6267           END IF;
6268 
6269 
6270       ELSIF  p_field_number = 99
6271       THEN
6272           -- Module Identifier 15
6273           IF g_he_st_prog.program_calc = 'N'
6274           AND g_total_mod >= 15
6275           THEN
6276               p_value := g_mod_rec.module_id(15);
6277           END IF;
6278 
6279 
6280       ELSIF  p_field_number = 100
6281       THEN
6282           -- Module Identifier 16
6283           IF g_he_st_prog.program_calc = 'N'
6284           AND g_total_mod >= 16
6285           THEN
6286               p_value := g_mod_rec.module_id(16);
6287           END IF;
6288 
6289       -- smaddali 13-oct-03  Modified student fields 101 to 116 for bug#3163324 ,
6290       --  to derive only for WELSH students
6291       ELSIF  p_field_number = 101
6292       THEN
6293           -- Module 1, Proportion of teaching in Welsh
6294           IF g_he_st_prog.program_calc = 'N'
6295           AND g_total_mod >= 1 AND g_he_submsn_header.validation_country   = 'WALES'
6296           THEN
6297               --smaddali adding format mask '000.0' for bug 2437081
6298               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(1),'000.0') );
6299           END IF;
6300 
6301       ELSIF  p_field_number = 102
6302       THEN
6303           -- Module 2, Proportion of teaching in Welsh
6304           IF g_he_st_prog.program_calc = 'N'
6305           AND g_total_mod >= 2 AND g_he_submsn_header.validation_country   = 'WALES'
6306           THEN
6307               --smaddali adding format mask '000.0' for bug 2437081
6308               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(2),'000.0') );
6309           END IF;
6310 
6311       ELSIF  p_field_number = 103
6312       THEN
6313           -- Module 3, Proportion of teaching in Welsh
6314           IF g_he_st_prog.program_calc = 'N'
6315           AND g_total_mod >= 3 AND g_he_submsn_header.validation_country   = 'WALES'
6316           THEN
6317               --smaddali adding format mask '000.0' for bug 2437081
6318               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(3),'000.0') );
6319           END IF;
6320 
6321       ELSIF  p_field_number = 104
6322       THEN
6323           -- Module 4, Proportion of teaching in Welsh
6324           IF g_he_st_prog.program_calc = 'N'
6325           AND g_total_mod >= 4 AND g_he_submsn_header.validation_country   = 'WALES'
6326           THEN
6327                --smaddali adding format mask '000.0' for bug 2437081
6328               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(4),'000.0') );
6329           END IF;
6330 
6331       ELSIF  p_field_number = 105
6332       THEN
6333           -- Module 5, Proportion of teaching in Welsh
6334           IF g_he_st_prog.program_calc = 'N'
6335           AND g_total_mod >= 5 AND g_he_submsn_header.validation_country   = 'WALES'
6336           THEN
6337                --smaddali adding format mask '000.0' for bug 2437081
6338               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(5),'000.0') );
6339           END IF;
6340 
6341 
6342       ELSIF  p_field_number = 106
6343       THEN
6344           -- Module 6, Proportion of teaching in Welsh
6345           IF g_he_st_prog.program_calc = 'N'
6346           AND g_total_mod >= 6 AND g_he_submsn_header.validation_country   = 'WALES'
6347           THEN
6348                --smaddali adding format mask '000.0' for bug 2437081
6349               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(6),'000.0') );
6350           END IF;
6351 
6352       ELSIF  p_field_number = 107
6353       THEN
6354           -- Module 7, Proportion of teaching in Welsh
6355           IF g_he_st_prog.program_calc = 'N'
6356           AND g_total_mod >= 7 AND g_he_submsn_header.validation_country   = 'WALES'
6357           THEN
6358                --smaddali adding format mask '000.0' for bug 2437081
6359               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(7),'000.0') );
6360           END IF;
6361 
6362       ELSIF  p_field_number = 108
6363       THEN
6364           -- Module 8, Proportion of teaching in Welsh
6365           IF g_he_st_prog.program_calc = 'N'
6366           AND g_total_mod >= 8 AND g_he_submsn_header.validation_country   = 'WALES'
6367           THEN
6368                --smaddali adding format mask '000.0' for bug 2437081
6369               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(8),'000.0') );
6370           END IF;
6371 
6372       ELSIF  p_field_number = 109
6373       THEN
6374           -- Module 9, Proportion of teaching in Welsh
6375           IF g_he_st_prog.program_calc = 'N'
6376           AND g_total_mod >= 9 AND g_he_submsn_header.validation_country   = 'WALES'
6377           THEN
6378                --smaddali adding format mask '000.0' for bug 2437081
6379               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(9),'000.0') );
6380           END IF;
6381 
6382       ELSIF  p_field_number = 110
6383       THEN
6384           -- Module 10, Proportion of teaching in Welsh
6385           IF g_he_st_prog.program_calc = 'N'
6386           AND g_total_mod >= 10 AND g_he_submsn_header.validation_country   = 'WALES'
6387           THEN
6388                --smaddali adding format mask '000.0' for bug 2437081
6389               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(10),'000.0') );
6390           END IF;
6391 
6392       ELSIF  p_field_number = 111
6393       THEN
6394           -- Module 11, Proportion of teaching in Welsh
6395           IF g_he_st_prog.program_calc = 'N'
6396           AND g_total_mod >= 11 AND g_he_submsn_header.validation_country   = 'WALES'
6397           THEN
6398                --smaddali adding format mask '000.0' for bug 2437081
6399               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(11),'000.0') );
6400           END IF;
6401 
6402       ELSIF  p_field_number = 112
6403       THEN
6404           -- Module 12, Proportion of teaching in Welsh
6405           IF g_he_st_prog.program_calc = 'N'
6406           AND g_total_mod >= 12 AND g_he_submsn_header.validation_country   = 'WALES'
6407           THEN
6408                --smaddali adding format mask '000.0' for bug 2437081
6409               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(12),'000.0') );
6410           END IF;
6411 
6412       ELSIF  p_field_number = 113
6413       THEN
6414           -- Module 13, Proportion of teaching in Welsh
6415           IF g_he_st_prog.program_calc = 'N'
6416           AND g_total_mod >= 13 AND g_he_submsn_header.validation_country   = 'WALES'
6417           THEN
6418                --smaddali adding format mask '000.0' for bug 2437081
6419               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(13),'000.0') );
6420           END IF;
6421 
6422       ELSIF  p_field_number = 114
6423       THEN
6424           -- Module 14, Proportion of teaching in Welsh
6425           IF g_he_st_prog.program_calc = 'N'
6426           AND g_total_mod >= 14 AND g_he_submsn_header.validation_country   = 'WALES'
6427           THEN
6428                --smaddali adding format mask '000.0' for bug 2437081
6429               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(14),'000.0') );
6430           END IF;
6431 
6432       ELSIF  p_field_number = 115
6433       THEN
6434           -- Module 15, Proportion of teaching in Welsh
6435           IF g_he_st_prog.program_calc = 'N'
6436           AND g_total_mod >= 15 AND g_he_submsn_header.validation_country   = 'WALES'
6437           THEN
6438                --smaddali adding format mask '000.0' for bug 2437081
6439               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(15),'000.0') );
6440           END IF;
6441 
6442       ELSIF  p_field_number = 116
6443       THEN
6444           -- Module 16, Proportion of teaching in Welsh
6445           IF g_he_st_prog.program_calc = 'N'
6446           AND g_total_mod >= 16 AND g_he_submsn_header.validation_country   = 'WALES'
6447           THEN
6448                --smaddali adding format mask '000.0' for bug 2437081
6449               p_value := Ltrim(To_Char(g_mod_rec.prop_in_welsh(16),'000.0') );
6450           END IF;
6451 
6452       ELSIF  p_field_number = 117
6453       THEN
6454           -- Module 1, Result
6455           IF g_he_st_prog.program_calc = 'N'
6456           AND g_total_mod >= 1
6457           THEN
6458               p_value := g_mod_rec.module_result(1);
6459           END IF;
6460 
6461       ELSIF  p_field_number = 118
6462       THEN
6463           -- Module 2, Result
6464           IF g_he_st_prog.program_calc = 'N'
6465           AND g_total_mod >= 2
6466           THEN
6467               p_value := g_mod_rec.module_result(2);
6468           END IF;
6469 
6470       ELSIF  p_field_number = 119
6471       THEN
6472           -- Module 3, Result
6473           IF g_he_st_prog.program_calc = 'N'
6474           AND g_total_mod >= 3
6475           THEN
6476               p_value := g_mod_rec.module_result(3);
6477           END IF;
6478 
6479       ELSIF  p_field_number = 120
6480       THEN
6481           -- Module 4, Result
6482           IF g_he_st_prog.program_calc = 'N'
6483           AND g_total_mod >= 4
6484           THEN
6485               p_value := g_mod_rec.module_result(4);
6486           END IF;
6487 
6488       ELSIF  p_field_number = 121
6489       THEN
6490           -- Module 5, Result
6491           IF g_he_st_prog.program_calc = 'N'
6492           AND g_total_mod >= 5
6493           THEN
6494               p_value := g_mod_rec.module_result(5);
6495           END IF;
6496 
6497 
6498       ELSIF  p_field_number = 122
6499       THEN
6500           -- Module 6, Result
6501           IF g_he_st_prog.program_calc = 'N'
6502           AND g_total_mod >= 6
6503           THEN
6504               p_value := g_mod_rec.module_result(6);
6505           END IF;
6506 
6507       ELSIF  p_field_number = 123
6508       THEN
6509           -- Module 7, Result
6510           IF g_he_st_prog.program_calc = 'N'
6511           AND g_total_mod >= 7
6512           THEN
6513               p_value := g_mod_rec.module_result(7);
6514           END IF;
6515 
6516       ELSIF  p_field_number = 124
6517       THEN
6518           -- Module 8, Result
6519           IF g_he_st_prog.program_calc = 'N'
6520           AND g_total_mod >= 8
6521           THEN
6522               p_value := g_mod_rec.module_result(8);
6523           END IF;
6524 
6525       ELSIF  p_field_number = 125
6526       THEN
6527           -- Module 9, Result
6528           IF g_he_st_prog.program_calc = 'N'
6529           AND g_total_mod >= 9
6530           THEN
6531               p_value := g_mod_rec.module_result(9);
6532           END IF;
6533 
6534       ELSIF  p_field_number = 126
6535       THEN
6536           -- Module 10, Result
6537           IF g_he_st_prog.program_calc = 'N'
6538           AND g_total_mod >= 10
6539           THEN
6540               p_value := g_mod_rec.module_result(10);
6541           END IF;
6542 
6543       ELSIF  p_field_number = 127
6544       THEN
6545           -- Module 11, Result
6546           IF g_he_st_prog.program_calc = 'N'
6547           AND g_total_mod >= 11
6548           THEN
6549               p_value := g_mod_rec.module_result(11);
6550           END IF;
6551 
6552       ELSIF  p_field_number = 128
6553       THEN
6554           -- Module 12, Result
6555           IF g_he_st_prog.program_calc = 'N'
6556           AND g_total_mod >= 12
6557           THEN
6558               p_value := g_mod_rec.module_result(12);
6559           END IF;
6560 
6561       ELSIF  p_field_number = 129
6562       THEN
6563           -- Module 13, Result
6564           IF g_he_st_prog.program_calc = 'N'
6565           AND g_total_mod >= 13
6566           THEN
6567               p_value := g_mod_rec.module_result(13);
6568           END IF;
6569 
6570       ELSIF  p_field_number = 130
6571       THEN
6572           -- Module 14, Result
6573           IF g_he_st_prog.program_calc = 'N'
6574           AND g_total_mod >= 14
6575           THEN
6576               p_value := g_mod_rec.module_result(14);
6577           END IF;
6578 
6579       ELSIF  p_field_number = 131
6580       THEN
6581           -- Module 15, Result
6582           IF g_he_st_prog.program_calc = 'N'
6583           AND g_total_mod >= 15
6584           THEN
6585               p_value := g_mod_rec.module_result(15);
6586           END IF;
6587 
6588       ELSIF  p_field_number = 132
6589       THEN
6590           -- Module 16, Result
6591           IF g_he_st_prog.program_calc = 'N'
6592           AND g_total_mod >= 16
6593           THEN
6594               p_value := g_mod_rec.module_result(16);
6595           END IF;
6596 
6597       -- Modified the derivation of this field to derive regardless of the value of the HESA MODE field (70)
6598       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
6599       ELSIF  p_field_number = 133
6600       THEN
6601 
6602          IF g_field_defn.hesa_value.EXISTS(133)
6603          THEN
6604              p_value :=  g_field_defn.hesa_value(133);
6605          ELSE
6606 
6607            IF  g_he_st_spa.associate_ucas_number = 'Y' THEN
6608 
6609               -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
6610               igs_he_extract_fields_pkg.get_ucasnum
6611                 (p_person_id            => p_person_id,
6612                 p_ucasnum              => p_value,
6613                 p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
6614                 p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date);
6615 
6616            END IF;
6617 
6618          END IF;
6619 
6620       ELSIF  p_field_number = 134
6621       THEN
6622           -- Institutions Own Id for Student
6623           p_value := g_pe_person.person_number;
6624 
6625       ELSIF  p_field_number = 135
6626       THEN
6627           -- Institutes program of study
6628           p_value := p_course_cd || '.' || To_Char(p_crv_version_number);
6629 
6630       ELSIF  p_field_number = 136
6631       THEN
6632           -- Student Instance Number
6633           p_value := g_he_st_spa.student_inst_number;
6634 
6635       ELSIF  p_field_number = 137
6636       THEN
6637           -- Suspension of Active studies
6638           igs_he_extract_fields_pkg.get_studies_susp
6639               (p_person_id          =>  p_person_id,
6640                p_course_cd          =>  p_course_cd,
6641                p_version_number     =>  p_crv_version_number,
6642                p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
6643                p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date,
6644                p_susp_act_std       =>  p_value);
6645 
6646       ELSIF  p_field_number = 138
6647       THEN
6648           -- Type of Program year
6649           igs_he_extract_fields_pkg.get_pyr_type
6650               (p_oss_pyr_type     =>  NVL(g_he_en_susa.type_of_year,g_he_poous.type_of_year),
6651                p_hesa_pyr_type    =>  p_value);
6652 
6653       ELSIF  p_field_number = 139
6654       THEN
6655           -- Level applicable for funding
6656           igs_he_extract_fields_pkg.get_lvl_appl_to_fund
6657               (p_poous_lvl_appl_fund   =>  g_he_poous.level_applicable_to_funding,
6658                p_prg_lvl_appl_fund     =>  g_he_st_prog.level_applicable_to_funding,
6659                p_hesa_lvl_appl_fund    =>  p_value);
6660 
6661       -- The derivation of this field has changed majorly to consider the new setup
6662       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
6663       ELSIF  p_field_number = 140
6664       THEN
6665 
6666          -- The default value not to be done  for all the contries
6667          g_default_pro := 'N' ;
6668 
6669          IF g_he_submsn_header.validation_country IN ('ENGLAND','WALES','NORTHERN IRELAND')  THEN
6670 
6671             -- Check for the existence of the fields 139, 28, 137, 70 and 138. If not exists pass NULL value
6672             IF g_field_defn.hesa_value.EXISTS(139) THEN
6673               l_fundlev := g_field_defn.hesa_value(139);
6674             ELSE
6675               l_fundlev := NULL;
6676             END IF;
6677 
6678             IF g_field_defn.hesa_value.EXISTS(28) THEN
6679               l_spcstu := g_field_defn.hesa_value(28);
6680             ELSE
6681               l_spcstu := NULL;
6682             END IF;
6683 
6684             IF g_field_defn.hesa_value.EXISTS(137) THEN
6685               l_notact := g_field_defn.hesa_value(137);
6686             ELSE
6687               l_notact := NULL;
6688             END IF;
6689 
6690             IF g_field_defn.hesa_value.EXISTS(70) THEN
6691               l_mode := g_field_defn.hesa_value(70);
6692             ELSE
6693               l_mode := NULL;
6694             END IF;
6695 
6696             IF g_field_defn.hesa_value.EXISTS(138) THEN
6697               l_typeyr := g_field_defn.hesa_value(138);
6698             ELSE
6699               l_typeyr := NULL;
6700             END IF;
6701 
6702             -- Completion of Year of Program of study
6703             igs_he_extract_fields_pkg.get_comp_pyr_study (
6704               p_susa_comp_pyr_study  =>  g_he_en_susa.complete_pyr_study_cd,
6705               p_fundlev              =>  l_fundlev,
6706               p_spcstu               =>  l_spcstu,
6707               p_notact               =>  l_notact,
6708               p_mode                 =>  l_mode,
6709               p_typeyr               =>  l_typeyr,
6710               p_crse_rqr_complete_ind => g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
6711               p_crse_req_complete_dt =>  g_en_stdnt_ps_att.course_rqrmnts_complete_dt,
6712               p_disc_reason_cd       =>  g_en_stdnt_ps_att.discontinuation_reason_cd,
6713               p_discont_dt           =>  g_en_stdnt_ps_att.discontinued_dt,
6714               p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
6715               p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date,
6716               p_person_id            =>  p_person_id,
6717               p_course_cd            =>  p_course_cd,
6718               p_hesa_comp_pyr_study  =>  p_value);
6719 
6720              -- The default value valid for only thses the contries
6721              g_default_pro := 'Y' ;
6722          END IF;
6723 
6724       ELSIF  p_field_number = 141
6725       THEN
6726 
6727         IF (g_he_submsn_header.validation_country =   'WALES' AND ( g_field_defn.hesa_value.EXISTS(6) and  g_field_defn.hesa_value(6) IN (1,3,4))) THEN
6728           -- Get the value
6729           -- Destination
6730           igs_he_extract_fields_pkg.get_destination
6731               (p_oss_destination     =>  g_he_st_spa.destination,
6732                p_hesa_destination    =>  p_value);
6733         ELSE
6734                     -- The default value should not be calculated for  any other condition
6735                      g_default_pro := 'N' ;
6736 
6737         END IF;
6738 
6739       ELSIF  p_field_number = 142
6740       THEN
6741           -- Not used
6742           p_value := NULL;
6743 
6744       ELSIF  p_field_number = 143
6745       THEN
6746           -- Not used
6747           p_value := NULL;
6748 
6749       ELSIF  p_field_number = 144
6750       THEN
6751           -- Not used
6752           p_value := NULL;
6753 
6754       ELSIF  p_field_number = 145
6755       THEN
6756           -- Not used
6757           p_value := NULL;
6758 
6759       ELSIF  p_field_number = 146
6760       THEN
6761         --Set the  default variable value as default value has to be calculated only for the down condition
6762         g_default_pro := 'N';
6763 
6764         IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES') THEN
6765               -- Get the value
6766               -- Outcome of ITT Program
6767           IF (g_field_defn.hesa_value.EXISTS(53)  AND g_field_defn.hesa_value(53) IN (1,6,7)) THEN
6768                 IF  g_field_defn.hesa_value.EXISTS(146)     THEN
6769                -- Calculated earlier, for field 29
6770                     p_value :=   g_field_defn.hesa_value(146);
6771 
6772                 ELSE
6773                    igs_he_extract_fields_pkg.get_itt_outcome
6774                     (p_oss_itt_outcome     =>  g_he_st_spa.itt_prog_outcome,
6775                      p_teach_train_prg     =>  g_field_defn.hesa_value(53),
6776                      p_hesa_itt_outcome    =>  p_value);
6777 
6778                 END IF;
6779                 --If the value is calculated as NULL above then do the default processing for this field
6780                 g_default_pro := 'Y' ;
6781           END IF;
6782         END IF;
6783 
6784       ELSIF  p_field_number = 147
6785       THEN
6786           -- Not used
6787           p_value := NULL;
6788 
6789       ELSIF  p_field_number = 148
6790       THEN
6791           -- Not used
6792           p_value := NULL;
6793 
6794       ELSIF  p_field_number = 149
6795       THEN
6796           -- UFI Place
6797           igs_he_extract_fields_pkg.get_ufi_place
6798               (p_oss_ufi_place     =>  NVL(g_he_st_spa.ufi_place,g_he_poous.ufi_place),
6799                p_hesa_ufi_place    =>  p_value);
6800 
6801       ELSIF  p_field_number = 150
6802       THEN
6803           --Franchising Activity
6804           igs_he_extract_fields_pkg.get_franchising_activity
6805               (p_susa_franch_activity   => g_he_en_susa.franchising_activity,
6806                p_poous_franch_activity  => g_he_poous.franchising_activity,
6807                p_prog_franch_activity   => g_he_st_prog.franchising_activity,
6808                p_hesa_franch_activity   =>  p_value);
6809 
6810       ELSIF  p_field_number = 151
6811       THEN
6812           -- Institutions own campus identifier
6813           igs_he_extract_fields_pkg.get_campus_id
6814               (p_location_cd => g_en_stdnt_ps_att.location_cd,
6815                p_campus_id   => p_value);
6816 
6817       ELSIF  p_field_number = 152
6818       THEN
6819 
6820           -- sjlaporte use date comparison rather than text bug 3933715
6821           -- Social Class Indicator
6822       IF g_en_stdnt_ps_att.commencement_dt  > TO_DATE('31/07/2002', 'DD/MM/YYYY')
6823           THEN
6824               igs_he_extract_fields_pkg.get_social_class_ind
6825                   (p_spa_social_class_ind   => g_he_st_spa.social_class_ind,
6826                    p_adm_social_class_ind   => g_he_ad_dtl.social_class_cd,
6827                    p_hesa_social_class_ind  => p_value);
6828           END IF;
6829 
6830       ELSIF  p_field_number = 153
6831       THEN
6832 
6833           -- sjlaporte use date comparison rather than text bug 3933715
6834           -- Occupation Code
6835           IF g_en_stdnt_ps_att.commencement_dt  > TO_DATE('31/07/2002', 'DD/MM/YYYY')
6836           THEN
6837               igs_he_extract_fields_pkg.get_occupation_code
6838                   (p_spa_occupation_code   => g_he_st_spa.occupation_code,
6839                    p_hesa_occupation_code  =>  p_value);
6840 
6841           END IF;
6842 
6843       ELSIF  p_field_number = 154
6844       THEN
6845           -- Insitute last attended
6846         -- smaddali modified this field to remove the dependency on field 148UCASNUM for bug 2663717
6847                   igs_he_extract_fields_pkg.get_inst_last_attended
6848                      (p_person_id         =>  p_person_id,
6849                       p_com_date          =>  g_en_stdnt_ps_att.commencement_dt,
6850                       p_inst_last_att     =>  p_value,
6851                       p_enrl_start_dt      =>  g_he_submsn_header.enrolment_start_date,
6852                       p_enrl_end_dt        =>  g_he_submsn_header.enrolment_end_date
6853                       );
6854 
6855       ELSIF  p_field_number = 155
6856       THEN
6857           -- Regulatory Body
6858           igs_he_extract_fields_pkg.get_regulatory_body
6859               (p_course_cd               =>  p_course_cd,
6860                p_version_number          =>  p_crv_version_number,
6861                p_hesa_regulatory_body    =>  p_value);
6862 
6863       -- Modified the field derivation to derive a default value based on field numbers 41 and 155
6864       -- as part of HEFD311 - July 2004 Changes enhancement bug, 2956444
6865       ELSIF  p_field_number = 156
6866       THEN
6867 
6868           -- Regulatory Body Registration Number
6869           -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
6870           -- and adding validation to derive this field only if associate_nhs_reg_num=Y
6871           IF g_he_st_spa.associate_nhs_reg_num = 'Y' THEN
6872                   igs_he_extract_fields_pkg.get_alt_pers_id
6873                       (p_person_id              => p_person_id,
6874                        p_id_type                => 'DH REG REF',
6875                        p_api_id                 => p_value,
6876                        p_enrl_start_dt          =>  g_he_submsn_header.enrolment_start_date,
6877                        p_enrl_end_dt            =>  g_he_submsn_header.enrolment_end_date);
6878            END IF ;
6879 
6880           -- If the field not derived and
6881           -- If field 41- QUALAIM  is 18 or 33 and Field 155 - Regulatory body for
6882           -- health and Social care students is 06 or 07 then use default value, 99999999
6883           IF p_value IS NULL AND g_field_defn.hesa_value.EXISTS(41) AND g_field_defn.hesa_value(41) IN (18,33) AND
6884              g_field_defn.hesa_value.EXISTS(155)  AND g_field_defn.hesa_value(155) IN ('06', '07') THEN
6885 
6886             p_value := '99999999';
6887 
6888           END IF;
6889 
6890       ELSIF  p_field_number = 157
6891       THEN
6892           -- Source of NHS funding
6893           igs_he_extract_fields_pkg.get_nhs_fund_src
6894               (p_spa_nhs_fund_src    =>  g_he_st_spa.nhs_funding_source,
6895                p_prg_nhs_fund_src    =>  g_he_st_prog.nhs_funding_source,
6896                p_hesa_nhs_fund_src   =>  p_value);
6897 
6898       ELSIF  p_field_number = 158
6899       THEN
6900           -- NHS Employer
6901           igs_he_extract_fields_pkg.get_nhs_employer
6902               (p_spa_nhs_employer     => g_he_st_spa.nhs_employer,
6903                p_hesa_nhs_employer    => p_value);
6904 
6905       ELSIF  p_field_number = 159
6906       THEN
6907 
6908           g_default_pro := 'N';
6909 
6910           -- Number of GCE AS Levels
6911           igs_he_extract_fields_pkg.get_qual_dets
6912               (p_person_id            =>  p_person_id,
6913                p_course_cd            =>  p_course_cd,
6914                p_hesa_qual            =>  'GCSEAS',
6915                p_no_of_qual           =>  p_value,
6916                p_tariff_score         =>  g_field_defn.hesa_value(160));
6917 
6918           IF p_value IS NOT NULL THEN
6919             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
6920                                                        p_person_number  => g_pe_person.person_number,
6921                                                        p_course_cd      => p_course_cd,
6922                                                        p_hesa_qual      => 'GCEASN',
6923                                                        p_no_of_qual     => p_value);
6924           ELSE
6925               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
6926               IF g_field_defn.hesa_value.EXISTS(41)  AND
6927                  g_field_defn.hesa_value.EXISTS(26)  AND
6928                  g_field_defn.hesa_value.EXISTS(133) AND
6929                  igs_he_extract_fields_pkg.is_ucas_ftug
6930                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
6931                       p_hesa_commdate     => g_field_defn.hesa_value(26),
6932                       p_ucasnum           => g_field_defn.hesa_value(133),
6933                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
6934               THEN
6935                 g_default_pro := 'Y';
6936               END IF;
6937 
6938           END IF;
6939 
6940       ELSIF  p_field_number = 160
6941       THEN
6942 
6943           g_default_pro := 'N';
6944 
6945           -- GCE AS level Tariff Score
6946           IF g_field_defn.hesa_value.EXISTS(160) AND g_field_defn.hesa_value(160) IS NOT NULL
6947           THEN
6948               p_value := g_field_defn.hesa_value(160);
6949               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
6950                                                            p_person_number  => g_pe_person.person_number,
6951                                                            p_course_cd      => p_course_cd,
6952                                                            p_hesa_qual      => 'GCEASTS',
6953                                                            p_tariff_score   => p_value);
6954 
6955           END IF;
6956 
6957           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
6958           IF p_value IS NULL AND
6959              g_field_defn.hesa_value.EXISTS(41)  AND
6960              g_field_defn.hesa_value.EXISTS(26)  AND
6961              g_field_defn.hesa_value.EXISTS(133) AND
6962              igs_he_extract_fields_pkg.is_ucas_ftug
6963                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
6964                   p_hesa_commdate     => g_field_defn.hesa_value(26),
6965                   p_ucasnum           => g_field_defn.hesa_value(133),
6966                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
6967           THEN
6968               g_default_pro := 'Y';
6969           END IF;
6970 
6971       ELSIF  p_field_number = 161
6972       THEN
6973 
6974           g_default_pro := 'N';
6975 
6976           -- Number of VCE AS Levels
6977           igs_he_extract_fields_pkg.get_qual_dets
6978               (p_person_id            =>  p_person_id,
6979                p_course_cd            =>  p_course_cd,
6980                p_hesa_qual            =>  'VCSEAS',
6981                p_no_of_qual           =>  p_value,
6982                p_tariff_score         =>  g_field_defn.hesa_value(162));
6983 
6984           IF p_value IS NOT NULL THEN
6985             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
6986                                                        p_person_number  => g_pe_person.person_number,
6987                                                        p_course_cd      => p_course_cd,
6988                                                        p_hesa_qual      => 'VCEASN',
6989                                                        p_no_of_qual     => p_value);
6990           ELSE
6991               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
6992               IF g_field_defn.hesa_value.EXISTS(41)  AND
6993                  g_field_defn.hesa_value.EXISTS(26)  AND
6994                  g_field_defn.hesa_value.EXISTS(133) AND
6995                  igs_he_extract_fields_pkg.is_ucas_ftug
6996                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
6997                       p_hesa_commdate     => g_field_defn.hesa_value(26),
6998                       p_ucasnum           => g_field_defn.hesa_value(133),
6999                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7000               THEN
7001                 g_default_pro := 'Y';
7002               END IF;
7003 
7004           END IF;
7005 
7006       ELSIF  p_field_number = 162
7007       THEN
7008 
7009           g_default_pro := 'N';
7010 
7011           -- VCE AS level Tariff Score
7012           IF g_field_defn.hesa_value.EXISTS(162) AND g_field_defn.hesa_value(162) IS NOT NULL
7013           THEN
7014               p_value := g_field_defn.hesa_value(162);
7015               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7016                                                            p_person_number  => g_pe_person.person_number,
7017                                                            p_course_cd      => p_course_cd,
7018                                                            p_hesa_qual      => 'VCEASTS',
7019                                                            p_tariff_score   => p_value);
7020 
7021           END IF;
7022 
7023           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7024           IF p_value IS NULL AND
7025              g_field_defn.hesa_value.EXISTS(41)  AND
7026              g_field_defn.hesa_value.EXISTS(26)  AND
7027              g_field_defn.hesa_value.EXISTS(133) AND
7028              igs_he_extract_fields_pkg.is_ucas_ftug
7029                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7030                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7031                   p_ucasnum           => g_field_defn.hesa_value(133),
7032                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7033           THEN
7034               g_default_pro := 'Y';
7035           END IF;
7036 
7037       ELSIF  p_field_number = 163
7038       THEN
7039 
7040           g_default_pro := 'N';
7041 
7042           -- Number of GCE A Levels
7043           igs_he_extract_fields_pkg.get_qual_dets
7044               (p_person_id            =>  p_person_id,
7045                p_course_cd            =>  p_course_cd,
7046                p_hesa_qual            =>  'GCSEA',
7047                p_no_of_qual           =>  p_value,
7048                p_tariff_score         =>  g_field_defn.hesa_value(164));
7049 
7050           IF p_value IS NOT NULL THEN
7051             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7052                                                        p_person_number  => g_pe_person.person_number,
7053                                                        p_course_cd      => p_course_cd,
7054                                                        p_hesa_qual      => 'GCEAN',
7055                                                        p_no_of_qual     => p_value);
7056           ELSE
7057               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7058               IF g_field_defn.hesa_value.EXISTS(41)  AND
7059                  g_field_defn.hesa_value.EXISTS(26)  AND
7060                  g_field_defn.hesa_value.EXISTS(133) AND
7061                  igs_he_extract_fields_pkg.is_ucas_ftug
7062                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7063                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7064                       p_ucasnum           => g_field_defn.hesa_value(133),
7065                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7066               THEN
7067                 g_default_pro := 'Y';
7068               END IF;
7069 
7070           END IF;
7071 
7072       ELSIF  p_field_number = 164
7073       THEN
7074 
7075           g_default_pro := 'N';
7076 
7077           -- GCE A level Tariff Score
7078           IF g_field_defn.hesa_value.EXISTS(164) AND g_field_defn.hesa_value(164) IS NOT NULL
7079           THEN
7080               p_value := g_field_defn.hesa_value(164);
7081 
7082               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7083                                                            p_person_number  => g_pe_person.person_number,
7084                                                            p_course_cd      => p_course_cd,
7085                                                            p_hesa_qual      => 'GCEATS',
7086                                                            p_tariff_score   => p_value);
7087 
7088           END IF;
7089 
7090           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7091           IF p_value IS NULL AND
7092              g_field_defn.hesa_value.EXISTS(41)  AND
7093              g_field_defn.hesa_value.EXISTS(26)  AND
7094              g_field_defn.hesa_value.EXISTS(133) AND
7095              igs_he_extract_fields_pkg.is_ucas_ftug
7096                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7097                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7098                   p_ucasnum           => g_field_defn.hesa_value(133),
7099                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7100           THEN
7101               g_default_pro := 'Y';
7102           END IF;
7103 
7104       ELSIF  p_field_number = 165
7105       THEN
7106 
7107           g_default_pro := 'N';
7108 
7109           -- Number of VCE A Levels
7110           igs_he_extract_fields_pkg.get_qual_dets
7111               (p_person_id            =>  p_person_id,
7112                p_course_cd            =>  p_course_cd,
7113                p_hesa_qual            =>  'VCSEA',
7114                p_no_of_qual           =>  p_value,
7115                p_tariff_score         =>  g_field_defn.hesa_value(166));
7116 
7117           IF p_value IS NOT NULL THEN
7118             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7119                                                        p_person_number  => g_pe_person.person_number,
7120                                                        p_course_cd      => p_course_cd,
7121                                                        p_hesa_qual      => 'VCEAN',
7122                                                        p_no_of_qual     => p_value);
7123           ELSE
7124               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7125               IF g_field_defn.hesa_value.EXISTS(41)  AND
7126                  g_field_defn.hesa_value.EXISTS(26)  AND
7127                  g_field_defn.hesa_value.EXISTS(133) AND
7128                  igs_he_extract_fields_pkg.is_ucas_ftug
7129                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7130                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7131                       p_ucasnum           => g_field_defn.hesa_value(133),
7132                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7133               THEN
7134                 g_default_pro := 'Y';
7135               END IF;
7136 
7137           END IF;
7138 
7139       ELSIF  p_field_number = 166
7140       THEN
7141 
7142           g_default_pro := 'N';
7143 
7144           -- VCE A level Tariff Score
7145           IF g_field_defn.hesa_value.EXISTS(166) AND g_field_defn.hesa_value(166) IS NOT NULL
7146           THEN
7147               p_value := g_field_defn.hesa_value(166);
7148 
7149               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7150                                                            p_person_number  => g_pe_person.person_number,
7151                                                            p_course_cd      => p_course_cd,
7152                                                            p_hesa_qual      => 'VCEATS',
7153                                                            p_tariff_score   => p_value);
7154 
7155           END IF;
7156 
7157           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7158           IF p_value IS NULL AND
7159              g_field_defn.hesa_value.EXISTS(41)  AND
7160              g_field_defn.hesa_value.EXISTS(26)  AND
7161              g_field_defn.hesa_value.EXISTS(133) AND
7162              igs_he_extract_fields_pkg.is_ucas_ftug
7163                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7164                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7165                   p_ucasnum           => g_field_defn.hesa_value(133),
7166                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7167           THEN
7168               g_default_pro := 'Y';
7169           END IF;
7170 
7171       ELSIF  p_field_number = 167
7172       THEN
7173 
7174           g_default_pro := 'N';
7175 
7176           -- Number of Key Skill Qualifications
7177           igs_he_extract_fields_pkg.get_qual_dets
7178               (p_person_id            =>  p_person_id,
7179                p_course_cd            =>  p_course_cd,
7180                p_hesa_qual            =>  'KEYSKL',
7181                p_no_of_qual           =>  p_value,
7182                p_tariff_score         =>  g_field_defn.hesa_value(168));
7183 
7184           IF p_value IS NOT NULL THEN
7185             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7186                                                        p_person_number  => g_pe_person.person_number,
7187                                                        p_course_cd      => p_course_cd,
7188                                                        p_hesa_qual      => 'KSQN',
7189                                                        p_no_of_qual     => p_value);
7190           ELSE
7191               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7192               IF g_field_defn.hesa_value.EXISTS(41)  AND
7193                  g_field_defn.hesa_value.EXISTS(26)  AND
7194                  g_field_defn.hesa_value.EXISTS(133) AND
7195                  igs_he_extract_fields_pkg.is_ucas_ftug
7196                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7197                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7198                       p_ucasnum           => g_field_defn.hesa_value(133),
7199                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7200               THEN
7201                 g_default_pro := 'Y';
7202               END IF;
7203 
7204           END IF;
7205 
7206       ELSIF  p_field_number = 168
7207       THEN
7208 
7209           g_default_pro := 'N';
7210 
7211           -- Key Skills Tariff Score
7212           IF g_field_defn.hesa_value.EXISTS(168) AND g_field_defn.hesa_value(168) IS NOT NULL
7213           THEN
7214               p_value := g_field_defn.hesa_value(168);
7215 
7216               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7217                                                            p_person_number  => g_pe_person.person_number,
7218                                                            p_course_cd      => p_course_cd,
7219                                                            p_hesa_qual      => 'KSQTS',
7220                                                            p_tariff_score   => p_value);
7221 
7222           END IF;
7223 
7224           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7225           IF p_value IS NULL AND
7226              g_field_defn.hesa_value.EXISTS(41)  AND
7227              g_field_defn.hesa_value.EXISTS(26)  AND
7228              g_field_defn.hesa_value.EXISTS(133) AND
7229              igs_he_extract_fields_pkg.is_ucas_ftug
7230                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7231                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7232                   p_ucasnum           => g_field_defn.hesa_value(133),
7233                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7234           THEN
7235               g_default_pro := 'Y';
7236           END IF;
7237 
7238       ELSIF  p_field_number = 169
7239       THEN
7240 
7241           g_default_pro := 'N';
7242 
7243           -- Number of 1 unit key skill awards
7244           igs_he_extract_fields_pkg.get_qual_dets
7245               (p_person_id            =>  p_person_id,
7246                p_course_cd            =>  p_course_cd,
7247                p_hesa_qual            =>  '1UNKEYSKL',
7248                p_no_of_qual           =>  p_value,
7249                p_tariff_score         =>  g_field_defn.hesa_value(170));
7250 
7251           IF p_value IS NOT NULL THEN
7252             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7253                                                        p_person_number  => g_pe_person.person_number,
7254                                                        p_course_cd      => p_course_cd,
7255                                                        p_hesa_qual      => 'UKSAN',
7256                                                        p_no_of_qual     => p_value);
7257           ELSE
7258               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7259               IF g_field_defn.hesa_value.EXISTS(41)  AND
7260                  g_field_defn.hesa_value.EXISTS(26)  AND
7261                  g_field_defn.hesa_value.EXISTS(133) AND
7262                  igs_he_extract_fields_pkg.is_ucas_ftug
7263                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7264                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7265                       p_ucasnum           => g_field_defn.hesa_value(133),
7266                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7267               THEN
7268                 g_default_pro := 'Y';
7269               END IF;
7270 
7271           END IF;
7272       ELSIF  p_field_number = 170
7273       THEN
7274 
7275           g_default_pro := 'N';
7276 
7277           -- 1 Unit Key Skill Tariff Score
7278           IF g_field_defn.hesa_value.EXISTS(170) AND g_field_defn.hesa_value(170) IS NOT NULL
7279           THEN
7280               p_value := g_field_defn.hesa_value(170);
7281 
7282               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7283                                                            p_person_number  => g_pe_person.person_number,
7284                                                            p_course_cd      => p_course_cd,
7285                                                            p_hesa_qual      => 'UKSATS',
7286                                                            p_tariff_score   => p_value);
7287 
7288           END IF;
7289 
7290           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7291           IF p_value IS NULL AND
7292              g_field_defn.hesa_value.EXISTS(41)  AND
7293              g_field_defn.hesa_value.EXISTS(26)  AND
7294              g_field_defn.hesa_value.EXISTS(133) AND
7295              igs_he_extract_fields_pkg.is_ucas_ftug
7296                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7297                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7298                   p_ucasnum           => g_field_defn.hesa_value(133),
7299                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7300           THEN
7301               g_default_pro := 'Y';
7302           END IF;
7303 
7304       ELSIF  p_field_number = 171
7305       THEN
7306 
7307           g_default_pro := 'N';
7308 
7309           -- Number of Scottish Advanced Higher Levels
7310           igs_he_extract_fields_pkg.get_qual_dets
7311               (p_person_id            =>  p_person_id,
7312                p_course_cd            =>  p_course_cd,
7313                p_hesa_qual            =>  'SCOTADH',
7314                p_no_of_qual           =>  p_value,
7315                p_tariff_score         =>  g_field_defn.hesa_value(172));
7316 
7317           IF p_value IS NOT NULL THEN
7318             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7319                                                        p_person_number  => g_pe_person.person_number,
7320                                                        p_course_cd      => p_course_cd,
7321                                                        p_hesa_qual      => 'SAHN',
7322                                                        p_no_of_qual     => p_value);
7323           ELSE
7324               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7325               IF g_field_defn.hesa_value.EXISTS(41)  AND
7326                  g_field_defn.hesa_value.EXISTS(26)  AND
7327                  g_field_defn.hesa_value.EXISTS(133) AND
7328                  igs_he_extract_fields_pkg.is_ucas_ftug
7329                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7330                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7331                       p_ucasnum           => g_field_defn.hesa_value(133),
7332                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7333               THEN
7334                 g_default_pro := 'Y';
7335               END IF;
7336 
7337           END IF;
7338 
7339 
7340       ELSIF  p_field_number = 172
7341       THEN
7342 
7343           g_default_pro := 'N';
7344 
7345           -- Scottish Advanced Higher level Tariff Score
7346           IF g_field_defn.hesa_value.EXISTS(172) AND g_field_defn.hesa_value(172) IS NOT NULL
7347           THEN
7348               p_value := g_field_defn.hesa_value(172);
7349 
7350               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7351                                                            p_person_number  => g_pe_person.person_number,
7352                                                            p_course_cd      => p_course_cd,
7353                                                            p_hesa_qual      => 'SAHTS',
7354                                                            p_tariff_score   => p_value);
7355 
7356           END IF;
7357 
7358           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7359           IF p_value IS NULL AND
7360              g_field_defn.hesa_value.EXISTS(41)  AND
7361              g_field_defn.hesa_value.EXISTS(26)  AND
7362              g_field_defn.hesa_value.EXISTS(133) AND
7363              igs_he_extract_fields_pkg.is_ucas_ftug
7364                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7365                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7366                   p_ucasnum           => g_field_defn.hesa_value(133),
7367                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7368           THEN
7369               g_default_pro := 'Y';
7370           END IF;
7371 
7372       ELSIF  p_field_number = 173
7373       THEN
7374 
7375           g_default_pro := 'N';
7376 
7377           -- Number of Scottish Higher Levels
7378           igs_he_extract_fields_pkg.get_qual_dets
7379               (p_person_id            =>  p_person_id,
7380                p_course_cd            =>  p_course_cd,
7381                p_hesa_qual            =>  'SCOTH',
7382                p_no_of_qual           =>  p_value,
7383                p_tariff_score         =>  g_field_defn.hesa_value(174));
7384 
7385           IF p_value IS NOT NULL THEN
7386             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7387                                                        p_person_number  => g_pe_person.person_number,
7388                                                        p_course_cd      => p_course_cd,
7389                                                        p_hesa_qual      => 'SHN',
7390                                                        p_no_of_qual     => p_value);
7391           ELSE
7392               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7393               IF g_field_defn.hesa_value.EXISTS(41)  AND
7394                  g_field_defn.hesa_value.EXISTS(26)  AND
7395                  g_field_defn.hesa_value.EXISTS(133) AND
7396                  igs_he_extract_fields_pkg.is_ucas_ftug
7397                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7398                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7399                       p_ucasnum           => g_field_defn.hesa_value(133),
7400                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7401               THEN
7402                 g_default_pro := 'Y';
7403               END IF;
7404 
7405           END IF;
7406 
7407       ELSIF  p_field_number = 174
7408       THEN
7409 
7410           g_default_pro := 'N';
7411 
7412           -- Scottish Higher level Tariff Score
7413           IF g_field_defn.hesa_value.EXISTS(174) AND g_field_defn.hesa_value(174) IS NOT NULL
7414           THEN
7415               p_value := g_field_defn.hesa_value(174);
7416 
7417               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7418                                                            p_person_number  => g_pe_person.person_number,
7419                                                            p_course_cd      => p_course_cd,
7420                                                            p_hesa_qual      => 'SHTS',
7421                                                            p_tariff_score   => p_value);
7422 
7423           END IF;
7424 
7425           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7426           IF p_value IS NULL AND
7427              g_field_defn.hesa_value.EXISTS(41)  AND
7428              g_field_defn.hesa_value.EXISTS(26)  AND
7429              g_field_defn.hesa_value.EXISTS(133) AND
7430              igs_he_extract_fields_pkg.is_ucas_ftug
7431                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7432                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7433                   p_ucasnum           => g_field_defn.hesa_value(133),
7434                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7435           THEN
7436               g_default_pro := 'Y';
7437           END IF;
7438 
7439       ELSIF  p_field_number = 175
7440       THEN
7441 
7442           g_default_pro := 'N';
7443 
7444           -- Number of Scottish Intermediate Levels
7445           igs_he_extract_fields_pkg.get_qual_dets
7446               (p_person_id            =>  p_person_id,
7447                p_course_cd            =>  p_course_cd,
7448                p_hesa_qual            =>  'SCOTI2',
7449                p_no_of_qual           =>  p_value,
7450                p_tariff_score         =>  g_field_defn.hesa_value(176));
7451 
7452           IF p_value IS NOT NULL THEN
7453             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7454                                                        p_person_number  => g_pe_person.person_number,
7455                                                        p_course_cd      => p_course_cd,
7456                                                        p_hesa_qual      => 'SI2N',
7457                                                        p_no_of_qual     => p_value);
7458           ELSE
7459               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7460               IF g_field_defn.hesa_value.EXISTS(41)  AND
7461                  g_field_defn.hesa_value.EXISTS(26)  AND
7462                  g_field_defn.hesa_value.EXISTS(133) AND
7463                  igs_he_extract_fields_pkg.is_ucas_ftug
7464                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7465                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7466                       p_ucasnum           => g_field_defn.hesa_value(133),
7467                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7468               THEN
7469                 g_default_pro := 'Y';
7470               END IF;
7471 
7472           END IF;
7473 
7474       ELSIF  p_field_number = 176
7475       THEN
7476 
7477           g_default_pro := 'N';
7478 
7479           -- Scottish Intermediate level Tariff Score
7480           IF g_field_defn.hesa_value.EXISTS(176) AND g_field_defn.hesa_value(176) IS NOT NULL
7481           THEN
7482               p_value := g_field_defn.hesa_value(176);
7483 
7484               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7485                                                            p_person_number  => g_pe_person.person_number,
7486                                                            p_course_cd      => p_course_cd,
7487                                                            p_hesa_qual      => 'SI2TS',
7488                                                            p_tariff_score   => p_value);
7489 
7490           END IF;
7491 
7492           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7493           IF p_value IS NULL AND
7494              g_field_defn.hesa_value.EXISTS(41)  AND
7495              g_field_defn.hesa_value.EXISTS(26)  AND
7496              g_field_defn.hesa_value.EXISTS(133) AND
7497              igs_he_extract_fields_pkg.is_ucas_ftug
7498                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7499                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7500                   p_ucasnum           => g_field_defn.hesa_value(133),
7501                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7502           THEN
7503               g_default_pro := 'Y';
7504           END IF;
7505 
7506       ELSIF  p_field_number = 177
7507       THEN
7508 
7509           g_default_pro := 'N';
7510 
7511           -- Number of Scottish Standard Grade Credit Levels
7512           igs_he_extract_fields_pkg.get_qual_dets
7513               (p_person_id            =>  p_person_id,
7514                p_course_cd            =>  p_course_cd,
7515                p_hesa_qual            =>  'SCOTST',
7516                p_no_of_qual           =>  p_value,
7517                p_tariff_score         =>  g_field_defn.hesa_value(178));
7518 
7519           IF p_value IS NOT NULL THEN
7520             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7521                                                        p_person_number  => g_pe_person.person_number,
7522                                                        p_course_cd      => p_course_cd,
7523                                                        p_hesa_qual      => 'SSGCN',
7524                                                        p_no_of_qual     => p_value);
7525           ELSE
7526               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7527               IF g_field_defn.hesa_value.EXISTS(41)  AND
7528                  g_field_defn.hesa_value.EXISTS(26)  AND
7529                  g_field_defn.hesa_value.EXISTS(133) AND
7530                  igs_he_extract_fields_pkg.is_ucas_ftug
7531                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7532                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7533                       p_ucasnum           => g_field_defn.hesa_value(133),
7534                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7535               THEN
7536                 g_default_pro := 'Y';
7537               END IF;
7538 
7539           END IF;
7540 
7541 
7542       ELSIF  p_field_number = 178
7543       THEN
7544 
7545           g_default_pro := 'N';
7546 
7547           --  Scottish Standard Grade  level Tariff Score
7548           IF g_field_defn.hesa_value.EXISTS(178) AND g_field_defn.hesa_value(178) IS NOT NULL
7549           THEN
7550               p_value := g_field_defn.hesa_value(178);
7551 
7552               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7553                                                            p_person_number  => g_pe_person.person_number,
7554                                                            p_course_cd      => p_course_cd,
7555                                                            p_hesa_qual      => 'SSGCTS',
7556                                                            p_tariff_score   => p_value);
7557 
7558           END IF;
7559 
7560           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7561           IF p_value IS NULL AND
7562              g_field_defn.hesa_value.EXISTS(41)  AND
7563              g_field_defn.hesa_value.EXISTS(26)  AND
7564              g_field_defn.hesa_value.EXISTS(133) AND
7565              igs_he_extract_fields_pkg.is_ucas_ftug
7566                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7567                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7568                   p_ucasnum           => g_field_defn.hesa_value(133),
7569                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7570           THEN
7571               g_default_pro := 'Y';
7572           END IF;
7573 
7574       ELSIF  p_field_number = 179
7575       THEN
7576 
7577           g_default_pro := 'N';
7578 
7579           -- Number of Scottish Core Skills Levels
7580           igs_he_extract_fields_pkg.get_qual_dets
7581               (p_person_id            =>  p_person_id,
7582                p_course_cd            =>  p_course_cd,
7583                p_hesa_qual            =>  'SCOTCO',
7584                p_no_of_qual           =>  p_value,
7585                p_tariff_score         =>  g_field_defn.hesa_value(180));
7586 
7587           IF p_value IS NOT NULL THEN
7588             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7589                                                        p_person_number  => g_pe_person.person_number,
7590                                                        p_course_cd      => p_course_cd,
7591                                                        p_hesa_qual      => 'SCSN',
7592                                                        p_no_of_qual     => p_value);
7593           ELSE
7594               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7595               IF g_field_defn.hesa_value.EXISTS(41)  AND
7596                  g_field_defn.hesa_value.EXISTS(26)  AND
7597                  g_field_defn.hesa_value.EXISTS(133) AND
7598                  igs_he_extract_fields_pkg.is_ucas_ftug
7599                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7600                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7601                       p_ucasnum           => g_field_defn.hesa_value(133),
7602                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7603               THEN
7604                 g_default_pro := 'Y';
7605               END IF;
7606 
7607           END IF;
7608 
7609       ELSIF  p_field_number = 180
7610       THEN
7611 
7612           g_default_pro := 'N';
7613 
7614           -- Scottish Core Skills level Tariff Score
7615           IF g_field_defn.hesa_value.EXISTS(180) AND g_field_defn.hesa_value(180) IS NOT NULL
7616           THEN
7617               p_value := g_field_defn.hesa_value(180);
7618 
7619               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7620                                                            p_person_number  => g_pe_person.person_number,
7621                                                            p_course_cd      => p_course_cd,
7622                                                            p_hesa_qual      => 'SCSTS',
7623                                                            p_tariff_score   => p_value);
7624 
7625           END IF;
7626 
7627           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7628           IF p_value IS NULL AND
7629              g_field_defn.hesa_value.EXISTS(41)  AND
7630              g_field_defn.hesa_value.EXISTS(26)  AND
7631              g_field_defn.hesa_value.EXISTS(133) AND
7632              igs_he_extract_fields_pkg.is_ucas_ftug
7633                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7634                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7635                   p_ucasnum           => g_field_defn.hesa_value(133),
7636                   p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7637           THEN
7638               g_default_pro := 'Y';
7639           END IF;
7640 
7641       ELSIF  p_field_number = 181
7642       THEN
7643 
7644           g_default_pro := 'N';
7645 
7646           -- Number of Advanced Extension
7647           igs_he_extract_fields_pkg.get_qual_dets
7648               (p_person_id            =>  p_person_id,
7649                p_course_cd            =>  p_course_cd,
7650                p_hesa_qual            =>  'ADVEXT',
7651                p_no_of_qual           =>  p_value,
7652                p_tariff_score         =>  g_field_defn.hesa_value(182));
7653 
7654           IF p_value IS NOT NULL THEN
7655             igs_he_extract_fields_pkg.limit_no_of_qual(p_field_number   => p_field_number,
7656                                                        p_person_number  => g_pe_person.person_number,
7657                                                        p_course_cd      => p_course_cd,
7658                                                        p_hesa_qual      => 'AEAN',
7659                                                        p_no_of_qual     => p_value);
7660           ELSE
7661               -- If is a UCAS (FTUG, NMAS or SWAS) student with no qualification details use default value
7662               IF g_field_defn.hesa_value.EXISTS(41)  AND
7663                  g_field_defn.hesa_value.EXISTS(26)  AND
7664                  g_field_defn.hesa_value.EXISTS(133) AND
7665                  igs_he_extract_fields_pkg.is_ucas_ftug
7666                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7667                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7668                       p_ucasnum           => g_field_defn.hesa_value(133),
7669                       p_min_commdate      => TO_DATE('31/07/2003', 'DD/MM/YYYY'))
7670               THEN
7671                 g_default_pro := 'Y';
7672               END IF;
7673 
7674           END IF;
7675 
7676       ELSIF  p_field_number = 182
7677       THEN
7678 
7679           g_default_pro := 'N';
7680 
7681           -- Advanced Extension Tariff Score
7682           IF g_field_defn.hesa_value.EXISTS(182) AND g_field_defn.hesa_value(182) IS NOT NULL
7683           THEN
7684               p_value := g_field_defn.hesa_value(182);
7685 
7686               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7687                                                            p_person_number  => g_pe_person.person_number,
7688                                                            p_course_cd      => p_course_cd,
7689                                                            p_hesa_qual      => 'AENTS',
7690                                                            p_tariff_score   => p_value);
7691 
7692           END IF;
7693 
7694           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7695           IF p_value IS NULL AND
7696              g_field_defn.hesa_value.EXISTS(41)  AND
7697              g_field_defn.hesa_value.EXISTS(26)  AND
7698              g_field_defn.hesa_value.EXISTS(133) AND
7699              igs_he_extract_fields_pkg.is_ucas_ftug
7700                  (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7701                   p_hesa_commdate     => g_field_defn.hesa_value(26),
7702                   p_ucasnum           => g_field_defn.hesa_value(133),
7703                   p_min_commdate      => TO_DATE('31/07/2003', 'DD/MM/YYYY'))
7704           THEN
7705               g_default_pro := 'Y';
7706           END IF;
7707 
7708       ELSIF  p_field_number = 183
7709       THEN
7710 
7711           g_default_pro := 'N';
7712 
7713           -- Total Tariff Score
7714           p_value :=  g_he_st_spa.total_ucas_tariff;
7715 
7716           -- If is a UCAS (FTUG, NMAS or SWAS) student with no tariff information use default value
7717           IF p_value IS NOT NULL
7718           THEN
7719               igs_he_extract_fields_pkg.limit_tariff_score(p_field_number   => p_field_number,
7720                                                            p_person_number  => g_pe_person.person_number,
7721                                                            p_course_cd      => p_course_cd,
7722                                                            p_hesa_qual      => 'TOTALTS',
7723                                                            p_tariff_score   => p_value);
7724           ELSE
7725               IF g_field_defn.hesa_value.EXISTS(41)  AND
7726                  g_field_defn.hesa_value.EXISTS(26)  AND
7727                  g_field_defn.hesa_value.EXISTS(133) AND
7728                  igs_he_extract_fields_pkg.is_ucas_ftug
7729                      (p_hesa_qual_aim     => g_field_defn.hesa_value(41),
7730                       p_hesa_commdate     => g_field_defn.hesa_value(26),
7731                       p_ucasnum           => g_field_defn.hesa_value(133),
7732                       p_min_commdate      => TO_DATE('31/07/2002', 'DD/MM/YYYY'))
7733               THEN
7734                   g_default_pro := 'Y';
7735               END IF;
7736           END IF;
7737 
7738       ELSIF  p_field_number = 184
7739       THEN
7740           -- Number of CACHE qualifications
7741           igs_he_extract_fields_pkg.get_qual_dets
7742               (p_person_id            =>  p_person_id,
7743                p_course_cd            =>  p_course_cd,
7744                p_hesa_qual            =>  'CACHE',
7745                p_no_of_qual           =>  p_value,
7746                p_tariff_score         =>  g_field_defn.hesa_value(185));
7747 
7748       ELSIF  p_field_number = 185
7749       THEN
7750           -- CACHE qualifications Tariff Score
7751           IF g_field_defn.hesa_value.EXISTS(185)
7752           THEN
7753               p_value := g_field_defn.hesa_value(185);
7754           END IF;
7755 
7756       ELSIF  p_field_number = 186
7757       THEN
7758           -- Number of BTEC
7759           igs_he_extract_fields_pkg.get_qual_dets
7760               (p_person_id            =>  p_person_id,
7761                p_course_cd            =>  p_course_cd,
7762                p_hesa_qual            =>  'BTEC',
7763                p_no_of_qual           =>  p_value,
7764                p_tariff_score         =>  g_field_defn.hesa_value(187));
7765 
7766       ELSIF  p_field_number = 187
7767       THEN
7768           -- BTEC Tariff Score
7769           IF g_field_defn.hesa_value.EXISTS(187)
7770           THEN
7771               p_value := g_field_defn.hesa_value(187);
7772           END IF;
7773 
7774       ELSIF  p_field_number = 188
7775       THEN
7776           -- International Baccalaureate Tariff Score
7777           igs_he_extract_fields_pkg.get_qual_dets
7778               (p_person_id            =>  p_person_id,
7779                p_course_cd            =>  p_course_cd,
7780                p_hesa_qual            =>  'INBA',
7781                p_no_of_qual           =>  l_dummy,
7782                p_tariff_score         =>  p_value);
7783 
7784       ELSIF  p_field_number = 189
7785       THEN
7786           -- Irish Leaving certificate tariff score
7787           igs_he_extract_fields_pkg.get_qual_dets
7788               (p_person_id            =>  p_person_id,
7789                p_course_cd            =>  p_course_cd,
7790                p_hesa_qual            =>  'ILC',
7791                p_no_of_qual           =>  l_dummy,
7792                p_tariff_score         =>  p_value);
7793 
7794       ELSIF  p_field_number = 190
7795       THEN
7796           -- Music, Drama and Performing Arts
7797           igs_he_extract_fields_pkg.get_qual_dets
7798               (p_person_id            =>  p_person_id,
7799                p_course_cd            =>  p_course_cd,
7800                p_hesa_qual            =>  'MUDRPA',
7801                p_no_of_qual           =>  l_dummy,
7802                p_tariff_score         =>  p_value);
7803 
7804       ELSIF  p_field_number = 191
7805       THEN
7806                g_default_pro:= 'N';
7807                IF g_field_defn.hesa_value.EXISTS(6) AND   g_field_defn.hesa_value(6) IN (1,3,4)     THEN
7808                   -- Guided Learning Hours
7809                   p_value := To_char(g_ps_ver.contact_hours,'00000');
7810                   g_default_pro:= 'Y';
7811                END IF;
7812 
7813       ELSIF  p_field_number = 192
7814       THEN
7815           -- Marital Status
7816           igs_he_extract_fields_pkg.get_marital_status
7817               (p_oss_marital_status     =>  g_pe_stat_v.marital_status,
7818                p_hesa_marital_status    =>  p_value);
7819 
7820       ELSIF  p_field_number = 193
7821       THEN
7822           -- Dependants
7823           igs_he_extract_fields_pkg.get_dependants
7824               (p_oss_dependants     =>  g_he_st_spa.dependants_cd,
7825                p_hesa_dependants    =>  p_value);
7826 
7827       ELSIF  p_field_number = 194
7828       THEN
7829         -- Eligibility for enhanced funding
7830         --Set the  default variable value as default value has to be calculated only for the down condition
7831         g_default_pro := 'N';
7832 
7833         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7834 
7835           -- Student must be FE student
7836           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7837 
7838                 igs_he_extract_fields_pkg.get_enh_fund_elig
7839                  (p_susa_enh_fund_elig   => g_he_en_susa.enh_fund_elig_cd,
7840                   p_spa_enh_fund_elig    => g_he_st_spa.enh_fund_elig_cd,
7841                   p_hesa_enh_fund_elig   => p_value);
7842 
7843                 --If the value is calculated as NULL above then do the default processing for this field
7844                 g_default_pro := 'Y' ;
7845           END IF;
7846         END IF;
7847 
7848       ELSIF  p_field_number = 195
7849       THEN
7850         --Additional Support Cost
7851         --Set the  default variable value as default value has to be calculated only for the down condition
7852         g_default_pro := 'N';
7853 
7854         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7855 
7856           -- Student must be FE student
7857           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7858 
7859                 IF (g_he_en_susa.additional_sup_cost IS NOT NULL) THEN
7860                       -- LPad additional_sup_cost to 6 places
7861                       p_value := LPAD(g_he_en_susa.additional_sup_cost, 6,'0');
7862                 END IF;
7863 
7864                 --If the value is calculated as NULL above then do the default processing for this field
7865                 g_default_pro := 'Y' ;
7866           END IF;
7867         END IF;
7868 
7869       ELSIF  p_field_number = 196
7870       THEN
7871         -- Learning Difficulty
7872         --Set the  default variable value as default value has to be calculated only for the down condition
7873         g_default_pro := 'N';
7874 
7875         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7876 
7877           -- Student must be FE student
7878           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7879 
7880                 igs_he_extract_fields_pkg.get_learn_dif
7881                  (p_person_id            =>  p_person_id,
7882                   p_enrl_start_dt        =>  g_he_submsn_header.enrolment_start_date,
7883                   p_enrl_end_dt          =>  g_he_submsn_header.enrolment_end_date,
7884                   p_hesa_disability_type =>  p_value);
7885 
7886                 --If the value is calculated as NULL above then do the default processing for this field
7887                 g_default_pro := 'Y' ;
7888           END IF;
7889         END IF;
7890 
7891       ELSIF  p_field_number = 197
7892       THEN
7893         --Implied rate of council partial funding
7894         --Set the  default variable value as default value has to be calculated only for the down condition
7895         g_default_pro := 'N';
7896 
7897         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7898 
7899           -- Student must be FE student
7900           -- AND ESF funded
7901           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4))
7902              AND (g_field_defn.hesa_value.EXISTS(64)  AND g_field_defn.hesa_value(64) IN ('86','87','88','AA','AB','AC','AD'))
7903           THEN
7904 
7905                 p_value := NVL(g_he_st_spa.implied_fund_rate,g_he_st_prog.implied_fund_rate);
7906 
7907                 IF (p_value IS NOT NULL) THEN
7908                       p_value := LPAD(p_value, 3,'0');
7909                 END IF;
7910 
7911                 --If the value is calculated as NULL above then do the default processing for this field
7912                 g_default_pro := 'Y' ;
7913           END IF;
7914         END IF;
7915 
7916 
7917       ELSIF  p_field_number = 198
7918       THEN
7919         --Government initiatives
7920         --Set the  default variable value as default value has to be calculated only for the down condition
7921         g_default_pro := 'N';
7922 
7923         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7924 
7925           -- Student must be FE student
7926           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7927 
7928                 igs_he_extract_fields_pkg.get_gov_init
7929                  (p_spa_gov_initiatives_cd   => g_he_st_spa.gov_initiatives_cd,
7930                   p_prog_gov_initiatives_cd  => g_he_st_prog.gov_initiatives_cd,
7931                   p_hesa_gov_initiatives_cd  => p_value);
7932 
7933                 --If the value is calculated as NULL above then do the default processing for this field
7934                 g_default_pro := 'Y' ;
7935           END IF;
7936         END IF;
7937 
7938       ELSIF  p_field_number = 199
7939       THEN
7940         -- Number of units completed
7941         --Set the  default variable value as default value has to be calculated only for the down condition
7942         g_default_pro := 'N';
7943 
7944         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7945 
7946           -- Student must be FE student
7947           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7948 
7949                 igs_he_extract_fields_pkg.get_units_completed
7950                  (p_person_id                => p_person_id,
7951                   p_course_cd                => p_course_cd,
7952                   p_enrl_end_dt              => g_he_submsn_header.enrolment_end_date,
7953                   p_spa_units_completed      => g_he_st_spa.units_completed,
7954                   p_hesa_units_completed     => p_value);
7955 
7956                 IF (p_value IS NOT NULL) THEN
7957                       p_value := LPAD(p_value, 2,'0');
7958                 END IF;
7959 
7960                 --If the value is calculated as NULL above then do the default processing for this field
7961                 g_default_pro := 'Y' ;
7962           END IF;
7963         END IF;
7964 
7965         ELSIF  p_field_number = 200
7966         THEN
7967          --Number of units to achieve full qualification
7968           --Set the  default variable value as default value has to be calculated only for the down condition
7969           g_default_pro := 'N';
7970 
7971           IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7972 
7973             -- Student must be FE student
7974             IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7975 
7976                   p_value := NVL(g_he_st_spa.units_for_qual,g_he_st_prog.units_for_qual);
7977 
7978                   IF (p_value IS NOT NULL) THEN
7979                         p_value := LPAD(p_value, 2,'0');
7980                   END IF;
7981 
7982                   --If the value is calculated as NULL above then do the default processing for this field
7983                   g_default_pro := 'Y' ;
7984             END IF;
7985          END IF;
7986 
7987       ELSIF  p_field_number = 201
7988       THEN
7989         --Eligibility for disadvantage uplift
7990         --Set the  default variable value as default value has to be calculated only for the down condition
7991         g_default_pro := 'N';
7992 
7993         IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
7994 
7995           -- Student must be FE student
7996           IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
7997 
7998                 igs_he_extract_fields_pkg.get_disadv_uplift_elig
7999                  (p_spa_disadv_uplift_elig_cd   => g_he_st_spa.disadv_uplift_elig_cd,
8000                   p_prog_disadv_uplift_elig_cd  => g_he_st_prog.disadv_uplift_elig_cd,
8001                   p_hesa_disadv_uplift_elig_cd  => p_value);
8002 
8003                 --If the value is calculated as NULL above then do the default processing for this field
8004                 g_default_pro := 'Y' ;
8005           END IF;
8006         END IF;
8007 
8008        ELSIF  p_field_number = 202
8009        THEN
8010          --Disadvantage uplift factor
8011          --Set the  default variable value as default value has to be calculated only for the down condition
8012          g_default_pro := 'N';
8013 
8014          IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
8015 
8016            -- Student must be FE student
8017            IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
8018 
8019                  l_disadv_uplift_factor := NVL(g_he_en_susa.disadv_uplift_factor,g_he_st_spa.disadv_uplift_factor) ;
8020 
8021                  IF (l_disadv_uplift_factor IS NOT NULL) THEN
8022                        p_value := Ltrim(To_Char(l_disadv_uplift_factor,'0.0000'));
8023                  END IF;
8024 
8025                  --If the value is calculated as NULL above then do the default processing for this field
8026                  g_default_pro := 'Y' ;
8027            END IF;
8028         END IF;
8029 
8030        ELSIF  p_field_number = 203
8031        THEN
8032          --Franchised out arrangements
8033          --Set the  default variable value as default value has to be calculated only for the down condition
8034          g_default_pro := 'N';
8035 
8036          IF g_he_submsn_header.validation_country IN   ('ENGLAND') THEN
8037 
8038            -- Student must be FE student
8039            IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
8040 
8041                  igs_he_extract_fields_pkg.get_franch_out_arr
8042                   (p_spa_franch_out_arr_cd   => g_he_st_spa.franch_out_arr_cd,
8043                    p_prog_franch_out_arr_cd  => g_he_st_prog.franch_out_arr_cd,
8044                    p_hesa_franch_out_arr_cd  => p_value);
8045 
8046                  --If the value is calculated as NULL above then do the default processing for this field
8047                  g_default_pro := 'Y' ;
8048            END IF;
8049         END IF;
8050 
8051        ELSIF  p_field_number = 204
8052        THEN
8053          --Employer role
8054          --Set the  default variable value as default value has to be calculated only for the down condition
8055          g_default_pro := 'N';
8056 
8057          IF g_he_submsn_header.validation_country IN   ('ENGLAND','WALES') THEN
8058 
8059            -- Student must be FE student
8060            IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
8061 
8062                  igs_he_extract_fields_pkg.get_employer_role
8063                   (p_spa_employer_role_cd   => g_he_st_spa.employer_role_cd,
8064                    p_hesa_employer_role_cd  => p_value);
8065 
8066                  --If the value is calculated as NULL above then do the default processing for this field
8067                  g_default_pro := 'Y' ;
8068            END IF;
8069         END IF;
8070 
8071        ELSIF  p_field_number = 205
8072        THEN
8073          --Franchise partner code
8074          --Set the  default variable value as default value has to be calculated only for the down condition
8075          g_default_pro := 'N';
8076 
8077          IF g_he_submsn_header.validation_country IN   ('WALES') THEN
8078 
8079            -- Student must be FE student
8080            IF (g_field_defn.hesa_value.EXISTS(6)  AND g_field_defn.hesa_value(6) IN (1,3,4)) THEN
8081 
8082                  igs_he_extract_fields_pkg.get_franchise_partner
8083                   (p_spa_franch_partner_cd    => g_he_st_spa.franch_partner_cd,
8084                    p_hesa_franch_partner_cd   => p_value);
8085 
8086                  --If the value is calculated as NULL above then do the default processing for this field
8087                  g_default_pro := 'Y' ;
8088            END IF;
8089         END IF;
8090 
8091        ELSIF  p_field_number = 206
8092        THEN
8093          -- Welsh speaker identifier
8094          --Set the  default variable value as default value has to be calculated only for the down condition
8095          g_default_pro := 'N';
8096 
8097          IF g_he_submsn_header.validation_country IN   ('WALES') THEN
8098 
8099            -- Student must be FE student
8100            IF (g_field_defn.hesa_value.EXISTS(12)  AND g_field_defn.hesa_value(12) IN (6826)) THEN
8101 
8102                  igs_he_extract_fields_pkg.get_welsh_speaker_ind
8103                   (p_person_id                => p_person_id,
8104                    p_hesa_welsh_speaker_ind   => p_value);
8105 
8106                  --If the value is calculated as NULL above then do the default processing for this field
8107                  g_default_pro := 'Y' ;
8108            END IF;
8109         END IF;
8110 
8111        ELSIF  p_field_number = 207
8112        THEN
8113          -- National ID 1
8114          --Set the  default variable value as default value has to be calculated only for the down condition
8115          g_default_pro := 'N';
8116 
8117          IF g_he_submsn_header.validation_country IN   ('WALES') THEN
8118 
8119            -- Student must be FE student
8120            IF (g_field_defn.hesa_value.EXISTS(12)  AND g_field_defn.hesa_value(12) IN (6826)) THEN
8121 
8122                  igs_he_extract_fields_pkg.get_national_id
8123                   (p_person_id                => p_person_id,
8124                    p_hesa_national_id1        => p_value,
8125                    p_hesa_national_id2        => g_field_defn.hesa_value(208) );
8126 
8127                   --If the value is calculated as NULL above then do the default processing for this field
8128                  g_default_pro := 'Y' ;
8129            END IF;
8130          END IF;
8131 
8132         ELSIF  p_field_number = 208
8133         THEN
8134 
8135           -- National ID 2
8136           IF g_field_defn.hesa_value.EXISTS(208)
8137           THEN
8138               p_value :=  g_field_defn.hesa_value(208);
8139           ELSE
8140 
8141              --Set the  default variable value as default value has to be calculated only for the down condition
8142              g_default_pro := 'N';
8143 
8144              IF g_he_submsn_header.validation_country IN   ('WALES') THEN
8145 
8146                -- Student must be FE student
8147                IF (g_field_defn.hesa_value.EXISTS(12)  AND g_field_defn.hesa_value(12) IN (6826)) THEN
8148 
8149                      igs_he_extract_fields_pkg.get_national_id
8150                       (p_person_id                => p_person_id,
8151                        p_hesa_national_id1        => g_field_defn.hesa_value(207),
8152                        p_hesa_national_id2        => p_value);
8153 
8154                      --If the value is calculated as NULL above then do the default processing for this field
8155                      g_default_pro := 'Y' ;
8156                END IF;
8157             END IF;
8158          END IF;
8159 
8160         -- anwest 19-Dec-2005 (4731723) HE360 - HESA REQUIREMENTS FOR 2005/06 REPORTING
8161         ELSIF  p_field_number = 209 THEN
8162 
8163           IF p_value IS NULL THEN
8164 
8165             IF g_field_defn.hesa_value.EXISTS(12) AND
8166                g_field_defn.hesa_value(12) IN ('6826') THEN
8167 
8168               igs_he_extract_fields_pkg.get_welsh_bacc_qual(p_person_id  => p_person_id,
8169                                                             p_welsh_bacc => p_value);
8170 
8171               IF p_value = '3' THEN
8172 
8173                 IF g_he_submsn_header.validation_country = 'WALES' AND
8174                    g_en_stdnt_ps_att.commencement_dt > TO_DATE('31/07/2005', 'DD/MM/YYYY') AND
8175                    g_field_defn.hesa_value.EXISTS(41) AND
8176                    ((g_field_defn.hesa_value(41) >= 18 AND g_field_defn.hesa_value(41) <= 52) OR
8177                      g_field_defn.hesa_value(41) IN ('61', '97')) THEN
8178 
8179                   null; -- Leave field value as '3'
8180 
8181                 ELSE
8182 
8183                   p_value := NULL;
8184 
8185                 END IF;
8186 
8187               END IF;
8188 
8189             ELSE
8190 
8191               g_default_pro := 'N';
8192               p_value := NULL;
8193 
8194             END IF;
8195 
8196           END IF;
8197 
8198         END IF; -- for each field from 1 to 209
8199 
8200       EXCEPTION
8201       WHEN OTHERS
8202       THEN
8203           write_to_log(SQLERRM);
8204           fnd_message.set_name('IGS','IGS_HE_FIELD_NUM');
8205           fnd_message.set_token('field_number',p_field_number);
8206           IGS_GE_MSG_STACK.ADD;
8207           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
8208           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_stdnt_fields');
8209           IGS_GE_MSG_STACK.ADD;
8210           App_Exception.Raise_Exception;
8211 
8212    END process_stdnt_fields;
8213 
8214    /*----------------------------------------------------------------------
8215    This procedure gets values for the individual fields to be
8216    submitted in the HESA MODULE Return
8217 
8218    Parameters :
8219    p_unit_cd                Unit Code
8220    p_uv_version_number      Unit Code Version Number
8221    p_field_number           Field Number currently being processed.
8222    p_value                  Calculated Value of the field.
8223    ----------------------------------------------------------------------*/
8224    PROCEDURE process_module_fields
8225              (p_unit_cd             IN igs_he_ex_rn_dat_ln.unit_cd%TYPE,
8226               p_uv_version_number   IN igs_he_ex_rn_dat_ln.uv_version_number%TYPE,
8227               p_field_number        IN igs_he_ex_rn_dat_fd.field_number%TYPE,
8228               p_value               IN OUT NOCOPY igs_he_ex_rn_dat_fd.value%TYPE)
8229    IS
8230  /***************************************************************
8231    Created By           :
8232    Date Created By      :
8233    Purpose              :This procedure gets the value for the module related fields
8234    Known Limitations,Enhancements or Remarks:
8235    Change History       :
8236    Who                  When                  What
8237    Bayadav  26-Mar-2002 Changed the logic for field number 3 as a part of HECR001 (Bug number 2278825)
8238    Bayadav  26-Mar-2002 Changed the logic for field number 13 and 16 as a part of HECR004(Bug number 2278825)
8239    smaddali 17-dec-03   for field 3 ,removed the code getting campusid from igs_en_stdnt_ps_att.location_cd for bug#3216400  |
8240    jbaber   20-Sep-04   Modified as per HEFD350 - Statutory changes for 2004/05 Reporting
8241                         Modified fields: 12
8242                         Created fields:  21-26
8243  ***************************************************************/
8244    l_message               VARCHAR2(2000);
8245    l_fte_prop    igs_he_st_unt_vs.proportion_of_fte%TYPE  ;
8246    l_prop_not_taught  NUMBER ;
8247 
8248    BEGIN
8249 
8250       p_value := NULL;
8251       l_fte_prop := NULL;
8252       l_prop_not_taught := NULL;
8253 
8254       IF      p_field_number = 1
8255       THEN
8256           -- Record Type Identifier
8257           p_value := g_he_submsn_return.record_id;
8258 
8259       ELSIF  p_field_number = 2
8260       THEN
8261           -- Hesa Institution Id
8262           igs_he_extract_fields_pkg.get_hesa_inst_id
8263               (p_hesa_inst_id => p_value);
8264 
8265       ELSIF  p_field_number = 3
8266       THEN
8267 
8268    -- Included the below logic as a part of HECR001(Bug 2278825)
8269     --Check if location is recroded at unit level .If yes then get the cooressponding HESA mapped campus id
8270       IF g_he_st_unt_vs.location_cd IS NOT NULL THEN
8271          igs_he_extract_fields_pkg.get_campus_id
8272                          (p_location_cd => g_he_st_unt_vs.location_cd,
8273                           p_campus_id   => p_value);
8274          -- smaddali removed the code getting campusid from igs_en_stdnt_ps_att.location_cd for bug#3216400
8275          -- because student is not related to module return
8276       END IF;
8277 
8278       ELSIF  p_field_number = 4
8279       THEN
8280           -- Module Title
8281           p_value := g_ps_unit_ver_v.title;
8282 
8283       ELSIF  p_field_number = 5
8284       THEN
8285           -- Module Identifier
8286           p_value := p_unit_cd || '.' ||
8287                      p_uv_version_number;
8288 
8289       ELSIF  p_field_number = 6
8290       THEN
8291           -- Proportion of FTE
8292            --smaddali adding format mask '000.0' for bug 2437081
8293           IF g_he_st_unt_vs.proportion_of_fte IS NOT NULL
8294           THEN
8295               p_value := Ltrim(To_Char(g_he_st_unt_vs.proportion_of_fte,'000.0') );
8296           ELSE
8297               igs_he_extract_fields_pkg.get_mod_prop_fte
8298                   (p_enrolled_credit_points   =>  g_ps_unit_ver_v.enrolled_credit_points,
8299                    p_unit_level               =>  g_ps_unit_ver_v.unit_level,
8300                    p_prop_of_fte              =>  l_fte_prop);
8301                --smaddali adding format mask '000.0' for bug 2437081
8302                p_value := Ltrim( To_char(l_fte_prop,'000.0') );
8303 
8304           END IF;
8305 
8306 
8307       ELSIF  p_field_number = 7
8308       THEN
8309           -- Proportion not taught by this institution
8310           igs_he_extract_fields_pkg.get_mod_prop_not_taught
8311               (p_unit_cd            =>  p_unit_cd,
8312                p_version_number     =>  p_uv_version_number,
8313                p_prop_not_taught    =>  l_prop_not_taught);
8314            --smaddali adding format mask '000.0' for bug 2437081
8315            p_value := ltrim(to_char(l_prop_not_taught,'000.0' )) ;
8316 
8317       ELSIF  p_field_number = 8
8318       THEN
8319           -- Credit Transfer Scheme
8320           igs_he_extract_fields_pkg.get_credit_trans_sch
8321           (p_oss_credit_trans_sch   =>  g_he_st_unt_vs.credit_transfer_scheme,
8322            p_hesa_credit_trans_sch  =>  p_value);
8323 
8324       ELSIF  p_field_number = 9
8325       THEN
8326           -- Credit Value of Module
8327            --smaddali adding format mask '000' for bug 2437081
8328           p_value := Ltrim( to_char(g_ps_unit_ver_v.enrolled_credit_points,'000') );
8329 
8330       ELSIF  p_field_number = 10
8331       THEN
8332           -- Level of Credit Points
8333           IF g_field_defn.hesa_value.EXISTS(9)
8334           THEN
8335               IF  g_field_defn.hesa_value(9) <> '999'
8336               THEN
8337                   igs_he_extract_fields_pkg.get_credit_level
8338                      (p_susa_credit_level    => NULL ,
8339                       p_poous_credit_level     =>  g_ps_unit_ver_v.unit_level,
8340                       p_hesa_credit_level    =>  p_value);
8341               END IF;
8342           END IF;
8343 
8344       ELSIF  p_field_number = 11
8345       THEN
8346           -- Module length
8347           p_value := g_he_st_unt_vs.module_length;
8348 
8349       ELSIF  p_field_number = 12
8350       THEN
8351           -- Cost Centre 1
8352           --smaddali added the initialisation of variable g_cc_rec for bug 2417370
8353           --jbaber added p_validation_country for HEFD350
8354           g_cc_rec := NULL ;
8355           g_total_ccs := 0;
8356           igs_he_extract_fields_pkg.get_cost_centres
8357           (p_person_id           =>  NULL,
8358            p_course_cd           =>  NULL,
8359            p_version_number      =>  NULL,
8360            p_unit_set_cd         =>  NULL,
8361            p_us_version_number   =>  NULL,
8362            p_cal_type            =>  NULL,
8363            p_attendance_mode     =>  NULL,
8364            p_attendance_type     =>  NULL,
8365            p_location_cd         =>  NULL,
8366            p_program_calc        =>  NULL,
8367            p_unit_cd             =>  p_unit_cd,
8368            p_uv_version_number   =>  p_uv_version_number,
8369            p_return_type         =>  'M',
8370            p_cost_ctr_rec        =>  g_cc_rec,
8371            p_total_recs          =>  g_total_ccs,
8372            p_enrl_start_dt       => NULL,
8373            p_enrl_end_dt         => NULL,
8374            p_sequence_number     => NULL,
8375            p_validation_country  =>  g_he_submsn_header.validation_country);
8376 
8377 
8378            IF g_total_ccs >= 1
8379            THEN
8380                p_value := g_cc_rec.cost_centre(1);
8381            END IF;
8382 
8383 
8384       ELSIF  p_field_number = 13
8385       THEN
8386           -- Subject 1
8387           IF g_total_ccs >= 1
8388           THEN
8389               -- smaddali removed the corsor getting govt field of study for bug 2417454
8390                     p_value := g_cc_rec.subject(1) ;
8391           END IF;
8392 
8393       ELSIF  p_field_number = 14
8394       THEN
8395           -- Proportion 1
8396           IF g_total_ccs >= 1
8397           THEN
8398               --smaddali added format mask '000.0' to this field for bug 2437279
8399               p_value := Ltrim(To_Char(g_cc_rec.proportion(1),'000.0') );
8400           END IF;
8401 
8402 
8403       ELSIF  p_field_number = 15
8404       THEN
8405           -- Cost centre 2
8406           IF g_total_ccs >= 2
8407           THEN
8408               p_value := g_cc_rec.cost_centre(2);
8409           END IF;
8410 
8411       ELSIF  p_field_number = 16
8412       THEN
8413           -- Subject 2
8414           IF g_total_ccs >= 2
8415           THEN
8416               -- smaddali removed the corsor getting govt field of study for bug 2417454
8417                    p_value := g_cc_rec.subject(2);
8418           END IF;
8419 
8420       ELSIF  p_field_number = 17
8421       THEN
8422           -- Proportion 2
8423           --smaddali added format mask '000.0' to this field for bug 2437279
8424           IF g_total_ccs >= 2
8425           THEN
8426               p_value := Ltrim(To_Char(g_cc_rec.proportion(2),'000.0') );
8427           END IF;
8428 
8429       ELSIF  p_field_number = 18
8430       THEN
8431           -- Not Used
8432           p_value := NULL;
8433 
8434       ELSIF  p_field_number = 19
8435       THEN
8436           -- Other Institution Providing teaching 1
8437           igs_he_extract_fields_pkg.get_mod_oth_teach_inst
8438               (p_unit_cd             =>  p_unit_cd,
8439                p_version_number      =>  p_uv_version_number,
8440                p_oth_teach_inst      =>  p_value);
8441 
8442       ELSIF  p_field_number = 20
8443       THEN
8444           -- Not Used
8445           p_value := NULL;
8446 
8447       -- jbaber - HEFD350 - Added fields 21-26
8448       ELSIF  p_field_number = 21
8449       THEN
8450 
8451           -- Value or default only used if validation country is Scotland for bug 4242260
8452           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8453 
8454               g_default_pro := 'Y';
8455 
8456           -- Cost centre 3
8457           IF g_total_ccs >= 3
8458           THEN
8459               p_value := g_cc_rec.cost_centre(3);
8460           END IF;
8461 
8462           ELSE
8463               p_value := NULL;
8464               g_default_pro := 'N';
8465           END IF;
8466 
8467 
8468       ELSIF  p_field_number = 22
8469       THEN
8470 
8471           -- Value or default only used if validation country is Scotland for bug 4242260
8472           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8473 
8474               g_default_pro := 'Y';
8475 
8476           -- Subject 3
8477           IF g_total_ccs >= 3
8478           THEN
8479               -- smaddali removed the corsor getting govt field of study for bug 2417454
8480                    p_value := g_cc_rec.subject(3);
8481           END IF;
8482 
8483           ELSE
8484               p_value := NULL;
8485               g_default_pro := 'N';
8486           END IF;
8487 
8488       ELSIF  p_field_number = 23
8489       THEN
8490 
8491           -- Value or default only used if validation country is Scotland for bug 4242260
8492           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8493 
8494               g_default_pro := 'Y';
8495 
8496           -- Proportion 3
8497           --smaddali added format mask '000.0' to this field for bug 2437279
8498           IF g_total_ccs >= 3
8499           THEN
8500               p_value := Ltrim(To_Char(g_cc_rec.proportion(3),'000.0') );
8501           END IF;
8502 
8503           ELSE
8504               p_value := NULL;
8505               g_default_pro := 'N';
8506           END IF;
8507 
8508       ELSIF  p_field_number = 24
8509       THEN
8510 
8511           -- Value or default only used if validation country is Scotland for bug 4242260
8512           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8513 
8514               g_default_pro := 'Y';
8515 
8516           -- Cost centre 4
8517           IF g_total_ccs >= 4
8518           THEN
8519               p_value := g_cc_rec.cost_centre(4);
8520           END IF;
8521 
8522           ELSE
8523               p_value := NULL;
8524               g_default_pro := 'N';
8525           END IF;
8526 
8527       ELSIF  p_field_number = 25
8528       THEN
8529 
8530           -- Value or default only used if validation country is Scotland for bug 4242260
8531           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8532 
8533               g_default_pro := 'Y';
8534 
8535           -- Subject 4
8536           IF g_total_ccs >= 4
8537           THEN
8538               -- smaddali removed the corsor getting govt field of study for bug 2417454
8539                    p_value := g_cc_rec.subject(4);
8540           END IF;
8541 
8542           ELSE
8543               p_value := NULL;
8544               g_default_pro := 'N';
8545           END IF;
8546 
8547       ELSIF  p_field_number = 26
8548       THEN
8549 
8550           -- Value or default only used if validation country is Scotland for bug 4242260
8551           IF g_he_submsn_header.validation_country IN   ('SCOTLAND') THEN
8552 
8553               g_default_pro := 'Y';
8554 
8555           -- Proportion 4
8556           --smaddali added format mask '000.0' to this field for bug 2437279
8557           IF g_total_ccs >= 4
8558           THEN
8559               p_value := Ltrim(To_Char(g_cc_rec.proportion(4),'000.0') );
8560           END IF;
8561 
8562           ELSE
8563               p_value := NULL;
8564               g_default_pro := 'N';
8565           END IF;
8566 
8567       END IF ; -- p_field_number
8568 
8569       EXCEPTION
8570       WHEN OTHERS
8571       THEN
8572           write_to_log(SQLERRM);
8573           fnd_message.set_name('IGS','IGS_HE_FIELD_NUM');
8574           fnd_message.set_token('field_number',p_field_number);
8575           IGS_GE_MSG_STACK.ADD;
8576 
8577           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
8578           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_module_fields');
8579           IGS_GE_MSG_STACK.ADD;
8580           App_Exception.Raise_Exception;
8581    END process_module_fields;
8582 
8583 
8584 
8585 
8586    /*----------------------------------------------------------------------
8587    This procedure gets values for the individual fields to be
8588    submitted in the HESA DLHE returns
8589 
8590    Parameters :
8591    p_person_id              Person_id for the student
8592    p_field_number           Field Number currently being processed.
8593    p_value                  Calculated Value of the field.
8594 
8595    ----------------------------------------------------------------------*/
8596    PROCEDURE process_dlhe_fields
8597              (p_person_id           IN  igs_he_ex_rn_dat_ln.person_id%TYPE,
8598               p_field_number        IN   NUMBER,
8599               p_value               IN OUT NOCOPY   igs_he_ex_rn_dat_fd.value%TYPE)
8600 
8601    IS
8602    /***************************************************************
8603    Created By           :       smaddali
8604    Date Created By      :       9-apr-03
8605    Purpose              :This procedure gets the value of DLHE related fields
8606    Known Limitations,Enhancements or Remarks:
8607    Change History       :
8608    Who        When          What
8609    smaddali   23-sep-03    Modified fields 14 and 37 to 46 for HECR011 build, bug#3051597
8610  ***************************************************************/
8611 
8612            l_inst_id          igs_or_institution.govt_institution_cd%TYPE;
8613 
8614    BEGIN
8615 
8616       p_value           := NULL;
8617       g_default_pro     := 'Y';
8618 
8619       -- depending on the field number call the respective procedure to derive its value
8620       IF      p_field_number = 1
8621       THEN
8622           -- Record Type Identifier
8623           p_value := g_he_submsn_return.record_id;
8624 
8625       ELSIF  p_field_number = 2
8626       THEN
8627           -- Hesa Institution Id
8628           igs_he_extract_fields_pkg.get_hesa_inst_id
8629               (p_hesa_inst_id => p_value);
8630 
8631       ELSIF  p_field_number = 3
8632       THEN
8633           -- Student Identifier
8634           -- Pass in the Institution Id
8635           IF g_field_defn.hesa_value.EXISTS(2)
8636           THEN
8637               l_inst_id := g_field_defn.hesa_value(2);
8638           ELSE
8639               l_inst_id := 0;
8640           END IF;
8641 
8642         -- smaddali 11-dec-03   Modified for bug#3235753 , added 2 new parameters
8643           igs_he_extract_fields_pkg.get_stdnt_id
8644               (p_person_id              => p_person_id,
8645                p_inst_id                => l_inst_id,
8646                p_stdnt_id               => p_value,
8647                p_enrl_start_dt          =>  g_he_submsn_header.enrolment_start_date,
8648                p_enrl_end_dt            =>  g_he_submsn_header.enrolment_end_date);
8649 
8650 
8651       ELSIF  p_field_number = 4
8652       THEN
8653           -- Method of data collection
8654           igs_he_extract_dlhe_fields_pkg.get_survey_method
8655                  (p_dlhe_method    => g_he_stdnt_dlhe.survey_method,
8656                   p_hesa_method    => p_value);
8657           l_hesa_method := p_value ;
8658 
8659       ELSIF  p_field_number = 5
8660       THEN
8661           -- Employment circumstances
8662           igs_he_extract_dlhe_fields_pkg.get_empcir
8663                  (p_hesa_method     => l_hesa_method,
8664                   p_dlhe_employment => g_he_stdnt_dlhe.Employment,
8665                   p_hesa_empcir     => p_value);
8666           l_hesa_empcir := p_value ;
8667 
8668       ELSIF  p_field_number = 6
8669       THEN
8670           -- Mode of Study
8671           igs_he_extract_dlhe_fields_pkg.get_mode_study
8672                  (p_hesa_method        => l_hesa_method,
8673                   p_dlhe_further_study => g_he_stdnt_dlhe.Further_study,
8674                   p_hesa_modstudy      => p_value);
8675           l_hesa_modstudy := p_value ;
8676 
8677       ELSIF  p_field_number = 7
8678       THEN
8679           -- Nature of employers business
8680           igs_he_extract_dlhe_fields_pkg.get_makedo
8681                  (p_hesa_method       => l_hesa_method,
8682                   p_hesa_empcir       => l_hesa_empcir,
8683                   p_dlhe_Emp_business => g_he_stdnt_dlhe.Employer_business,
8684                   p_hesa_makedo       => p_value);
8685 
8686       ELSIF  p_field_number = 8
8687       THEN
8688           -- Standard Industrial Classification
8689           igs_he_extract_dlhe_fields_pkg.get_sic
8690                  (p_hesa_method    => l_hesa_method,
8691                   p_hesa_empcir    => l_hesa_empcir,
8692                   p_dlhe_Emp_class => g_he_stdnt_dlhe.Employer_classification,
8693                   p_hesa_sic       => p_value);
8694 
8695 
8696       ELSIF  p_field_number = 9
8697       THEN
8698           -- Location of employment
8699           igs_he_extract_dlhe_fields_pkg.get_emp_loc
8700                  (p_hesa_method       => l_hesa_method,
8701                   p_hesa_empcir       => l_hesa_empcir,
8702                   p_dlhe_Emp_postcode => g_he_stdnt_dlhe.Employer_postcode,
8703                   p_dlhe_emp_country  => g_he_stdnt_dlhe.Employer_country,
8704                   p_hesa_locemp       => p_value);
8705 
8706       ELSIF  p_field_number = 10
8707       THEN
8708           -- Job title
8709           igs_he_extract_dlhe_fields_pkg.get_job_title
8710                  (p_hesa_method    => l_hesa_method,
8711                   p_hesa_empcir    => l_hesa_empcir,
8712                   p_dlhe_jobtitle  => g_he_stdnt_dlhe.Job_title,
8713                   p_hesa_jobtitle  => p_value);
8714 
8715       ELSIF  p_field_number = 11
8716       THEN
8717           -- Standard Occupational Classification
8718           igs_he_extract_dlhe_fields_pkg.get_occ_class
8719                  (p_hesa_method    => l_hesa_method,
8720                   p_hesa_empcir    => l_hesa_empcir,
8721                   p_dlhe_job_class => g_he_stdnt_dlhe.Job_classification,
8722                   p_hesa_soc       => p_value);
8723 
8724       ELSIF  p_field_number = 12
8725       THEN
8726           -- Employer size
8727           igs_he_extract_dlhe_fields_pkg.get_emp_size
8728                  (p_hesa_method    => l_hesa_method,
8729                   p_hesa_empcir    => l_hesa_empcir,
8730                   p_dlhe_emp_size  => g_he_stdnt_dlhe.Employer_size,
8731                   p_hesa_empsize   => p_value);
8732 
8733       ELSIF  p_field_number = 13
8734       THEN
8735           -- Duration of employment
8736           igs_he_extract_dlhe_fields_pkg.get_emp_duration
8737                  (p_hesa_method       => l_hesa_method,
8738                   p_hesa_empcir       => l_hesa_empcir,
8739                   p_dlhe_emp_duration => g_he_stdnt_dlhe.Job_duration,
8740                   p_hesa_duration     => p_value);
8741 
8742       ELSIF  p_field_number = 14
8743       THEN
8744           -- Salary
8745           igs_he_extract_dlhe_fields_pkg.get_salary
8746                  (p_hesa_method     => l_hesa_method,
8747                   p_hesa_empcir     => l_hesa_empcir,
8748                   p_dlhe_Job_salary => g_he_stdnt_dlhe.Job_salary,
8749                   p_hesa_salary     => p_value);
8750           -- smaddali added lpad for HECR11  build , bug#3051597
8751           p_value := LPAD(p_value,6,0) ;
8752 
8753       ELSIF  p_field_number = 15
8754       THEN
8755           -- Qualification required for job
8756           igs_he_extract_dlhe_fields_pkg.get_qual_req
8757                  (p_hesa_method    => l_hesa_method,
8758                   p_hesa_empcir    => l_hesa_empcir,
8759                   p_dlhe_qual_req  => g_he_stdnt_dlhe.Qualification_requirement,
8760                   p_hesa_qualreq   => p_value);
8761 
8762       ELSIF  p_field_number = 16
8763       THEN
8764           -- Importance to employer
8765           igs_he_extract_dlhe_fields_pkg.get_emp_imp
8766                  (p_hesa_method   => l_hesa_method,
8767                   p_hesa_empcir   => l_hesa_empcir,
8768                   p_dlhe_emp_imp  => g_he_stdnt_dlhe.Qualification_importance,
8769                   p_hesa_empimp   => p_value);
8770 
8771       ELSIF  p_field_number BETWEEN 17 AND 24
8772       THEN
8773 
8774               IF  ( l_hesa_method IN ('3','4','8','9') OR
8775                     l_hesa_empcir IN ('6','7','8','9','10','11','12','13','14','XX' ) OR
8776                     ( g_he_stdnt_dlhe.Job_reason1='N' AND  g_he_stdnt_dlhe.Job_reason2='N' AND
8777                       g_he_stdnt_dlhe.Job_reason3='N' AND g_he_stdnt_dlhe.Job_reason4='N' AND
8778                       g_he_stdnt_dlhe.Job_reason5='N' AND g_he_stdnt_dlhe.Job_reason6='N' AND
8779                       g_he_stdnt_dlhe.Job_reason7='N' AND g_he_stdnt_dlhe.Job_reason8='N' AND
8780                       g_he_stdnt_dlhe.Other_job_reason IS NULL AND  g_he_stdnt_dlhe.No_other_job_reason = 'N'
8781                     )
8782                   )  THEN
8783                       p_value := 'X' ;
8784               ELSIF  p_field_number = 17
8785               THEN
8786                    -- Career related code 1
8787                    igs_he_extract_dlhe_fields_pkg.get_career
8788                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason1 ,
8789                           p_hesa_career    => p_value);
8790               ELSIF  p_field_number = 18
8791               THEN
8792                    -- Career related code 2
8793                    igs_he_extract_dlhe_fields_pkg.get_career
8794                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason2 ,
8795                           p_hesa_career    => p_value);
8796               ELSIF  p_field_number = 19
8797               THEN
8798                   -- Career related code 3
8799                       igs_he_extract_dlhe_fields_pkg.get_career
8800                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason3,
8801                           p_hesa_career    => p_value);
8802               ELSIF  p_field_number = 20
8803               THEN
8804                    -- Career related code 4
8805                       igs_he_extract_dlhe_fields_pkg.get_career
8806                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason4 ,
8807                           p_hesa_career    => p_value);
8808 
8809               ELSIF  p_field_number = 21
8810               THEN
8811                   -- Career related code 5
8812                       igs_he_extract_dlhe_fields_pkg.get_career
8813                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason5 ,
8814                           p_hesa_career    => p_value);
8815 
8816               ELSIF  p_field_number = 22
8817               THEN
8818                    -- Career related code 6
8819                       igs_he_extract_dlhe_fields_pkg.get_career
8820                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason6 ,
8821                           p_hesa_career    => p_value);
8822 
8823               ELSIF  p_field_number = 23
8824               THEN
8825                    -- Career related code 7
8826                       igs_he_extract_dlhe_fields_pkg.get_career
8827                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason7 ,
8828                           p_hesa_career    => p_value);
8829 
8830               ELSIF  p_field_number = 24
8831               THEN
8832                    -- Career related code 8
8833                       igs_he_extract_dlhe_fields_pkg.get_career
8834                          (p_hesa_reason    => g_he_stdnt_dlhe.Job_reason8 ,
8835                           p_hesa_career    => p_value);
8836               END IF; -- if default value condition is not satisfied
8837 
8838 
8839       ELSIF  p_field_number = 25
8840       THEN
8841           -- How found job
8842           igs_he_extract_dlhe_fields_pkg.get_job_find
8843                  (p_hesa_method     => l_hesa_method,
8844                   p_hesa_empcir     => l_hesa_empcir,
8845                   p_dlhe_job_source => g_he_stdnt_dlhe.Job_source,
8846                   p_hesa_jobfnd     => p_value);
8847 
8848       ELSIF  p_field_number = 26
8849       THEN
8850          -- Previously employed
8851          igs_he_extract_dlhe_fields_pkg.get_prev_emp
8852                  (p_hesa_method       => l_hesa_method,
8853                   p_hesa_empcir       => l_hesa_empcir,
8854                   p_dlhe_previous_job => g_he_stdnt_dlhe.Previous_job,
8855                   p_hesa_prevemp      => p_value);
8856          l_hesa_prevemp  := p_value ;
8857 
8858       ELSIF  p_field_number = 27
8859       THEN
8860           -- Category of previous employment 1
8861           igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8862                  (p_hesa_method           => l_hesa_method,
8863                   p_hesa_empcir           => l_hesa_empcir,
8864                   p_hesa_prevemp          => l_hesa_prevemp,
8865                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype1,
8866                   p_hesa_prevcat          => p_value);
8867 
8868       ELSIF  p_field_number = 28
8869       THEN
8870           -- Category of previous employment 2
8871           igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8872                  (p_hesa_method           => l_hesa_method,
8873                   p_hesa_empcir           => l_hesa_empcir,
8874                   p_hesa_prevemp          => l_hesa_prevemp,
8875                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype2,
8876                   p_hesa_prevcat          => p_value);
8877 
8878       ELSIF  p_field_number = 29
8879       THEN
8880            --  Category of previous employment 3
8881            igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8882                  (p_hesa_method           => l_hesa_method,
8883                   p_hesa_empcir           => l_hesa_empcir,
8884                   p_hesa_prevemp          => l_hesa_prevemp,
8885                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype3,
8886                   p_hesa_prevcat          => p_value);
8887 
8888      ELSIF  p_field_number = 30
8889       THEN
8890           -- Category of previous employment 4
8891           igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8892                  (p_hesa_method           => l_hesa_method,
8893                   p_hesa_empcir           => l_hesa_empcir,
8894                   p_hesa_prevemp          => l_hesa_prevemp,
8895                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype4,
8896                   p_hesa_prevcat          => p_value);
8897 
8898       ELSIF  p_field_number = 31
8899       THEN
8900           -- Category of previous employment 5
8901           igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8902                  (p_hesa_method           => l_hesa_method,
8903                   p_hesa_empcir           => l_hesa_empcir,
8904                   p_hesa_prevemp          => l_hesa_prevemp,
8905                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype5,
8906                   p_hesa_prevcat          => p_value);
8907 
8908       ELSIF  p_field_number = 32
8909       THEN
8910            -- Category of previous employment 6
8911            igs_he_extract_dlhe_fields_pkg.get_prev_emp_cat
8912                  (p_hesa_method           => l_hesa_method,
8913                   p_hesa_empcir           => l_hesa_empcir,
8914                   p_hesa_prevemp          => l_hesa_prevemp,
8915                   p_dlhe_previous_jobtype => g_he_stdnt_dlhe.Previous_jobtype6,
8916                   p_hesa_prevcat          => p_value);
8917 
8918       ELSIF  p_field_number = 33
8919       THEN
8920           -- Nature of study/training
8921           igs_he_extract_dlhe_fields_pkg.get_nat_study
8922                  (p_hesa_method     => l_hesa_method,
8923                   p_hesa_modstudy   => l_hesa_modstudy,
8924                   p_dlhe_study_type => g_he_stdnt_dlhe.Further_study_type,
8925                   p_hesa_natstudy   => p_value);
8926           l_hesa_natstudy := p_value;
8927 
8928       ELSIF  p_field_number = 34
8929       THEN
8930           -- Professional subject of training
8931           igs_he_extract_dlhe_fields_pkg.get_train_subj
8932                  (p_hesa_method          => l_hesa_method,
8933                   p_hesa_modstudy        => l_hesa_modstudy,
8934                   p_hesa_natstudy        => l_hesa_natstudy,
8935                   p_dlhe_crse_train_subj => g_he_stdnt_dlhe.Course_training_subject,
8936                   p_dlhe_res_train_subj  => g_he_stdnt_dlhe.Research_training_subject,
8937                   p_hesa_profsoct        => p_value);
8938 
8939       ELSIF  p_field_number = 35
8940       THEN
8941           -- Institution providing study
8942           igs_he_extract_dlhe_fields_pkg.get_inst_prov
8943                  (p_hesa_method      => l_hesa_method,
8944                   p_hesa_modstudy    => l_hesa_modstudy,
8945                   p_hesa_natstudy    => l_hesa_natstudy,
8946                   p_dlhe_study_prov  => g_he_stdnt_dlhe.Further_study_provider,
8947                   p_hesa_instprov    => p_value);
8948 
8949       ELSIF  p_field_number = 36
8950       THEN
8951           -- Type of qualification
8952           -- smaddali removed parameter p_hesa_natstudy from the call for build HECR011 ,bug#3051597
8953           igs_he_extract_dlhe_fields_pkg.get_type_qual
8954                  (p_hesa_method         => l_hesa_method,
8955                   p_hesa_modstudy       => l_hesa_modstudy,
8956                   p_dlhe_study_qualaim  => g_he_stdnt_dlhe.Further_study_qualaim,
8957                   p_hesa_typequal       => p_value);
8958 
8959       ELSIF  p_field_number = 37
8960       THEN
8961           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
8962           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
8963           -- Reason for taking another course 2
8964           igs_he_extract_dlhe_fields_pkg.get_study_reason2
8965                  (p_hesa_method        => l_hesa_method,
8966                   p_hesa_modstudy      => l_hesa_modstudy,
8967                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason1,
8968                   p_hesa_secint        => p_value);
8969 
8970       ELSIF  p_field_number = 38
8971       THEN
8972           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
8973           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
8974           -- Reason for taking another course 2
8975           igs_he_extract_dlhe_fields_pkg.get_study_reason2
8976                  (p_hesa_method        => l_hesa_method,
8977                   p_hesa_modstudy      => l_hesa_modstudy,
8978                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason2,
8979                   p_hesa_secint        => p_value);
8980 
8981       ELSIF  p_field_number = 39
8982       THEN
8983           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
8984           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
8985           -- Reason for taking another course 3
8986           igs_he_extract_dlhe_fields_pkg.get_study_reason2
8987                  (p_hesa_method        => l_hesa_method,
8988                   p_hesa_modstudy      => l_hesa_modstudy,
8989                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason3,
8990                   p_hesa_secint        => p_value);
8991 
8992       ELSIF  p_field_number = 40
8993       THEN
8994           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
8995           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
8996           -- Reason for taking another course 4
8997           igs_he_extract_dlhe_fields_pkg.get_study_reason2
8998                  (p_hesa_method        => l_hesa_method,
8999                   p_hesa_modstudy      => l_hesa_modstudy,
9000                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason4,
9001                   p_hesa_secint        => p_value);
9002 
9003       ELSIF  p_field_number = 41
9004       THEN
9005           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
9006           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
9007           -- Reason for taking another course 5
9008           igs_he_extract_dlhe_fields_pkg.get_study_reason2
9009                  (p_hesa_method        => l_hesa_method,
9010                   p_hesa_modstudy      => l_hesa_modstudy,
9011                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason5,
9012                   p_hesa_secint        => p_value);
9013 
9014       ELSIF  p_field_number = 42
9015       THEN
9016           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
9017           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
9018           -- Reason for taking another course 6
9019           igs_he_extract_dlhe_fields_pkg.get_study_reason2
9020                  (p_hesa_method         => l_hesa_method,
9021                   p_hesa_modstudy       => l_hesa_modstudy,
9022                   p_dlhe_study_reason   => g_he_stdnt_dlhe.Study_reason6,
9023                   p_hesa_secint         => p_value);
9024 
9025       ELSIF  p_field_number = 43
9026       THEN
9027           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
9028           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
9029           -- Reason for taking another course 7
9030               igs_he_extract_dlhe_fields_pkg.get_study_reason2
9031                  (p_hesa_method        => l_hesa_method,
9032                   p_hesa_modstudy      => l_hesa_modstudy,
9033                   p_dlhe_study_reason  => g_he_stdnt_dlhe.Study_reason7,
9034                   p_hesa_secint        => p_value);
9035 
9036       ELSIF  p_field_number = 44
9037       THEN
9038           -- smaddali removed calculation of field 45 EMPPAID for build HECR011 ,bug#3051597
9039           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
9040           -- Reason for taking another course 8
9041           igs_he_extract_dlhe_fields_pkg.get_study_reason8
9042                  (p_hesa_method             => l_hesa_method,
9043                   p_hesa_modstudy           => l_hesa_modstudy,
9044                   p_dlhe_other_study_reason => g_he_stdnt_dlhe.Other_study_reason,
9045                   p_dlhe_no_study_reason    => g_he_stdnt_dlhe.No_other_study_reason,
9046                   p_hesa_secint8            => p_value);
9047 
9048       ELSIF  p_field_number = 45
9049       THEN
9050 
9051          -- not used
9052          p_value := 'X';
9053 
9054       ELSIF  p_field_number = 46
9055       THEN
9056           -- smaddali removed parameter p_hesa_natstudy,p_hesa_emppaid from the call for build HECR011 ,bug#3051597
9057           -- How funding further study
9058           igs_he_extract_dlhe_fields_pkg.get_funding_source
9059                  (p_hesa_method          => l_hesa_method,
9060                   p_hesa_modstudy        => l_hesa_modstudy,
9061                   p_dlhe_funding_source  => g_he_stdnt_dlhe.Funding_source,
9062                   p_hesa_fundstudy       => p_value);
9063 
9064       ELSIF  p_field_number = 47
9065       THEN
9066           -- Teaching employment marker
9067           igs_he_extract_dlhe_fields_pkg.get_teaching_emp
9068                  (p_hesa_method     => l_hesa_method,
9069                   p_dlhe_qualified  => g_he_stdnt_dlhe.Qualified_teacher,
9070                   p_dlhe_teaching   => g_he_stdnt_dlhe.Teacher_teaching ,
9071                   p_dlhe_seeking    => g_he_stdnt_dlhe.Teacher_seeking ,
9072                   p_hesa_tchemp     => p_value);
9073           l_hesa_tchemp := p_value ;
9074 
9075       ELSIF  p_field_number = 48
9076       THEN
9077           -- Teaching sector
9078           igs_he_extract_dlhe_fields_pkg.get_teaching_sector
9079                  (p_hesa_method        => l_hesa_method,
9080                   p_hesa_tchemp        => l_hesa_tchemp,
9081                   p_dlhe_teach_sector  => g_he_stdnt_dlhe.Teaching_sector,
9082                   p_hesa_teachsct      => p_value);
9083 
9084       ELSIF  p_field_number = 49
9085       THEN
9086           -- Teaching phase
9087           igs_he_extract_dlhe_fields_pkg.get_teaching_phase
9088                  (p_hesa_method        => l_hesa_method,
9089                   p_hesa_tchemp        => l_hesa_tchemp,
9090                   p_dlhe_teach_level   => g_he_stdnt_dlhe.Teaching_level,
9091                   p_hesa_teachphs      => p_value);
9092 
9093       ELSIF  p_field_number = 50
9094       THEN
9095           -- Reason for taking original course
9096           igs_he_extract_dlhe_fields_pkg.get_intent
9097                  (p_hesa_method         => l_hesa_method,
9098                   p_dlhe_pt_study       => g_he_stdnt_dlhe.PT_Study,
9099                   p_dlhe_reason_ptcrse  => g_he_stdnt_dlhe.Reason_for_PTcourse,
9100                   p_hesa_intent         => p_value);
9101 
9102       ELSIF  p_field_number = 51
9103       THEN
9104           -- Employed during course
9105           igs_he_extract_dlhe_fields_pkg.get_job_while_study
9106                  (p_hesa_method           => l_hesa_method,
9107                   p_dlhe_pt_study         => g_he_stdnt_dlhe.PT_Study,
9108                   p_dlhe_job_while_study  => g_he_stdnt_dlhe.Job_while_studying,
9109                   p_hesa_empcrse          => p_value);
9110           l_hesa_empcrse := p_value ;
9111 
9112       ELSIF  p_field_number = 52
9113       THEN
9114           -- Employer sponsorship 1
9115           igs_he_extract_dlhe_fields_pkg.get_emp_sponsorship
9116                  (p_hesa_method       => l_hesa_method,
9117                   p_hesa_empcrse      => l_hesa_empcrse,
9118                   p_dlhe_pt_study     => g_he_stdnt_dlhe.PT_Study,
9119                   p_dlhe_emp_support  => g_he_stdnt_dlhe.Employer_support1,
9120                   p_hesa_empspns      => p_value);
9121 
9122       ELSIF  p_field_number = 53
9123       THEN
9124           -- Employer sponsorship 2
9125           igs_he_extract_dlhe_fields_pkg.get_emp_sponsorship
9126                  (p_hesa_method       => l_hesa_method,
9127                   p_hesa_empcrse      => l_hesa_empcrse,
9128                   p_dlhe_pt_study     => g_he_stdnt_dlhe.PT_Study,
9129                   p_dlhe_emp_support  => g_he_stdnt_dlhe.Employer_support2,
9130                   p_hesa_empspns      => p_value);
9131 
9132       ELSIF  p_field_number = 54
9133       THEN
9134           -- Employer sponsorship 3
9135           igs_he_extract_dlhe_fields_pkg.get_emp_sponsorship
9136                  (p_hesa_method       => l_hesa_method,
9137                   p_hesa_empcrse      => l_hesa_empcrse,
9138                   p_dlhe_pt_study     => g_he_stdnt_dlhe.PT_Study,
9139                   p_dlhe_emp_support  => g_he_stdnt_dlhe.Employer_support3,
9140                   p_hesa_empspns      => p_value);
9141 
9142       ELSIF  p_field_number = 55
9143       THEN
9144           -- Employer sponsorship 4
9145           igs_he_extract_dlhe_fields_pkg.get_emp_sponsorship
9146                  (p_hesa_method       => l_hesa_method,
9147                   p_hesa_empcrse      => l_hesa_empcrse,
9148                   p_dlhe_pt_study     => g_he_stdnt_dlhe.PT_Study,
9149                   p_dlhe_emp_support  => g_he_stdnt_dlhe.Employer_support4,
9150                   p_hesa_empspns      => p_value);
9151 
9152       ELSIF  p_field_number = 56
9153       THEN
9154           -- Employer sponsorship 5
9155           igs_he_extract_dlhe_fields_pkg.get_emp_sponsorship
9156                  (p_hesa_method       => l_hesa_method,
9157                   p_hesa_empcrse      => l_hesa_empcrse,
9158                   p_dlhe_pt_study     => g_he_stdnt_dlhe.PT_Study,
9159                   p_dlhe_emp_support  => g_he_stdnt_dlhe.Employer_support5,
9160                   p_hesa_empspns      => p_value);
9161 
9162       END IF; -- for each field from 1 to  56
9163 
9164       EXCEPTION
9165       WHEN OTHERS
9166       THEN
9167           write_to_log(SQLERRM);
9168           fnd_message.set_name('IGS','IGS_HE_FIELD_NUM');
9169           fnd_message.set_token('field_number',p_field_number);
9170           IGS_GE_MSG_STACK.ADD;
9171           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
9172           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_dlhe_fields');
9173           IGS_GE_MSG_STACK.ADD;
9174           App_Exception.Raise_Exception;
9175 
9176    END process_dlhe_fields;
9177 
9178 
9179    /*----------------------------------------------------------------------
9180    This procedure processes each field to be submitted in the HESA return
9181 
9182    Parameters :
9183    p_extract_run_id         The Extract Run Id
9184    p_person_id              Person_id for the student
9185    p_course_cd              Course Code that the student is attempting
9186    p_crv_version_number     Version Number of the course code
9187    p_student_inst_number    Student Instance Number
9188    p_unit_cd              Unit Code
9189    p_uv_version_number      Unit Code Version Number
9190    p_line_number            Line Number of the current line being processed
9191    ----------------------------------------------------------------------*/
9192    PROCEDURE process_fields
9193              (p_extract_run_id         igs_he_ext_run_dtls.extract_run_id%TYPE,
9194               p_person_id              igs_he_ex_rn_dat_ln.person_id%TYPE,
9195               p_course_cd              igs_he_ex_rn_dat_ln.course_cd%TYPE,
9196               p_crv_version_number     igs_he_ex_rn_dat_ln.crv_version_number%TYPE,
9197               p_student_inst_number    igs_he_ex_rn_dat_ln.student_inst_number%TYPE,
9198               p_unit_cd                igs_he_ex_rn_dat_ln.unit_cd%TYPE,
9199               p_uv_version_number      igs_he_ex_rn_dat_ln.uv_version_number%TYPE,
9200               p_line_number            igs_he_ex_rn_dat_ln.line_number%TYPE)
9201    IS
9202    /***************************************************************
9203    Created By           :        Bidisha S
9204    Date Created By      :        28-Jan-02
9205    Purpose              :This procedure processes each field to be submitted in the HESA return
9206    Known Limitations,Enhancements or Remarks:
9207    Change History       :
9208    Who       When         What
9209    smaddali  09-Apr-03    modified procedure for HEFD203 build , bug 2717745
9210    jchakrab  05-Feb-05    Modified for 4006205 -
9211                           Replaced call to TBH insert_row() with direct DML
9212    sjlaport  31-May-05    Modified for 4304808 - Error message only created for mandatory
9213                           fields derived with null value. Removed check for included fields.
9214    jbaber    15-Mar-2006  Update recalculated fields for HE365 - Extract Rerun
9215   ***************************************************************/
9216 
9217    l_rowid          VARCHAR2(30);
9218    l_fld_seq        igs_he_ex_rn_dat_fd.rn_dat_fd_id%TYPE;
9219    l_index          NUMBER;
9220    l_value          igs_he_ex_rn_dat_fd.value%TYPE;
9221 
9222    l_last_update_date           DATE;
9223    l_last_updated_by            NUMBER;
9224    l_last_update_login          NUMBER;
9225 
9226 
9227    BEGIN
9228       -- Initialize l_index with the first element in the array
9229       -- This is cause, the user might not have selected all the
9230       -- fields to be calculated. Therefore we need to travel
9231       -- through the array stopping at only those Subscripts which
9232       -- have data in it.
9233       l_index  := g_field_defn.field_number.FIRST;
9234 
9235       --smaddali added this code to delete plsql tables hesa_value and oss_value so that they are initialized properly
9236       -- for bug 2417370
9237       g_field_defn.hesa_value.delete ;
9238       g_field_defn.oss_value.delete ;
9239       -- smaddali added code to initialize dlhe return variables, for HEFD203 build , bug#2717745
9240       l_hesa_method     := NULL;
9241       l_hesa_empcir     := NULL;
9242       l_hesa_modstudy   := NULL;
9243       l_hesa_natstudy   := NULL;
9244       l_hesa_empcrse    := NULL;
9245       l_hesa_prevemp    := NULL;
9246       l_hesa_tchemp     := NULL;
9247 
9248       --jchakrab - added for 4006205 - replace TBH insert_row() with direct DML call
9249       --set values for WHO columns for all fields
9250       l_last_update_date := SYSDATE;
9251       l_last_updated_by := NVL(fnd_global.user_id,-1);
9252       l_last_update_login := NVL(fnd_global.login_id,-1);
9253 
9254       -- Populate each field for the Student / Combined / Module record
9255       WHILE l_index IS NOT NULL
9256       LOOP
9257               -- Initialize variables.
9258               l_value := NULL;
9259 
9260               -- Check if constant value has been provided.
9261               -- We do not need to derive the field if a value has been given
9262               IF g_field_defn.constant_val(l_index) IS  NOT NULL
9263               THEN
9264                   -- Check if constant value should be NULL
9265                   IF g_field_defn.constant_val(l_index) = 'NULL' THEN
9266                       l_value := NULL;
9267                   ELSE
9268                       l_value := g_field_defn.constant_val(l_index);
9269                   END IF;
9270               ELSE
9271                   -- Constant value not specified, therefore derive the field value
9272                   -- Do the Combined Return Fields
9273                   IF Substr(g_he_submsn_return.record_id,4,2) = '11'
9274                   THEN
9275                       -- smaddali passing g_en_stdnt_ps_att.version_number instead of p_crv_version_number, for HECR214 build
9276                       -- the field derivations should use term version number instead of sca.version_number
9277                       process_comb_fields
9278                            (p_person_id           => p_person_id,
9279                             p_course_cd           => p_course_cd,
9280                             p_crv_version_number  => g_en_stdnt_ps_att.version_number,
9281                             p_student_inst_number => p_student_inst_number,
9282                             p_field_number        => g_field_defn.field_number(l_index) ,
9283                             p_value               => l_value);
9284 
9285                   -- Do the Student Return Fields
9286                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '12'
9287                   THEN
9288                       -- smaddali passing g_en_stdnt_ps_att.version_number instead of p_crv_version_number, for HECR214 build
9289                       -- the field derivations should use term version number instead of sca.version_number
9290                       process_stdnt_fields
9291                            (p_person_id           => p_person_id,
9292                             p_course_cd           => p_course_cd,
9293                             p_crv_version_number  => g_en_stdnt_ps_att.version_number,
9294                             p_student_inst_number => p_student_inst_number,
9295                             p_field_number        => g_field_defn.field_number(l_index) ,
9296                             p_value               => l_value);
9297 
9298                   -- Do the Module Return Fields
9299                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '13'
9300                   THEN
9301                       process_module_fields
9302                            (p_unit_cd             => p_unit_cd,
9303                             p_uv_version_number   => p_uv_version_number,
9304                             p_field_number        => g_field_defn.field_number(l_index) ,
9305                             p_value               => l_value);
9306 
9307                   -- Do the DLHE Return Fields
9308                   -- smaddali added processing for DLHE fields for bug#2717745 HEFD203 build
9309                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '18'
9310                   THEN
9311                       process_dlhe_fields
9312                            (p_person_id           => p_person_id,
9313                             p_field_number        => g_field_defn.field_number(l_index) ,
9314                             p_value               => l_value);
9315 
9316                   END IF; -- Module Return Fields
9317 
9318                   -- If calculated value was null then use the default value
9319                   IF l_value IS NULL
9320                   THEN
9321                           -- if default value processing validation is satisfied then use default value
9322                           IF g_default_pro = 'Y' THEN
9323                               l_value := g_field_defn.default_val(l_index);
9324                           END IF ;
9325                   END IF;
9326 
9327               END IF; -- Constant value has not been provided.
9328 
9329 
9330               -- If a mandatory field is derived as null with no constant or default value
9331               -- defined, record error
9332               IF l_value IS NULL AND g_field_defn.report_null_flag(l_index) = 'Y'
9333               THEN
9334 
9335                   -- Initialize Record to Null.
9336                   g_he_ext_run_except := NULL;
9337 
9338                   -- Populate the required fields.
9339                   g_he_ext_run_except.extract_run_id      := p_extract_run_id;
9340                   g_he_ext_run_except.exception_reason    := g_msg_ext_fld_val_null;
9341                   g_he_ext_run_except.person_id           := p_person_id;
9342                   g_he_ext_run_except.person_number       := g_pe_person.person_number;
9343                   g_he_ext_run_except.course_cd           := p_course_cd;
9344                   g_he_ext_run_except.crv_version_number  := p_crv_version_number;
9345                   g_he_ext_run_except.unit_cd             := p_unit_cd;
9346                   g_he_ext_run_except.uv_version_number   := p_uv_version_number;
9347                   g_he_ext_run_except.line_number         := p_line_number;
9348                   g_he_ext_run_except.field_number        := g_field_defn.field_number(l_index);
9349 
9350                   -- Call procedure to log error
9351                   log_error (g_he_ext_run_except);
9352               END IF; -- Field Value is NULL
9353 
9354               l_rowid := NULL;
9355 
9356               -- If field is being recalculated then we should update field rather than insert
9357               IF g_field_exists  THEN
9358 
9359                   UPDATE igs_he_ex_rn_dat_fd
9360                   SET value = l_value
9361                   WHERE extract_run_id = p_extract_run_id
9362                     AND line_number = p_line_number
9363                     AND field_number = g_field_defn.field_number(l_index);
9364 
9365               END IF;
9366 
9367               -- SQL%ROWCOUNT = 0 is for exceptional case where users have added a new field
9368               -- to the extract between runs. This is to be consistent with new lines that are appended
9369               -- which will pick up the new fields.
9370               IF NOT g_field_exists OR (SQL%ROWCOUNT = 0) THEN
9371 
9372                   --jchakrab - 4006205 - replace TBH with direct DML call
9373                   INSERT INTO igs_he_ex_rn_dat_fd (
9374                                 rn_dat_fd_id,
9375                                 extract_run_id,
9376                                 line_number,
9377                                 field_number,
9378                                 value,
9379                                 override_value,
9380                                 creation_date,
9381                                 created_by,
9382                                 last_update_date,
9383                                 last_updated_by,
9384                                 last_update_login
9385                   ) VALUES (
9386                                 IGS_HE_EX_RN_DAT_FD_S.NEXTVAL,
9387                                 p_extract_run_id,
9388                                 p_line_number,
9389                                 g_field_defn.field_number(l_index),
9390                                 l_value,
9391                                 NULL,
9392                                 l_last_update_date,
9393                                 l_last_updated_by,
9394                                 l_last_update_date,
9395                                 l_last_updated_by,
9396                                 l_last_update_login
9397                   );
9398 
9399               END IF;
9400 
9401           -- Store the value calculated into the array so that
9402           -- it can be used in calcualations of other fields.
9403           g_field_defn.hesa_value(l_index) := l_value;
9404 
9405           -- Get the next subscript for the array
9406           l_index := g_field_defn.field_number.NEXT(l_index);
9407 
9408           -- Continue with the next field.
9409       END LOOP; -- Loop for each field to be submitted.
9410 
9411    END process_fields;
9412 
9413 
9414    /*----------------------------------------------------------------------
9415    This function does the processing for a Student / Combined Return
9416    It will select all the required details and then call the individual
9417    procedures to derive the field values.
9418 
9419    Parameters :
9420    p_extract_run_id         The Extract Run Id
9421    p_person_id              Person_id for the student
9422    p_course_cd              Course Code that the student is attempting
9423    p_crv_version_number     Version Number of the course code
9424    p_student_inst_number    Student Instance Number
9425    p_line_number            Line Number of the current line being processed
9426    ----------------------------------------------------------------------*/
9427    FUNCTION  process_comb_stdnt_return
9428              (p_extract_run_id         igs_he_ext_run_dtls.extract_run_id%TYPE,
9429               p_person_id              igs_he_ex_rn_dat_ln.person_id%TYPE,
9430               p_course_cd              igs_he_ex_rn_dat_ln.course_cd%TYPE,
9431               p_crv_version_number     igs_he_ex_rn_dat_ln.crv_version_number%TYPE,
9432               p_student_inst_number    igs_he_ex_rn_dat_ln.student_inst_number%TYPE,
9433               p_line_number            igs_he_ex_rn_dat_ln.line_number%TYPE)
9434              RETURN BOOLEAN
9435  /***************************************************************
9436    Created By           :
9437    Date Created By      :
9438    Known Limitations,Enhancements or Remarks:
9439    Change History       :
9440    Who       When          What
9441    pkpatel   27-MAR-2003   Bug No: 2261717
9442                            These 2 columns are obsolete from igs_pe_person_v and here they are not being used for any processing.
9443                            Hence removed to avoid confusion.
9444    smaddali  3-dec-03      modified cursors c_yop to add condition complete_ind=Y , for HECR210 build, bug#2874542
9445    smaddali 10-dec-03      Modified logic to get Term record details for HECR214 - Term based fees enhancement, bug#3291656
9446    smaddali 14-jan-04      Modified logic not to stop processing student when igs_pe_stats record is not found : bug#3361317
9447    ayedubat 11-may-04      Modified the cursor, c_pe_stats to remove the effective dates comparision for Bug, 3614658
9448    jbaber   20-sep-04      Modified c_spa, c_pe_stats, c_yop, c_crse as per HE350 - Statutory Changes for 2004/05 Reporting
9449    jtmathew 23-dec-05      Modified c_spa, c_yop for HE309
9450    jchin    20-jan-06      Modified c_pe_stats and c_pers cursor queries for bug 4251011, 3717086 and 4250923
9451 ***************************************************************/
9452    IS
9453    -- smaddali selecting version_number for HECR214 build
9454    CURSOR c_spa IS
9455    SELECT sca.version_number,
9456           sca.cal_type,
9457           sca.location_cd ,
9458           sca.attendance_mode,
9459           sca.attendance_type,
9460           sca.coo_id ,
9461           sca.student_confirmed_ind,
9462           sca.commencement_dt ,
9463           sca.course_attempt_status,
9464           sca.progression_status ,
9465           sca.discontinued_dt,
9466           sca.discontinuation_reason_cd,
9467           sca.funding_source ,
9468           sca.exam_location_cd,
9469           sca.course_rqrmnt_complete_ind,
9470           sca.course_rqrmnts_complete_dt,
9471           sca.override_time_limitation,
9472           sca.advanced_standing_ind,
9473           sca.fee_cat,
9474           sca.adm_admission_appl_number,
9475           sca.adm_nominated_course_cd,
9476           sca.adm_sequence_number,
9477           hspa.fe_student_marker,
9478           hspa.domicile_cd,
9479           hspa.inst_last_attended,
9480           hspa.year_left_last_inst ,
9481           hspa.highest_qual_on_entry ,
9482           hspa.date_qual_on_entry_calc ,
9483           hspa.a_level_point_score,
9484           hspa.highers_points_scores ,
9485           hspa.occupation_code,
9486           hspa.commencement_dt,
9487           hspa.special_student,
9488           hspa.student_qual_aim,
9489           hspa.student_fe_qual_aim ,
9490           hspa.teacher_train_prog_id ,
9491           hspa.itt_phase,
9492           hspa.bilingual_itt_marker ,
9493           hspa.teaching_qual_gain_sector ,
9494           hspa.teaching_qual_gain_subj1,
9495           hspa.teaching_qual_gain_subj2,
9496           hspa.teaching_qual_gain_subj3,
9497           hspa.hesa_return_name,
9498           hspa.hesa_return_id,
9499           hspa.hesa_submission_name,
9500           hspa.associate_ucas_number,
9501           hspa.associate_scott_cand ,
9502           hspa.associate_teach_ref_num,
9503           hspa.associate_nhs_reg_num,
9504           hspa.itt_prog_outcome,
9505           hspa.nhs_funding_source ,
9506           hspa.ufi_place,
9507           hspa.postcode ,
9508           hspa.social_class_ind ,
9509           hspa.destination,
9510           hspa.occcode,
9511           hspa.total_ucas_tariff ,
9512           hspa.nhs_employer,
9513           hspa.return_type,
9514           hspa.student_inst_number,
9515           hspa.qual_aim_subj1 ,
9516           hspa.qual_aim_subj2 ,
9517           hspa.qual_aim_subj3 ,
9518           hspa.qual_aim_proportion,
9519           hspa.dependants_cd,
9520           hspa.enh_fund_elig_cd,
9521           hspa.implied_fund_rate,
9522           hspa.gov_initiatives_cd,
9523           hspa.units_completed,
9524           hspa.units_for_qual,
9525           hspa.disadv_uplift_elig_cd,
9526           hspa.disadv_uplift_factor,
9527           hspa.franch_out_arr_cd,
9528           hspa.employer_role_cd,
9529           hspa.franch_partner_cd,
9530           pst.course_type
9531    FROM   igs_en_stdnt_ps_att_all   sca,
9532           igs_he_st_spa_all         hspa,
9533           igs_ps_ver_all            psv,
9534           igs_ps_type_all           pst
9535    WHERE  sca.person_id          = p_person_id
9536    AND    sca.course_cd          = p_course_cd
9537    AND    sca.version_number     = p_crv_version_number
9538    AND    sca.person_id          = hspa.person_id
9539    AND    sca.course_cd          = hspa.course_cd
9540    AND    psv.course_cd          = p_course_cd
9541    AND    psv.version_number     = p_crv_version_number
9542    AND    psv.course_type        = pst.course_type;
9543 
9544    -- smaddali modified this cursor to remove join with igs_pe_stat_v for bug#3361317
9545    -- jchin - bug 4950293
9546    CURSOR c_pers  IS
9547      SELECT P.PARTY_NUMBER PERSON_NUMBER,
9548             P.PARTY_NAME PERSON_NAME,
9549             P.PERSON_LAST_NAME SURNAME,
9550             P.PERSON_FIRST_NAME GIVEN_NAMES,
9551             P.PERSON_MIDDLE_NAME MIDDLE_NAME,
9552             P.PERSON_TITLE TITLE,
9553             NVL (P.KNOWN_AS,
9554               SUBSTR (P.PERSON_FIRST_NAME, 1, DECODE (INSTR (P.PERSON_FIRST_NAME, ' '), 0, LENGTH (P.PERSON_FIRST_NAME),
9555               (INSTR (P.PERSON_FIRST_NAME, ' ') - 1))))
9556               || ' '
9557               || P.PERSON_LAST_NAME PREFERRED_NAME,
9558             P.KNOWN_AS PREFERRED_GIVEN_NAME,
9559             PP.GENDER SEX,
9560             PP.DATE_OF_BIRTH BIRTH_DT,
9561             PP.PERSON_NAME FULL_NAME
9562      FROM   HZ_PARTIES P,
9563             HZ_PERSON_PROFILES PP
9564      WHERE  P.PARTY_ID = PP.PARTY_ID
9565      AND    SYSDATE BETWEEN PP.EFFECTIVE_START_DATE
9566                    AND NVL (PP.EFFECTIVE_END_DATE, SYSDATE)
9567      AND    P.PARTY_ID = P_PERSON_ID;
9568 
9569    -- smaddali seperated this cursor from c_pers for bug#3361317
9570    -- jbaber modified for HEFD350 to include marital status
9571    -- jchin - modified for bug 4251011, 3717086
9572    CURSOR c_pe_stats(cp_enrl_start_dt      igs_he_submsn_header.enrolment_start_date%TYPE,
9573            cp_enrl_end_dt        igs_he_submsn_header.enrolment_end_date%TYPE) IS
9574    SELECT HPP.DECLARED_ETHNICITY ETHNIC_ORIGIN_ID,
9575           SD.RELIGION_CD RELIGION,
9576           HPP.MARITAL_STATUS MARITAL_STATUS
9577    FROM   HZ_PERSON_PROFILES HPP,
9578           IGS_PE_STAT_DETAILS SD
9579    WHERE  HPP.PARTY_ID = SD.PERSON_ID(+)
9580    AND    HPP.PARTY_ID = P_PERSON_ID
9581    AND    SYSDATE BETWEEN HPP.EFFECTIVE_START_DATE
9582    AND    NVL(HPP.EFFECTIVE_END_DATE, SYSDATE);
9583 
9584     --smaddali modified where clause for comparing the enrolment dates for bug 2415632
9585     -- smaddali 27-desc-2002 modified cursor to check for conferral date , bug 2702100
9586     -- smaddali 4-dec-03 modified cursor to remove igs_gr_graduand table and add conition complete_ind=Y, for HECR210 build
9587    CURSOR c_yop  (p_start_date          DATE,
9588                   p_end_date            DATE,
9589                   p_awd_conf_start_dt   DATE,
9590                   p_awd_conf_end_dt     DATE) IS
9591    SELECT DISTINCT susa.unit_set_cd,
9592           susa.us_version_number,
9593           susa.sequence_number,
9594           susa.selection_dt,
9595           susa.end_dt,
9596           susa.rqrmnts_complete_ind,
9597           susa.rqrmnts_complete_dt,
9598           husa.new_he_entrant_cd,
9599           husa.term_time_accom ,
9600           husa.disability_allow,
9601           husa.additional_sup_band,
9602           husa.sldd_discrete_prov,
9603           husa.study_mode,
9604           husa.study_location ,
9605           husa.fte_perc_override,
9606           husa.franchising_activity,
9607           husa.completion_status,
9608           husa.good_stand_marker,
9609           husa.complete_pyr_study_cd,
9610           husa.credit_value_yop1,
9611           husa.credit_value_yop2,
9612           husa.credit_value_yop3,
9613           husa.credit_value_yop4,
9614           husa.credit_level_achieved1,
9615           husa.credit_level_achieved2,
9616           husa.credit_level_achieved3,
9617           husa.credit_level_achieved4,
9618           husa.credit_pt_achieved1,
9619           husa.credit_pt_achieved2,
9620           husa.credit_pt_achieved3,
9621           husa.credit_pt_achieved4,
9622           husa.credit_level1,
9623           husa.credit_level2,
9624           husa.credit_level3,
9625           husa.credit_level4,
9626           husa.grad_sch_grade,
9627           husa.mark,
9628           husa.teaching_inst1,
9629           husa.teaching_inst2,
9630           husa.pro_not_taught,
9631           husa.fundability_code,
9632           husa.fee_eligibility,
9633           husa.fee_band,
9634           husa.non_payment_reason,
9635           husa.student_fee,
9636           husa.calculated_fte,
9637           husa.fte_intensity,
9638           husa.type_of_year,
9639           husa.year_stu,
9640           husa.enh_fund_elig_cd,
9641           husa.additional_sup_cost,
9642           husa.disadv_uplift_factor
9643    FROM  igs_as_su_setatmpt  susa,
9644          igs_he_en_susa      husa,
9645          igs_en_unit_set     us,
9646          igs_en_unit_set_cat susc,
9647          igs_en_spa_awd_aim enawd,
9648          igs_en_stdnt_ps_att_all   sca
9649    WHERE susa.person_id = sca.person_id
9650    AND   susa.course_cd = sca.course_cd
9651    AND    sca.person_id          = enawd.person_id(+)
9652    AND    sca.course_cd          = enawd.course_cd(+)
9653    AND    susa.person_id              = p_person_id
9654    AND   susa.course_cd              = p_course_cd
9655    AND   susa.unit_set_cd            = husa.unit_set_cd
9656    AND   susa.us_version_number      = husa.us_version_number
9657    AND   susa.person_id              = husa.person_id
9658    AND   susa.course_cd              = husa.course_cd
9659    AND   susa.sequence_number        = husa.sequence_number
9660    AND   susa.unit_set_cd            = us.unit_set_cd
9661    AND   susa.us_version_number      = us.version_number
9662    AND   us.unit_set_cat             = susc.unit_set_cat
9663    AND   susc.s_unit_set_cat         = 'PRENRL_YR'
9664    -- the program attempt is overlapping with the submission period and the yop is also overlapping with the submission period
9665    AND   ( (  sca.commencement_dt     <= p_end_date AND
9666              (sca.discontinued_dt  IS NULL OR  sca.discontinued_dt   >= p_start_date ) AND
9667              (sca.course_rqrmnts_complete_dt IS NULL OR  sca.course_rqrmnts_complete_dt >= p_start_date ) AND
9668               susa.selection_dt           <= p_end_date AND
9669              (susa.end_dt  IS NULL OR susa.end_dt   >= p_start_date )  AND
9670              (susa.rqrmnts_complete_dt IS NULL OR susa.rqrmnts_complete_dt >= p_start_date)
9671            )
9672            OR
9673               -- the yop has completed before the start of the submission period
9674               -- AND the program attempt has completed before the end of the submission period
9675               -- AND an award has been conferred between the NVL(award conferral dates, submission period)
9676            (  susa.rqrmnts_complete_dt < p_start_date AND
9677               sca.course_rqrmnts_complete_dt <= p_end_date AND
9678               enawd.complete_ind = 'Y' AND
9679               enawd.conferral_date BETWEEN p_awd_conf_start_dt AND p_awd_conf_end_dt
9680            )
9681          )
9682    ORDER BY susa.rqrmnts_complete_dt DESC, susa.end_dt DESC,  susa.selection_dt DESC;
9683 
9684    -- smaddali modified this cursor to select funding_source field from igs_he_poous for hefd208 - bug#2717751
9685    -- smaddali added version_number parameter for HECR214 build, we need to get the Term record program version details
9686    CURSOR c_crse (p_cal_type            igs_ps_ofr_opt.cal_type%TYPE,
9687                   p_attendance_mode     igs_ps_ofr_opt.attendance_mode%TYPE,
9688                   p_attendance_type     igs_ps_ofr_opt.attendance_type%TYPE,
9689                   p_location_cd         igs_ps_ofr_opt.location_cd%TYPE,
9690                   p_unit_set_cd         igs_he_poous_all.unit_set_cd%TYPE,
9691                   p_us_version_number   igs_he_poous_all.us_version_number%TYPE,
9692                   cp_crv_version_number igs_ps_ver_all.version_number%TYPE ) IS
9693    SELECT crv.title,
9694           crv.std_annual_load,
9695           pop.program_length,
9696           pop.program_length_measurement,
9697           crv.contact_hours,
9698           crv.govt_special_course_type,
9699           hpr.teacher_train_prog_id,
9700           hpr.itt_phase ,
9701           hpr.bilingual_itt_marker ,
9702           hpr.teaching_qual_sought_sector,
9703           hpr.teaching_qual_sought_subj1,
9704           hpr.teaching_qual_sought_subj2,
9705           hpr.teaching_qual_sought_subj3,
9706           hpr.location_of_study ,
9707           hpr.other_inst_prov_teaching1,
9708           hpr.other_inst_prov_teaching2,
9709           hpr.prop_teaching_in_welsh ,
9710           hpr.prop_not_taught,
9711           hpr.credit_transfer_scheme ,
9712           hpr.return_type,
9713           hpr.default_award,
9714           Nvl(hpr.program_calc,'N') ,
9715           hpr.level_applicable_to_funding,
9716           hpr.franchising_activity,
9717           hpr.nhs_funding_source,
9718           hpr.fe_program_marker,
9719           hpr.fee_band  ,
9720           hpr.fundability,
9721           hpr.implied_fund_rate,
9722           hpr.gov_initiatives_cd,
9723           hpr.units_for_qual,
9724           hpr.disadv_uplift_elig_cd,
9725           hpr.franch_out_arr_cd,
9726           hpud.location_of_study,
9727           hpud.mode_of_study,
9728           hpud.ufi_place ,
9729           hpud.franchising_activity,
9730           hpud.type_of_year,
9731           hpud.leng_current_year,
9732           hpud.grading_schema_cd,
9733           hpud.gs_version_number,
9734           hpud.credit_value_yop1,
9735           hpud.level_credit1    ,
9736           hpud.credit_value_yop2,
9737           hpud.level_credit2    ,
9738           hpud.credit_value_yop3,
9739           hpud.level_credit3    ,
9740           hpud.credit_value_yop4,
9741           hpud.level_credit4    ,
9742           hpud.fte_intensity  ,
9743           hpud.other_instit_teach1,
9744           hpud.other_instit_teach2,
9745           hpud.prop_not_taught,
9746           hpud.fundability_cd,
9747           hpud.fee_band,
9748           hpud.level_applicable_to_funding,
9749           hpud.funding_source
9750    FROM   igs_ps_ver       crv,
9751           igs_he_st_prog   hpr,
9752           igs_he_poous     hpud,
9753           igs_ps_ofr_opt pop
9754    WHERE  crv.course_cd             = hpr.course_cd
9755    AND    crv.version_number        = hpr.version_number
9756    AND    crv.course_cd             = p_course_cd
9757    AND    crv.version_number        = cp_crv_version_number
9758    AND    hpud.course_cd            = crv.course_cd
9759    AND    hpud.crv_version_number   = crv.version_number
9760    AND    hpud.cal_type             = p_cal_type
9761    AND    hpud.attendance_mode      = p_attendance_mode
9762    AND    hpud.attendance_type      = p_attendance_type
9763    AND    hpud.location_cd          = p_location_cd
9764    AND    hpud.unit_set_cd          = p_unit_set_cd
9765    AND    hpud.us_version_number    = p_us_version_number
9766    AND    pop.course_cd             = p_course_cd
9767    AND    pop.version_number        = cp_crv_version_number
9768    AND    pop.cal_type              = p_cal_type
9769    AND    pop.attendance_mode      = p_attendance_mode
9770    AND    pop.attendance_type      = p_attendance_type
9771    AND    pop.location_cd          = p_location_cd  ;
9772 
9773    CURSOR c_adm (p_admission_appl_number   igs_he_ad_dtl.admission_appl_number%TYPE,
9774                  p_nominated_course_cd     igs_he_ad_dtl.nominated_course_cd%TYPE ,
9775                  p_sequence_number         igs_he_ad_dtl.sequence_number%TYPE) IS
9776    SELECT had.occupation_cd,
9777           had.domicile_cd,
9778           had.social_class_cd ,
9779           had.special_student_cd
9780    FROM   igs_he_ad_dtl        had
9781    WHERE  had.person_id             = p_person_id
9782    AND    had.admission_appl_number = p_admission_appl_number
9783    AND    had.nominated_course_cd   = p_nominated_course_cd
9784    AND    had.sequence_number       = p_sequence_number;
9785 
9786    l_message              VARCHAR2(2000);
9787 
9788       -- smaddali added following cursors for HECR214 - term based fees enhancement build, bug#3291656
9789 
9790       -- Get the latest Term record for the Leavers,where the student left date lies between term start and end dates
9791       CURSOR c_term1_lev( cp_person_id  igs_en_spa_terms.person_id%TYPE,
9792                           cp_course_cd  igs_en_spa_terms.program_cd%TYPE,
9793                           cp_lev_dt  DATE ) IS
9794       SELECT  tr.program_version , tr.acad_cal_type, tr.location_cd, tr.attendance_mode, tr.attendance_type, tr.fee_cat
9795       FROM  igs_en_spa_terms tr , igs_ca_inst_all ca
9796       WHERE  tr.term_cal_type = ca.cal_type AND
9797              tr.term_sequence_number = ca.sequence_number AND
9798              tr.person_id = cp_person_id AND
9799              tr.program_cd = cp_course_cd AND
9800              cp_lev_dt BETWEEN ca.start_dt AND ca.end_dt
9801       ORDER BY  ca.start_dt DESC;
9802       c_term1_lev_rec   c_term1_lev%ROWTYPE ;
9803 
9804       -- Get the latest Term record for the Leavers just before the student left
9805       CURSOR c_term2_lev( cp_person_id          igs_en_spa_terms.person_id%TYPE,
9806                           cp_course_cd          igs_en_spa_terms.program_cd%TYPE,
9807                           cp_lev_dt             DATE,
9808                           cp_enrl_start_dt      igs_he_submsn_header.enrolment_start_date%TYPE,
9809                           cp_enrl_end_dt        igs_he_submsn_header.enrolment_end_date%TYPE ) IS
9810       SELECT  tr.program_version , tr.acad_cal_type, tr.location_cd, tr.attendance_mode, tr.attendance_type , tr.fee_cat
9811       FROM  igs_en_spa_terms tr , igs_ca_inst_all ca
9812       WHERE  tr.term_cal_type = ca.cal_type AND
9813              tr.term_sequence_number = ca.sequence_number AND
9814              tr.person_id = cp_person_id AND
9815              tr.program_cd = cp_course_cd AND
9816              cp_lev_dt > ca.start_dt AND
9817              ca.start_dt BETWEEN cp_enrl_start_dt AND cp_enrl_end_dt
9818       ORDER BY  ca.start_dt DESC;
9819       c_term2_lev_rec    c_term2_lev%ROWTYPE ;
9820 
9821       -- Get the latest term record for the Continuing students, where the term start date lies in the HESA submission period
9822       CURSOR c_term_con ( cp_person_id          igs_en_spa_terms.person_id%TYPE,
9823                           cp_course_cd          igs_en_spa_terms.program_cd%TYPE,
9824                           cp_enrl_start_dt      igs_he_submsn_header.enrolment_start_date%TYPE,
9825                           cp_enrl_end_dt        igs_he_submsn_header.enrolment_end_date%TYPE ) IS
9826       SELECT  tr.program_version , tr.acad_cal_type, tr.location_cd, tr.attendance_mode, tr.attendance_type, tr.fee_cat
9827       FROM  igs_en_spa_terms tr , igs_ca_inst_all ca
9828       WHERE  tr.term_cal_type = ca.cal_type AND
9829              tr.term_sequence_number = ca.sequence_number AND
9830              tr.person_id = cp_person_id AND
9831              tr.program_cd = cp_course_cd AND
9832              ca.start_dt BETWEEN cp_enrl_start_dt AND cp_enrl_end_dt
9833       ORDER BY  ca.start_dt DESC;
9834       c_term_con_rec    c_term_con%ROWTYPE ;
9835       l_lev_dt   igs_en_stdnt_ps_att_all.discontinued_dt%TYPE ;
9836 
9837       -- smaddali added cursor for bug#3361317
9838       CURSOR c_pers_number ( cp_person_id igs_pe_person_base_v.person_id%TYPE) IS
9839       SELECT party_number person_number
9840       FROM hz_parties
9841       WHERE party_id = cp_person_id ;
9842       l_person_number igs_pe_Person_base_v.person_number%TYPE;
9843 
9844    BEGIN
9845 
9846       -- Fetch the Person Details
9847       g_pe_person       := NULL;
9848       -- smaddali seperated person statistics details from person details cursor c_pers for bug#3361317
9849       OPEN c_pers ;
9850       FETCH c_pers INTO g_pe_person.person_number,
9851                         g_pe_person.person_name,
9852                         g_pe_person.surname  ,
9853                         g_pe_person.given_names,
9854                         g_pe_person.middle_name,
9855                         g_pe_person.title  ,
9856                         g_pe_person.preferred_name,
9857                         g_pe_person.preferred_given_name,
9858                         g_pe_person.sex,
9859                         g_pe_person.birth_dt ,
9860                         g_pe_person.full_name ;
9861       IF c_pers%NOTFOUND
9862       THEN
9863           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_PSN_NOT_FOUND');
9864           l_message := Fnd_Message.Get;
9865 
9866           -- Initialize Record to Null.
9867           g_he_ext_run_except := NULL;
9868 
9869           -- smaddali added code to derive person number to be shown in the exception report, bug#3361317
9870           l_person_number := NULL;
9871           OPEN c_pers_number(p_person_id );
9872           FETCH c_pers_number INTO l_person_number;
9873           CLOSE c_pers_number ;
9874 
9875           -- Populate the required fields.
9876           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
9877           g_he_ext_run_except.exception_reason    := l_message;
9878           g_he_ext_run_except.person_id           := p_person_id;
9879           g_he_ext_run_except.person_number       := l_person_number;
9880           g_he_ext_run_except.course_cd           := p_course_cd;
9881           g_he_ext_run_except.crv_version_number  := p_crv_version_number;
9882 
9883           -- Call procedure to log error
9884           log_error (g_he_ext_run_except);
9885 
9886          -- Dont process this student any further
9887          CLOSE c_pers;
9888          RETURN FALSE;
9889       END IF;
9890 
9891       CLOSE c_pers;
9892 
9893       -- Fetch the Person statistics Details
9894       -- jbaber modified to include marital status for HEFD350
9895       g_pe_stat_v       := NULL;
9896       OPEN c_pe_stats(g_he_submsn_header.enrolment_start_date,
9897                   g_he_submsn_header.enrolment_end_date);
9898       FETCH c_pe_stats INTO g_pe_stat_v.ethnic_origin_id,
9899                         g_pe_stat_v.religion, g_pe_stat_v.marital_status;
9900       CLOSE c_pe_stats;
9901 
9902       -- Fetch the Student Program Attempt Details
9903       g_en_stdnt_ps_att := NULL ;
9904       g_he_st_spa       := NULL;
9905       g_ps_type         := NULL ;
9906       OPEN   c_spa;
9907       FETCH c_spa INTO g_en_stdnt_ps_att.version_number,
9908                       g_en_stdnt_ps_att.cal_type,
9909                       g_en_stdnt_ps_att.location_cd ,
9910                       g_en_stdnt_ps_att.attendance_mode,
9911                       g_en_stdnt_ps_att.attendance_type,
9912                       g_en_stdnt_ps_att.coo_id ,
9913                       g_en_stdnt_ps_att.student_confirmed_ind,
9914                       g_en_stdnt_ps_att.commencement_dt ,
9915                       g_en_stdnt_ps_att.course_attempt_status,
9916                       g_en_stdnt_ps_att.progression_status ,
9917                       g_en_stdnt_ps_att.discontinued_dt,
9918                       g_en_stdnt_ps_att.discontinuation_reason_cd,
9919                       g_en_stdnt_ps_att.funding_source ,
9920                       g_en_stdnt_ps_att.exam_location_cd,
9921                       g_en_stdnt_ps_att.course_rqrmnt_complete_ind,
9922                       g_en_stdnt_ps_att.course_rqrmnts_complete_dt,
9923                       g_en_stdnt_ps_att.override_time_limitation,
9924                       g_en_stdnt_ps_att.advanced_standing_ind,
9925                       g_en_stdnt_ps_att.fee_cat,
9926                       g_en_stdnt_ps_att.adm_admission_appl_number,
9927                       g_en_stdnt_ps_att.adm_nominated_course_cd,
9928                       g_en_stdnt_ps_att.adm_sequence_number,
9929                       g_he_st_spa.fe_student_marker,
9930                       g_he_st_spa.domicile_cd,
9931                       g_he_st_spa.inst_last_attended,
9932                       g_he_st_spa.year_left_last_inst ,
9933                       g_he_st_spa.highest_qual_on_entry ,
9934                       g_he_st_spa.date_qual_on_entry_calc ,
9935                       g_he_st_spa.a_level_point_score,
9936                       g_he_st_spa.highers_points_scores ,
9937                       g_he_st_spa.occupation_code,
9938                       g_he_st_spa.commencement_dt,
9939                       g_he_st_spa.special_student,
9940                       g_he_st_spa.student_qual_aim,
9941                       g_he_st_spa.student_fe_qual_aim ,
9942                       g_he_st_spa.teacher_train_prog_id ,
9943                       g_he_st_spa.itt_phase,
9944                       g_he_st_spa.bilingual_itt_marker ,
9945                       g_he_st_spa.teaching_qual_gain_sector ,
9946                       g_he_st_spa.teaching_qual_gain_subj1,
9947                       g_he_st_spa.teaching_qual_gain_subj2,
9948                       g_he_st_spa.teaching_qual_gain_subj3,
9949                       g_he_st_spa.hesa_return_name,
9950                       g_he_st_spa.hesa_return_id,
9951                       g_he_st_spa.hesa_submission_name,
9952                       g_he_st_spa.associate_ucas_number,
9953                       g_he_st_spa.associate_scott_cand ,
9954                       g_he_st_spa.associate_teach_ref_num,
9955                       g_he_st_spa.associate_nhs_reg_num,
9956                       g_he_st_spa.itt_prog_outcome,
9957                       g_he_st_spa.nhs_funding_source ,
9958                       g_he_st_spa.ufi_place,
9959                       g_he_st_spa.postcode ,
9960                       g_he_st_spa.social_class_ind ,
9961                       g_he_st_spa.destination,
9962                       g_he_st_spa.occcode,
9963                       g_he_st_spa.total_ucas_tariff ,
9964                       g_he_st_spa.nhs_employer,
9965                       g_he_st_spa.return_type,
9966                       g_he_st_spa.student_inst_number,
9967                       g_he_st_spa.qual_aim_subj1,
9968                       g_he_st_spa.qual_aim_subj2,
9969                       g_he_st_spa.qual_aim_subj3,
9970                       g_he_st_spa.qual_aim_proportion,
9971                       g_he_st_spa.dependants_cd,
9972                       g_he_st_spa.enh_fund_elig_cd,
9973                       g_he_st_spa.implied_fund_rate,
9974                       g_he_st_spa.gov_initiatives_cd,
9975                       g_he_st_spa.units_completed,
9976                       g_he_st_spa.units_for_qual,
9977                       g_he_st_spa.disadv_uplift_elig_cd,
9978                       g_he_st_spa.disadv_uplift_factor,
9979                       g_he_st_spa.franch_out_arr_cd,
9980                       g_he_st_spa.employer_role_cd,
9981                       g_he_st_spa.franch_partner_cd,
9982                       g_ps_type.course_type;
9983 
9984       IF c_spa%NOTFOUND
9985       THEN
9986           -- If SPA details were not found, then log error
9987           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_SPA_DTL_NOT_FOUND');
9988           l_message := Fnd_Message.Get;
9989 
9990           -- Initialize Record to Null.
9991           g_he_ext_run_except := NULL;
9992 
9993           -- Populate the required fields.
9994           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
9995           g_he_ext_run_except.exception_reason    := l_message;
9996           g_he_ext_run_except.person_id           := p_person_id;
9997           g_he_ext_run_except.course_cd           := p_course_cd;
9998           g_he_ext_run_except.crv_version_number  := p_crv_version_number;
9999           g_he_ext_run_except.person_number       := g_pe_person.person_number;
10000 
10001           -- Call procedure to log error
10002           log_error (g_he_ext_run_except);
10003 
10004          -- Dont process this student any further
10005          CLOSE c_spa;
10006          RETURN FALSE;
10007       END IF; -- SPA record not found
10008 
10009       CLOSE c_spa;
10010 
10011 
10012         -- smaddali added following code for HECR214 - term based fees enhancement build , Bug#3291656
10013         -- to get version_number,cal_type,location_cd, attendance_type and mode from the Term record
10014         -- Get the Leaving date for the student
10015         l_lev_dt     := NULL;
10016         l_lev_dt       := NVL(g_en_stdnt_ps_att.course_rqrmnts_complete_dt,g_en_stdnt_ps_att.discontinued_dt) ;
10017 
10018         -- If the student is a leaver(i.e leaving date falls within the HESA Submission period)
10019         -- then get the latest term rec where the leaving date falls within the term calendar start and end dates
10020         IF  l_lev_dt BETWEEN g_he_submsn_header.enrolment_start_date AND g_he_submsn_header.enrolment_end_date THEN
10021                  -- get the latest term record within which the Leaving date falls
10022                  c_term1_lev_rec        := NULL ;
10023                  OPEN c_term1_lev (p_person_id, p_course_cd, l_lev_dt );
10024                  FETCH c_term1_lev INTO c_term1_lev_rec ;
10025                  IF c_term1_lev%NOTFOUND THEN
10026                      -- Get the latest term record just before the Leaving date
10027                      c_term2_lev_rec    := NULL ;
10028                      OPEN c_term2_lev(p_person_id, p_course_cd, l_lev_dt,g_he_submsn_header.enrolment_start_date,
10029                    g_he_submsn_header.enrolment_end_date ) ;
10030                      FETCH c_term2_lev INTO c_term2_lev_rec ;
10031                      IF  c_term2_lev%FOUND THEN
10032                              -- Override the location_cd,cal_type,version_number,attendance_type,attendance_mode
10033                              -- in the SCA record with the term record values
10034                              g_en_stdnt_ps_att.version_number       := c_term2_lev_rec.program_version ;
10035                              g_en_stdnt_ps_att.cal_type             := c_term2_lev_rec.acad_cal_type ;
10036                              g_en_stdnt_ps_att.location_cd          := c_term2_lev_rec.location_cd ;
10037                              g_en_stdnt_ps_att.attendance_mode      := c_term2_lev_rec.attendance_mode ;
10038                              g_en_stdnt_ps_att.attendance_type      := c_term2_lev_rec.attendance_type ;
10039                              g_en_stdnt_ps_att.fee_cat              := c_term2_lev_rec.fee_cat ;
10040                      END IF ;
10041                      CLOSE c_term2_lev ;
10042                  ELSE
10043                              -- Override the location_cd,cal_type,version_number,attendance_type,attendance_mode
10044                              -- in the SCA record with the term record values
10045                              g_en_stdnt_ps_att.version_number       := c_term1_lev_rec.program_version ;
10046                              g_en_stdnt_ps_att.cal_type             := c_term1_lev_rec.acad_cal_type ;
10047                              g_en_stdnt_ps_att.location_cd          := c_term1_lev_rec.location_cd ;
10048                              g_en_stdnt_ps_att.attendance_mode      := c_term1_lev_rec.attendance_mode ;
10049                              g_en_stdnt_ps_att.attendance_type      := c_term1_lev_rec.attendance_type ;
10050                              g_en_stdnt_ps_att.fee_cat              := c_term1_lev_rec.fee_cat ;
10051                  END IF ;
10052                  CLOSE c_term1_lev ;
10053 
10054         -- Else the student is continuing student then get the latest term rec
10055         -- where the Term start date falls within the HESA Submission start and end dates
10056         ELSE
10057                 -- Get the latest term record which falls within the FTE period and term start date > commencement dt
10058                 c_term_con_rec  := NULL ;
10059                 OPEN c_term_con(p_person_id, p_course_cd, g_he_submsn_header.enrolment_start_date,
10060                    g_he_submsn_header.enrolment_end_date );
10061                 FETCH c_term_con INTO c_term_con_rec ;
10062                 IF c_term_con%FOUND THEN
10063                      -- Override the location_cd,cal_type,version_number,attendance_type,attendance_mode
10064                      -- in the SCA record with the term record values
10065                      g_en_stdnt_ps_att.version_number       := c_term_con_rec.program_version ;
10066                      g_en_stdnt_ps_att.cal_type             := c_term_con_rec.acad_cal_type ;
10067                      g_en_stdnt_ps_att.location_cd          := c_term_con_rec.location_cd ;
10068                      g_en_stdnt_ps_att.attendance_mode      := c_term_con_rec.attendance_mode ;
10069                      g_en_stdnt_ps_att.attendance_type      := c_term_con_rec.attendance_type ;
10070                      g_en_stdnt_ps_att.fee_cat              := c_term_con_rec.fee_cat ;
10071                 END IF ;
10072                 CLOSE c_term_con ;
10073         END IF ; -- if student is leaving / continuing
10074 
10075       -- Get Award Conferral Dates
10076       igs_he_extract_fields_pkg.get_awd_conferral_dates
10077                            (g_awd_table,
10078                             g_he_ext_run_dtls.submission_name,
10079                             g_prog_rec_flag,
10080                             g_prog_type_rec_flag,
10081                             p_course_cd,
10082                             g_ps_type.course_type,
10083                             g_he_submsn_header.enrolment_start_date,
10084                             g_he_submsn_header.enrolment_end_date,
10085                             l_awd_conf_start_dt,
10086                             l_awd_conf_end_dt);
10087 
10088       -- Get Year of Program Details
10089       g_as_su_setatmpt  := NULL;
10090       g_he_en_susa      := NULL;
10091       OPEN  c_yop (g_he_submsn_header.enrolment_start_date,
10092                    g_he_submsn_header.enrolment_end_date,
10093                    l_awd_conf_start_dt,
10094                    l_awd_conf_end_dt);
10095       FETCH c_yop INTO g_as_su_setatmpt.unit_set_cd,
10096                        g_as_su_setatmpt.us_version_number,
10097                        g_as_su_setatmpt.sequence_number,
10098                        g_as_su_setatmpt.selection_dt,
10099                        g_as_su_setatmpt.end_dt,
10100                        g_as_su_setatmpt.rqrmnts_complete_ind,
10101                        g_as_su_setatmpt.rqrmnts_complete_dt,
10102                        g_he_en_susa.new_he_entrant_cd,
10103                        g_he_en_susa.term_time_accom ,
10104                        g_he_en_susa.disability_allow,
10105                        g_he_en_susa.additional_sup_band,
10106                        g_he_en_susa.sldd_discrete_prov,
10107                        g_he_en_susa.study_mode,
10108                        g_he_en_susa.study_location ,
10109                        g_he_en_susa.fte_perc_override,
10110                        g_he_en_susa.franchising_activity,
10111                        g_he_en_susa.completion_status,
10112                        g_he_en_susa.good_stand_marker,
10113                        g_he_en_susa.complete_pyr_study_cd,
10114                        g_he_en_susa.credit_value_yop1,
10115                        g_he_en_susa.credit_value_yop2,
10116                        g_he_en_susa.credit_value_yop3,
10117                        g_he_en_susa.credit_value_yop4,
10118                        g_he_en_susa.credit_level_achieved1,
10119                        g_he_en_susa.credit_level_achieved2,
10120                        g_he_en_susa.credit_level_achieved3,
10121                        g_he_en_susa.credit_level_achieved4,
10122                        g_he_en_susa.credit_pt_achieved1,
10123                        g_he_en_susa.credit_pt_achieved2,
10124                        g_he_en_susa.credit_pt_achieved3,
10125                        g_he_en_susa.credit_pt_achieved4,
10126                        g_he_en_susa.credit_level1,
10127                        g_he_en_susa.credit_level2,
10128                        g_he_en_susa.credit_level3,
10129                        g_he_en_susa.credit_level4,
10130                        g_he_en_susa.grad_sch_grade,
10131                        g_he_en_susa.mark,
10132                        g_he_en_susa.teaching_inst1,
10133                        g_he_en_susa.teaching_inst2,
10134                        g_he_en_susa.pro_not_taught,
10135                        g_he_en_susa.fundability_code,
10136                        g_he_en_susa.fee_eligibility,
10137                        g_he_en_susa.fee_band,
10138                        g_he_en_susa.non_payment_reason,
10139                        g_he_en_susa.student_fee,
10140                        g_he_en_susa.calculated_fte,
10141                        g_he_en_susa.fte_intensity,
10142                        g_he_en_susa.type_of_year,
10143                        g_he_en_susa.year_stu,
10144                        g_he_en_susa.enh_fund_elig_cd,
10145                        g_he_en_susa.additional_sup_cost,
10146                        g_he_en_susa.disadv_uplift_factor;
10147 
10148       IF c_yop%NOTFOUND
10149       THEN
10150           -- If Year of Program details were not found, then log error
10151           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_YOP_NOT_FOUND');
10152           l_message := Fnd_Message.Get;
10153 
10154           -- Initialize Record to Null.
10155           g_he_ext_run_except := NULL;
10156 
10157           -- Populate the required fields.
10158           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
10159           g_he_ext_run_except.exception_reason    := l_message;
10160           g_he_ext_run_except.person_id           := p_person_id;
10161           g_he_ext_run_except.course_cd           := p_course_cd;
10162           g_he_ext_run_except.crv_version_number  := p_crv_version_number;
10163           g_he_ext_run_except.person_number       := g_pe_person.person_number;
10164 
10165           -- Call procedure to log error
10166           log_error (g_he_ext_run_except);
10167 
10168          -- Dont process this student any further
10169          CLOSE c_yop;
10170          RETURN FALSE;
10171       END IF; -- YOP record not found
10172 
10173       CLOSE c_yop;
10174 
10175       g_ps_ver          := NULL;
10176       g_ps_ofr_opt      := NULL;
10177       g_he_st_prog      := NULL;
10178       g_he_poous        := NULL;
10179       -- smaddali passing g_en_stdnt_ps_att.version_number instead of p_crv_version_number, for HECR214 build
10180       OPEN c_crse (g_en_stdnt_ps_att.cal_type,
10181                    g_en_stdnt_ps_att.attendance_mode,
10182                    g_en_stdnt_ps_att.attendance_type,
10183                    g_en_stdnt_ps_att.location_cd,
10184                    g_as_su_setatmpt.unit_set_cd,
10185                    g_as_su_setatmpt.us_version_number,
10186                    g_en_stdnt_ps_att.version_number);
10187      -- smaddali modified this cursor to select funding_source field from igs_he_poous for hefd208 - bug#2717751
10188       FETCH c_crse INTO g_ps_ver.title,
10189                         g_ps_ver.std_annual_load,
10190                         g_ps_ofr_opt.program_length,
10191                         g_ps_ofr_opt.program_length_measurement,
10192                         g_ps_ver.contact_hours,
10193                         g_ps_ver.govt_special_course_type,
10194                         g_he_st_prog.teacher_train_prog_id,
10195                         g_he_st_prog.itt_phase ,
10196                         g_he_st_prog.bilingual_itt_marker ,
10197                         g_he_st_prog.teaching_qual_sought_sector,
10198                         g_he_st_prog.teaching_qual_sought_subj1,
10199                         g_he_st_prog.teaching_qual_sought_subj2,
10200                         g_he_st_prog.teaching_qual_sought_subj3,
10201                         g_he_st_prog.location_of_study ,
10202                         g_he_st_prog.other_inst_prov_teaching1,
10203                         g_he_st_prog.other_inst_prov_teaching2,
10204                         g_he_st_prog.prop_teaching_in_welsh ,
10205                         g_he_st_prog.prop_not_taught,
10206                         g_he_st_prog.credit_transfer_scheme ,
10207                         g_he_st_prog.return_type,
10208                         g_he_st_prog.default_award,
10209                         g_he_st_prog.program_calc ,
10210                         g_he_st_prog.level_applicable_to_funding,
10211                         g_he_st_prog.franchising_activity,
10212                         g_he_st_prog.nhs_funding_source,
10213                         g_he_st_prog.fe_program_marker,
10214                         g_he_st_prog.fee_band  ,
10215                         g_he_st_prog.fundability,
10216                         g_he_st_prog.implied_fund_rate,
10217                         g_he_st_prog.gov_initiatives_cd,
10218                         g_he_st_prog.units_for_qual,
10219                         g_he_st_prog.disadv_uplift_elig_cd,
10220                         g_he_st_prog.franch_out_arr_cd,
10221                         g_he_poous.location_of_study,
10222                         g_he_poous.mode_of_study,
10223                         g_he_poous.ufi_place ,
10224                         g_he_poous.franchising_activity,
10225                         g_he_poous.type_of_year,
10226                         g_he_poous.leng_current_year,
10227                         g_he_poous.grading_schema_cd,
10228                         g_he_poous.gs_version_number,
10229                         g_he_poous.credit_value_yop1,
10230                         g_he_poous.level_credit1    ,
10231                         g_he_poous.credit_value_yop2,
10232                         g_he_poous.level_credit2    ,
10233                         g_he_poous.credit_value_yop3,
10234                         g_he_poous.level_credit3    ,
10235                         g_he_poous.credit_value_yop4,
10236                         g_he_poous.level_credit4    ,
10237                         g_he_poous.fte_intensity  ,
10238                         g_he_poous.other_instit_teach1,
10239                         g_he_poous.other_instit_teach2,
10240                         g_he_poous.prop_not_taught,
10241                         g_he_poous.fundability_cd,
10242                         g_he_poous.fee_band,
10243                         g_he_poous.level_applicable_to_funding,
10244                         g_he_poous.funding_source ;
10245 
10246       IF c_crse%NOTFOUND
10247       THEN
10248           -- If Course details were not found, then log error
10249           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_CRSE_DTL_NOT_FOUND');
10250           l_message := Fnd_Message.Get;
10251 
10252           -- Initialize Record to Null.
10253           g_he_ext_run_except := NULL;
10254 
10255           -- Populate the required fields.
10256           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
10257           g_he_ext_run_except.exception_reason    := l_message;
10258           g_he_ext_run_except.person_id           := p_person_id;
10259           g_he_ext_run_except.course_cd           := p_course_cd;
10260           g_he_ext_run_except.crv_version_number  := p_crv_version_number;
10261           g_he_ext_run_except.person_number       := g_pe_person.person_number;
10262 
10263           -- Call procedure to log error
10264           log_error (g_he_ext_run_except);
10265 
10266          -- Dont process this student any further
10267          CLOSE c_crse;
10268          RETURN FALSE;
10269       END IF; -- Crse record not found
10270 
10271       CLOSE c_crse;
10272 
10273       --smaddali added this code to initialize cursor variable for bug 2417370
10274       g_he_ad_dtl := NULL ;
10275       OPEN  c_adm (g_en_stdnt_ps_att.adm_admission_appl_number,
10276                   g_en_stdnt_ps_att.adm_nominated_course_cd,
10277                   g_en_stdnt_ps_att.adm_sequence_number);
10278       FETCH c_adm INTO g_he_ad_dtl.occupation_cd,
10279                        g_he_ad_dtl.domicile_cd,
10280                        g_he_ad_dtl.social_class_cd ,
10281                        g_he_ad_dtl.special_student_cd;
10282       CLOSE c_adm;
10283 
10284       process_fields
10285              (p_extract_run_id         => p_extract_run_id,
10286               p_person_id              => p_person_id,
10287               p_course_cd              => p_course_cd,
10288               p_crv_version_number     => p_crv_version_number,
10289               p_student_inst_number    => p_student_inst_number,
10290               p_unit_cd                => NULL,
10291               p_uv_version_number      => NULL,
10292               p_line_number            => p_line_number);
10293 
10294       RETURN TRUE;
10295 
10296       EXCEPTION
10297       WHEN OTHERS
10298       THEN
10299           write_to_log(SQLERRM);
10300           -- Close Cursors
10301           IF c_pers%ISOPEN
10302           THEN
10303               CLOSE c_pers;
10304           END IF;
10305 
10306           IF c_spa%ISOPEN
10307           THEN
10308               CLOSE c_spa;
10309           END IF;
10310 
10311           IF c_yop%ISOPEN
10312           THEN
10313               CLOSE c_yop;
10314           END IF;
10315 
10316           IF c_adm%ISOPEN
10317           THEN
10318               CLOSE c_adm;
10319           END IF;
10320 
10321           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
10322           Fnd_Message.Set_Token('NAME',
10323                                 'IGS_HE_EXTRACT2_PKG.process_comb_stdnt_return');
10324           IGS_GE_MSG_STACK.ADD;
10325           App_Exception.Raise_Exception;
10326    END process_comb_stdnt_return;
10327 
10328 
10329    /*----------------------------------------------------------------------
10330    This function does the processing for a Module Return
10331    It will select all the required details and then call the individual
10332    procedures to derive the field values.
10333 
10334    Parameters :
10335    p_extract_run_id         The Extract Run Id
10336    p_unit_cd                Unit Code
10337    p_uv_version_number      Version Number of the Unit Code
10338    p_line_number            Line Number of the current line being processed
10339    ----------------------------------------------------------------------*/
10340    FUNCTION process_module_return
10341              (p_extract_run_id      igs_he_ext_run_dtls.extract_run_id%TYPE,
10342               p_unit_cd             igs_he_ex_rn_dat_ln.unit_cd%TYPE,
10343               p_uv_version_number   igs_he_ex_rn_dat_ln.uv_version_number%TYPE,
10344               p_line_number         igs_he_ex_rn_dat_ln.line_number%TYPE)
10345              RETURN BOOLEAN
10346    IS
10347    --smaddali modified the order of columns because they donot match that of the Fetch statement bug 2417454
10348    CURSOR c_moddtl IS
10349    SELECT a.prop_of_teaching_in_welsh ,
10350           a.credit_transfer_scheme ,
10351           a.module_length ,
10352           a.proportion_of_fte,
10353           a.location_cd ,
10354           b.title,
10355           b.enrolled_credit_points,
10356           b.unit_level
10357    FROM   igs_he_st_unt_vs  a,
10358           igs_ps_unit_ver_v b
10359    WHERE  a.unit_cd = b.unit_cd
10360    AND    a.version_number = b.version_number
10361    AND    a.unit_cd        = p_unit_cd
10362    AND    a.version_number = p_uv_version_number;
10363 
10364    l_message               VARCHAR2(2000);
10365 
10366    BEGIN
10367 
10368       -- Get the Unit Details
10369       g_he_st_unt_vs    := NULL;
10370       g_ps_unit_ver_v   := NULL;
10371       OPEN c_moddtl;
10372       FETCH c_moddtl INTO g_he_st_unt_vs.prop_of_teaching_in_welsh ,
10373                           g_he_st_unt_vs.credit_transfer_scheme ,
10374                           g_he_st_unt_vs.module_length ,
10375                           g_he_st_unt_vs.proportion_of_fte,
10376                           g_he_st_unt_vs.location_cd,
10377                           g_ps_unit_ver_v.title,
10378                           g_ps_unit_ver_v.enrolled_credit_points,
10379                           g_ps_unit_ver_v.unit_level;
10380 
10381       IF c_moddtl%NOTFOUND
10382       THEN
10383           -- If Module details were not found, then log error
10384           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_MOD_DTL_NOT_FOUND');
10385           l_message := Fnd_Message.Get;
10386 
10387           -- Initialize Record to Null.
10388           g_he_ext_run_except := NULL;
10389 
10390           -- Populate the required fields.
10391           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
10392           g_he_ext_run_except.exception_reason    := l_message;
10393           g_he_ext_run_except.person_id           := NULL;
10394           g_he_ext_run_except.course_cd           := NULL;
10395           g_he_ext_run_except.crv_version_number  := NULL;
10396           g_he_ext_run_except.person_number       := NULL;
10397           g_he_ext_run_except.unit_cd             := p_unit_cd;
10398           g_he_ext_run_except.uv_version_number   := p_uv_version_number;
10399 
10400           -- Call procedure to log error
10401           log_error (g_he_ext_run_except);
10402 
10403          -- Dont process this module any further
10404          CLOSE c_moddtl;
10405          RETURN FALSE;
10406       END IF; -- Module details not found
10407 
10408       CLOSE c_moddtl;
10409 
10410       process_fields
10411              (p_extract_run_id         => p_extract_run_id,
10412               p_person_id              => NULL,
10413               p_course_cd              => NULL,
10414               p_crv_version_number     => NULL,
10415               p_student_inst_number    => NULL,
10416               p_unit_cd                => p_unit_cd,
10417               p_uv_version_number      => p_uv_version_number,
10418               p_line_number            => p_line_number);
10419 
10420       RETURN TRUE;
10421 
10422       EXCEPTION
10423       WHEN OTHERS
10424       THEN
10425           write_to_log(SQLERRM);
10426           IF c_moddtl%ISOPEN
10427           THEN
10428               CLOSE c_moddtl;
10429           END IF;
10430 
10431           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
10432           Fnd_Message.Set_Token('NAME',
10433                                 'IGS_HE_EXTRACT2_PKG.process_module_return');
10434           IGS_GE_MSG_STACK.ADD;
10435           App_Exception.Raise_Exception;
10436    END process_module_return;
10437 
10438 
10439 
10440    /*----------------------------------------------------------------------
10441    This function does the processing for a DLHE Return
10442    It will select all the required details and then call the individual
10443    procedures to derive the field values.
10444 
10445    Parameters :
10446    p_extract_run_id         The Extract Run Id
10447    p_person_id              Person Id
10448    p_line_number            Line Number of the current line being processed
10449    ----------------------------------------------------------------------*/
10450    FUNCTION process_dlhe_return
10451              (p_extract_run_id      igs_he_ext_run_dtls.extract_run_id%TYPE,
10452               p_person_id              igs_he_ex_rn_dat_ln.person_id%TYPE,
10453               p_line_number         igs_he_ex_rn_dat_ln.line_number%TYPE)
10454              RETURN BOOLEAN
10455    IS
10456    /***************************************************************
10457    Created By           :       smaddali
10458    Date Created By      :       9-apr-03
10459    Purpose              :This procedure does the processing for a DLHE Return
10460    Known Limitations,Enhancements or Remarks:
10461    Change History       :
10462    Who                  When                    What
10463 
10464    ***************************************************************/
10465            CURSOR c_dlhe_dtls(cp_submission_name igs_he_submsn_return.submission_name%TYPE ,
10466                               cp_return_name igs_he_submsn_return.return_name%TYPE ) IS
10467            SELECT *
10468            FROM   igs_he_stdnt_dlhe
10469            WHERE  person_id  = p_person_id
10470            AND    submission_name = cp_submission_name
10471            AND    return_name    = cp_return_name ;
10472 
10473            CURSOR c_pers_number IS
10474            SELECT pe.party_number person_number
10475            FROM   hz_parties pe
10476            WHERE  pe.party_id = p_person_id;
10477 
10478            l_message               VARCHAR2(2000);
10479 
10480    BEGIN
10481 
10482       -- Fetch the Person Number
10483       g_pe_person       := NULL;
10484       OPEN c_pers_number;
10485       FETCH c_pers_number INTO g_pe_person.person_number;
10486       IF c_pers_number%NOTFOUND
10487       THEN
10488           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_PSN_NOT_FOUND');
10489           l_message := Fnd_Message.Get;
10490 
10491           -- Initialize Record to Null.
10492           g_he_ext_run_except := NULL;
10493 
10494           -- Populate the required fields.
10495           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
10496           g_he_ext_run_except.exception_reason    := l_message;
10497           g_he_ext_run_except.person_id           := p_person_id;
10498           g_he_ext_run_except.person_number       := p_person_id;
10499           g_he_ext_run_except.course_cd           := NULL;
10500           g_he_ext_run_except.crv_version_number  := NULL;
10501 
10502           -- Call procedure to log error
10503           log_error (g_he_ext_run_except);
10504 
10505          -- Dont process this student any further
10506          CLOSE c_pers_number;
10507          RETURN FALSE;
10508       ELSE
10509          CLOSE c_pers_number;
10510       END IF;
10511 
10512       -- Get the dlhe student Details
10513       g_he_stdnt_dlhe   := NULL;
10514       OPEN c_dlhe_dtls(g_he_ext_run_dtls.submission_name , g_he_ext_run_dtls.return_name);
10515       FETCH c_dlhe_dtls INTO g_he_stdnt_dlhe;
10516 
10517       IF c_dlhe_dtls%NOTFOUND
10518       THEN
10519           -- If dlhe person details were not found, then log error
10520           Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_DLHE_DTL_NOT_FOUND');
10521           l_message := Fnd_Message.Get;
10522 
10523           -- Initialize Record to Null.
10524           g_he_ext_run_except := NULL;
10525 
10526           -- Populate the required fields.
10527           g_he_ext_run_except.extract_run_id      := p_extract_run_id;
10528           g_he_ext_run_except.exception_reason    := l_message;
10529           g_he_ext_run_except.person_id           := p_person_id;
10530           g_he_ext_run_except.course_cd           := NULL;
10531           g_he_ext_run_except.crv_version_number  := NULL;
10532           g_he_ext_run_except.person_number       := g_pe_person.person_number;
10533           g_he_ext_run_except.unit_cd             := NULL;
10534           g_he_ext_run_except.uv_version_number   := NULL;
10535 
10536           -- Call procedure to log error
10537           log_error (g_he_ext_run_except);
10538 
10539          -- Dont process this Student any further
10540          CLOSE c_dlhe_dtls;
10541          RETURN FALSE;
10542       ELSE
10543          CLOSE c_dlhe_dtls;
10544       END IF; -- Student details not found
10545 
10546       process_fields
10547              (p_extract_run_id         => p_extract_run_id,
10548               p_person_id              => p_person_id,
10549               p_course_cd              => NULL,
10550               p_crv_version_number     => NULL,
10551               p_student_inst_number    => NULL,
10552               p_unit_cd                => NULL,
10553               p_uv_version_number      => NULL,
10554               p_line_number            => p_line_number);
10555 
10556       RETURN TRUE;
10557 
10558       EXCEPTION
10559       WHEN OTHERS
10560       THEN
10561           write_to_log(SQLERRM);
10562           IF c_dlhe_dtls%ISOPEN
10563           THEN
10564               CLOSE c_dlhe_dtls;
10565           END IF;
10566 
10567           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
10568           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_dlhe_return');
10569           IGS_GE_MSG_STACK.ADD;
10570           App_Exception.Raise_Exception;
10571    END process_dlhe_return;
10572 
10573 
10574 
10575    /*----------------------------------------------------------------------
10576    This procedure processes the records that have been inserted into
10577    the temporary run table.
10578    For each student / module, it will derive each of the fields and insert
10579    the rows into the extarct run data tables.
10580 
10581    Parameters :
10582    p_extract_run_id     IN     The Extract Run Id
10583    ----------------------------------------------------------------------*/
10584    PROCEDURE process_temp_table
10585           (p_extract_run_id         IN igs_he_ext_run_dtls.extract_run_id%TYPE,
10586            p_module_called_from     IN VARCHAR2,
10587            p_new_run_flag           IN VARCHAR2)
10588    IS
10589    /***************************************************************
10590    Created By           :        Bidisha S
10591    Date Created By      :        28-Jan-02
10592    Purpose              :This procedure processes the records that have been inserted into
10593                          the temporary run table.
10594    Known Limitations,Enhancements or Remarks:
10595    Change History       :
10596    Who       When       What
10597    smaddali  09-apr-03  modified procedure for HEFD203 build , bug 2717745
10598    sjlaport  03-Jun-05  Cache translated error message IGS_HE_EXT_FLD_VAL_NULL bug 4304808
10599    jbaber    15-Mar-06  Better support for recalculated records as per HE365 - Exract Rerun
10600   ***************************************************************/
10601            CURSOR c_get_temp_rows IS
10602            SELECT rowid,
10603                   ext_interim_id,
10604                   person_id,
10605                   course_cd,
10606                   crv_version_number ,
10607                   unit_cd,
10608                   uv_version_number,
10609                   student_inst_number,
10610                   line_number
10611            FROM   igs_he_ext_run_interim
10612            WHERE  extract_run_id = p_extract_run_id;
10613 
10614            l_line_number        igs_he_ex_rn_dat_ln.line_number%TYPE;
10615            l_he_ex_rn_dat_ln    igs_he_ex_rn_dat_ln%ROWTYPE;
10616            l_rowid              VARCHAR2(30);
10617            l_message            VARCHAR2(2000);
10618 
10619 
10620       -- smaddali added cursor for bug#3361317
10621       CURSOR c_pers_number ( cp_person_id igs_pe_person_base_v.person_id%TYPE) IS
10622       SELECT party_number person_number
10623       FROM hz_parties
10624       WHERE party_id = cp_person_id ;
10625       l_person_number igs_pe_Person_base_v.person_number%TYPE;
10626 
10627      TYPE INTRM_RECORDS IS TABLE OF NUMBER(15) NOT NULL INDEX BY BINARY_INTEGER;
10628      l_rec_list INTRM_RECORDS;
10629      l_rec_cnt NUMBER;
10630 
10631    BEGIN
10632 
10633       -- Initialize the global variable at the start of the process
10634       g_default_pro := 'Y';
10635       g_prog_rec_flag := FALSE;
10636       g_prog_type_rec_flag := FALSE;
10637 
10638       -- printing datetimestamp for monitoring performance
10639       fnd_message.set_name('IGS','IGS_HE_ST_PROC_TIME');
10640       fnd_message.set_token('PROCEDURE', 'PROCESS_TEMP_TABLE');
10641       fnd_message.set_token('TIMESTAMP',TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
10642       fnd_file.put_line(fnd_file.log, fnd_message.get);
10643 
10644 
10645       Fnd_Message.Set_Name('IGS', 'IGS_HE_EXT_FLD_VAL_NULL');
10646       g_msg_ext_fld_val_null := Fnd_Message.Get;
10647 
10648       -- Load the field definitions for each field of the return
10649       -- into an array
10650       get_field_defn (p_extract_run_id );
10651 
10652       -- If fields are setup for this submission then process interim table
10653       IF g_field_defn.field_number.COUNT <> 0
10654       THEN
10655 
10656               SELECT MAX(line_number)
10657               INTO   l_line_number
10658               FROM   igs_he_ex_rn_dat_ln
10659               WHERE  extract_run_id = p_extract_run_id;
10660 
10661               l_line_number := Nvl(l_line_number,0) + 1;
10662 
10663               -- Get the rows from the temporary processing table which
10664               -- needs to be processed.
10665 
10666             BEGIN
10667 
10668               l_rec_cnt := 0;
10669 
10670               -- Store values in g_prog_rec_flag and g_prog_type_rec_flag global fields
10671               IF Substr(g_he_submsn_return.record_id,4,2) = '11'
10672               OR Substr(g_he_submsn_return.record_id,4,2) = '12'
10673               THEN
10674 
10675                  igs_he_extract_fields_pkg.get_awd_dtls (g_he_ext_run_dtls.submission_name,
10676                                                          g_awd_table,
10677                                                          g_prog_rec_flag,
10678                                                          g_prog_type_rec_flag);
10679               END IF;
10680 
10681               FOR l_temp_rows IN c_get_temp_rows
10682               LOOP
10683                   -- Initialize record to NULL
10684                   l_he_ex_rn_dat_ln := NULL;
10685 
10686                   SAVEPOINT savepoint_dat_ln_ins;
10687 
10688                   IF Substr(g_he_submsn_return.record_id,4,2) = '11'
10689                   OR Substr(g_he_submsn_return.record_id,4,2) = '12'
10690                   THEN
10691                       -- Student or Combined Return
10692                       l_he_ex_rn_dat_ln.person_id  := l_temp_rows.person_id;
10693                       l_he_ex_rn_dat_ln.course_cd  := l_temp_rows.course_cd;
10694                       l_he_ex_rn_dat_ln.crv_version_number
10695                                                    := l_temp_rows.crv_version_number;
10696                       l_he_ex_rn_dat_ln.student_inst_number
10697                                                    := l_temp_rows.student_inst_number;
10698 
10699                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '13' THEN
10700                       -- Module Return
10701                       l_he_ex_rn_dat_ln.unit_cd            := l_temp_rows.unit_cd;
10702                       l_he_ex_rn_dat_ln.uv_version_number  := l_temp_rows.uv_version_number;
10703                   -- smaddali added processing for DLHE return , HEFD203 nuild bug#2717745
10704                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '18' THEN
10705                       -- DLHE return
10706                       l_he_ex_rn_dat_ln.person_id  := l_temp_rows.person_id;
10707                   END IF;
10708 
10709                   -- Populate table if line does not exist
10710                   IF l_temp_rows.line_number IS NULL
10711                   THEN
10712                       g_field_exists                           := FALSE;
10713                       l_he_ex_rn_dat_ln.extract_run_id         := p_extract_run_id;
10714                       l_he_ex_rn_dat_ln.record_id              := g_he_submsn_return.record_id;
10715                       l_he_ex_rn_dat_ln.line_number            := l_line_number;
10716                       l_he_ex_rn_dat_ln.manually_inserted      := 'N';
10717                       l_he_ex_rn_dat_ln.exclude_from_file      := 'N';
10718 
10719                       -- If process is called from IGSHEE008 then set recalculate flag to Y
10720                       IF p_module_called_from = 'IGSHE008' THEN
10721                          l_he_ex_rn_dat_ln.recalculate_flag    := 'Y';
10722                       ELSE
10723                          l_he_ex_rn_dat_ln.recalculate_flag    := 'N';
10724                       END IF;
10725 
10726                       Igs_He_Ex_Rn_Dat_Ln_Pkg.Insert_Row
10727                            (X_rowid                => l_rowid,
10728                             X_rn_dat_ln_id         => l_he_ex_rn_dat_ln.rn_dat_ln_id,
10729                             X_person_id            => l_he_ex_rn_dat_ln.person_id,
10730                             X_course_cd            => l_he_ex_rn_dat_ln.course_cd,
10731                             X_crv_version_number   => l_he_ex_rn_dat_ln.crv_version_number,
10732                             X_student_inst_number  => l_he_ex_rn_dat_ln.student_inst_number,
10733                             X_unit_cd              => l_he_ex_rn_dat_ln.unit_cd,
10734                             X_uv_version_number    => l_he_ex_rn_dat_ln.uv_version_number,
10735                             X_extract_run_id       => l_he_ex_rn_dat_ln.extract_run_id,
10736                             X_record_id            => l_he_ex_rn_dat_ln.record_id,
10737                             X_line_number          => l_he_ex_rn_dat_ln.line_number,
10738                             X_manually_inserted    => l_he_ex_rn_dat_ln.manually_inserted,
10739                             X_exclude_from_file    => l_he_ex_rn_dat_ln.exclude_from_file,
10740                             X_recalculate_flag     => l_he_ex_rn_dat_ln.recalculate_flag);
10741 
10742                       -- increment line number
10743                       l_line_number := l_line_number + 1;
10744 
10745                   ELSE
10746 
10747                       g_field_exists := TRUE;
10748 
10749                       -- Store the line number for the rows marked as 'recalculate'
10750                       l_he_ex_rn_dat_ln.line_number := l_temp_rows.line_number;
10751 
10752                       -- Update timestamp of recalulated record
10753                       -- to allow filtering on date when creating the extract file.
10754                       -- Also update recalculate flag for any records that were picked up from
10755                       -- person or program criteria.
10756                       UPDATE igs_he_ex_rn_dat_ln
10757                       SET    last_update_date = sysdate,
10758                              recalculate_flag = 'Y'
10759                       WHERE  extract_run_id = p_extract_run_id
10760                       AND    line_number = l_he_ex_rn_dat_ln.line_number;
10761 
10762                   END IF; -- Line already exists?
10763 
10764                   -- smaddali added code to derive person number to be shown in the log file., bug#3361317
10765                   l_person_number := NULL;
10766                   IF l_he_ex_rn_dat_ln.person_id IS NOT NULL THEN
10767                      OPEN c_pers_number(l_he_ex_rn_dat_ln.person_id  );
10768                      FETCH c_pers_number INTO l_person_number;
10769                      CLOSE c_pers_number ;
10770                   END IF ;
10771 
10772                   IF Substr(g_he_submsn_return.record_id,4,2) = '11'
10773                   OR Substr(g_he_submsn_return.record_id,4,2) = '12'
10774                   THEN
10775                       --  Combined Return
10776                       IF NOT process_comb_stdnt_return(p_extract_run_id,
10777                                           l_he_ex_rn_dat_ln.person_id,
10778                                           l_he_ex_rn_dat_ln.course_cd,
10779                                           l_he_ex_rn_dat_ln.crv_version_number,
10780                                           l_he_ex_rn_dat_ln.student_inst_number,
10781                                           l_he_ex_rn_dat_ln.line_number)
10782                       THEN
10783 
10784                         fnd_message.set_name('IGS','IGS_HE_COM_STD_PROC');
10785                         fnd_message.set_token('person',l_person_number);
10786                         fnd_file.put_line(fnd_file.log,fnd_message.get());
10787 
10788 
10789                           -- Not processed successfully, therefore rollback
10790                           -- for this student record
10791                           ROLLBACK TO savepoint_dat_ln_ins;
10792 
10793                           -- Decrement the line number as this line will not
10794                           -- be processed.
10795                           l_line_number := l_line_number - 1;
10796                       END IF;
10797                   ELSIF Substr(g_he_submsn_return.record_id,4,2) = '13' THEN
10798                       -- Module Return
10799                       IF NOT process_module_return(p_extract_run_id,
10800                                             l_he_ex_rn_dat_ln.unit_cd,
10801                                             l_he_ex_rn_dat_ln.uv_version_number,
10802                                             l_he_ex_rn_dat_ln.line_number)
10803                       THEN
10804                           -- Not processed successfully, therefore rollback
10805                           -- for this module record
10806                           ROLLBACK TO savepoint_dat_ln_ins;
10807 
10808                           fnd_message.set_name('IGS','IGS_HE_MOD_PROC');
10809                           fnd_message.set_token('unit',l_he_ex_rn_dat_ln.unit_cd);
10810                           fnd_file.put_line(fnd_file.log,fnd_message.get());
10811 
10812                           -- Decrement the line number as this line will not
10813                           -- be processed.
10814                           l_line_number := l_line_number - 1;
10815                       END IF;
10816                   -- smaddali added code to process dlhe return , for HEFD203 build , bug#2717745
10817                   ELSIF SUBSTR(g_he_submsn_return.record_id,4,2) = '18' THEN
10818                       -- DLHE return
10819                       IF NOT process_dlhe_return(p_extract_run_id,
10820                                             l_he_ex_rn_dat_ln.person_id,
10821                                             l_he_ex_rn_dat_ln.line_number)
10822                       THEN
10823                           -- Not processed successfully, therefore rollback
10824                           -- for this student record
10825                           ROLLBACK TO savepoint_dat_ln_ins;
10826 
10827                           fnd_message.set_name('IGS','IGS_HE_DLHE_PROC');
10828                           fnd_message.set_token('unit',l_person_number);
10829                           fnd_file.put_line(fnd_file.log,fnd_message.get());
10830 
10831                           -- Decrement the line number as this line will not
10832                           -- be processed.
10833                           l_line_number := l_line_number - 1;
10834                       END IF;
10835                   END IF; -- Process fields.
10836 
10837                   l_rec_list(l_rec_cnt) := l_temp_rows.ext_interim_id;
10838                   l_rec_cnt := l_rec_cnt + 1;
10839 
10840                   -- Commit transaction for this row.
10841                   COMMIT;
10842 
10843               END LOOP; -- End Loop for rows from the Interm Processing Table
10844 
10845 
10846             EXCEPTION
10847             WHEN OTHERS THEN
10848               write_to_log(SQLERRM);
10849               ROLLBACK;
10850               -- Delete the records processed before raising the exception
10851               FOR l_rec IN 0 .. l_rec_cnt -1 LOOP
10852                 DELETE FROM igs_he_ext_run_interim WHERE ext_interim_id = l_rec_list(l_rec_cnt);
10853               END LOOP;
10854               -- Commit the Delete Records as they are already processed successfully
10855               COMMIT;
10856               -- Raise The exception
10857               App_Exception.Raise_Exception;
10858             END;
10859 
10860             -- Delete the records from igs_he_ext_run_interim of the current Run ID, p_extract_run_id
10861             -- The direct Delete Statement is used against the standards because of performance improvement only.
10862             -- Same issue was fixed in IGSHE9AB.pls for bug,3179585
10863             DELETE FROM igs_he_ext_run_interim WHERE extract_run_id = p_extract_run_id;
10864 
10865       END IF;
10866 
10867       EXCEPTION
10868       WHEN OTHERS
10869       THEN
10870           write_to_log(SQLERRM);
10871           Fnd_Message.Set_Name('IGS','IGS_GE_UNHANDLED_EXP');
10872           Fnd_Message.Set_Token('NAME','IGS_HE_EXTRACT2_PKG.process_temp_table');
10873           IGS_GE_MSG_STACK.ADD;
10874           App_Exception.Raise_Exception;
10875 
10876    END process_temp_table;
10877 
10878 END IGS_HE_EXTRACT2_PKG;