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

Friday, June 26, 2009

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: