Function SET189K

LANSA

Function SET189K

********** COMMENT(=======================================================);
********** COMMENT(Process ........: SET_189);
********** COMMENT(Function .......: SET189K);
********** COMMENT(Created on .....: 22/09/00 at 14:43:32);
********** COMMENT(Description ....: SELECT_SQL - (NOT) LIKE);
********** COMMENT(Version.........: 1);
**********;
********** COMMENT(Full Description: The purpose of this function is to);
********** COMMENT(demonstrate the use of IN in SELECT_SQL );
**********;
********** COMMENT(Note: To use variables in SELECT_SQL statements see);
********** COMMENT(example SET_010.);
**********;
********** 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(Minimum LANSA release: 8.0);
**********;
********** COMMENT(=======================================================);
********** COMMENT(Function control options);
FUNCTION OPTIONS(*DIRECT);
**********;
OPEN USE_OPTION(*ONDEMAND);
********** COMMENT(Group and field definitions);
**********;
DEF_LIST NAME(#S_LSTPSL) FIELDS(#SURNAME);
DEF_LIST NAME(#S_LSTSEL) FIELDS((#S_189OPT *HIDDEN) (#S_189DESC *OUTPUT) (#S_189LIKE *INPUT) (#S_189NOT *INPUT));
**********;
DEFINE FIELD(#S_189DESC) TYPE(*CHAR) LENGTH(40) INPUT_ATR(LC);
DEFINE FIELD(#S_189LIKE) TYPE(*CHAR) LENGTH(1) COLHDG('Like') INPUT_ATR(RLTB);
DEFINE FIELD(#S_189NOT) TYPE(*CHAR) LENGTH(1) COLHDG('Not LIKE') INPUT_ATR(RLTB);
DEFINE FIELD(#S_189OPT) TYPE(*DEC) LENGTH(2) DECIMALS(0);
DEFINE FIELD(#S_189LK) TYPE(*CHAR) LENGTH(10) DESC('LIKE/NOTLIKE indicator');
**********;
DEFINE FIELD(#S_189TXT1) TYPE(*CHAR) LENGTH(079) INPUT_ATR(LC);
**********;
**********;
********** COMMENT(Build the list of options for the user to choose from);
SET_MODE TO(*CHANGE);
EXECUTE SUBROUTINE(ADD_OPT) WITH_PARMS('All names where the first character is B' 1);
EXECUTE SUBROUTINE(ADD_OPT) WITH_PARMS('All names containing the letter B' 2);
EXECUTE SUBROUTINE(ADD_OPT) WITH_PARMS('All names with a second character of L' 3);
EXECUTE SUBROUTINE(ADD_OPT) WITH_PARMS('All names with exactly 5 characters' 4);
EXECUTE SUBROUTINE(ADD_OPT) WITH_PARMS('All names with 5 or more characters' 5);
**********;
CHANGE FIELD(#S_189TXT1) TO('''Select an example or examples to display and press enter ''');
**********;
BEGIN_LOOP;
********** COMMENT(request user to select option);
REQUEST FIELDS((#S_189TXT1 *OUTPUT *NOID)) BROWSELIST(#S_LSTSEL);
**********;
SELECTLIST NAMED(#S_LSTSEL);
IF COND('#S_189LIKE *NE *BLANKS');
EXECUTE SUBROUTINE(DISP) WITH_PARMS('LIKE');
CHANGE FIELD(#S_189LIKE) TO(*NULL);
ENDIF;
**********;
IF COND('#S_189NOT *NE *BLANKS');
EXECUTE SUBROUTINE(DISP) WITH_PARMS('NOTLIKE');
CHANGE FIELD(#S_189NOT) TO(*NULL);
ENDIF;
**********;
UPD_ENTRY IN_LIST(#S_LSTSEL) WITH_MODE(*CHANGE);
ENDSELECT;
**********;
**********;
END_LOOP;
**********;
**********;
SUBROUTINE NAME(DISP) PARMS(#S_189LK);
CLR_LIST NAMED(#S_LSTPSL);
SET_MODE TO(*DISPLAY);
CASE OF_FIELD(#S_189OPT);
WHEN VALUE_IS('= 1');
********** COMMENT(Surname starts with the letter B);
IF COND('#S_189LK *EQ ''LIKE''');
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME LIKE ''B%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ELSE;
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME NOT LIKE ''B%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDIF;
WHEN VALUE_IS('= 2');
********** COMMENT(Surname contains the letter B);
IF COND('#S_189LK *EQ ''LIKE''');
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME LIKE ''%B%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ELSE;
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME NOT LIKE ''%B%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDIF;
WHEN VALUE_IS('= 3');
********** COMMENT(Surname has second letter L );
IF COND('#S_189LK *EQ ''LIKE''');
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME LIKE ''_L%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ELSE;
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME NOT LIKE ''_L%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDIF;
WHEN VALUE_IS('= 4');
********** COMMENT(All names with exactly 5 characters );
IF COND('#S_189LK *EQ ''LIKE''');
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME LIKE ''_____''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ELSE;
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME NOT LIKE ''_____''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDIF;
WHEN VALUE_IS('= 5');
********** COMMENT(All names with at least 5 characters );
IF COND('#S_189LK *EQ ''LIKE''');
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME LIKE ''_____%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ELSE;
SELECT_SQL FIELDS(#SURNAME) FROM_FILES((PSLMST)) WHERE('SURNAME NOT LIKE ''_____%''');
ADD_ENTRY TO_LIST(#S_LSTPSL);
ENDSELECT;
ENDIF;
ENDCASE;
DISPLAY FIELDS((#S_189DESC *NOID) (#S_189LK *NOID)) DESIGN(*ACROSS) IDENTIFY(*NOID) BROWSELIST(#S_LSTPSL);
ENDROUTINE;
**********;
SUBROUTINE NAME(ADD_OPT) PARMS(#S_189DESC #S_189OPT);
ADD_ENTRY TO_LIST(#S_LSTSEL);
ENDROUTINE;