FILTERS and FUNCTIONS: Hidden Gems Walter F. Blood Technical Director, FOCUS Division June, 2008.

Slides:



Advertisements
Similar presentations
Formulas, Ranges, and Functions. Formulas n Formulas perform operations such as addition, multiplication, and comparison on worksheet values. n Formulas.
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Copyright 2007, Information Builders. Slide 1 Walter Brengel & Cesare Petrizio Unintended Consequences or…. Why Did FOCUS Do THAT!
3/5/2009Computer systems1 Analyzing System Using Data Dictionaries Computer System: 1. Data Dictionary 2. Data Dictionary Categories 3. Creating Data Dictionary.
ITEC113 Algorithms and Programming Techniques
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Guide To UNIX Using Linux Third Edition
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 2: Single-Table Selections.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Exploring Formulas.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
1 JOIN: Rules, Roles, and Conventions Floria Foote June 2008.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Copyright 2007, Information Builders. Slide 1 FOR and the FML Syntax Noreen Redden Information Builders FOCUS Users of New England.
Copyright 2007, Information Builders. Slide 1 JOIN, MATCH and MORE– Making the Connections Walter F. Blood Technical Director, FOCUS Division May, 2011.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Lesson 1: Introduction to ABAP OBJECTS Todd A. Boyle, Ph.D. St. Francis Xavier University.
XP Agenda Video Last Class Excel Tutorial 5: Working with Excel Lists Agenda for Next Class 1 New Perspectives on Microsoft Office Excel 2003 Tutorial.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Access 2003 Lab 3 Analyzing Data and Creating Reports.
Microsoft Access 2010 Building and Using Queries.
Analyzing Data For Effective Decision Making Chapter 3.
S511 Session 9, IU-SLIS 1 DB Implementation: MS Access Macros & Expressions.
Discovering Computers Fundamentals Fifth Edition Chapter 9 Database Management.
Professor Michael J. Losacco CIS 1110 – Using Computers Database Management Chapter 9.
Examining data using Microsoft Access Queries Using Criteria and Calculations SESSION 3.2 This section covers specifying an exact match condition in a.
Concepts of Database Management Seventh Edition
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 23 Getting Started with Access Essentials 1 Morrison / Wells / Ruffolo.
Presented By: Gail Rose-Innes Camps Bay High School ICT & CAT Department Microsoft Access 2010.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Microsoft Office XP Illustrated Introductory, Enhanced Tables and Queries Using.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
XP Tutorial 8 Adding Interactivity with ActionScript.
Microsoft® Excel Key and format dates and times. 1 Use Date & Time functions. 2 Use date and time arithmetic. 3 Use the IF function. 4 Create.
Microsoft Access.  What is Data ?  Data vs. Information  Database History.  What is a Database?  Examples for Small and Large Databases.  Types.
Session Making Queries and Multiple Entry Work for You in Direct Loans (Hands-On) Session 21.
1 Lesson 13 Organizing and Enhancing Worksheets Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
What’s New in MAS 90 and MAS ?. Agenda Benefits of 4.0 New Look and Feel Security GL Enhancements Reporting Customizer.
Starting Out with C++ Early Objects ~~ 7 th Edition by Tony Gaddis, Judy Walters, Godfrey Muganda Modified for CMPS 1044 Midwestern State University 6-1.
Introduction to Access Chapter 13 pages 1-4. What is a database??? Related information is stored in databases  All SC student information is stored in.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
Lesson 4.  After a table has been created, you may need to modify it. You can make many changes to a table—or other database object—using its property.
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
Copyright 2007, Information Builders. Slide 1 Hidden Gems Walter F. Blood Technical Director Information Builders, Inc.
Overview Excel is a spreadsheet, a grid made from columns and rows. It is a software program that can make number manipulation easy and somewhat painless.
Microsoft Access Database Creation and Management.
SQL Server 2012 Session: 1 Session: 12 Triggers Data Management Using Microsoft SQL Server.
PeopleSoft Financials Advanced Query Training Financial Information Systems and Reporting Controller’s Division
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Pages Appendix B: Review of ExcelChapter 3 Market Trends & Analysis IBM 320 CAL POLY POMONA IBM320 Market Trends and Analysis Maha Ghosn.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
To play, start slide show and click on circle Access 1 Access 2 Access 3 Access 4 Access Access
N5 Databases Notes Information Systems Design & Development: Structures and links.
Fundamentals of DBMS Notes-1.
The Basics of FOCUS Reporting Syntax
The Selection Structure
Microsoft Office Illustrated Fundamentals
Chapter 3 The DATA DIVISION.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Presentation transcript:

FILTERS and FUNCTIONS: Hidden Gems Walter F. Blood Technical Director, FOCUS Division June, 2008

FILTERS and FUNCTIONS FILTERs TWO Types of Filters  Visible  Stored in Master File  Activated by reference in a request  Invisible  Independent command  Executable in PROFILEs, or FOCEXECs  Active for the entire session  Added to every request using the Master

FILTERS and FUNCTIONS Visible FILTERs What is a visible FILTER?  Virtual Field stored in Master File.  Must evaluate to True or False – 1 or 0.  Format is always I1.  Only evaluated when referenced in your request.  Functional with  CHECK FILE  TABLE/TABLEF FILE  MATCH FILE  MORE  SQL

FILTERS and FUNCTIONS Visible FILTER Visible FILTER syntax FILTER = expression;$  Positioned anywhere in Master.  Use any expression legal for WHERE  Usable with Business View or Join.  Shortest unique truncation will access it.  FILTER TOPSELLERS = SALES GT 20000;$

FILTERS and FUNCTIONS Visible FILTER Expressions WHERE (expression) (operator) (expression) AND/OR … (field/literal/function) (operator) (field/literal/function)  Each expression has one or more operators  Can use real and virtual fields in the Master file.  Cannot use virtual fields created in the request or fields described in other files.  Selections based on fields from multiple files must be AND/OR in the WHERE phrase – not in the FILTER.  IF..THEN..ELSE and DECODE to Alpha are not supported in FILTERs.

FILTERS and FUNCTIONS Visible FILTER Referencing Visible FILTERs WHERE  No limit to the number of Filters.  FILTER from Master File is automatically included on reference in request.  Beware collisions– multiple WHEREs are ANDed together. From Master and Request!  Be precise not creative with the Filter Names – indicate what it does.

FILTERS and FUNCTIONS Visible FILTER Filter Naming  Think of your endusers and how they see the data!  Combine complex selection criteria into one filter!  Give the filter a meaningful name!  FILTER1 – probably useless  FROMLASTWEEK - better

FILTERS and FUNCTIONS Visible FILTER Examples REVIEW4RAISE = HIRE_DATE LT AND CURR_SAL LT AND CURR_JOBCODE CONTAINS ‘A’;$ REVIEW4RAISE = HIRE_DATE LT AND CURR_SAL LT AND CURR_JOBCODE CONTAINS ‘A’;$ GETWKLYBONUS=((WKLYSALES/DOLQUOTA) GT AND (WKLYUNITS/UNTQUOTA) GT 1.100) OR ((TOTSALES/TOTDOLQUOTA) GT 1.500) OR ((TOTUNITS/TOTUNTQUOTA) GT 2.000);$ GETWKLYBONUS=((WKLYSALES/DOLQUOTA) GT AND (WKLYUNITS/UNTQUOTA) GT 1.100) OR ((TOTSALES/TOTDOLQUOTA) GT 1.500) OR ((TOTUNITS/TOTUNTQUOTA) GT 2.000);$

FILTERS and FUNCTIONS Invisible FILTERs What is an invisible FILTER? And how is it different from a visible FILTER?  Activated anywhere in session.  Not referenced in request.  Controlled with commands  Declared with FILTER FILE command.  Activated/Deactivated with SET FILTER command.  Requires SET KEEPFILTERS to cross JOINs  Status of FILTER can be queried -? FILTER.  Supports Defines available only to FILTERs.  Allows both WHERE and IF syntax.

FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTERS and FUNCTIONS Invisible FILTERs FILTER FILE command

FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTERS and FUNCTIONS Invisible FILTERs FILTER FILE command Deletes existing FILTER phrases and defines for this file. Adds new filter phrases to existing FILTER phrases and defines for this file. Describes the filter and can be issued in profile, focexec, or command line

FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTERS and FUNCTIONS Invisible FILTERs FILTER FILE command Virtual fields used in Filters. More on this later! Only referenceable in Filters!

FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTER FILE [ CLEAR | ADD ] [filter-defines;] NAME=filtername1 [,DESC=text] where-if phrases. NAME=filternamen [,DESC=text] where-if phrases END FILTERS and FUNCTIONS Invisible FILTERs FILTER FILE command Any valid WHERE or IF screening conditions. Must reference filter defines, or real or virtual fields in Master only. Filter Name must be 8 characters or less and unique for the master file. Used by SET FILTER= Filter Name must be 8 characters or less and unique for the master file. Used by SET FILTER= Only one line of text allowed

FILTERS and FUNCTIONS Invisible FILTER Filter Define Limitations  Local to specific filter declaration  Cannot be used in DEFINE or TABLE  Supports standard DEFINE functionality  Unlike DEFINE, do not count toward display field limit  Must all be declared before first named filter  Cannot reuse another virtual field from the same file.

FILTERS and FUNCTIONS Invisible FILTER Activating and Deactivating FILTERs SET FILTER = * IN ON/OFF ALL declared filters. Be careful using this setting. SET FILTER = name1 name2 …namen IN <filename ON/OFF Only named declared filters will be affected.

FILTERS and FUNCTIONS Invisible FILTER Filter Declaration Example FILTER FILE CAR ADD PROFIT/D7=(RCOST-DCOST); MARGINPCT/D7.2=(PROFIT/DCOST)*100 ; NAME=HIMARGIN WHERE MARGINPCT GT 20.0 NAME=MDMARGIN WHERE MARGINPCT FROM 10.0 to 20.0 NAME=LOMARGIN WHERE MARGINPCT LT 10.0 END FILTER FILE CAR ADD PROFIT/D7=(RCOST-DCOST); MARGINPCT/D7.2=(PROFIT/DCOST)*100 ; NAME=HIMARGIN WHERE MARGINPCT GT 20.0 NAME=MDMARGIN WHERE MARGINPCT FROM 10.0 to 20.0 NAME=LOMARGIN WHERE MARGINPCT LT 10.0 END

FILTERS and FUNCTIONS Invisible FILTER > > set filter = himargin in car on > >> > table file car > print sales > by country > by car > by model > end NUMBER OF RECORDS IN TABLE= 8 LINES= 8 ACCESS LIMITED BY FILTERS PAUSE.. PLEASE ISSUE CARRIAGE RETURN WHEN READY > > set filter = himargin in car on > >> > table file car > print sales > by country > by car > by model > end NUMBER OF RECORDS IN TABLE= 8 LINES= 8 ACCESS LIMITED BY FILTERS PAUSE.. PLEASE ISSUE CARRIAGE RETURN WHEN READY PAGE 1 COUNTRY CAR MODEL SALES ENGLAND JAGUAR XJ12L AUTO FRANCE PEUGEOT DOOR 0 ITALY ALFA ROMEO 2000 GT VELOCE SPIDER VELOCE DOOR BERLINA 4800 MASERATI DORA 2 DOOR 0 W GERMANY BMW 3.0 SI 4 DOOR SI 4 DOOR AUTO END OF REPORT PAGE 1 COUNTRY CAR MODEL SALES ENGLAND JAGUAR XJ12L AUTO FRANCE PEUGEOT DOOR 0 ITALY ALFA ROMEO 2000 GT VELOCE SPIDER VELOCE DOOR BERLINA 4800 MASERATI DORA 2 DOOR 0 W GERMANY BMW 3.0 SI 4 DOOR SI 4 DOOR AUTO END OF REPORT

FILTERS and FUNCTIONS Invisible FILTER > set filter = himargin in car off > > set filter = lomargin in car on > > table file car > print sales > by country > by car > by model > end NUMBER OF RECORDS IN TABLE= 3 LINES= 3 ACCESS LIMITED BY FILTERS PAUSE.. PLEASE ISSUE CARRIAGE RETURN WHEN READY > set filter = himargin in car off > > set filter = lomargin in car on > > table file car > print sales > by country > by car > by model > end NUMBER OF RECORDS IN TABLE= 3 LINES= 3 ACCESS LIMITED BY FILTERS PAUSE.. PLEASE ISSUE CARRIAGE RETURN WHEN READY PAGE 1 COUNTRY CAR MODEL SALES W GERMANY BMW DOOR DOOR AUTO I 4 DOOR END OF REPORT PAGE 1 COUNTRY CAR MODEL SALES W GERMANY BMW DOOR DOOR AUTO I 4 DOOR END OF REPORT

FILTERS and FUNCTIONS Invisible FILTER ? FILTER [ {file | * } [ SET ] [ ALL ] ] Checking FILTER status With no parms ? FILTER * SET With no parms ? FILTER * SET Specify a single file or * for all files Show status of each declared filter Show description and WHERE/IF definition for each declared filter

> > ? FILTER CAR SET > > ? FILTER CAR SET SET FILE FILTER NAME DESCRIPTION CAR HIMARGIN MARGIN GREATER THAN 10% CAR MDMARGIN MARGIN BETWEEN 10 AND 20% * CAR LOMARGIN MARGIN BELOW 10% > > > ? FILTER CAR SET SET FILE FILTER NAME DESCRIPTION CAR HIMARGIN MARGIN GREATER THAN 10% CAR MDMARGIN MARGIN BETWEEN 10 AND 20% * CAR LOMARGIN MARGIN BELOW 10% > FILTERS and FUNCTIONS Invisible FILTER Checking FILTER status Active Filters indicated with * Use DESC to differentiate FILTERs since Filter Name only 8 characters

> > ? filter car all > > ? filter car all FILTER FILE CAR ADD PROFIT/D7=(RCOST-DCOST); MARGINPCT/D7.2=(PROFIT/DCOST)*100 ; NAME=HIMARGIN, DESC=MARGIN GREATER THAN 10% WHERE MARGINPCT GT 20.0 NAME=MDMARGIN, DESC=MARGIN BETWEEN 10 AND 20% WHERE MARGINPCT FROM 10.0 TO 20.0 NAME=LOMARGIN, DESC=MARGIN BELOW 10% WHERE MARGINPCT LT 10.0 END > > > ? filter car all FILTER FILE CAR ADD PROFIT/D7=(RCOST-DCOST); MARGINPCT/D7.2=(PROFIT/DCOST)*100 ; NAME=HIMARGIN, DESC=MARGIN GREATER THAN 10% WHERE MARGINPCT GT 20.0 NAME=MDMARGIN, DESC=MARGIN BETWEEN 10 AND 20% WHERE MARGINPCT FROM 10.0 TO 20.0 NAME=LOMARGIN, DESC=MARGIN BELOW 10% WHERE MARGINPCT LT 10.0 END > FILTERS and FUNCTIONS Invisible FILTER Checking FILTER status  Displays FILTER declarations.  Decrypts declarations for use and display. Be careful!

FILTERS and FUNCTIONS Invisible FILTER FILTERs, DEFINEs and JOIN FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR TABLE FILE CAR TABLE FILE CAR JOIN COUNTRY IN CAR TO ALL COUNTRY IN SALES AS J1 Context 1 Context 2 DEFINES and FILTERS From Context 1 cleared by JOIN DEFINES and FILTERS added in Context 2 cleared by JOIN CLEAR

FILTERS and FUNCTIONS Invisible FILTER FILTERs, DEFINEs and JOIN FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR FILTER FILE CAR … DEFINE FILE CAR … TABLE FILE CAR SET KEEPFILTERS=ON, KEEPDEFINES=ON JOIN COUNTRY IN CAR TO ALL COUNTRY IN SALES AS J1 Context 1 Context 2 DEFINES and FILTERS from Context 1 retained! DEFINES and FILTERS added in Context 2 cleared by JOIN CLEAR

FILTERS and FUNCTIONS Invisible FILTER

FILTERS and FUNCTIONS Functions The Path to FUNCTIONS  Virtual fields are linked to Master File or Synonym  DEFINE  COMPUTE  RECAP  Often contain logic common to many fields  Reformating dates, names, times  Calculating standard comparison – margin, percent  Use DEFINE FUNCTION to make that logic reusable  DEFINEd FUNCTIONS - callable like IB functions  DEFINEd FUNCTIONS - independent of Master File

FILTERS and FUNCTIONS Functions The Uses of FUNCTIONS  Standardizing  Corporate business logic  FOCUS/WebFOCUS coding standards  Simplifying  Complicated groups of expressions  Repeated groups of expressions  Creating  New subroutines currently unavailable  Customization of existing functions  Based on the FOCUS/WebFOCUS language

FILTERS and FUNCTIONS Functions The Syntax of FUNCTIONS - 1 DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END  Name of function.  Last field calculated in function.  Returns value to calling procedure.  Name of function.  Last field calculated in function.  Returns value to calling procedure.  Arguments and formats that are used when the function is called.  Fields actually used in call must match the type indicated – alpha or numeric.  Alpha  Too short – padded with spaces  Too long – truncated  Arguments and formats that are used when the function is called.  Fields actually used in call must match the type indicated – alpha or numeric.  Alpha  Too short – padded with spaces  Too long – truncated

FILTERS and FUNCTIONS Functions The Syntax of FUNCTIONS - 2 DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END  Intermediate fields use in calculation of final result.  Unlimited number  Use argments, constants and other temporary fields declared in the function.  Intermediate fields use in calculation of final result.  Unlimited number  Use argments, constants and other temporary fields declared in the function.

FILTERS and FUNCTIONS Functions The Syntax of FUNCTIONS - 3 DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END DEFINE FUNCTION name (argument1/format,…argumentn/formatn) [tempvariablea/formata = expressiona;]. [tempvariablen/formatn = expressionn;] name/format = [result_expression]; END  Final field defines the value returned.  Name must match name of function.  Format indicates the format returned.  Final field defines the value returned.  Name must match name of function.  Format indicates the format returned.

FILTERS and FUNCTIONS Functions Using DEFINEd FUNCTIONS  DEFINE Functions can be called by other DEFINE Functions.  DEFINE FUNCTION Unlimits  Number of Functions used in session  Number of arguments used in a function.  DEFINE FUNCTION Limits  Can not call themselves.  Names must be 8 characters or less.  Argument names must be 12 characters or less.

FILTERS and FUNCTIONS Functions MKMARGIN Function DEFINE FUNCTION MKMARGIN CLEAR DEFINE FUNCTION MKMARGIN (RC/D7, DC/D7) NETPROFIT/D7=RC-DC; MKMARGIN/D5.2=(NETPROFIT*100)/DC; END TABLE FILE CAR PRINT COUNTRY CAR MODEL SALES AND COMPUTE MARGIN/D5.2 = MKMARGIN(RETAIL_COST,DEALER_COST); WHERE MKMARGIN(RETAIL_COST, DEALER_COST) GT 20 END DEFINE FUNCTION MKMARGIN CLEAR DEFINE FUNCTION MKMARGIN (RC/D7, DC/D7) NETPROFIT/D7=RC-DC; MKMARGIN/D5.2=(NETPROFIT*100)/DC; END TABLE FILE CAR PRINT COUNTRY CAR MODEL SALES AND COMPUTE MARGIN/D5.2 = MKMARGIN(RETAIL_COST,DEALER_COST); WHERE MKMARGIN(RETAIL_COST, DEALER_COST) GT 20 END

FILTERS and FUNCTIONS Functions MKMARGIN Function results PAGE 1 COUNTRY CAR MODEL SALES MARGIN ENGLAND JAGUAR XJ12L AUTO ITALY ALFA ROMEO 2000 GT VELOCE ITALY ALFA ROMEO 2000 SPIDER VELOCE ITALY ALFA ROMEO DOOR BERLINA ITALY MASERATI DORA 2 DOOR W GERMANY BMW 3.0 SI 4 DOOR W GERMANY BMW 3.0 SI 4 DOOR AUTO FRANCE PEUGEOT DOOR END OF REPORT PAGE 1 COUNTRY CAR MODEL SALES MARGIN ENGLAND JAGUAR XJ12L AUTO ITALY ALFA ROMEO 2000 GT VELOCE ITALY ALFA ROMEO 2000 SPIDER VELOCE ITALY ALFA ROMEO DOOR BERLINA ITALY MASERATI DORA 2 DOOR W GERMANY BMW 3.0 SI 4 DOOR W GERMANY BMW 3.0 SI 4 DOOR AUTO FRANCE PEUGEOT DOOR END OF REPORT

FILTERS and FUNCTIONS Functions Displaying Active FUNCTIONS > ? FUNCTION > ? FUNCTION > ? FUNCTION FUNCTIONS CURRENTLY ACTIVE Name Format Parameter Format MKMARGIN D5.2 RC D7 DC D7 SUBTRACT D8.2 VAL1 D7 VAL2 D7 > ? FUNCTION FUNCTIONS CURRENTLY ACTIVE Name Format Parameter Format MKMARGIN D5.2 RC D7 DC D7 SUBTRACT D8.2 VAL1 D7 VAL2 D7

FILTERS and FUNCTIONS Functions Clearing FUNCTIONS DEFINE FUNCTION MKMARGIN CLEAR DEFINE FUNCTION MKMARGIN (RC/D7, DC/D7) NETPROFIT/D7=RC-DC; MKMARGIN/D5.2=(NETPROFIT*100)/DC; END TABLE FILE CAR PRINT COUNTRY CAR MODEL SALES AND COMPUTE MARGIN/D5.2 = MKMARGIN(RETAIL_COST,DEALER_COST); WHERE MKMARGIN(RETAIL_COST, DEALER_COST) GT 20 END DEFINE FUNCTION * CLEAR DEFINE FUNCTION MKMARGIN CLEAR DEFINE FUNCTION MKMARGIN (RC/D7, DC/D7) NETPROFIT/D7=RC-DC; MKMARGIN/D5.2=(NETPROFIT*100)/DC; END TABLE FILE CAR PRINT COUNTRY CAR MODEL SALES AND COMPUTE MARGIN/D5.2 = MKMARGIN(RETAIL_COST,DEALER_COST); WHERE MKMARGIN(RETAIL_COST, DEALER_COST) GT 20 END DEFINE FUNCTION * CLEAR  Clear one specific function  Prevent collision of multiple functions  Allow dynamic function creation and use  Clear one specific function  Prevent collision of multiple functions  Allow dynamic function creation and use  Clear all active functions  Provides quick and easy cleanup  Clear all active functions  Provides quick and easy cleanup

FILTERS and FUNCTIONS Functions STDNAME Function – alpha formatting DEFINE FUNCTION STDNAME (FN/A30, MI/A1, LN/A30) LNLOC/A30 = LCWORD( 30, LN, LNLOC ); FNLOC/A30 = LCWORD( 30, FN, FNLOC ); MIPER/A1=UPCASE( 1, MI, MIPER ) ; STDNAME/A65=LNLOC || (', ' | FNLOC) || ( ' ' | MIPER) || '.'; END DEFINE FUNCTION STDNAME (FN/A30, MI/A1, LN/A30) LNLOC/A30 = LCWORD( 30, LN, LNLOC ); FNLOC/A30 = LCWORD( 30, FN, FNLOC ); MIPER/A1=UPCASE( 1, MI, MIPER ) ; STDNAME/A65=LNLOC || (', ' | FNLOC) || ( ' ' | MIPER) || '.'; END  Produces “Lastname, Firstname Middleinitial. “  Oversized alpha parameters accommodate multiple field sizes  Parentheses to control spacing in final expression  Produces “Lastname, Firstname Middleinitial. “  Oversized alpha parameters accommodate multiple field sizes  Parentheses to control spacing in final expression DEFINE FUNCTION STDNAME (FN/A30, MI/A1, LN/A30) LNLOC/A30 = LCWORD( 30, LN, LNLOC ); FNLOC/A30 = LCWORD( 30, FN, FNLOC ); MIPER/A1=UPCASE( 1, MI, MIPER ) ; STDNAME/A65=LNLOC || (', ' | FNLOC) || ( ' ' | MIPER) || '.'; END TABLE FILE EMPDATA PRINT PIN AS EMPID AND COMPUTE NAME/A65 = STDNAME( FIRSTNAME, MIDINITIAL, LASTNAME ); END DEFINE FUNCTION STDNAME (FN/A30, MI/A1, LN/A30) LNLOC/A30 = LCWORD( 30, LN, LNLOC ); FNLOC/A30 = LCWORD( 30, FN, FNLOC ); MIPER/A1=UPCASE( 1, MI, MIPER ) ; STDNAME/A65=LNLOC || (', ' | FNLOC) || ( ' ' | MIPER) || '.'; END TABLE FILE EMPDATA PRINT PIN AS EMPID AND COMPUTE NAME/A65 = STDNAME( FIRSTNAME, MIDINITIAL, LASTNAME ); END

FILTERS and FUNCTIONS Functions STDNAME Function results PAGE 1 EMPID NAME Valino, Daniel A Bella, Michael D Cassanova, Lois E Adams, Ruth B Addams, Peter C Patel, Dorina K Sanchez, Evelyn P So, Pamela L Pulaski, Marianne D Anderson, Tim A. PAGE 1 EMPID NAME Valino, Daniel A Bella, Michael D Cassanova, Lois E Adams, Ruth B Addams, Peter C Patel, Dorina K Sanchez, Evelyn P So, Pamela L Pulaski, Marianne D Anderson, Tim A.

FILTERS and FUNCTIONS Functions Other Candidates for Reformatting  Any standardized alpha format  ID Numbers or SSNs  Telephone Numbers  Product codes or SKUs  Address lines  Irregular line indentation

