Please do post your comments and suggestions for me to improve on chowdary1105@gmail.com

Sunday, August 9, 2009

Date related calucations using rowsets

Local Rowset &RS0, &RS1;
Local date &From_Date, &To_Dt;
&Duration = 0;
&Tot_Holi = 0;
&Sat = 0;
&Sun = 0;
&RS0 = GetLevel0();
&RS1 = &RS0(1).GetRowset(Scroll.SRI_STUMOD_TBL);
For &I = 1 To &RS1.ActiveRowCount
&From_Date=&RS1(I).GetRecord(Record.SRI_STUMOD_TBL).GetField(Field.SRI_STUAB_STD).Value;
&To_Dt =&RS1(&I).GetRecord(Record.SRI_STUMOD_TBL).GetField(Field.SRI_STUAB_END).Value;
While (&From_Date <= &To_Dt);

If (Weekday(&From_Date) = 7) Then
&Sat = &Sat + 1;
End-If;

If (Weekday(&From_Date) = 1) Then
&Sun = &Sun + 1;
End-If;

If Weekday(&From_Date) <> 7 And
Weekday(&From_Date) <> 1 And
&flag <> "x" Then
&Duration = &Duration + 1;

End-If;
&From_Date = AddToDate(&From_Date, 0, 0, 1);

End-While;

&RS1(&I).GetRecord(Record.SRI_STUMOD_TBL).GetField(Field.SRI_STUAB_DURATION).Value = &Duration;
If &Duration > 20 Then
Error MsgGet(11100, 180, "Only 20 leaves per annum please select the correct dates");
End-If;

&RS1(&I).GetRecord(Record.SRI_STUMOD_TBL).GetField(Field.SRI_STUAB_SAT).Value = &Sat;
WinMessage(&Sat, 0);
&Sat = 0;

&RS1(&I).GetRecord(Record.SRI_STUMOD_TBL).GetField(Field.SRI_STUAB_SUN).Value = &Sun;
&Sun = 0;

End-For;

No comments: