Function SET177C

LANSA

Function SET177C

********** COMMENT(=======================================================);
********** COMMENT(Process ........: SET_177);
********** COMMENT(Function .......: SET177C);
********** COMMENT(Created on .....: 07/06/00 at 10:34:40);
********** COMMENT(Description ....: Display Time sheet);
********** COMMENT(Version.........: 1);
********** COMMENT();
********** COMMENT(Full Description: This function displays the time sheet);
********** COMMENT(for the employee selected in SET177B for the requested);
********** COMMENT(month.);
********** COMMENT();
********** COMMENT(Disclaimer: The following material is supplied as);
********** COMMENT(sample material only. No warranty concerning the);
********** COMMENT(material or its use in any way whatsoever is);
********** COMMENT(expressed or implied.);
********** COMMENT();
********** COMMENT(Minimum Release of LANSA: 8.0);
********** COMMENT();
********** COMMENT(=======================================================);
********** COMMENT(Function control options);
FUNCTION OPTIONS(*DIRECT *WEBEVENT);
********** COMMENT();
********** COMMENT(Group and field definitions);
DEFINE FIELD(#S_177BCMP) TYPE(*CHAR) LENGTH(015);
DEFINE FIELD(#COLOR_FLG) TYPE(*CHAR) LENGTH(001);
********** COMMENT();
DEF_LIST NAME(#S_177TIMS) FIELDS((#S_177BCMP)(#S_177PRJ1 *HIDDEN)(#S_177PRJ2 *HIDDEN)(#S_177PRJ3 *HIDDEN)(#S_177PRJ4 *HIDDEN)(#S_177DAY *HIDDEN)(#S_177HHP1 *HIDDEN)(#S_177HHP2 *HIDDEN)(#S_177HHP3 *HIDDEN)(#S_177HHP4 *HIDDEN)(#DAY_WORD *HIDDEN)(#S_177DAYC *HIDDEN)(#COLOR_FLG *HIDDEN));
GROUP_BY NAME(#PANELDATA) FIELDS((#STDRENTRY *HIDDEN)(#FULLNAME *HIDDEN)(#S_177MNTH *HIDDEN)(#S_177EMPN *HIDDEN));
********** COMMENT();
********** COMMENT(Mainline);
********** COMMENT();
IF COND('#stdrentry *ne Y');
CLR_LIST NAMED(#S_177TIMS);
CHANGE FIELD(#STDRENTRY) TO(Y);
EXECUTE SUBROUTINE(LOAD_TIMSH);
GOTO LABEL(REQ);
ENDIF;
********** COMMENT();
EXECUTE SUBROUTINE(WRITE_TIMS);
********** COMMENT();
REQ: REQUEST FIELDS(#PANELDATA) BROWSELIST(#S_177TIMS) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
********** COMMENT();
SUBROUTINE NAME(LOAD_TIMSH);
********** COMMENT();
EXECUTE SUBROUTINE(PREP_DATE);
********** COMMENT(First, add the start table tag: <TABLE>);
CHANGE FIELD(#S_177BCMP) TO(S_177TSTART);
ADD_ENTRY TO_LIST(#S_177TIMS);
********** COMMENT(Second, add the column headings. These are the specific);
********** COMMENT(projects the employee works for.);
FETCH FIELDS(*ALL) FROM_FILE(SETEMP) WITH_KEY(#S_177EMPN);
USE BUILTIN(BCONCAT) WITH_ARGS(#S_177NAME #S_177SURN) TO_GET(#FULLNAME);
CHANGE FIELD(#S_177BCMP) TO(S_177COLHDG);
ADD_ENTRY TO_LIST(#S_177TIMS);
********** COMMENT(Check whether there is a time sheet for the requested);
********** COMMENT(month. If there is, fill the time sheet with the existin);
********** COMMENT(data, otherwise, fill it with zeros.);
CHANGE FIELD(#S_177DAY) TO(1);
FETCH FIELDS(*ALL) FROM_FILE(SETTIM) WITH_KEY(#S_177EMPN #S_177MNTH #S_177DAY);
IF_STATUS IS(*OKAY);
EXECUTE SUBROUTINE(FILL_EXIST);
ELSE;
EXECUTE SUBROUTINE(FILL_EMPTY);
ENDIF;
********** COMMENT(Last, add the end table tag: </TABLE>);
CHANGE FIELD(#S_177BCMP) TO(S_177TEND);
CHANGE FIELD(#S_177DAY) TO(0);
ADD_ENTRY TO_LIST(#S_177TIMS);
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(FILL_EXIST);
********** COMMENT();
CHANGE FIELD(#S_177BCMP) TO(S_177TDATA);
SELECT FIELDS(#S_177TIMS) FROM_FILE(SETTIM) WITH_KEY(#S_177EMPN #S_177MNTH);
EXECUTE SUBROUTINE(SET_DAT_FL);
ADD_ENTRY TO_LIST(#S_177TIMS);
ENDSELECT;
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(FILL_EMPTY);
********** COMMENT();
CHANGE FIELD(#S_177HHP1 #S_177HHP2 #S_177HHP3 #S_177HHP4) TO(*ZERO);
CHANGE FIELD(#S_177BCMP) TO(S_177TDATA);
BEGIN_LOOP USING(#S_177DAY) TO(#NO_DAYS);
SUBSTRING FIELD(#S_177DAY 1) INTO_FIELD(#S_177DAYC 1);
EXECUTE SUBROUTINE(SET_DAT_FL);
ADD_ENTRY TO_LIST(#S_177TIMS);
END_LOOP;
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(WRITE_TIMS);
********** COMMENT();
CHECK_FOR IN_FILE(SETTIM) WITH_KEY(#S_177EMPN #S_177MNTH) VAL_ERROR(*NEXT);
IF_STATUS IS(*EQUALKEY);
EXECUTE SUBROUTINE(UPD_MONTH);
ELSE;
EXECUTE SUBROUTINE(FILL_MONTH);
ENDIF;
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(FILL_MONTH);
********** COMMENT();
SELECTLIST NAMED(#S_177TIMS);
CONTINUE IF('#s_177day *eq 0');
INSERT FIELDS(*ALL) TO_FILE(SETTIM);
ENDSELECT;
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(UPD_MONTH);
********** COMMENT();
SELECTLIST NAMED(#S_177TIMS);
CONTINUE IF('#s_177day *eq 0');
UPDATE FIELDS((#S_177HHP1)(#S_177HHP2)(#S_177HHP3)(#S_177HHP4)) IN_FILE(SETTIM) WITH_KEY(#S_177EMPN #S_177MNTH #S_177DAY);
ENDSELECT;
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(SET_DAT_FL);
********** COMMENT(Get day in word and set the background color flag for);
********** COMMENT(the week ends.);
USE BUILTIN(CONVERTDATE) WITH_ARGS(#DDMMYYC B R) TO_GET(#DAY_WORD);
IF COND('(#DAY_WORD = SUN) or (#DAY_WORD = SAT)');
CHANGE FIELD(#COLOR_FLG) TO(X);
ELSE;
CHANGE FIELD(#COLOR_FLG) TO(*BLANK);
ENDIF;
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(PREP_DATE);
********** COMMENT(fields to use in CONVERTDATE);
DEFINE FIELD(#DD) TYPE(*CHAR) LENGTH(002) TO_OVERLAY(#DAY_WORD 002);
DEFINE FIELD(#DAY_WORD) TYPE(*CHAR) LENGTH(003);
DEFINE FIELD(#NO_DAYS) TYPE(*DEC) LENGTH(002) DECIMALS(0);
OVERRIDE FIELD(#YEARC) TO_OVERLAY(#DDMMYYC 005);
OVERRIDE FIELD(#S_177DAYC) TO_OVERLAY(#DDMMYYC 001);
OVERRIDE FIELD(#MONTHC) TO_OVERLAY(#DDMMYYC 003);
********** COMMENT();
CASE OF_FIELD(#S_177MNTH);
WHEN VALUE_IS('= JUNE');
CHANGE FIELD(#MONTHC) TO('''06''');
CHANGE FIELD(#NO_DAYS) TO(30);
WHEN VALUE_IS('= MAY');
CHANGE FIELD(#MONTHC) TO('''05''');
CHANGE FIELD(#NO_DAYS) TO(31);
WHEN VALUE_IS('= APRIL');
CHANGE FIELD(#MONTHC) TO('''04''');
CHANGE FIELD(#NO_DAYS) TO(30);
WHEN VALUE_IS('= MARCH');
CHANGE FIELD(#NO_DAYS) TO(31);
CHANGE FIELD(#MONTHC) TO('''03''');
ENDCASE;
ENDROUTINE;