Wednesday, August 3, 2011

Functions with EFFDT and EFFSEQ to get row

1. Obtain the row number of Prior Effective date row.  Does not use row with same date and sequence number as itself.

Function prior_effdt_row(&EFFDT, &EFFSEQ, &PRIORDT, &PRIORSEQ, &PRIOR_ROW);
&ACTIVE_ROW = ActiveRowCount(JOB.EMPLID);
For &I = 1 To &ACTIVE_ROW;
&FETCH_EFFDT = FetchValue(JOB.EFFDT, &I);
&FETCH_EFFSEQ = FetchValue(JOB.EFFSEQ, &I);
If (&FETCH_EFFDT < &EFFDT Or
(&FETCH_EFFDT = &EFFDT And
&FETCH_EFFSEQ < &EFFSEQ)) And
(&FETCH_EFFDT > &PRIORDT Or
(&FETCH_EFFDT = &PRIORDT And
&FETCH_EFFSEQ > &PRIORSEQ)) Then
&PRIORDT = &FETCH_EFFDT;
&PRIORSEQ = &FETCH_EFFSEQ;
&PRIOR_ROW = &I;
End-If;
End-For;
End-Function;

2. Obtain the row number of Prior Effective date row. If it finds row with same effdt and seq row that is not itself, it uses that row.


Function prior_same_effdt(&EFFDT, &EFFSEQ, &CURRENT_ROW, &PRIORDT, &PRIORSEQ, &PRIOR_ROW);
&ACTIVE_ROW = ActiveRowCount(JOB.EMPLID);
For &I = 1 To &ACTIVE_ROW;
&FETCH_EFFDT = FetchValue(JOB.EFFDT, &I);
&FETCH_EFFSEQ = FetchValue(JOB.EFFSEQ, &I);
If (&FETCH_EFFDT < &EFFDT Or
(&FETCH_EFFDT = &EFFDT And
&FETCH_EFFSEQ <= &EFFSEQ)) And
(&FETCH_EFFDT > &PRIORDT Or
(&FETCH_EFFDT = &PRIORDT And
&FETCH_EFFSEQ > &PRIORSEQ)) And
&CURRENT_ROW <> &I Then
&PRIORDT = &FETCH_EFFDT;
&PRIORSEQ = &FETCH_EFFSEQ;
&PRIOR_ROW = &I;
End-If;
End-For;
End-Function;



3. Obtain the row number of Next Effective date row


Function next_effdt_row(&EFFDT, &EFFSEQ, &NEXTDT, &NEXTSEQ, &NEXT_ROW);
&NEXTDT = Date(30001231);
&NEXTSEQ = 9;
&ACTIVE_ROW = ActiveRowCount(JOB.EMPLID);
For &I = 1 To &ACTIVE_ROW;
&FETCH_EFFDT = FetchValue(JOB.EFFDT, &I);
&FETCH_EFFSEQ = FetchValue(JOB.EFFSEQ, &I);
If (&FETCH_EFFDT > &EFFDT Or
(&FETCH_EFFDT = &EFFDT And
&FETCH_EFFSEQ > &EFFSEQ)) And
(&FETCH_EFFDT < &NEXTDT Or
(&FETCH_EFFDT = &NEXTDT And
&FETCH_EFFSEQ < &NEXTSEQ)) Then
&NEXTDT = &FETCH_EFFDT;
&NEXTSEQ = &FETCH_EFFSEQ;
&NEXT_ROW = &I;
End-If;
End-For;
End-Function;



4. Obtain the row number of First Effective date row.


Function first_effdt_row(&FIRSTDT, &FIRSTSEQ, &FIRST_ROW);
&FIRSTDT = Date(30001231);
&FIRSTSEQ = 9;
&ACTIVE_ROW = ActiveRowCount(JOB.EMPLID);
For &I = 1 To &ACTIVE_ROW
&FETCH_EFFDT = FetchValue(JOB.EFFDT, &I);
&FETCH_EFFSEQ = FetchValue(JOB.EFFSEQ, &I);
If (&FETCH_EFFDT < &FIRSTDT Or
(&FETCH_EFFDT = &FIRSTDT And
&FETCH_EFFSEQ < &FIRSTSEQ)) Then
&FIRSTDT = &FETCH_EFFDT;
&FIRSTSEQ = &FETCH_EFFSEQ;
&FIRST_ROW = &I;
End-If;
End-For;
End-Function;



5. Obtain the row number of row matching date and sequence.



Function det_effdt_row(&EFFDT, &EFFSEQ, &ROW);
   &ACTIVE_ROW = ActiveRowCount(JOB.EMPLID);
   For &I = 1 To &ACTIVE_ROW
      &FETCH_EFFDT = FetchValue(JOB.EFFDT, &I);
      &FETCH_EFFSEQ = FetchValue(JOB.EFFSEQ, &I);
      If &FETCH_EFFDT = &EFFDT And
            &FETCH_EFFSEQ = &EFFSEQ Then
         &ROW = &I;
         &I = &ACTIVE_ROW
      End-If;
   End-For;
End-Function;


0 comments:

Post a Comment