Wednesday, May 5, 2010

Employee Change Request Application Enginer Code

1.The Final Record format should be Emplid,Name,Date, Total working hours,Total working mins,Late time in hours ,Late time in  mins.
2 Late Time Caluculation Criterias:
Consider the Shift Begin time as Actual entry time and Shift End time as Actual Exit time.
   Late Time=(Entry time - Actual entry time) if employee is coming late   OR             
(Actual Exit Time – ExitTime) if employee is leaving early  OR
   [(Entry time - Actual entry time) + (Actual Exit Time – ExitTime)] for both coming late and leaving early.
Negative values thus obtained should be considered as 0.
In case of multiple Time-In and Time-Out on any particular day, Late Time would be:
(First TimeIn - Actual entry time) + (Second TimeIn – First TimeOut) + (Third TimeIn – Second TimeOut) + (Actual Exit Time – Third TimeOut).
 
Consider the Following fields as constant in calculation of Late Time :
                Actual entry time=8.00
               Actual Exit time=16.00
 
3.Suppose if the employee dont have either Entry time or Exit time,consider that employee is absent for that particular day (Means Track working Time is Zero).
 
If the entry time is more than actual entry time consider that as Actual entry time  & if the exit time is more than actual exit time consider that as Actual exit time.
 
In the data base tables if out time is not there for employee u have to insert intime and vice versa.
 
If i add any new data in the file (for example next day attendence)  it should be inserted in the database  .

Employee Change Request Application Enginer Code

&MYFILE = GetFile("C:\Documents and Settings\Trainees.AST\Desktop\CR2.csv", "R", %FilePath_Absolute);
&MYFILE1 = GetFile("C:\Documents and Settings\Trainees.AST\Desktop\EMPChange Request AE.TXT", "W", %FilePath_Absolute);
&array = CreateArrayRept("", 0);
&array3 = CreateArrayRept("", 0);
&array4 = CreateArrayRept("", 0);
&intime = CreateArrayRept("", 0);
&outtime = CreateArrayRept("", 0);
&entrytime = 8 * 60;
&exittime = 16 * 60;
&num = 8;
rem Local string &str, &str1;
Local Record &R0;

&R0 = CreateRecord(Record.ABC_EMPCR_TBL);

If &MYFILE.IsOpen Then
While &MYFILE.Readline(&string);
&array = Split(&string, ",");
REM &MYFILE1.WRITELINE(&array.LEN);


&MYFILE1.WRITELINE(&array [1]);
&R0.EMPLID.Value = &array [1];
rem &MYFILE1.WRITELINE(&array [2]);
&R0.ABC_EMPCR_NAME.Value = &array [2];
rem &MYFILE1.WRITELINE(&array [4]);
If &array [4] = "" Then
&R0.ABC_EMP_DATE.Value = "";
Else
&R0.ABC_EMP_DATE.Value = DateValue(&array [4]);
End-If;



If &array [5] <> "" And
&array [6] <> "" Then
&str = TimeValue(&array [5]);
&intime = Split(&str, ".");
&str1 = TimeValue(&array [6]);
&outtime = Split(&str1, ".");



&str = &intime [1] * 60;


rem &MYFILE1.writeline("---Tot Late Min when =8-----" | &str);



If &str = &entrytime Then
&inhrs = 8;
&inmins = &intime [2];
&inmins1 = (&intime [1] * 60) + &intime [2];
&entrymins = 0;
&latentrymin = &inmins - &entrymins;
&MYFILE1.writeline("---Total Late Min when Employee logs at 8=" | &latentrymin);
End-If;

If &str < &entrytime Then
&inhrs = 8;
&inmin = 0;
&MYFILE1.writeline("---Total Late Min when Employee logs at <8-----" | &inmin);
&inmins1 = 480;
End-If;
If &str > &entrytime Then
&inmins = (&intime [1] * 60) + &intime [2];
&entrymins = 8 * 60;
&latentrymin = &inmins - &entrymins;
&MYFILE1.writeline("---Total Late Min when Employee logs at >8-----" | &latentrymin);
&inmins1 = (&intime [1] * 60) + &intime [2];
End-If;

