Function SET184U
* =======================================================;
* Process ........: SET_184;
* Function .......: SET184U;
* Created on .....: 26/07/00 at 14:43:32;
* Description ....: Sorting columns in a browselist;
* Version.........: 1;
*;
* Full Description: The purpose of this function is to;
* show how to allow the user to sort the browselist;
*;
* Disclaimer: The following material is supplied as an;
* example only. No warranty is expressed or implied.;
*;
* Receives: nothing;
*;
* =======================================================;
* Function control options;
FUNCTION OPTIONS(*DIRECT *WEBEVENT);
*;
* Group and field definitions;
*;
DEFINE FIELD(#S_184SORT) TYPE(*CHAR) LENGTH(004) LABEL('Sort by');
* (This field is used to request the field to sort by;
* from the user.;
* It displayed via component SET184U which displays it;
* as a radio button.);
*;
GROUP_BY NAME(#S_GRPPANL) FIELDS((#S_184FDES *INPUT *NOID) (#STDRENTRY *HIDDEN) (#S_FUNDES *HIDDEN));
* (Field #S_184FDES has a component S_184FDES which;
* merges in a component with the same name as the;
* function (in this case component SET184U));
*;
DEF_LIST NAME(#S_184UFVC) FIELDS(#S_184CDE #S_184DES #S_184QTY #S_184UNIT #S_184UPRC #S_184TPRC);
DEF_LIST NAME(#S_WRKFVC) FIELDS(#S_184CDE #S_184DES #S_184QTY #S_184UNIT #S_184UPRC #S_184TPRC #S_184IMG) TYPE(*WORKING) ENTRYS(0009999);
*;
* Mainline;
*;
*;
CHANGE FIELD(#S_FUNDES) TO(*FUNCTION_DESC);
*;
*;
CASE OF_FIELD(#STDRENTRY);
WHEN VALUE_IS('= *BLANKS');
* first time in - populate list;
CHANGE FIELD(#STDRENTRY) TO(Y);
CLR_LIST NAMED(#S_184UFVC);
* Function SET184Y populates list #S_WRKFVC with data;
CALL PROCESS(*DIRECT) FUNCTION(SET184Y) PASS_LST(#S_WRKFVC);
SELECTLIST NAMED(#S_WRKFVC);
ADD_ENTRY TO_LIST(#S_184UFVC);
ENDSELECT;
* Set requested sort to product code;
CHANGE FIELD(#S_184SORT) TO(CDE);
*;
WHEN VALUE_IS('= Y');
* subsequent iteration;
* sort the list according to the user's selection;
*;
* move the browselist into a working list for sorting;
CLR_LIST NAMED(#S_WRKFVC);
SELECTLIST NAMED(#S_184UFVC);
ADD_ENTRY TO_LIST(#S_WRKFVC);
ENDSELECT;
*;
CASE OF_FIELD(#S_184SORT);
WHEN VALUE_IS('= CDE');
* sort by code;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS(#S_184CDE);
WHEN VALUE_IS('= DES');
* sort by description;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS(#S_184DES);
WHEN VALUE_IS('= TPRC');
* sort by total price;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS((#S_184TPRC *DESCEND));
ENDCASE;
* Now move the working list back into the browselist;
CLR_LIST NAMED(#S_184UFVC);
SELECTLIST NAMED(#S_WRKFVC);
ADD_ENTRY TO_LIST(#S_184UFVC);
ENDSELECT;
ENDCASE;
*;
* Display the list and request the sort criteria;
*;
REQUEST FIELDS(#S_GRPPANL) BROWSELIST(#S_184UFVC) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
* (Component SET184U is displayed here. This component;
* displays field #S_184SORT as a radio button.;
* =======================================================;
* Process ........: SET_184;
* Function .......: SET184U;
* Created on .....: 26/07/00 at 14:43:32;
* Description ....: Sorting columns in a browselist;
* Version.........: 1;
*;
* Full Description: The purpose of this function is to;
* show how to allow the user to sort the browselist;
*;
* Disclaimer: The following material is supplied as an;
* example only. No warranty is expressed or implied.;
*;
* Receives: nothing;
*;
* =======================================================;
* Function control options;
FUNCTION OPTIONS(*DIRECT *WEBEVENT);
*;
* Group and field definitions;
*;
DEFINE FIELD(#S_184SORT) TYPE(*CHAR) LENGTH(004) LABEL('Sort by');
* (This field is used to request the field to sort by;
* from the user.;
* It displayed via component SET184U which displays it;
* as a radio button.);
*;
GROUP_BY NAME(#S_GRPPANL) FIELDS((#S_184FDES *INPUT *NOID) (#STDRENTRY *HIDDEN) (#S_FUNDES *HIDDEN));
* (Field #S_184FDES has a component S_184FDES which;
* merges in a component with the same name as the;
* function (in this case component SET184U));
*;
DEF_LIST NAME(#S_184UFVC) FIELDS(#S_184CDE #S_184DES #S_184QTY #S_184UNIT #S_184UPRC #S_184TPRC);
DEF_LIST NAME(#S_WRKFVC) FIELDS(#S_184CDE #S_184DES #S_184QTY #S_184UNIT #S_184UPRC #S_184TPRC #S_184IMG) TYPE(*WORKING) ENTRYS(0009999);
*;
* Mainline;
*;
*;
CHANGE FIELD(#S_FUNDES) TO(*FUNCTION_DESC);
*;
*;
CASE OF_FIELD(#STDRENTRY);
WHEN VALUE_IS('= *BLANKS');
* first time in - populate list;
CHANGE FIELD(#STDRENTRY) TO(Y);
CLR_LIST NAMED(#S_184UFVC);
* Function SET184Y populates list #S_WRKFVC with data;
CALL PROCESS(*DIRECT) FUNCTION(SET184Y) PASS_LST(#S_WRKFVC);
SELECTLIST NAMED(#S_WRKFVC);
ADD_ENTRY TO_LIST(#S_184UFVC);
ENDSELECT;
* Set requested sort to product code;
CHANGE FIELD(#S_184SORT) TO(CDE);
*;
WHEN VALUE_IS('= Y');
* subsequent iteration;
* sort the list according to the user's selection;
*;
* move the browselist into a working list for sorting;
CLR_LIST NAMED(#S_WRKFVC);
SELECTLIST NAMED(#S_184UFVC);
ADD_ENTRY TO_LIST(#S_WRKFVC);
ENDSELECT;
*;
CASE OF_FIELD(#S_184SORT);
WHEN VALUE_IS('= CDE');
* sort by code;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS(#S_184CDE);
WHEN VALUE_IS('= DES');
* sort by description;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS(#S_184DES);
WHEN VALUE_IS('= TPRC');
* sort by total price;
SORT_LIST NAMED(#S_WRKFVC) BY_FIELDS((#S_184TPRC *DESCEND));
ENDCASE;
* Now move the working list back into the browselist;
CLR_LIST NAMED(#S_184UFVC);
SELECTLIST NAMED(#S_WRKFVC);
ADD_ENTRY TO_LIST(#S_184UFVC);
ENDSELECT;
ENDCASE;
*;
* Display the list and request the sort criteria;
*;
REQUEST FIELDS(#S_GRPPANL) BROWSELIST(#S_184UFVC) EXIT_KEY(*NO) MENU_KEY(*NO) PROMPT_KEY(*NO);
* (Component SET184U is displayed here. This component;
* displays field #S_184SORT as a radio button.;