HOSTEL/i — Hotel Reservations & Front-Desk / Folio Management

SteelFrame X application operation manual  ·  ← back to Operation Manuals  ·  Sign On

HOSTEL/i is a hotel front-desk and folio-management application: reservation capture and room allocation by type, check-in, a nightly room+tax posting (the night audit), incidental and payment application, check-out with settlement, weekly housekeeping turnover and no-show release, a monthly occupancy/revenue report and a room-revenue/tax GL feed, and a year-end folio archive. The application is a classic IBM i estate app: RPG IV programs over keyed DB2 for i physical and logical files, one ILE COBOL control report, DDS display and printer files, embedded SQL for the GL distribution, and CL job cycles. This manual is the reference for the operator who runs the online screens and the four periodic cycles, and for the developer maintaining the application. It is grounded entirely in the committed source (hotel-app/src/sources.mjs, src/seed.mjs, and the test/ht_*.mjs drivers). Everything runs in library HOSTEL.

Contents

A. Overview & Architecture ↑ top

A.1 What it does

HOSTEL/i services the full life of a hotel stay, from reservation to settled folio to year-end archive:

A.2 Architecture & the status model

HOSTEL/i is a conventional record-level-access RPG estate app, not a two-layer SQL-PL design: business logic lives in the RPG programs, which read and update keyed DB2 files directly (CHAIN / READ / READE / UPDATE / WRITE). Embedded SQL appears in exactly one place — HTGLPST, the GL post — and one ILE COBOL program, HTAUDRPT, produces a folio control report. The whole estate is built and compiled by one CL setup program (HTSETUP) and driven by four CL job cycles (HTDAILY, HTWEEK, HTMONTH, HTYEAR).

The heart of the application is the reservation status model on HTRESV.RSTAT, which every program keys its behaviour off:

RSTATMeaningSet by
NNew — captured, room type requested, no room yet.Front desk (reservation write).
WWaitlisted — no room of the type was free at capture.HTRESERV.
BBooked — a specific room assigned, arrival pending.HTRESERV.
IChecked in — guest in-house, folio open.HTCHKIN.
OChecked out — stay settled and closed.HTCHKOUT.
XCancelled.Front desk.
SNo-show — past arrival, never checked in.HTNOSHOW.

A parallel room status on HTROOM.RSTAT drives availability: V vacant-clean (sellable), O occupied (taken off the pool at booking), D vacant-dirty (checked out, needs housekeeping before resale), X out-of-order (never allocated). The "stamp it once, trust the stamp" invariant used across the estate applies here to the rate: RATELOCK captures the room-type rate at booking so a later rate change never reprices a guest already holding a reservation.

A.3 Component & flow

  ONLINE                      BATCH CYCLES (CL job streams)
  ------                      ----------------------------
  HTMENU (5250)               HTDAILY  --> HTRESERV  (allocate room by type)
    opt 1 -> HTRESVIQ                      HTCHKIN   (check in arrivals + night 1)
    opt 2 -> HTFOLIQ (SFL)                 HTNAUDIT  (post each further night room+tax)
                                           HTINCTAL  (accrue F&B / minibar lines)
                                           HTPAYAPL  (apply PY payment lines)
                                           HTCHKOUT  (settle + release room dirty)
                            HTWEEK   --> HTHSKP    (dirty -> clean)
                                         HTNOSHOW  (release no-show rooms)
                            HTMONTH  --> HTOCCRPT  (occupancy/revenue printer report)
                                         HTGLPST   (room-rev/tax GL post, embedded SQL)
                                         HTAUDRPT  (ILE COBOL folio control report)
                            HTYEAR   --> HTARCHIV  (folio archive + counter reset)
                                         HTAUDRPT

  HTRESV (reservation header, RBAL mirror) <----writes---- every posting program
     |  \                                   HTFOLIO (one row per charge/payment line)
     |   +--> HTROOM (V/O/D/X availability) HTGLDIST (SQL GL distribution, HTGLPST)
     +------> HTRTYP (type rate) / HTGUEST (guest master)

A single processing event — say, one night's audit — flows: HTNAUDIT reads its fixed run date → for each checked-in stay not yet audited today it posts a room line and a tax line to HTFOLIO and raises HTRESV.RBAL by room+tax → the reservation header's RBAL mirror then answers "what is owed" without re-summing the folio. The RLAUDT stamp on the header makes a same-day re-run a no-op.

A.4 Object inventory

ObjectTypeRole
HTRTYPPFRoom-type / rate master.
HTROOMPFRoom master (availability by number).
HTROOMLFLFRooms keyed by RTYPE (availability-by-type walk).
HTGUESTPFGuest master.
HTRESVPFReservation header (the stay lifecycle + RBAL mirror).
HTRESVLFLFReservations keyed by ARRDT (arrivals / no-show walk).
HTFOLIOPFFolio charge/payment lines (composite key RESVNO,FSEQ).
HTFOLLFLFFolio lines keyed by FCODE (revenue-by-department).
HTGLDISTSQL tableRoom-revenue/tax GL distribution (HTGLDACC index).
HTRESVD / HTFOLD / HTMENUDDSPFInquiry, subfile-folio and menu display files.
HTOCCPPRTFOccupancy/revenue printer file.
HTREFLDRPGSeed reference data (types, rooms, guests).
HTRESERVRPGReservation capture + room allocation.
HTCHKINRPGCheck-in + first night's room+tax.
HTNAUDITRPGNight audit (each further night's room+tax).
HTINCTALRPGIncidental (F&B/minibar) accrual.
HTPAYAPLRPGPayment application.
HTCHKOUTRPGCheck-out + settlement + room release.
HTHSKPRPGWeekly housekeeping turnover sweep.
HTNOSHOWRPGWeekly no-show release sweep.
HTOCCRPTRPGMonthly occupancy/revenue report.
HTGLPSTSQLRPGLEMonthly room-revenue/tax GL post.
HTARCHIVRPGAnnual folio archive + counter reset.
HTRESVIQ / HTFOLIQ / HTMENURPGOnline inquiry, subfile-folio, menu.
HTAUDRPTILE COBOLFolio control report (room/tax reconciliation).
HTSETUPCLCreate every object & compile every program.
HTDAILY / HTWEEK / HTMONTH / HTYEARCLThe four job-cycle streams.

The full catalogue is 5 physical files + 3 logical files + 1 SQL table (with index), 3 display files and 1 printer file, driven by 15 RPG programs, 1 ILE COBOL program and 5 CL programs. Sections D and F expand each.

B. Online Transactions & Screens ↑ top

B.1 The command/entry line

HOSTEL/i has no CICS transaction identifiers and no transid switch. On IBM i, each program is reached by name from a 5250 command-entry line (or a JOBQ/scheduler for the batch cycles). The operator equivalent of "type a transid and Enter" is "type a CALL command and Enter". Before invoking anything, the job's library list must include HOSTEL — the tested jobs run with LIBL = QSYS QGPL HOSTEL QTEMP and CURLIB = HOSTEL.

To do thisType on the command line
Open the operator menuCALL HOSTEL/HTMENU
Open the reservation inquiry directlyCALL HOSTEL/HTRESVIQ
Open the folio inquiry (subfile) directlyCALL HOSTEL/HTFOLIQ
Run the daily cycleCALL HOSTEL/HTDAILY (or SBMJOB it)
Run the weekly cycleCALL HOSTEL/HTWEEK
Run the monthly closeCALL HOSTEL/HTMONTH
Run the annual archiveCALL HOSTEL/HTYEAR
Build/compile the whole estateCALL HOSTEL/HTSETUP
Load the seed reference dataCALL HOSTEL/HTREFLD

The batch drivers take no CALL parameters. Only HTMENU, HTRESVIQ and HTFOLIQ are interactive; every batch program runs to completion and DSPLYs a one-line result (its counts) to the job log.

B.2 The menu & inquiry screens

HOSTEL/i has three interactive programs. The menu (HTMENU / HTMENUD) is the entry point; it CALLs one of the two inquiry programs by option and returns on F3. The inquiry programs are read-only — they display reservation and folio data but do not post or maintain it. All maintenance (reservations, incidentals, payments) is data-entry into the files plus the batch cycle; see B.3.

HTMENU — operator menu

HOSTEL/i Main Menu 1. Reservation Inquiry 2. Folio Inquiry Option . . . . : _ F3=Exit Enter=Select

HTRESVIQ / HTRESVD — reservation inquiry (plain screen)

A plain (non-subfile) screen. Key a reservation number and Enter; the program CHAINs HTRESV and (for the guest name) HTGUEST, and renders the header plus the locked rate and folio balance. An unknown number clears the detail and shows Reservation not found.

Reservation Inquiry - HOSTEL/i Reservation number: RESV0001 Guest . . . . : JANET OKAFOR Room type . . : STD Room number . : 0101 Status . . . . : I Rate/night . . : 100.00 Arrival . . . : 20260801 Departure . . : 20260803 Folio balance : 220.00 Reservation found. F3=Exit Enter=Inquire
FieldType (DDS)Shows
IRESV8A input/outputReservation number keyed in.
DGNAME30A outputGuest name (from HTGUEST).
DRTYPE / DROOM3A / 4A outputRoom type and assigned room number.
DSTAT1A outputReservation status (RSTAT).
DRATE14A outputLocked nightly rate (RATELOCK, edited).
DARR / DDEP10A outputArrival / departure dates.
DBAL14A outputFolio balance from the RBAL mirror (edited).
DMSG50A outputFound / not-found message line.

HTFOLIQ / HTFOLD — folio inquiry (subfile)

The app's subfile screen. DDS record FSFL under control record FCTL, SFLPAG(5) per page, SFLSIZ(20), with ROLLUP/ROLLDOWN paging keys and SFLEND(*MORE). Key a reservation number and Enter; the program clears the subfile (*IN31 drives SFLCLR), CHAINs the header/guest, then READEs every folio line for that reservation into the subfile and displays it. A subsequent enquiry clears and reloads — a genuine clear-then-reload discipline so an unknown number does not redisplay the previous stay's rows.

Folio Inquiry - HOSTEL/i Reservation number: RESV0001 Guest . . . . : JANET OKAFOR Status . . . . : I Balance . . . : 220.00 Seq Cd Date Amount S 1 RM 20260801 100.00 O 2 TX 20260801 10.00 O 3 RM 20260802 100.00 O 4 TX 20260802 10.00 O Folio found. F3=Exit Roll=Page Enter=Inquire
FieldType (DDS)Shows
IRESV8A input/outputReservation number keyed in.
DGNAME / DSTAT / DBALoutputHeader: guest, status, folio balance.
SSEQ3Y,0 outputFolio line sequence (FSEQ).
SCODE2A outputCharge code: RM/TX/FB/MB/PY/YE.
SDT10A outputLine date (FDT, edited).
SAMT12A outputLine amount (FAMT, edited; PY is negative).
SFST1A outputLine status: O open, S settled, A accrued/applied.
The subfile display is gated on N31/N32 so it is shown only once at least one row has actually loaded — the program source notes this prevents an unknown reservation number from redisplaying the previous enquiry's rows. Operationally the screen behaves as described; the interactive test asserts the 4-row load, the rendered 100.00 room / 10.00 tax lines, and the 220.00 header balance.

B.3 Controls & audit workflow

Honest statement: HOSTEL/i does not model a four-eyes maker–checker / separate-authorization workflow, and it has no dedicated audit-trail file. The inquiry screens are read-only; front-desk maintenance is performed by writing reservation and folio rows (the test drivers do this directly against HTRESV/HTFOLIO) and then running the daily cycle, which applies each new row exactly once. The control model the application does have is built from state gating and idempotency:

In sum, the control posture is state gating + a settlement gate + a reconstructable folio ledger + idempotency, all in RPG record-level logic, rather than a segregation-of-duties approval workflow or a trigger-written audit file.

C. Batch Jobs & the Periodic Cycle ↑ top

HOSTEL/i runs as four CL job-cycle streams rather than one monolithic nightly job: a daily cycle (the reservation-to-folio flow), a weekly cycle (housekeeping + no-show), a monthly close (report + GL + control report), and an annual roll (archive + reset). Each CL simply ADDLIBLE HOSTEL then CALLs its programs in order; the batch programs take no parameters. This is the SBMJOB idiom — a scheduled submission is a bare CALL of the cycle CL.

-- submit a (parameterless) cycle
SBMJOB CMD(CALL PGM(HOSTEL/HTDAILY)) JOB(HTDAILY)
SBMJOB CMD(CALL PGM(HOSTEL/HTWEEK))  JOB(HTWEEK)
SBMJOB CMD(CALL PGM(HOSTEL/HTMONTH)) JOB(HTMONTH)
SBMJOB CMD(CALL PGM(HOSTEL/HTYEAR))  JOB(HTYEAR)
The run date is a compiled constant, not a control row. Unlike a control-table design, each date-sensitive HOSTEL/i program carries its processing date as a literal (WRUNDT): HTCHKIN 20260801, HTNAUDIT 20260802, HTCHKOUT 20260803, HTNOSHOW 20260805; the GL post batches 202608 and dates rows 20260831; the archive writes 20261231. This makes the estate-sample oracle exactly hand-checkable across the first days of August 2026. See F.4 for the operational consequence.

C.1 Full batch program set

ProgramCyclePurposeFilesOutput (DSPLY)
HTRESERVDailyAllocate a room by type to each new (N) reservation; lock the rate; else waitlist.HTRESV(UF), HTRTYP(IF), HTROOMLF(UF)HTRESERV BOOKED=n WAITLIST=n SKIP=n
HTCHKINDailyCheck in B arrivals due (ARRDT≤rundate); post night-1 room+tax.HTRESV(UF), HTFOLIO(UF A)HTCHKIN CHECKEDIN=n SKIP=n
HTNAUDITDailyPost each further night's room+tax on checked-in stays not yet audited today.HTRESV(UF), HTFOLIO(UF A)HTNAUDIT POSTED=n SKIP=n
HTINCTALDailyAccrue open F&B/minibar folio lines into RBAL once (stamp FSTAT='A').HTFOLIO(UF), HTRESV(UF)HTINCTAL ACCRUED=n SKIP=n
HTPAYAPLDailyApply open PY payment lines against RBAL once (stamp FSTAT='A').HTFOLIO(UF), HTRESV(UF)HTPAYAPL APPLIED=n SKIP=n
HTCHKOUTDailyCheck out settled (RBAL≤0) stays past departure; release room 'D'; settle open lines. Unsettled → held.HTRESV(UF), HTROOM(UF), HTFOLIO(UF)HTCHKOUT OUT=n HELD=n SKIP=n
HTHSKPWeeklyTurn every vacant-dirty (D) room back to vacant-clean (V).HTROOM(UF)HTHSKP CLEANED=n
HTNOSHOWWeeklyMark B reservations past arrival as no-show (S); release their earmarked room to V.HTRESVLF(UF), HTROOM(UF)HTNOSHOW RELEASED=n
HTOCCRPTMonthlyPrint every occupied room with guest and folio balance; total occupied + balance.HTROOM/HTRESV/HTGUEST(IF), HTOCCP(PRTF)HTOCCRPT ROOMS=n BAL=n
HTGLPSTMonthlySum posted room + tax revenue; post the movement since last close (cash Dr / room Cr / tax Cr).HTFOLIO(IF), HTGLDIST(SQL)HTGLPST BATCH=202608 ROWS=n
HTAUDRPTMonthly/AnnualILE COBOL folio control report: total room/tax/other, count lines and open lines.HTFOLIO (indexed)HTAUDRPT ROOM/TAX/OTHER/LINES/OPEN
HTARCHIVAnnualWrite one YE archive line per settled (O) stay with its full room+tax+incidental turnover; reset RNIGHTS/RLAUDT.HTRESV(UF), HTFOLIO(UF A)HTARCHIV ARCHIVED=n RESET=n SKIP=n

C.2 Daily / weekly / monthly / annual detail

Daily — HTDAILY

Runs the six programs above in order: HTRESERV → HTCHKIN → HTNAUDIT → HTINCTAL → HTPAYAPL → HTCHKOUT. Allocation walks the type-keyed room LF in (RTYPE,ROOMNO) order for the first vacant-clean room; a booked room is taken off the vacant pool immediately (RSTAT→'O') so a second reservation cannot double-book it. Occupancy tax is a flat 10% of the room charge. The daily chain is safely re-runnable end to end — every step's guard makes a re-run a no-op.

Expected DSPLY (four seeded reservations, two STD rooms free):
  HTRESERV BOOKED=3 WAITLIST=1     2 STD + 1 DLX booked; 3rd STD waitlisted (0103 is OOO)
  HTCHKIN  CHECKEDIN=2             2 arrivals due 20260801 (DLX arrives 20260802, not yet)
  HTNAUDIT POSTED=2                a 2nd night for both -> each folio 110.00 -> 220.00
  HTINCTAL ACCRUED=1               one 45.00 F&B line -> 265.00
  HTPAYAPL APPLIED=2               full 265.00 -> 0.00; partial 100.00 -> 120.00
  HTCHKOUT OUT=1 HELD=1            settled stay out (room -> D); unsettled 120.00 held

Weekly — HTWEEK

Runs HTHSKP → HTNOSHOW. Housekeeping returns every vacant-dirty room (left by a check-out) to vacant-clean; the no-show sweep walks the arrival-date-keyed reservation LF and, for every B booked stay whose arrival date has passed (relative to HTNOSHOW's 20260805 run date) without a check-in, marks it S and releases its room to V.

Expected DSPLY:
  HTHSKP   CLEANED=1               the checked-out room 0101 D -> V
  HTNOSHOW RELEASED=1              DLX RESV0004 never checked in -> S, room 0201 -> V

Monthly — HTMONTH

Runs HTOCCRPT → HTGLPST → HTAUDRPT. The occupancy report lists each occupied room with its checked-in guest and running balance. The GL post sums every room and tax folio line ever posted, then posts only the movement since the last close — it reads back what is already on 4100-ROOM/2200-TAX and subtracts it, so a re-run in the same period posts zero rows. Each post is a balanced set: cash debit = room credit + tax credit. The COBOL control report reconciles the folio totals independently.

Expected DSPLY (one checked-in stay, 2 nights, balance 220.00):
  HTOCCRPT ROOMS=1 BAL=220.00
  HTGLPST  BATCH=202608 ROWS=3     1100-CASH D 220.00, 4100-ROOM C 200.00, 2200-TAX C 20.00
  HTAUDRPT ROOM 200.00 / TAX 20.00 / LINES 4 / OPEN 4

Annual — HTYEAR

Runs HTARCHIV → HTAUDRPT. For every settled (checked-out, O) reservation still carrying nights, the archive sums the stay's room+tax+F&B+minibar turnover from its own folio lines and writes one summary line into the same folio file under code YE at a reservation-derived sequence band (900 + RNIGHTS×2) that no live posting program uses, then resets RNIGHTS=0 and RLAUDT=0 so next year's audit does not inherit this year's counters. The RNIGHTS=0 reset is itself the re-run guard.

Expected DSPLY (one settled stay, 220.00 turnover):
  HTARCHIV ARCHIVED=1 RESET=1      one YE line of 220.00; counters cleared

C.3 Ordering & dependencies

D. Data Files (data dictionary) ↑ top

All files are in library HOSTEL, grounded in the DDS and SQL DDL in src/sources.mjs. Dates are stored as signed numeric YYYYMMDD (8S,0) or YYYYMM for the GL batch; money is packed decimal (nP m). "P" = packed, "S" = zoned/signed, "A" = character.

HTRTYP — Room-type / rate master (unique key RTYPE)

FieldTypeMeaning
RTYPE3ARoom-type code (key), e.g. STD/DLX/STE.
RDESC20ADescription, e.g. STANDARD DOUBLE.
RATE9P 2Standard nightly rate this type books at.
MAXOCC1S 0Maximum guests the type sleeps.
RSTAT1AA active (sellable); else withdrawn.

Seeded types: STD 100.00/maxocc 2, DLX 150.00/maxocc 2, STE 250.00/maxocc 4 (all active).

HTROOM — Room master (unique key ROOMNO)

FieldTypeMeaning
ROOMNO4ARoom number (key), e.g. 0101.
RTYPE3ARoom type it belongs to (drives its rate).
RFLOOR2S 0Floor number.
RSTAT1AV vacant-clean, O occupied, D vacant-dirty, X out-of-order.

Seeded rooms: 0101/0102 STD V, 0103 STD X (out-of-order — drives the waitlist case), 0201 DLX V, 0301 STE V.

HTROOMLF — Room logical, keyed by RTYPE (then ROOMNO)

Alternate access path over HTROOM keyed RTYPE, ROOMNO — the availability-by-type walk allocation genuinely wants (find a free room of the requested type) instead of scanning the whole room list in room-number order.

HTGUEST — Guest master (unique key GUESTID)

FieldTypeMeaning
GUESTID6AGuest id (key), e.g. G00001.
GNAME30AGuest name.
GPHONE15APhone number.
GVIP1AVIP Y/N — cosmetic on the inquiry screen, not load-bearing in the arithmetic (no invented VIP discount).
GSTAT1AA active.

Seeded guests: G00001 JANET OKAFOR (N), G00002 MARCUS VANCE (VIP Y), G00003 PRIYA RAMASWAMY (N), G00004 TOM LINDQVIST (N).

HTRESV — Reservation header (unique key RESVNO)

FieldTypeMeaning
RESVNO8AReservation number (key), e.g. RESV0001.
GUESTID6AOwning guest.
RTYPE3ARequested room type.
ARRDT / DEPDT8S 0Arrival / departure dates (YYYYMMDD).
ROOMNO4AAssigned room (blank until booked; blank on waitlist).
RSTAT1AStay lifecycle: N/W/B/I/O/X/S (see A.2).
RATELOCK9P 2Room-type rate stamped at booking (never repriced later).
RNIGHTS3S 0Nights already posted by the night audit (re-run guard; 0 = year-end reset).
RLAUDT8S 0Last calendar date audited (same-day double-post guard).
RBAL11P 2Folio running-balance mirror — what the stay owes.

HTRESVLF — Reservation logical, keyed by ARRDT (then RESVNO)

Alternate access path keyed ARRDT, RESVNO — the arrivals list the front desk works from (who is due in today) and the walk the no-show sweep needs (who is still B past their arrival date).

HTFOLIO — Folio charge/payment lines (unique composite key RESVNO, FSEQ)

FieldTypeMeaning
RESVNO8AReservation the line belongs to (key part 1).
FSEQ3S 0Line sequence within the stay (key part 2).
FDT8S 0Line date (YYYYMMDD).
FCODE2ARM room, TX occupancy tax, FB food&beverage, MB minibar, PY payment (negative), YE year-end archive.
FAMT11P 2Line amount (payments are negative).
FSTAT1AO open, S settled, A accrued/applied into RBAL.
Every idempotency guard that chains this file uses a KLIST (composite key), not a single-field CHAIN, e.g. FKEY KLIST over (WRESV, WSEQ) in the night audit — the same convention as the estate's order-line files.

HTFOLLF — Folio logical, keyed by FCODE (then RESVNO, FSEQ)

Alternate access path keyed FCODE, RESVNO, FSEQ — the revenue-by-department view (room vs tax vs F&B vs minibar) the monthly close and GL post want without re-summing every folio.

HTGLDIST — GL distribution (SQL table, PK GLSEQ)

FieldTypeMeaning
GLSEQDECIMAL(8,0)GL row sequence (PK) — never restarted; MAX+1 each post.
GLBATCHDECIMAL(6,0)Batch/period, e.g. 202608.
ACCTCHAR(9)Account: 1100-CASH, 4100-ROOM, 2200-TAX.
DRCRCHAR(1)D debit / C credit.
AMTDECIMAL(11,2)Posted amount.
GLREFCHAR(8)Reference, e.g. ROOMREV.
GLDTDECIMAL(8,0)GL date (YYYYMMDD).

Index HTGLDACC on (ACCT, DRCR) supports the movement-since-last-close read-back.

Display & printer files

Relationships

E. Operations Runbook ↑ top

E.1 Day-in-the-life

  1. Confirm the job's library list includes HOSTEL (LIBL = QSYS QGPL HOSTEL QTEMP).
  2. Capture the day's reservation requests as HTRESV rows with RSTAT='N' (guest, type, arrival, departure; room blank, balances zero).
  3. Post any incidentals as HTFOLIO lines (FCODE='FB'/'MB', FSTAT='O') and any payments (FCODE='PY', FAMT negative, FSTAT='O').
  4. Submit the daily cycle: SBMJOB CMD(CALL PGM(HOSTEL/HTDAILY)).
  5. Post-check the daily run (see below).
  6. Handle look-ups interactively through CALL HOSTEL/HTMENU (reservation and folio inquiry).
  7. On the weekly schedule, submit HTWEEK to clean turned-over rooms and release no-shows.

Post-checks after the daily cycle (each program DSPLYs its counts to the job log):

E.2 Month-end & year-end close

Month-end:

  1. Confirm the period's daily cycles have run and front-desk postings are applied.
  2. Submit HTMONTH. Confirm HTOCCRPT ROOMS=/BAL=, HTGLPST BATCH=202608 ROWS=, and the HTAUDRPT totals.
  3. Review and reconcile the GL distribution:
SELECT ACCT, DRCR, AMT FROM HOSTEL.HTGLDIST ORDER BY GLSEQ;

Reconciling figures (the same ones the cycles battle checks by hand against the seeded scenario — one checked-in STD stay, 2 nights):

Year-end: after the settled stays have checked out, submit HTYEAR. Confirm HTARCHIV ARCHIVED=/RESET=; each settled stay gets one YE folio line carrying its full room+tax(+F&B+minibar) turnover (e.g. 220.00) and its RNIGHTS/RLAUDT reset to 0.

E.3 Failure & re-run rules

Every program DSPLYs its counts; a healthy re-run of an already-processed cycle shows all-zero action counts (nothing left in the acted-on state). The estate tests assert every cycle is safely re-runnable.

SituationBehaviourAction
Daily chain fails partwayCompleted steps left their state stamped (RSTAT/FSTAT/RLAUDT); pending rows untouched.Re-submit HTDAILY: each step skips what it already did and finishes the rest. Idempotent by state.
Re-run allocationOnly N reservations are processed.Safe no-op: HTRESERV BOOKED=0 WAITLIST=0.
Re-run night audit same dayRLAUDT ≥ run date guard skips every stay.Safe no-op: POSTED=0, balances unchanged. A new night requires advancing the run date (see F.4).
Re-run incidental / paymentA line already folded into RBAL is FSTAT='A'.Safe no-op: ACCRUED=0 / APPLIED=0; never double-counted.
Check-out of an unsettled stayBalance > 0 → counted as HELD, left checked-in.Post/apply a payment to clear the balance, then re-run HTCHKOUT.
Re-run GL post same periodMovement-since-last-close read-back nets to zero.Safe no-op: ROWS=0; the ledger is not double-posted. A refused insert is not counted as a posted row (guarded on sqlcod=0).
Re-run annual archiveRNIGHTS=0 reset signal is already set.Safe no-op: ARCHIVED=0 RESET=0; a stay is never archived twice.
Because every money movement is a folio line and the reservation header mirrors the balance, any cycle's effect is fully reconstructable after the fact from HTFOLIO plus HTRESV.RBAL, and HTAUDRPT reconciles the room/tax totals independently for recovery.

F. Developer Reference ↑ top

The complete program surface, from src/sources.mjs. All objects are in library HOSTEL. Fixed-form RPG C-specs and free-form /free blocks are used side by side, mirroring the estate's ibmi/samples.js convention.

F.1 Programs

HTREFLD (RPG) — seed reference data
Writes the 3 room types, 5 rooms and 4 guests. DSPLYs HTREFLD RTYPE=3 ROOM=5 GUEST=4. Run once after HTSETUP.
HTRESERV (RPG) — reservation capture + allocation. Daily.
For each N reservation: CHAIN HTRTYP for the rate; SETLL/READE the type-keyed HTROOMLF for the first V room; if found, flip room to O, set reservation ROOMNO/RATELOCK/RSTAT='B'; else RSTAT='W'. Re-CHAINs the reservation after the room walk moved the cursor.
HTCHKIN (RPG) — check-in + first night. Daily.
For each B stay with ARRDT ≤ run date: RSTAT='I', RNIGHTS=1, RLAUDT=run date, RBAL = rate + tax; WRITE folio lines FSEQ 1 (RM) and 2 (TX). Tax = rate × 10 / 100.
HTNAUDIT (RPG) — night audit. Daily.
For each I stay with RLAUDT < run date and DEPDT > RLAUDT: post one more room+tax pair at FSEQ = RNIGHTS×2 + 1 (and +1), RNIGHTS++, RLAUDT=run date, RBAL += rate + tax. Stays past departure are not billed further.
HTINCTAL (RPG) — incidental accrual. Daily.
Walks HTFOLIO; for each O line that is not RM/TX/PY, stamps it A and adds FAMT to the reservation's RBAL once.
HTPAYAPL (RPG) — payment application. Daily.
Walks HTFOLIO; for each O line with FCODE='PY' (amount already negative), stamps it A and adds the negative FAMT to RBAL once (reducing it).
HTCHKOUT (RPG) — check-out + settlement. Daily.
For each I stay with DEPDT ≤ run date: if RBAL > 0, count HELD and leave; else RSTAT='O', release room to D, and set every open folio line to S.
HTHSKP (RPG) — housekeeping. Weekly.
Walks HTROOM; every D room becomes V.
HTNOSHOW (RPG) — no-show release. Weekly.
Walks HTRESVLF (arrival-keyed); each B stay with ARRDT < run date becomes S and its room is released to V.
HTOCCRPT (RPG) — occupancy/revenue report. Monthly.
For each O (occupied) room, finds the checked-in reservation that holds it, resolves the guest, and prints room/type/status/guest/balance via HTOCCP; totals count and balance with overflow (*IN90) header reprint.
HTGLPST (SQLRPGLE) — GL post. Monthly.
Sums every RM and TX folio line; via embedded SQL reads MAX(GLSEQ) and the already-posted 4100-ROOM / 2200-TAX credits, subtracts them, and inserts the balanced movement (cash Dr, room Cr, tax Cr). A refused insert (sqlcod ≠ 0) is not counted.
HTARCHIV (RPG) — folio archive + reset. Annual.
For each O stay with RNIGHTS ≠ 0: sums the stay's RM/TX/FB/MB folio lines, WRITEs one YE line at FSEQ = 900 + RNIGHTS×2, then resets RNIGHTS=0, RLAUDT=0.
HTRESVIQ / HTFOLIQ / HTMENU (RPG) — online
Reservation inquiry (CHAIN HTRESV/HTGUEST), folio subfile inquiry (clear + reload FSFL), and the menu that CALLs them by option. All read-only.
HTAUDRPT (ILE COBOL) — folio control report
Reads HTFOLIO sequentially by key; accumulates room / tax / other and counts total lines and open lines; DISPLAYs the five totals. The independent reconciliation of the RPG postings.
HTSETUP (CL) — build
DLTF the files, CRTPF/CRTLF/CRTDSPF/CRTPRTF from QDDSSRC, RUNSQLSTM the GL table + index from QSQLSRC, CRTBNDRPG all 15 RPG programs and CRTBNDCBL the COBOL program.

F.2 Access paths & the allocation walk

The three logical files exist because each carries a genuinely different leading key from its PF, giving a program the ordering it actually needs:

Programs that walk a keyed file to enumerate rows and then need the header again re-CHAIN the header afterwards, because the row walk moved the shared cursor — e.g. HTRESERV re-CHAINs HTRESVR after the room walk, and HTARCHIV re-CHAINs after summing folio lines.

F.3 Idempotency guards

GuardWhereHow it prevents a double
RSTAT skipHTRESERV/HTCHKIN/HTNAUDIT/HTCHKOUT/HTNOSHOWOnly rows in the acted-on state are processed; a processed row has moved to a new state.
RLAUDT stampHTNAUDITRLAUDT ≥ run date skips a stay already audited on that date — the same-day double-post guard.
FSTAT flipHTINCTAL / HTPAYAPLA line folded into RBAL is stamped A; a re-run only sees O lines.
Movement read-backHTGLPSTReads already-posted 4100-ROOM/2200-TAX and subtracts, so a re-run's delta is zero (never restarts GLSEQ at 1).
RNIGHTS=0 resetHTARCHIVA reset stay carries RNIGHTS 0; a live stay always ≥ 1, so a second annual run finds nothing to archive.
Settlement gateHTCHKOUTRefuses RBAL > 0; a stay cannot be closed (or double-closed) with money owing.

F.4 The run-date model

Every date-sensitive program carries its processing date as a compiled literal in a WRUNDT/WBATCH field rather than reading a control row:

ProgramLiteralMeaning
HTCHKIN20260801Check-in / first-night run date.
HTNAUDIT20260802Night-audit run date (posts night 2).
HTCHKOUT20260803Check-out run date.
HTNOSHOW20260805No-show sweep run date.
HTGLPST202608 / 20260831GL batch period / GL row date.
HTARCHIV20261231Year-end archive-line date.

Operational consequence: the shipped estate is a hand-checkable oracle across the first days of August 2026 — the night audit posts exactly one further night, check-out lands on the departure date, and the no-show sweep fires for the DLX reservation that was never checked in. To advance the model to a new business date in a real deployment, the run-date literals are the single edit point (change WRUNDT and recompile), not a control-row update. This is an honest limitation of the sample: it trades a live clock for a deterministic, auditable oracle.

G. Glossary ↑ top

Allocation
Assigning a specific room to a reservation. HTRESERV walks the type-keyed room LF for the first vacant-clean room of the requested type and earmarks it (room → O, reservation → B); no room free → waitlisted (W).
Folio
A guest stay's running bill — here the set of HTFOLIO lines for one reservation, each a room night, tax, incidental, payment or year-end archive line. HTRESV.RBAL mirrors its balance.
Night audit
The nightly hotel batch that posts each in-house stay one more night's room charge and tax. HTNAUDIT; guarded by RLAUDT so it cannot double-post the same date.
Occupancy tax
A flat 10% of the room charge, posted as a separate TX folio line alongside each RM night.
No-show
A booked reservation whose arrival date passed without a check-in. HTNOSHOW marks it S and releases its earmarked room back to the vacant pool.
Rate lock (RATELOCK)
The room-type nightly rate stamped onto the reservation at booking, so a later rate change never reprices a guest already holding a reservation — "stamp it once, trust the stamp".
RBAL mirror
The folio running balance carried on the reservation header, so the header alone answers "what is owed" without a folio scan; every posting program keeps it in step.
Room status (V/O/D/X)
Availability of a physical room: vacant-clean (sellable), occupied, vacant-dirty (checked out, needs housekeeping before resale), out-of-order (never allocated).
Settlement gate
HTCHKOUT's refusal to close a stay whose balance is still positive — an unsettled folio cannot check out.
SBMJOB
Submit Job — the IBM i command that queues a program to run as a batch job (e.g. SBMJOB CMD(CALL PGM(HOSTEL/HTDAILY))). The cycle CLs take no parameters.
Subfile
A 5250 display construct listing many rows on one screen (DDS SFL/SFLCTL). HTFOLIQ's folio-line list is a subfile (SFLSIZ 20 / SFLPAG 5, roll keys).
Turnover sweep (housekeeping)
HTHSKP's weekly pass returning every vacant-dirty room to vacant-clean so it can be sold again.