If &outtime [1] > 16 Then
&outhrs = 16;
&outmin = 0;
&MYFILE1.writeline("---Total OUT Late Min when Employee logs OUT at >16-----" | &outmin);
&outmins1 = 16 * 60;
End-If;



If &outtime [1] < 16 Then
&outmins = (&outtime [1] * 60) + &outtime [2];
&exitmins = 16 * 60;
&latexitmin = &exitmins - &outmins;
&MYFILE1.writeline("---Total Late Min when Employee logs OUT at <16-----" | &latexitmin);
&outmins1 = (&outtime [1] * 60) + &outtime [2];
End-If;

If &outtime [1] = 16 Then
&outmins = &outtime [2];
&exitmins = 0;
&outmins1 = (&outtime [1] * 60) + &outtime [2];
rem &latexitmin = &outmins - &exitmins;
rem &MYFILE1.writeline("---Tot Late Min when =16-----" |&latentrymin);
End-If;
&totlatemin = &latentrymin + &latexitmin;
&MYFILE1.writeline("---Tot Late Min = &latentrymin + &latexitmin-----" | &totlatemin);

If Mod(&totlatemin, 60) = 0 Then
&latehrs1 = &totlatemin / 60;
&latehrs2 = Round(&latehrs1, 2);
&MYFILE1.writeline("---Total Late hrs when mod=0-----" | &latehrs2);
Else
&latehrs1 = &totlatemin / 60;
&hrs1 = Substring(&latehrs1, 1, 1);
rem &MYFILE1.writeline("---Tot Late hrs when mod != 0 -----" | &hrs1);
&mins1 = Mod(&totlatemin, 60);
&totlthrs = &hrs1 | ":" | &mins1;
rem late hrs1 and late min;
&MYFILE1.writeline("---Employee Total Late hrs when mod != 0 -----" | &totlthrs);
End-If;



&MYFILE1.writeline("---TOTAL OUT MINUTES---" | &outmins1);
&MYFILE1.writeline("---TOTAL IN MINUTES -----" | &inmins1);
&wrkhrs1 = &outmins1 - &inmins1;
&MYFILE1.writeline("---TOTAL WORKING MINUTES &outmins1 - &inmins1-----" | &wrkhrs1);


/*WORKING HOURS*/
If Mod(&wrkhrs1, 60) = 0 Then

&wrkhrs2 = &wrkhrs1 / 60;

&wrkhrs3 = Round(&wrkhrs2, 0);

&MYFILE1.writeline("---Total WORK hrs when mod=0-----" | &wrkhrs3);
Else

&wrkhrs2 = &wrkhrs1 / 60;
&wrkhrs3 = Substring(&wrkhrs2, 1, 1);
rem &MYFILE1.writeline("---Tot Late hrs when mod != 0 -----" | &hrs1);
&wrkmins1 = Mod(&wrkhrs1, 60);
&totwrkhrs = &wrkhrs3 | ":" | &wrkmins1;
rem Tot Working wrkhrs3 and Tot Working wrkmins1;


&MYFILE1.writeline("---EMPLOYEE TOTAL WORKING HOURS -----" | &totwrkhrs);
End-If;


Else
&wrkhrs3 = 0;
&wrkmins1 = 0;
&hrs1 = 0;
&mins1 = 0;
End-If;

&R0.ABC_EMP_WRKTIME.Value = &wrkhrs3;
&R0.ABC_EMP_TOTMIN.Value = &wrkmins1;
&R0.ABC_EMP_LATEHOUR.Value = &hrs1;
&R0.ABC_EMP_LATEMIN.Value = &mins1;

&R0.Insert();


End-While;
End-If;


rem &R0.Update();
&MYFILE.close();

No comments:

Post a Comment