<?xml version="1.0" encoding="UTF-8"?><!-- MAGEC is a trademark of Al Lee & Associates, Inc. © 2026 Al Lee & Associates, Inc. All rights reserved. All programs, scripts, diagrams, and documentation are copyright protected. -->
<flowchart title="NXT Function">
<settings theme="bold" exportWidth="600" grid="true" logo="ALA_Logo_gray.png"/>
    <nodes>

        <node id="title" type="title" label="NXT Function"><position x="300" y="20"/><narrative>NXT Function — Next Record logic flow diagram. The NXT function has NO NEW-TRANSACTION-MODE of its own. It relies on context stored in the Task Work Area from a prior SEE or CHG function. If NXT is invoked without that prior context, it will behave as if a SEE had just been done.</narrative></node>

        <node id="subtitle" type="comment" label="Maintenance Browse — Continuation Mode Only" width="300"><position x="300" y="60"/><narrative>Reads the next (or previous) record sequentially from the primary data class and displays it on the maintenance screen. Two decision branches handle key-changed and prior-read-failed conditions; all error paths converge at BB100-BLANK-SCREEN before SEND-SCREEN.</narrative></node>

        <node id="1" type="start" label="Begin">
            <position x="210" y="140"/>
            <narrative>Entry into the NXT Function (SFUNCT = xxxNXT). Because NXT has no new-transaction mode, control always arrives here from a prior SEE or CHG transaction context held in the TWA (Task Work Area). Click on any node on this chart for a pop-up with a fuller explanation plus a link to the documentation page for the insertion point referred to.</narrative>
            <link>insert_main.htm#top</link><target>MAIN</target>
        </node>

        <node id="2" type="process" label="AA100-CHECK-FUNCTION&lt;br&gt; %PREINIT">
            <position x="210" y="240"/>
            <narrative>The very first executable logic for all functions. AA100-CHECK-FUNCTION validates the function code. %PREINIT fires before VARIABLE-STORAGE is initialized, before TEST-KEY and TEST-FUNCT are set. No screen fields should be referenced here (except SFUNCT, SKEY, SCOMPL, SERRMSG) unless the mask is verified. Useful for DB binding (DL/1 PCB scheduling, SQL CONNECT), or to change D-LIMITER or WINDOW-COLOR.</narrative>
            <cobolparagraph>AA100-CHECK-FUNCTION</cobolparagraph>
            <link>insert_main.htm#insert001029</link>
            <target>MAIN</target>
        </node>
        <node id="2aside" type="aside" label=" Narrative of Steps - -NXT">
            <position x="480" y="240"/>
            <narrative>Narrative for function.</narrative>
            <link>https://www.magec.com/DOC/genmmp_main.htm#genmmp002011</link>
            <target>MAIN</target>
        </node>

        <edge from="2" to="2aside" style="dotted" label="see also"/>

        <node id="3" type="process" label="BA100-INIT-STORAGE&lt;br&gt; %INIT">
            <position x="210" y="340"/>
            <narrative>Initialization for all MAINT functions. VARIABLE-STORAGE is set to LOW-VALUES just before %INIT executes. Use %INIT to initialize custom work fields defined in %VARSTOR or %DATADEF, especially COMP-3 fields that need to be zeroed. Do not reference screen fields (other than the four standard MAGEC fields) since the proper mask may not yet be active.</narrative>
            <cobolparagraph>BA100-INIT-STORAGE</cobolparagraph>
            <link>insert_main.htm#insert001016</link>
            <target>MAIN</target>
        </node>
        <node id="3aside" type="aside" label="Maintenance Mainline">
            <position x="480" y="340"/>
            <narrative>Mainline logic for all maintenance functions.</narrative>
            <link>https://www.magec.com/DOC/genmmp_main.htm#genmmp004057</link>
            <target>MAIN</target>
        </node>

        <edge from="3" to="3aside" style="dotted" label="see also"/>

        <node id="4" type="process" label="AAM200-MAINTENANCE-MAINLINE&lt;br&gt; %PFKEYM" width="200">
  <position x="210" y="440"/>
  <narrative>Executed at the very top of the MAINT mainline for every transaction. Default logic handles PF7/PF8 (backward/forward browse → transfers to xxxNXT), PF4 (transfer to xxxLOC), PF1/PF2/PF11 (help), PF16/PF17 (copy/paste), and cursor-movement detection for implicit CHG. Developer can intercept any PF key, alter SKEY/TEST-KEY and SFUNCT/TEST-FUNCT, or bypass the entire mainline.</narrative>
  <link>insert_main.htm#insert001028</link>
  <target>MAIN</target>
  <cobolparagraph>AAM200-MAINTENANCE-MAINLINE</cobolparagraph>
</node>
        <node id="4aside" type="aside" label="TWA-MSK-AREA">
            <position x="480" y="440"/>
            <narrative>First 10-bytes of Mask Area give Mask ID, Cursor position, Entry key detection (ENTER, CLEAR, PF1, PA1, etc.).</narrative>
            <cobolparagraph>TWA-MSK-AREA</cobolparagraph>
            <link>https://www.magec.com/DOC/genmmp_main.htm#genmmp004025</link>
            <target>MAIN</target>
        </node>
        <edge from="4" to="4aside" style="dotted" label="see also"/>

        <node id="5" type="process" label="BA210-MAINT-SCREEN&lt;br&gt; %INITATB">
            <position x="210" y="540"/>
            <narrative>Executed only for MAINT functions. Initializes 3270 screen attributes (field protection, intensity, color). %INITATB fires at the very end of BA210-MAINT-SCREEN immediately before BA299-EXIT. Developer can override default attribute values based on function code, operator ID, or any other criteria. Do not reference file data items here — I/O has not yet been done.</narrative>
            <cobolparagraph>BA210-MAINT-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001017</link>
            <target>MAIN</target>
        </node>
        <node id="5aside" type="aside" label="3270 Attributes">
            <position x="480" y="540"/>
            <narrative>list of 3270 attributes and their meanings.</narrative>
            <cobolparagraph>3270 Attributes</cobolparagraph>
            <link>https://www.magec.com/DOC/magref_main.htm#MAGREF001001</link>
            <target>MAIN</target>
        </node>
        <edge from="5" to="5aside" style="dotted" label="see also"/>

        <node id="6" type="decision" label="Key = Last Key?">
            <position x="210" y="650"/>
            <narrative>Tests whether the key value currently in SKEY equals the key that was saved from the prior SEE or CHG (TWA-LAST-KEY). If YES, the key has not changed — proceed to test whether the prior read was successful. If NO, the key changed — test whether it is spaces.</narrative>
        </node>

        <node id="7" type="decision" label="Prior Read OK?">
            <position x="210" y="770"/>
            <narrative>Tests whether the prior read (from the previous SEE or CHG context) completed successfully. If NOT OK (end-of-file or error), flow routes right to BLNKSCR to blank the screen. If OK, flow drops down to %REDNX to read the next record.</narrative>
        </node>
        <node id="err5" type="elbow" label="">
            <position x="320" y="770"/>
            <narrative>Tests whether the prior read (from the previous SEE- or CHG context) completed successfully. If NOT OK (end-of-file or error), flow routes right to BLNKSCR to blank the screen. If OK, flow drops down to %REDNX to read the next record.</narrative>
        </node>
        <node id="err6" type="elbow" label="">
            <position x="320" y="840"/>
            <narrative>Tests whether the prior read (from the previous SEE or CHG context) completed successfully. If NOT OK (end-of-file or error), flow routes right to BLNKSCR to blank the screen. If OK, flow drops down to %REDNX to read the next record.</narrative>
        </node>

        <node id="8" type="decision" label="Test-Key = Spaces?">
            <position x="450" y="650"/>
            <narrative>When KEY ≠ LAST KEY, the program tests if TEST-KEY is spaces. A spaces key is treated as INVALID KEY and routes right to BLNKSCR. If not spaces, flow continues down to %NORMKEY for key normalization. This is done to try to satisfy the need for a SEE (or other) Function to act as the NEW-TRANSACTION for this task.</narrative>
        </node>

        <node id="9" type="process" label="BA400-NORMALIZE-MAINT-KEY&lt;br&gt; %NORMKEY" width="200">
  <position x="450" y="770"/>
  <narrative>Normalizes the operator-entered key value in SKEY into the internal FILE-KEY format used by MAGECIO. %NORMKEY fires after standard normalization succeeds. The developer can add further key edits, massage the key, or add prefix/suffix based on terminal/operator/location. On error: GO TO BA480-BAD-KEY. Note: this insertion point is for MAINT functions only; %NKLOC handles browse.</narrative>
  <link>insert_main.htm#insert001026</link>
  <target>MAIN</target>
  <cobolparagraph>BA400-NORMALIZE-MAINT-KEY</cobolparagraph>
</node>
        <node id="9a" type="elbow" label="">
            <position x="450" y="840"/>
            <narrative>Normalizes the operator-entered key value in SKEY into the internal FILE-KEY format used by MAGECIO. %NORMKEY fires after standard normalization succeeds. The developer can add further key edits, massage the key, or add prefix/suffix based on terminal/operator/location. On error: GO TO BA480-BAD-KEY. Note: this insertion point is for MAINT functions only; %NKLOC handles browse.</narrative>
            <cobolparagraph>BA400-NORMALIZE-MAINT-KEY</cobolparagraph>
            <link>insert_main.htm#insert001026</link>
            <target>MAIN</target>
        </node>

        <node id="10" type="process" label="AAM430-READ-NEXT-REC&lt;br&gt; %REDNX">
            <position x="210" y="900"/>
            <narrative>Reads the next (or previous, if PF7) record pseudo-sequentially from the Primary Data Class. Direction is controlled by TWA-BROWSE-DIRECTION (F=forward, B=backward). %REDNX appears in BOTH the MAINT and BROWSE mainlines; if exiting with a GO TO, check which mainline you are in (MAINT → AAM440-TEST-RETURN-CODE; BROWSE → AAL440-TEST-RETURN-CODE). Do not code paragraph names inside %REDNX.</narrative>
            <cobolparagraph>AAM430-READ-NEXT-REC</cobolparagraph>
            <link>insert_main.htm#insert001033</link>
            <target>MAIN</target>
        </node>

        <node id="11" type="process" label="JA100-LOGICAL-JOIN&lt;br&gt; %JOIN">
            <position x="210" y="1000"/>
            <narrative>Reads secondary files and computes derived fields to assemble the complete logical record. TWA-DB-REQUEST is saved/restored by the MMP before PERFORMing JA100. To exit: GO TO JA900-RETURN (not JA999-EXIT). If referencing screen fields, test IF (MAINT-FUNCTION) or IF (BROWS-FUNCTION) first. NOT FOUND here routes to BLNKSCR.</narrative>
            <cobolparagraph>JA100-LOGICAL-JOIN</cobolparagraph>
            <link>insert_main.htm#insert001018</link>
            <target>MAIN</target>
        </node>

        <node id="12" type="process" label="BB200-FILL-SCREEN&lt;br&gt; %COMP">
            <position x="210" y="1100"/>
            <narrative>Moves database field values from the Logical Record (TWA-DB-DATA) to screen fields. %COMP fires at the end of BB200-FILL-SCREEN, after all generated MOVEs, just before BB299-EXIT. Developer can move literals, computed values, or code translations, and can alter 3270 attributes based on data values. Do not reference MSK652 (Browse Mask) here.</narrative>
            <cobolparagraph>BB200-FILL-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001005</link>
            <target>MAIN</target>
        </node>

        <node id="13" type="process" label="BB200-FILL-SCREEN&lt;br&gt; %SKEYBLD">
            <position x="210" y="1200"/>
            <narrative>Constructs the Master (Primary) key in operator-entry format (including slashes, etc.) from the record data and MOVEs the result to SKEY and TWA-LAST-KEY. This is performed from the NXT maintenance mainline to simulate the operator's full key entry for cursor-selection and forward/backward reading. The default code for %SKEYBLD IS the entire CA800-BUILD-SKEY routine.</narrative>
            <cobolparagraph>BB200-FILL-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001038</link>
            <target>MAIN</target>
        </node>

        <!-- Right-column error convergence node -->
        <node id="err" type="process" label="BB100-BLANK-SCREEN&lt;br&gt; %BLNKSCR">
            <position x="650" y="1320"/>
            <narrative>Executed on INVALID KEY and on NOT-FOUND conditions. Blanks the screen by MOVEing underscores to all screen variables. %BLNKSCR fires at the very end of BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected screen fields to values other than underscores, read a file based on the key value, or test for key-edit failures (IF SCOMPLE = E). This logic executes only for MAINT functions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>
        <node id="err3" type="elbow" label="">
            <position x="650" y="650"/>
            <narrative>MOVEing to all screen variables. %BLNKSCR fires at the very end of BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected screen fields to values other than underscores, read a file based on the key value, or test for key-edit failures (IF SCOMPLE = E). This logic executes only for MAINT functions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>
        <node id="err4" type="elbow" label="">
            <position x="650" y="770"/>
            <narrative>MOVEing to all screen variables. %BLNKSCR fires at the very end of BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected screen fields to values other than underscores, read a file based on the key value, or test for key-edit failures (IF SCOMPLE = E). This logic executes only for MAINT functions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>
        <node id="err1" type="elbow" label="">
            <position x="650" y="900"/>
            <narrative>Executed on INVALID KEY and on NOT-FOUND conditions. Blanks the screen by MOVEing underscores to all screen variables. %BLNKSCR fires at the very end of BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected screen fields to values other than underscores, read a file based on the key value, or test for key-edit failures (IF SCOMPLE = E). This logic executes only for MAINT functions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>
        <node id="err2" type="elbow" label="">
            <position x="650" y="1000"/>
            <narrative>Executed on INVALID KEY and on NOT-FOUND conditions. Blanks the screen by MOVEing underscores to all screen variables. %BLNKSCR fires at the very end of BB100-BLANK-SCREEN, after all generated MOVEs. Developer can set selected screen fields to values other than underscores, read a file based on the key value, or test for key-edit failures (IF SCOMPLE = E). This logic executes only for MAINT functions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>

        <node id="14" type="process" label="AA800-SEND-SCREEN&lt;br&gt; %SNDSCRN">
            <position x="210" y="1320"/>
            <narrative>Executed just before the MMP exits to MAGECCP. %SNDSCRN fires for both MAINT and BROWSE functions. No default logic. Developer can put finishing touches on the screen (blank zero fields, set highlight/color based on value thresholds, massage SKEY from cursor-select). If referencing non-standard screen fields, test which mask is active first. To exit: GO TO AA900-GOBACK.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="15" type="process" label="AA900-GOBACK&lt;br&gt; %GOBACK">
            <position x="210" y="1420"/>
            <narrative>Absolutely the last logic point in the online process for all functions. %GOBACK fires here, for both MAINT and BROWSE functions. A good place for IMS PCB TERMINATE or other end-of-execution cleanup. Screen data may be referenced only after interrogating which mask is initialized.</narrative>
            <cobolparagraph>AA900-GOBACK</cobolparagraph>
            <link>insert_main.htm#insert001012</link>
            <target>MAIN</target>
        </node>

        <node id="99" type="end" label="End">
            <position x="210" y="1520"/>
            <narrative>NXT Function processing complete.</narrative>
        </node>

        <node id="999" type="comment" label="Figure 03 - NXT">
            <position x="350" y="1580"/>
            <narrative>NXT Function processing complete.</narrative>
        </node>

    </nodes>
    <edges>
        <!-- Main top-to-bottom path -->
        <edge from="1" to="2"/>
        <edge from="2" to="3"/>
        <edge from="3" to="4"/>
        <edge from="4" to="5"/>
        <edge from="5" to="6"/>

        <!-- Decision 1: Key = Last Key -->
        <edge from="6" to="7" label="✅ Key = Last Key"/>
        <edge from="6" to="8" label="Key ≠ Last Key"/>

        <!-- Decision 2: Prior Read OK -->
        <edge from="7" to="10" label="✅ OK"/>
        <edge from="7" to="err5" label="❌ No"/>
        <edge from="err5" to="err6" label=""/>
        <edge from="err6" to="err1" label=""/>

        <!-- Decision 3: Test-Key = Spaces -->
        <edge from="8" to="err3" label="❌ Spaces (Invalid)"/>
        <edge from="err3" to="err1" label=""/>
        <edge from="8" to="9" label="✅ Not Spaces"/>

        <!-- Normalize key -->
        <edge from="9" to="err4" label="❌ Invalid Key"/>
        <edge from="9" to="9a" label="✅ Valid Key"/>  
        <edge from="9a" to="10" label=""/>

        <!-- Read next record -->
        <edge from="10" to="11"/>
        <edge from="10" to="err1" label="❌ Not Found"/>

        <!-- Logical join -->
        <edge from="11" to="err2" label="❌ Not Found"/>
        <edge from="11" to="12" label="✅ OK"/>

        <!-- Fill screen and build key -->
        <edge from="12" to="13"/>

        <!-- Converge at SEND-SCREEN -->
        <edge from="13" to="14"/>
        <edge from="err1" to="err"/>
        <edge from="err" to="14"/>

        <!-- Finish -->
        <edge from="14" to="15"/>
        <edge from="15" to="99"/>
    </edges>
</flowchart>