The screens
A program is described, not written. Each screen holds part of the model; the COBOL source is generated from the whole, then compiled and run in the browser. The workshop and the terminal share the same model.
| Workshop | Terminal | What you describe there |
|---|---|---|
| Dictionary | R | The data elements, once: code, label, type X or 9, length, decimals, sign. Their format is used everywhere. |
| Records | E | The elements of a file line, in the order they follow each other. The positions come from it. |
| Files | C | The file calls: code, usage, record, name, argument (control break or matching). |
| Processing | T | The program name, the title, and for a listing without a report: filters, columns, detail, totals. The output files. |
| Reports | K | A report described the way the manual does: labels, structures, layout. |
| (at the terminal) | O | Entry screens that read and update the tables: description, Segments, mock-up, run. |
| Structured language | P | Your procedures, in functions and sub-functions. |
| Data | D | The content of the input files, typed column by column. |
| Database | B, Q | DB2-style tables, and an SQL console to query them. |
| Source, Run | G, X | The generated source, then the SYSOUT and the files produced. |
File calls
Each file of the program is called with a two-character code, which prefixes its fields, and a usage:
| C | Consulted: read in sequence. In a listing program, it is the one that gets printed. |
| P | Principal: the file being updated. Sorted on its argument, no duplicates. |
| M | Transactions: they update the principal file. Same argument, sorted, several transactions per key allowed. A one-character element gives the transaction code (create, modify, delete). |
| R | Result: the principal file after the update, with the same record. |
| I | Print: a report is written to it. Its argument is the report letter. |
Two kinds of program: the listing (a C file, a report) and the update (P + M give R, with a log). The argument of a C file declares its control breaks; that of P and M, the matching.
The fields of a file
For a file with code FA and an element CUSTNM:
| FA00-CUSTNM | The field read. When the file has control breaks or holds transactions, it is the next record, read ahead. |
| 1-FA00-CUSTNM | The record being processed (file with control breaks, transactions, principal file read). |
| 2-FA00-CUSTNM | The updated principal record, before the result is written. |
| FA-FT | End of work for the file. |
| FA-PEn, FA-DEn | First, last record at level n. |
| FA-CFn, FA-OCn | Matching: the record takes part in the cycle, exists. |
| W-CUSTNM | A working field, declared with the element's format. |
| D-CUSTNM | The element on the detail line of the simple listing. |
The function cycle
The generated program is cut into two-character functions, run in the order of their code. The program loops from F05 to F90, once per record, until the end of the files.
| F01 | Initialization: opening the files, once. |
| F05 | Start of iteration. |
| F10 | Read (with control break or matching). |
| F20 | End of processing: once every file is read, your F20 sub-functions, closing the files, stop. |
| F22 | Last-record computation: which record is the last of its group, at each level. |
| F24 to F39 | Update: configuration and occurrence (24), total breaks (26), control variables (30), transaction code (33), presence of elements (39). |
| F70 to F76 | Update: matching check (70), update (73), error storage (76). |
| F8E, F8e | Printing: F8E for the simple listing, F8e for the report with letter e. |
| F90 | Writes, then back to F05. |
Placing your functions
Your sub-functions add to the generated functions (for example 8E 10, 20 10), or form your own functions, placed according to their code. The order is EBCDIC: letters come before digits, so 0A before 00 and 8E before 80.
- Before F01: once, before initialization. Between F01 and F05: once, after it.
- Between F05 and F20: on every cycle, after the read, including the last pass.
- Between F20 and F90: for every record, before or after printing depending on the code.
- After F90: never on its own, only performed by the P operator.
Control breaks
Control breaks are declared in the call of the consulted file: up to three argument elements, from the broadest to the finest. The program sorts the file on this argument, then reads it one record ahead to know, before processing a record, whether a group starts or ends.
| RTPn = 1 | The record being processed is the first of its group at level n. |
| RTDn = 1 | It is the last one: time for the subtotals. |
| FA-FI = 1 | Nothing left to read ahead: the record being processed is the last of the file. |
A level 1 break triggers those of the finer levels. In the simple listing, each level prints its subtotal; in a report, these are the categories of type 1 to 3, and the grand total is type 0.
Reminder: the field read (FA00-) is the next record, the record being processed is 1-FA00-. Mixing them up shifts everything by one line.
The simple listing
A listing program without a report prints on the SYSOUT a listing set up in the Processing tab:
- Filters: records that do not pass every filter are skipped (counted as read, not as kept).
- Columns: the elements of the detail line, and the “print the detail” box.
- Totals: the numeric elements to total, at each break and in the grand total; “count the lines” adds the number of records.
- Output files: written from the structured language, with M then ECR.
The structured language
A sub-function starts with an N line: title, level (05, 10…), type and condition. The types: BL block, IT if, EL else, DW while. A sub-function with a higher level nests in the previous one.
| M a b | Move a to b. |
| A a b, S a b | Add a to b, subtract a from b. |
| C W-X = A + B | Compute. |
| P ff | Perform function ff. |
| MES … | Display on the SYSOUT. |
| ECR dd | Write a record of output file dd. |
| SQL tb aa | Access a table (see the database). |
| SCO, SRO | Commit, roll back. |
| COB … | A line of COBOL as is. |
| * | A comment. |
Conditions: = # (not equal) > < >= <=, joined by AND and OR.
Reports
A report is printed to a print file (usage I). Its code is the file code followed by its letter: file ET with letter 1 gives report ET1 and function F81. It is described on three screens.
Labels (-L)
The fixed lines, numbered from 01 with no gap, at the report's length.
Structures (-CE)
The elements to place on a line: structure (01, 02…), element, start column, mode, source and condition.
- Mode:
Mmove,Tto total,+orRcompute (R rounded),Uby you. - Source field type: blank for the field read,
1processing,2update,5counters,*free expression. - Source:
FFNNELEMNT(file, segment, element;FA00alone takes the element of the same name) or a quoted literal. - A continuation line (
*) holds a + - * / operation on another source, or the rest of the condition.
Layout (-D)
The characteristics (line length, lines per page, items) then the categories: lines printed under the same condition, in code order. Each line: number, type, structure, label, skip before the line, function to run first, condition.
| (blank) | Ordinary line. |
| A, Z | Page header and footer. |
| I | Iterative line, repeated. |
| * | Detail line, totaled. |
| T | Detail never printed, only totaled. |
| 0, 1 to 3 | Grand total, break total of the level. |
Skip 00: overprint; absolute skip * to 01: new page. Items at 0: each line is printed right away, without being stored. The counters 5-dd00-eCL (line in the page), CLM (lines per page), CP (page) and CE (lines written) are used in conditions and sources; CATX is the current category.
Entry screens
A screen has a six-character code, the first two being the Dialogue code (CL0010). It is described at the terminal (option O); the generated program is a pseudo-conversational transaction: each Enter or PF key receives the screen, checks it, updates the database and sends back the next screen.
Description (-CE)
One line per element, in line-number order. View C1: position and presentation; view C2 (PF11): update and source.
- Positioning:
Aabsolute (line, column), blank relative to the previous field (lines below, or columns after). - Nature:
Ventered,Fprotected but received,Pshown only,Olabel of the element only,Lfixed label (no element),Rstart of the repetitive part (RV lines, H lines per instance),Zstart of the bottom part. - Label presentation:
LMlong on 36, left or right,Nuseful long,STUthe same with the short label on 18,Felement alone,1column header. R: required entry. ProcessingI: transaction code of the category (Ccreate,Mmodify,Ddelete); with no transaction code, the update is implicit.- Update
M: the element updates the given Segment;V: allowed value, one per continuation line. Source: the displayed Segment that feeds the element. LIERR(nature P) receives the error message.PFKEYdescribes the keys:GorScalls another screen (blank: end of the conversation),Voperation code of the key (Snext page of the list…).
Segments (-CS)
The tables read or updated: Segment code (table code and two digits), category, reception usage (N L read E existence M modify X create and modify T all three), display usage (A), and the screen field that gives the key (0010-CUSTNO; blank: start of the table).
Mock-up and run
-SIM shows the screen as it will be, keys G and S chain the mock-ups; Clear goes back. -TP runs the transaction on the database; Clear leaves. -G shows the generated source. On an error, the faulty field is flagged, the cursor goes there and nothing is written.
The database
A database runs in the browser, the DB2 way. Each table has a two-letter code: its columns are used as CL-CUSTNM. The SQL operator takes the table code and the access type:
| R, RU | Read by key, read for update. |
| W, RW, D | Insert, update by key, delete by key. |
| P, RN, CL | Open the cursor (the whole table, in key order), next row, close. |
SQLCODE gives the result: 0 found, 100 not found or end of cursor, -803 duplicate key. The database keeps its rows from one run to the next.
The terminal
The same screens on 24 lines of 80 columns. A code on the OPTION line, then Enter: R E C T P D K (then -D, -L, -CE) O (then -CE, -CS, -SIM, -TP, -G) S B Q G X.
- Tab and Shift+Tab from field to field, Enter sends the screen, F1 to F12 for PF1 to PF12.
- PF3 back, PF7 and PF8 pages, PF10 and PF11 left and right, PF12 menu.
- In column A: an action code, S delete, D duplicate, I insert, depending on the screen. An empty line at the bottom is for creating.
END,END UPD,END REPORTload the examples;SHAREgives the program's link.