A function takes fields you already defined and returns a value you can store or test. You do not FILE a function and you do not run it from JCL. It sits in an expression in the JOB. Names differ between Easytrieve Plus and the Report Generator, and between 6.4 and 11.6, so match the name to the manual for the product you compile with. This page is the index. The category pages describe the work each family does.
12345* Names depend on your release. The shape is the same. WS-RESULT = FUNC(WS-SOURCE) IF FUNC(WS-SOURCE) EQ 0 PRINT EX-RPT END-IF
The result field has to be wide enough and the right type. Assigning a long character result into a short A field keeps the leftmost bytes and drops the rest.
| Category | What you use it for |
|---|---|
| String | Move, overlay, search, and case inside fixed A fields |
| Date | Current date, extract parts, convert formats |
| Numeric | Sign, scale, and numeric tests on amount fields |
| Math | Arithmetic helpers beyond +, -, *, / |
| Conversion | Change representation between character and numeric |
| Formatting | Edit a value for display |
| Testing | Ask a yes or no question about a field |
| File | Ask the runtime about an open file |
| System | Job, user, and environment values |
| Report | Values the report writer exposes, such as page |
A function is a helper sitting next to your desk. You hand them a number or a name, they hand back an answer, and you write that answer on the line. You still need a box (the field) big enough to hold what they hand back.
1. A built-in function is called:
2. Easytrieve Plus function names can differ from Report Generator because:
3. String work on a fixed A field uses:
4. Date functions belong on:
5. A function result that is longer than the target field: