Invoice generation transforms billing detail and customer master data into documents customers pay—whether paper, PDF, or electronic presentment. On the mainframe, Easytrieve has long formatted invoice registers, print tapes for commercial printers, and summary reports for accounts receivable clerks. A typical job reads unbilled or cycle billing extract, merges customer name and address, accumulates line items per invoice number, calculates tax and discounts, writes fixed-column print records, and produces control totals finance compares to AR posting. This tutorial walks through billing file layouts, master merge patterns, invoice control breaks, tax calculation modules, print record design, duplicate and reprint handling, and operational controls for high-volume billing cycles.
12345678910FILE BILLDET CUST-ID 9 NUM INVOICE-NO 12 A INV-DATE 8 NUM LINE-NO 3 NUM PROD-CODE 10 A QTY 7.0 UNIT-PRICE 9.2 LINE-AMT 9.2 TAX-FLAG 1 A
CUST-ID links to customer master. INVOICE-NO groups line items—multiple rows share same invoice number. LINE-NO sequences items on the invoice. LINE-AMT may be pre-calculated upstream or computed as QTY times UNIT-PRICE in Easytrieve. TAX-FLAG Y marks taxable lines for jurisdiction rules in CALC-TAX module.
Customer master carries bill-to name, address lines, tax id, payment terms, and remit-to address. Merge patterns: pre-sorted merge in JCL producing wide billing file, or SEARCH CUSTTAB TABLE WITH CUST-ID at invoice break reading master fields into header buffer when INVOICE-NO changes.
123456789101112JOB INPUT BILLDET IF INVOICE-NO NE W-SAVE-INV AND W-SAVE-INV NE SPACES PERFORM EMIT-INVOICE-TRAILER END-IF IF INVOICE-NO NE W-SAVE-INV PERFORM LOAD-CUSTOMER-HEADER PERFORM EMIT-INVOICE-HEADER W-SAVE-INV = INVOICE-NO W-INV-SUB = ZERO END-IF PERFORM EMIT-LINE-DETAIL ADD LINE-AMT TO W-INV-SUB
Input must be sorted by INVOICE-NO (and LINE-NO within invoice). When invoice changes, trailer record emits subtotal, tax, and total due. W-INV-CNT counts invoices for register. Grand totals W-GRAND-BILLED accumulate all invoice totals for control report.
| Output | Consumer | Content |
|---|---|---|
| Print file | Print vendor / AFP | Header, lines, trailer per invoice |
| Invoice register | AR supervisor | One line per invoice with amount |
| Exception file | Billing clerks | Missing master, zero amount, bad tax code |
| Control report | Finance | Count and sum tie-out |
PERFORM CALC-TAX after line accumulation reads customer ship-to state from master, applies rate from TAXTAB TABLE or fixed constants per state code. Taxable lines only when TAX-FLAG EQ Y. Document rounding—line-level versus invoice-level tax rounding affects penny tie-out with billing engine. Discount modules apply terms percent or flat credit lines with negative LINE-AMT.
Print vendor specifications define record types: H header, D detail, T trailer with fixed column positions. MOVE fields into OUT-REC buffer; WRITE PRINTFILE. Mask account numbers on customer-facing lines. Include barcode field if vendor prints remittance stub—barcode often encodes INVOICE-NO and amount check digit computed in PERFORM BARCODE-RTN.
123456789EMIT-LINE-DETAIL. PROC OUT-REC-TYPE = 'D' OUT-PROD = PROD-CODE SEARCH PRODTAB WITH PROD-CODE GIVING OUT-DESC OUT-QTY = QTY OUT-PRICE = UNIT-PRICE OUT-EXT = LINE-AMT WRITE PRINTFILE END-PROC
Rebill jobs read REPRINT-REQUEST file listing INVOICE-NO values to regenerate. IF INVOICE-NO not on request file GOTO JOB when running reprint-only cycle. Duplicate suppression compares against PRIOR-INV-FILE hash set or calls indicator from billing system on detail row BILL-STATUS already printed.
12345678//INVGEN EXEC PGM=EZTPA00,REGION=0M //SYSPRINT DD SYSOUT=* //SYSIN DD DSN=AR.LIB(EZTINV01),DISP=SHR //BILLDET DD DSN=AR.BILL.CYCLE(+1),DISP=SHR //CUSTMAST DD DSN=AR.CUSTOMER.MASTER,DISP=SHR //PRINTFIL DD DSN=AR.INV.PRINT(+1),DISP=(,CATLG,DELETE) //INVREG DD SYSOUT=(1,INTRDR) //EXCEPT DD DSN=AR.INV.EXCEPT(+1),DISP=(,CATLG,DELETE)
Monthly utility and telecom bills may reach millions of invoices. Split by customer region or invoice prefix into parallel Easytrieve steps; merge print files afterward. Avoid per-line SEARCH on huge product catalog—merge descriptions in upstream extract. Tune REGION and SORT workspace in JCL chain preceding invoice step.
Invoice generation is like filling out numbered bills for every customer who bought something. Each bill lists what they bought and the prices. Easytrieve copies their name and address from the address book, adds up each bill, adds tax if needed, and puts all the bills in a stack for the mail room. A cover sheet lists how many bills and how much money total so the grown-ups check the math.
1. Invoice generation jobs typically merge:
2. Invoice line items are often grouped by:
3. Tax amount on invoices usually applies:
4. Print-ready invoice output is typically:
5. Invoice register control totals include: