Function SET006A: Checkbox in a Browselist

LANSA

Function SET006A: Checkbox in a Browselist
********** COMMENT(=======================================================);
********** COMMENT(Copyright .....: (C) = LANSA SET Team = , 19);
********** COMMENT(99);
********** COMMENT(Process .......: SET_006);
********** COMMENT(Function ......: SET006A);
********** COMMENT(Created by ....: SETUSER);
********** COMMENT(Created on ....: 09/02/00 at 14:46:33);
********** COMMENT(Description ...: Checkbox Selector);
********** COMMENT(=======================================================);
********** COMMENT(Full Description: The purpose of this function is to);
********** COMMENT(to show how to use a checkbox component in a browselist);
********** COMMENT(specifically, how to set the initial state of the);
********** COMMENT(checkbox. It uses the visual component S_006CBOX.);
********** COMMENT();
********** COMMENT(This function was generated using the FRWEBENQ01 templ.);
********** COMMENT(Function control options);
FUNCTION OPTIONS(*WEBEVENT *DIRECT);
********** COMMENT();
********** COMMENT(Group and field definitions);
DEFINE FIELD(#S_COUNT) REFFLD(#LISTCOUNT);
DEFINE FIELD(#S_TCOUNT) REFFLD(#LISTCOUNT);
DEFINE FIELD(#S_ENTRY) REFFLD(#LISTCOUNT);
DEFINE FIELD(#S_EEND) REFFLD(#LISTCOUNT);
DEFINE FIELD(#S_PAGE) REFFLD(#LISTCOUNT) DEFAULT(10);
DEFINE FIELD(#S_LSTENT2) REFFLD(#LISTENTRY) DEFAULT(10);
********** COMMENT(Browselist used to keep the file records);
DEF_LIST NAME(#S_LIST) FIELDS((#EMPNO)(#SURNAME)(#GIVENAME)(#DEPTMENT)(#MNTHSAL)(#PRIFILRRN *HIDDEN)(#S_006CBOX)) COUNTER(#S_COUNT);
********** COMMENT(Browselist displayed. Note that the check box component);
********** COMMENT(MUST have the *INPUT attribute.);
DEF_LIST NAME(#S_LIST2) FIELDS((#S_006CBOX *INPUT)(#EMPNO)(#SURNAME)(#GIVENAME)(#DEPTMENT)(#MNTHSAL)(#PRIFILRRN *HIDDEN));
********** COMMENT();
********** COMMENT(Determine action to take according to STDRENTRY flag);
CASE OF_FIELD(#STDRENTRY);
********** COMMENT();
********** COMMENT(Request selection criteria);
WHEN VALUE_IS('= *blank');
L1: REQUEST FIELDS((#STDNEXT *HIDDEN)(#STDRENTRY *HIDDEN)(#EMPNO)) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
********** COMMENT();
********** COMMENT(Build list according to selection criteria and);
********** COMMENT(build the first page for display);
WHEN VALUE_IS('= N');
CHANGE FIELD(#STDRENTRY) TO(M);
CLR_LIST NAMED(#S_LIST);
CLR_LIST NAMED(#S_LIST2);
********** COMMENT(Read all the records matching the selection criteria);
********** COMMENT(and add them to a browselist.);
SELECT FIELDS(#S_LIST) FROM_FILE(PSLMST) WITH_KEY(#EMPNO) GENERIC(*YES) RETURN_RRN(#PRIFILRRN);
ADD_ENTRY TO_LIST(#S_LIST);
********** COMMENT(If the number of records is not greater than the);
********** COMMENT(desired page size (number of records to display in one);
********** COMMENT(page) add the record also to the displayable browse);
********** COMMENT(list.);
IF COND('#S_COUNT <= #S_PAGE');
ADD_ENTRY TO_LIST(#S_LIST2);
ENDIF;
ENDSELECT;
IF COND('#S_COUNT > 0');
********** COMMENT(Keep counter of the first record in the page shown);
CHANGE FIELD(#S_TCOUNT) TO(1);
ELSE;
********** COMMENT(no records matching the selection criteria.);
CHANGE FIELD(#S_TCOUNT) TO(0);
MESSAGE MSGID(DEM0046) MSGF(DC@M01);
GOTO LABEL(L1);
ENDIF;
********** COMMENT();
********** COMMENT(Build the previous page for display by reading the);
********** COMMENT(browselist with all records in it.);
WHEN VALUE_IS('= M');
********** COMMENT(This subroutine was added to the template generated);
********** COMMENT(code in order to update the saved list thus keeping the);
********** COMMENT(status of the checkbox.);
EXECUTE SUBROUTINE(SAVECURVAL);
CLR_LIST NAMED(#S_LIST2);
CHANGE FIELD(#S_TCOUNT) TO('#S_TCOUNT + #S_PAGE');
CHANGE FIELD(#S_EEND) TO('(#S_TCOUNT + #S_PAGE) - 1');
IF COND('#S_EEND > #S_COUNT');
CHANGE FIELD(#S_EEND) TO(#S_COUNT);
ENDIF;
BEGIN_LOOP USING(#S_ENTRY) FROM(#S_TCOUNT) TO(#S_EEND);
GET_ENTRY NUMBER(#S_ENTRY) FROM_LIST(#S_LIST);
ADD_ENTRY TO_LIST(#S_LIST2);
END_LOOP;
********** COMMENT();
********** COMMENT(Build the previous page for display by reading the);
********** COMMENT(browselist with all records in it.);
WHEN VALUE_IS('= P');
********** COMMENT(This subroutine was added to the template generated);
********** COMMENT(code in order to update the saved list thus keeping the);
********** COMMENT(status of the checkbox.);
EXECUTE SUBROUTINE(SAVECURVAL);
CLR_LIST NAMED(#S_LIST2);
CHANGE FIELD(#S_TCOUNT) TO('#S_TCOUNT - #S_PAGE');
CHANGE FIELD(#S_EEND) TO('(#S_TCOUNT + #S_PAGE) - 1');
BEGIN_LOOP USING(#S_ENTRY) FROM(#S_TCOUNT) TO(#S_EEND);
GET_ENTRY NUMBER(#S_ENTRY) FROM_LIST(#S_LIST);
ADD_ENTRY TO_LIST(#S_LIST2);
END_LOOP;
********** COMMENT();
ENDCASE;
********** COMMENT();
********** COMMENT(Enable the next and previous page buttons.);
CHANGE FIELD(#STDMORE #STDPREV) TO(*BLANK);
IF COND('(#S_TCOUNT + #S_PAGE) *LE #S_COUNT');
CHANGE FIELD(#STDMORE) TO(Y);
ENDIF;
IF COND('(#S_TCOUNT - #S_PAGE) *GT 0');
CHANGE FIELD(#STDPREV) TO(Y);
ENDIF;
********** COMMENT();
********** COMMENT(Display page of data for selection.);
REQUEST FIELDS((#S_PAGE *HIDDEN)(#S_TCOUNT *HIDDEN)(#STDRENTRY *HIDDEN)(#STDPREV *HIDDEN)(#STDMORE *HIDDEN)(#STDSEARCH *HIDDEN)(#STDROWNUM *HIDDEN)) BROWSELIST(#S_LIST2) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
********** COMMENT();
********** COMMENT(Dummy display for additional browse list.);
DISPLAY BROWSELIST(#S_LIST) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
********** COMMENT();
SUBROUTINE NAME(SAVECURVAL);
********** COMMENT();
DEFINE FIELD(#KEEP_EMPN) REFFLD(#EMPNO);
DEFINE FIELD(#KEEP_CBOX) REFFLD(#S_006CBOX);
********** COMMENT(The select loop will read the altered entries. In this);
********** COMMENT(case it is only the checkbox field the one who can be);
********** COMMENT(altered. The values for the checkbox status as they);
********** COMMENT(have been specified in the component are:);
********** COMMENT('Y' for a checked entry);
********** COMMENT(' ' for an unchecked entry);
********** COMMENT(When the browselist is read in order to populate the);
********** COMMENT(displayable browselist, those values will be);
********** COMMENT(interpreted by the Java Script added to the checkbox);
********** COMMENT(component S_006CBOX to determine its state.);
SELECTLIST NAMED(#S_LIST2) GET_ENTRYS(*ALTERED);
CHANGE FIELD(#KEEP_EMPN) TO(#EMPNO);
CHANGE FIELD(#KEEP_CBOX) TO(#S_006CBOX);
BEGIN_LOOP USING(#S_ENTRY);
GET_ENTRY NUMBER(#S_ENTRY) FROM_LIST(#S_LIST);
IF COND('#empno = #keep_empn');
CHANGE FIELD(#S_006CBOX) TO(#KEEP_CBOX);
UPD_ENTRY IN_LIST(#S_LIST);
LEAVE;
ENDIF;
END_LOOP;
ENDSELECT;
********** COMMENT();
ENDROUTINE;