Freshmark Report Runner Phase
Why this phase exists
The menu simulator has already proven the core chain:
- Read a menu row from
ZM_MENU - Parse
ZM_PGM - Resolve the target to a report key in
ZE_ENQ - Build preview SQL from report metadata
- Query the replicated
fmsdata schema - Return sample rows
That means we are past the "is this metadata real?" stage.
The next phase is to move from a limited report preview to a usable report runner.
Current state
What works today:
- menu items can be classified as submenu, program, report, or unknown
- report-backed menu items can load
ZE_ENQmetadata - the simulator can build live preview SQL from:
ZE_TABLEZE_JOINZE_SELECTION- the preview can execute against the configured data schema when live access is enabled
What is still missing:
- runtime parameter capture
- selector-driven prompts from
ZS_SEL - wrapper-program decoding from
ZP_PGMSandZX_PGMS_FIELDS - explicit handling of
ZE_ORDER - column projection and heading logic from report metadata
- a stable execution model for reports that are more than
SELECT *
Current execution flow
Target execution flow
Runtime components we need
1. Report launcher resolution
We already resolve ZM_MENU.ZM_PGM to a report key in the happy path.
What still needs work:
- identify wrapper launch patterns that do not point straight at
ZE_ENQ.ZE_KEY - understand whether
ZM_PGMBEFOREandZM_PGMAFTERinject state, prompts, or side effects - separate "direct report launch" from "program opens a prompt screen and then launches report"
2. Prompt and selector model
This is the biggest missing layer.
Likely metadata sources:
ZS_SELfor reusable lookup and selector definitionsZX_PGMS_FIELDSfor prompt-screen fields and embedded runtime logicZP_PGMSfor the wrapper program that hosts a prompt screen
We need to answer:
- which report launches require user input before execution
- how selector keys like
S:DEBTOR_CR2map into SQL conditions - whether parameter values are injected into
ZE_SELECTION,ZE_JOIN, or both - which prompts are optional versus required
Shortest path to a usable runner
Slice 1. Query plan endpoint
Add a backend layer that compiles a report into a structured query plan before execution.
Suggested output:
- report key
- base table
- join fragment
- where fragment
- order fragment
- required runtime inputs
- unresolved tokens
- compiled SQL preview
Why first:
- it gives us a stable debugging artifact
- it separates metadata decoding from execution
- it makes the next UI step much easier
Slice 2. Explicit ZE_ORDER support
The preview path currently exposes ZE_ORDER in the UI but does not compile it into SQL.
This is the smallest high-value upgrade because it:
- improves fidelity immediately
- requires no new UI concepts
- keeps the query planner honest
Slice 3. Promptless report runner
Support reports that can run with no extra user input.
Definition of done:
- choose report from menu simulator or reports list
- compile the query plan
- execute with table, join, selection, and order
- return rows plus the final SQL
This gets us from "preview" to "runner" for the simplest class of reports.
Slice 4. Prompt schema extraction
Build a metadata model for prompts even before the UI is complete.
Suggested normalized shape:
- prompt key
- label
- source table or selector
- field name
- operator
- required flag
- multi-select flag
- default value
This model should come from ZS_SEL plus relevant ZX_CODE token families.
Slice 5. Parameterized runner UI
Once the prompt schema exists, add a runtime form that:
- renders prompt fields
- runs selectors
- submits values to the query-plan compiler
- executes the report with those values bound
Slice 6. Layout fidelity
After execution works, improve presentation.
Likely sources:
ZE_FIELDSZE_HDG- wrapper program metadata
- field definitions referenced by the launching screen
This is where we move from "correct rows" to "report that looks like Freshmark".
Recommended architecture
Metadata dependencies by responsibility
| Responsibility | Likely source | Notes |
|---|---|---|
| menu entry point | fmsx.ZM_MENU |
starting point for user navigation |
| direct report definition | fmsz.ZE_ENQ |
base table, joins, filters, headings, ordering |
| selector definitions | fmsz.ZS_SEL |
lookup dialogs and reusable selection rules |
| wrapper program | fmsz.ZP_PGMS |
identifies report-launch programs and prompt screens |
| field and logic model | fmsz.ZX_PGMS_FIELDS |
prompt fields, ZX_CODE, validation, derived logic |
| table ownership | fmsz.ZT_TABLE |
tells us which schema a referenced table belongs to |
Success criteria for this phase
We should consider the report-runner phase successful when we can do all of the following for a representative subset of reports:
- start from a real menu item
- determine whether the launch is direct or wrapper-based
- identify all required runtime inputs
- compile the final SQL deterministically
- execute it safely against the replica
- display returned rows with meaningful headings
- explain which metadata rows were used to build the result
Suggested first report samples
Use a small set of representative reports instead of trying to support all ZE_ENQ rows at once.
Recommended buckets:
- one report with no prompts
- one report with a simple
ZS_SELselector - one report launched through a wrapper program
- one report with non-trivial joins
- one report where
ZX_CODEclearly injects runtime behavior
Immediate next implementation tasks
- Add a query-plan function that returns
table,join,where,order,sql, and unresolved tokens. - Extend the current preview SQL builder to compile
ZE_ORDER. - Add a "plan only" API route so we can inspect report compilation without executing it.
- Choose three sample reports and document their launcher path from
ZM_MENUtoZE_ENQ. - Start a token inventory for prompt-related
ZX_CODEand selector references.