FILTERS and FUNCTIONS Functions EXPDATE Function – Time Value calculation DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME ); DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME );  Generates date-time field &NUM hours from current time  Combines multiple Datetime calls into single function  Parentheses to control spacing in final expression.  Generates date-time field &NUM hours from current time  Combines multiple Datetime calls into single function  Parentheses to control spacing in final expression. DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME ); EXPDATE/HYYMDm = IF ( EDIT(LNAME, '9‘ )) EQ 'A' OR 'B' OR 'C' OR 'D' OR 'E' THEN HADD( CURTIM, 'HOUR', &NUM, 10, 'HYYMDm') DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME ); EXPDATE/HYYMDm = IF ( EDIT(LNAME, '9‘ )) EQ 'A' OR 'B' OR 'C' OR 'D' OR 'E' THEN HADD( CURTIM, 'HOUR', &NUM, 10, 'HYYMDm') DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME ); EXPDATE/HYYMDm = IF ( EDIT(LNAME, '9‘ )) EQ 'A' OR 'B' OR 'C' OR 'D' OR 'E' THEN HADD( CURTIM, 'HOUR', &NUM, 10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'F' OR 'G' OR 'H' OR 'I' OR 'J' THEN HADD( CURTIM, 'HOUR', &NUM+24,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'K' OR 'L' OR 'M' OR 'N' OR 'O' THEN HADD( CURTIM, 'HOUR', &NUM+48,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'P' OR 'Q' OR 'R' OR 'S' OR 'T' THEN HADD( CURTIM, 'HOUR', &NUM+72,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'U' OR 'V' OR 'W' OR 'X' OR 'Y' OR 'Z' THEN HADD( CURTIM, 'HOUR', &NUM+96,10, 'HYYMDm') ; END DEFINE FUNCTION EXPDATE (LASTNAME/A15) CURTIM/HYYMDm = HGETC( 10, 'HYYMDm‘ ); LNAME/A15 = UPCASE( 15, LASTNAME, LNAME ); EXPDATE/HYYMDm = IF ( EDIT(LNAME, '9‘ )) EQ 'A' OR 'B' OR 'C' OR 'D' OR 'E' THEN HADD( CURTIM, 'HOUR', &NUM, 10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'F' OR 'G' OR 'H' OR 'I' OR 'J' THEN HADD( CURTIM, 'HOUR', &NUM+24,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'K' OR 'L' OR 'M' OR 'N' OR 'O' THEN HADD( CURTIM, 'HOUR', &NUM+48,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'P' OR 'Q' OR 'R' OR 'S' OR 'T' THEN HADD( CURTIM, 'HOUR', &NUM+72,10, 'HYYMDm') ELSE IF (EDIT( LNAME,'9‘ )) EQ 'U' OR 'V' OR 'W' OR 'X' OR 'Y' OR 'Z' THEN HADD( CURTIM, 'HOUR', &NUM+96,10, 'HYYMDm') ; END

FILTERS and FUNCTIONS Functions EXPDATE Function DEFINE FILE EMPDATA CALLBACK/HYYMDm = EXPDATE (LASTNAME); END TABLE FILE EMPDATA PRINT LASTNAME BY CALLBACK END DEFINE FILE EMPDATA CALLBACK/HYYMDm = EXPDATE (LASTNAME); END TABLE FILE EMPDATA PRINT LASTNAME BY CALLBACK END  Create BY field in DEFINE  Prompt for &NUM as runtime or include on EX line  Create BY field in DEFINE  Prompt for &NUM as runtime or include on EX line

FILTERS and FUNCTIONS Functions EXPDATE Function results PAGE 1 CALLBACK LASTNAME /04/21 22:59: BELLA 2008/04/21 22:59: CASSANOVA 2008/04/21 22:59: ADAMS 2008/04/21 22:59: ADDAMS 2008/04/21 22:59: ANDERSON 2008/04/21 22:59: CVEK 2008/04/21 22:59: DUBOIS 2008/04/21 22:59: CONRAD 2008/04/21 22:59: CASTALANETTA 2008/04/21 22:59: DONATELLO PAGE 1 CALLBACK LASTNAME /04/21 22:59: BELLA 2008/04/21 22:59: CASSANOVA 2008/04/21 22:59: ADAMS 2008/04/21 22:59: ADDAMS 2008/04/21 22:59: ANDERSON 2008/04/21 22:59: CVEK 2008/04/21 22:59: DUBOIS 2008/04/21 22:59: CONRAD 2008/04/21 22:59: CASTALANETTA 2008/04/21 22:59: DONATELLO

FILTERS and FUNCTIONS Functions Other Candidates for Selection  Any field that could be used as a dimension  Location fields  UserID – additional DBA  Brand or Product fields  Product characteristic - color  Cost range or budget amount

FILTERS and FUNCTIONS Functions ROLL4AVG Function – Rolling Average DEFINE FUNCTION ROLL4AVG (COND/A10, VAL/D12.2) CURR/D12.2 = VAL; L1CURR/D12.2 = IF COND EQ LAST COND THEN LAST CURR ELSE 0; L2CURR/D12.2 = IF COND EQ LAST COND THEN LAST L1CURR ELSE 0; L3CURR/D12.2 = IF COND EQ LAST COND THEN LAST L2CURR ELSE 0; L4/D12.2 = CURR + L1CURR + L2CURR + L3CURR; DEFINE FUNCTION ROLL4AVG (COND/A10, VAL/D12.2) CURR/D12.2 = VAL; L1CURR/D12.2 = IF COND EQ LAST COND THEN LAST CURR ELSE 0; L2CURR/D12.2 = IF COND EQ LAST COND THEN LAST L1CURR ELSE 0; L3CURR/D12.2 = IF COND EQ LAST COND THEN LAST L2CURR ELSE 0; L4/D12.2 = CURR + L1CURR + L2CURR + L3CURR;  Produces rolling average of last 4 values excluding zeroes  Single condition field used but could easily use multiple  LAST is supported here  Produces rolling average of last 4 values excluding zeroes  Single condition field used but could easily use multiple  LAST is supported here DEFINE FUNCTION ROLL4AVG (COND/A10, VAL/D12.2) CURR/D12.2 = VAL; L1CURR/D12.2 = IF COND EQ LAST COND THEN LAST CURR ELSE 0; L2CURR/D12.2 = IF COND EQ LAST COND THEN LAST L1CURR ELSE 0; L3CURR/D12.2 = IF COND EQ LAST COND THEN LAST L2CURR ELSE 0; L4/D12.2 = CURR + L1CURR + L2CURR + L3CURR; L4NUM/I1 = IF L1CURR EQ 0 THEN 1 ELSE IF L2CURR EQ 0 THEN 2 ELSE IF L3CURR EQ 0 THEN 3 ELSE 4; ROLL4AVG/D12.2 = L4 / L4NUM; END DEFINE FUNCTION ROLL4AVG (COND/A10, VAL/D12.2) CURR/D12.2 = VAL; L1CURR/D12.2 = IF COND EQ LAST COND THEN LAST CURR ELSE 0; L2CURR/D12.2 = IF COND EQ LAST COND THEN LAST L1CURR ELSE 0; L3CURR/D12.2 = IF COND EQ LAST COND THEN LAST L2CURR ELSE 0; L4/D12.2 = CURR + L1CURR + L2CURR + L3CURR; L4NUM/I1 = IF L1CURR EQ 0 THEN 1 ELSE IF L2CURR EQ 0 THEN 2 ELSE IF L3CURR EQ 0 THEN 3 ELSE 4; ROLL4AVG/D12.2 = L4 / L4NUM; END

FILTERS and FUNCTIONS Functions ROLL4AVG Function – Rolling Average TABLE FILE HEMPLOYEE PRINT GROSS AND COMPUTE ROLLAVG/D12.2=ROLL4AVG(EMP_ID,GROSS); BY EMP_ID BY PAY_DATE WHERE EMP_ID EQ ‘ ’ END TABLE FILE HEMPLOYEE PRINT GROSS AND COMPUTE ROLLAVG/D12.2=ROLL4AVG(EMP_ID,GROSS); BY EMP_ID BY PAY_DATE WHERE EMP_ID EQ ‘ ’ END PAGE 1 EMP_ID PAY_DATE GROSS ROLLAVG /11/30 $2, , /12/31 $2, , /01/29 $2, , /02/26 $2, , /03/31 $2, , /04/30 $2, , /05/28 $2, , /06/30 $2, , /07/30 $2, , /08/31 $2, , END OF REPORT PAGE 1 EMP_ID PAY_DATE GROSS ROLLAVG /11/30 $2, , /12/31 $2, , /01/29 $2, , /02/26 $2, , /03/31 $2, , /04/30 $2, , /05/28 $2, , /06/30 $2, , /07/30 $2, , /08/31 $2, , END OF REPORT

FILTERS and FUNCTIONS Functions Other Candidates for Creativity  Your in-house “business logic”  Trigonometric functions  Different Rounding  Financial analysis  Accounting functions  Mathematical functions

FILTERS and FUNCTIONS Functions