<?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="DEL Function">
<settings theme="bold" exportWidth="600" grid="true" logo="ALA_Logo_gray.png"/>
    <nodes>

        <node id="title" type="title" label="DEL Function"><position x="340" y="20"/><narrative>DEL Function — Delete Record logic flow diagram. Allows an authorised operator to remove a record from the primary Data Class. Processing has two phases: New Transaction Mode (key entry, read, and display for confirmation) and Continuation Mode (operator confirms and the system performs the actual deletion).</narrative></node>

        <node id="subtitle" type="comment" label="Two-Phase Maintenance — Display for Confirmation, then Delete"><position x="340" y="70"/><narrative>The referential integrity rule RULDELT is inserted immediately after %DELEDIT. If RULDELT sets the ERROR-FOUND flag, processing follows the error path out of BB400-EDIT-FOR-DELETE rather than proceeding to the actual delete.</narrative></node>

        <node id="1" type="start" label="Begin">
            <position x="210" y="140"/>
            <narrative>Entry into the DEL Function (SFUNCT = xxxDEL).</narrative>
        </node>

        <node id="2" type="process" label="AA100-CHECK-FUNCTION- -%PREINIT">
            <position x="210" y="240"/>
            <narrative>The very first execution point for every transaction, regardless of function or mode. %PREINIT is called before VARIABLE-STORAGE is initialised and before TEST-FUNCT / TEST-KEY are set. No 88-level condition names are yet reliable unless SFUNCT is first MOVEd to TEST-FUNCT. Commonly used for database binding (DL/1 PCB scheduling, SQL CONNECT) or to alter the key delimiter character.</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 - -DEL">
            <position x="480" y="240"/>
            <narrative>Narrative for function.</narrative>
            <link>https://www.magec.com/DOC/genmmp_main.htm#genmmp002007</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>Initialisation routine for all MAINT-FUNCTIONs. VARIABLE-STORAGE is set to LOW-VALUES immediately before %INIT executes. Use to initialise custom COMP-3 work fields or other variables defined in %VARSTOR or %DATADEF.</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>Top of the maintenance mainline. Executed for every MAINT transaction in both modes. Default logic handles PF7/PF8 (browse backward/forward), PF4 (transfer to LOC), PF1/PF2/PF11 (help), PF16/PF17 (copy/paste), and cursor-movement detection. Developers can intercept or override PF-key handling here.</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>Attribute initialisation for MAINT functions only. Fires at the end of the attribute-init routine, just before BA299-EXIT. Developers may override 3270 field attributes or set variable screen headings based on function code, operator ID, or other criteria.</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="process" label="BA400-NORMALIZE-MAINT-KEY&lt;br&gt;  %NORMKEY" width="200">
  <position x="210" y="640"/>
  <narrative>Normalises the operator's key entry from SKEY into FILE-KEY, then MOVEs FILE-KEY to NORMALIZED-KEY. %NORMKEY fires after standard editing and reformatting, and only if no key errors were detected. Branching to BA480-BAD-KEY raises the INVALID-KEY condition.</narrative>
  <link>insert_main.htm#insert001026</link>
  <target>MAIN</target>
  <cobolparagraph>BA400-NORMALIZE-MAINT-KEY</cobolparagraph>
</node>

        <node id="7" type="decision" label="Key Mode?">
            <position x="290" y="750"/>
            <narrative>Determines the read path after normalization: New Transaction Mode reads the record fresh by key (non-exclusive); Continuation Mode reads the record for update (exclusive control); Invalid Key blanks the screen.</narrative>
        </node>
        <node id="7a" type="elbow" label="">
            <position x="570" y="750"/>
            <narrative/>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="8" type="process" label="AAM410-READ-BY-KEY&lt;br&gt;  %REDKY">
            <position x="400" y="870"/>
            <narrative>Read the primary Data Class by key (non-exclusive) in new-transaction mode. Default logic: FSTAT to check file status, REDKY to read using NORMALIZED-KEY, then PERFORMs JA100-LOGICAL-JOIN. Also saves the Audit-Stamp for later comparison in %RDUKY. Must exit to AAM440-TEST-RETURN-CODE.</narrative>
            <cobolparagraph>AAM410-READ-BY-KEY</cobolparagraph>
            <link>insert_main.htm#insert001031</link>
            <target>MAIN</target>
        </node>

        <node id="9" type="process" label="AAM420-READ-BY-KEY-FOR-UPDAT&lt;br&gt;  %RDUKY" width="200">
  <position x="190" y="870"/>
  <narrative>Read the primary Data Class with EXCLUSIVE CONTROL in preparation for delete. Default logic: RDUKY command, then PERFORMs JA100-LOGICAL-JOIN, then compares the current Audit-Stamp against the saved one to detect concurrent updates. Must exit to AAM440-TEST-RETURN-CODE.</narrative>
  <link>insert_main.htm#insert001030</link>
  <target>MAIN</target>
  <cobolparagraph>AAM420-READ-BY-KEY-FOR-UPDAT</cobolparagraph>
</node>

        <node id="10" type="process" label="JA100-LOGICAL-JOIN&lt;br&gt;  %JOIN">
            <position x="290" y="980"/>
            <narrative>PERFORMed after every primary read. Reads secondary Data Classes and/or computes derived fields to build the MMP's Logical Record. Executed for both MAINT and BROWS functions. Exit via GO TO JA900-RETURN (not JA999-EXIT). MAGEC may auto-generate join code here from Screen Painting definitions or SQL.</narrative>
            <cobolparagraph>JA100-LOGICAL-JOIN</cobolparagraph>
            <link>insert_main.htm#insert001018</link>
            <target>MAIN</target>
        </node>

        <node id="11" type="decision" label="Rec Found?">
            <position x="290" y="1090"/>
            <narrative>Tests whether the primary read returned a record. NOT FOUND routes to the blank-screen path. Found routes to the new-transaction-vs-continuation mode decision.</narrative>
        </node>

        <node id="12" type="decision" label="Mode?">
            <position x="290" y="1200"/>
            <narrative>Mode decision point after a successful read and join. In NEW-TRANSACTION MODE, flow goes to %COMP (BB200-FILL-SCREEN) to display the record for operator confirmation. In CONTINUATION MODE, flow goes to %DELEDIT (BB400-EDIT-FOR-DELETE) to validate the deletion.</narrative>
        </node>

        <node id="13" type="process" label="BB200-FILL-SCREEN&lt;br&gt;  %COMP">
            <position x="460" y="1310"/>
            <narrative>Fires in NEW-TRANSACTION-MODE after a successful read, when REC-FOUND. Default logic MOVEs all database fields to their corresponding screen fields. %COMP fires at the end, before BB299-EXIT, allowing the developer to translate codes, compute derived display values, or set 3270 colour attributes.</narrative>
            <cobolparagraph>BB200-FILL-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001005</link>
            <target>MAIN</target>
        </node>
        <node id="13a" type="elbow" label="">
            <position x="570" y="1310"/>
            <narrative/>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="14" type="process" label="BB400-EDIT-FOR-DELETE&lt;br&gt;  %DELEDIT">
            <position x="120" y="1310"/>
            <narrative>Entire BB400-EDIT-FOR-DELETE routine is composed of %DELEDIT logic (no default generated code). Only executed in CONTINUATION-MODE for DEL functions. Developer may check for subordinate records, non-zero balances, or require a specific PF key before allowing deletion. The MAGEC referential integrity rule RULDELT is inserted immediately after %DELEDIT — if either sets FATAL-ERR = E / ERROR-FOUND, the error path is taken. TWA-DB-REQ-SAV holds the saved TWA-DB-REQUEST; do not corrupt it.</narrative>
            <cobolparagraph>BB400-EDIT-FOR-DELETE</cobolparagraph>
            <link>insert_main.htm#insert001007</link>
            <target>MAIN</target>
        </node>

        <node id="15" type="decision" label="Error Found?">
            <position x="120" y="1420"/>
            <narrative>Evaluates the result of %DELEDIT and the RULDELT referential-integrity rule. If ERROR FOUND, the delete is suppressed and the flow routes to SEND-SCREEN with an error message. If no error, the flow proceeds to the actual delete.</narrative>
        </node>
        <node id="15a" type="elbow" label="">
            <position x="570" y="1420"/>
            <narrative/>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="16" type="process" label="AAM730-DELETE-FROM-DATABASE&lt;br&gt;  %DELET" width="200">
  <position x="120" y="1540"/>
  <narrative>Performs the actual physical deletion of the primary Data Class record. Default logic calls the MAGEC I/O module with the DELET command. Only executed in CONTINUATION-MODE and only when ERROR-FOUND is NOT set. Developer may override to access non-MAGEC files/DBMS. Must exit to AAM750-TEST-RETURN-CODE.</narrative>
  <link>insert_main.htm#insert001008</link>
  <target>MAIN</target>
  <cobolparagraph>AAM730-DELETE-FROM-DATABASE</cobolparagraph>
</node>

        <node id="17" type="decision" label="Delete OK?">
            <position x="120" y="1650"/>
            <narrative>Tests the return code from the DELET I/O call. A failure routes to the update-error paragraph; success routes to the good-delete paragraph.</narrative>
        </node>

        <node id="18" type="process" label="AAM751-UPDERR&lt;br&gt;  %UPDERR">
            <position x="430" y="1650"/>
            <narrative>Executed when the DELET I/O fails (bad return code from MAGEC I/O module). Default logic: MOVE DB-ERR-MSG to SCOMPL, GO TO AA800-SEND-SCREEN. Developer may attempt custom recovery but this is rarely necessary; true I/O errors are usually handled by MAGEC itself.</narrative>
            <cobolparagraph>AAM751-UPDERR</cobolparagraph>
            <link>insert_main.htm#insert001044</link>
            <target>MAIN</target>
        </node>
        <node id="18a" type="elbow" label="">
            <position x="430" y="1880"/>
            <narrative>I/O fail (bad return code from MAGEC I/O module). </narrative>
            <cobolparagraph>AAM751-UPDERR</cobolparagraph>
            <link>insert_main.htm#insert001044</link>
            <target>MAIN</target>
        </node>

        <node id="19" type="process" label="AAM757-GOODDEL&lt;br&gt;  %GOODDEL">
            <position x="120" y="1760"/>
            <narrative>Executed only after a SUCCESSFUL delete of the primary record. Default logic: MOVE DELETED-MSG to SCOMPL. Developer may update related files, post to a control record, or FETCH to another function/screen after the deletion. Must exit to AA800-SEND-SCREEN or AA900-GOBACK.</narrative>
            <cobolparagraph>AAM757-GOODDEL</cobolparagraph>
            <link>insert_main.htm#insert001015</link>
            <target>MAIN</target>
        </node>

        <!-- Error/not-found convergence node -->
        <node id="err" type="process" label="BB100-BLANK-SCREEN&lt;br&gt;  %BLNKSCR">
            <position x="570" y="1090"/>
            <narrative>Reached when the key is INVALID or the record is NOT FOUND. Default logic MOVEs underscores to all screen variables. %BLNKSCR fires at the very end, allowing the developer to override individual field values, display a custom error message, or look up related data based on any partial key entered.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>

        <node id="20" type="process" label="AA800-SEND-SCREEN&lt;br&gt;  %SNDSCRN">
            <position x="120" y="1880"/>
            <narrative>Last execution point before the MMP returns to MAGECCP. Fired for all functions and both modes. Developer may make final screen adjustments — blanking zero-value fields, highlighting out-of-range values, or massaging SKEY — before the screen is sent or a FETCH command is executed. Exit via GO TO AA900-GOBACK.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>
        <node id="20a" type="elbow" label="">
            <position x="570" y="1880"/>
            <narrative>Last execution point before the MMP returns to MAGECCP. Fired for all functions and both modes. Developer may make final screen adjustments — blanking zero-value fields, highlighting out-of-range values, or massaging SKEY — before the screen is sent or a FETCH command is executed. Exit via GO TO AA900-GOBACK.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="21" type="process" label="AA900-GOBACK&lt;br&gt;  %GOBACK">
            <position x="120" y="1980"/>
            <narrative>Absolute last execution point for ALL functions in ALL modes. No default code. Developer may insert final housekeeping — for example, TERMINATE for an IMS PCB. Screen Mask context must be tested before referencing screen fields.</narrative>
            <cobolparagraph>AA900-GOBACK</cobolparagraph>
            <link>insert_main.htm#insert001012</link>
            <target>MAIN</target>
        </node>

        <node id="99" type="end" label="End">
            <position x="120" y="2080"/>
            <narrative>DEL Function processing complete.</narrative>
        </node>
        <node id="999" type="comment" label="Figure 04 - DEL">
            <position x="350" y="2140"/>
            <narrative>Figure 04 - DEL Function</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"/>
        <edge from="6" to="7"/>

        <!-- Key mode decision -->
        <edge from="7" to="8" label="New Transaction"/>
        <edge from="7" to="9" label="Continuation"/>
        <edge from="7" to="7a" label="❌ Invalid Key"/>
        <edge from="7a" to="err"/>

        <!-- Converge to logical join -->
        <edge from="8" to="10"/>
        <edge from="9" to="10"/>
        <edge from="10" to="11"/>

        <!-- Rec found decision -->
        <edge from="11" to="err" label="❌ Not Found"/>
        <edge from="11" to="12" label="✅ Rec Found"/>

        <!-- Mode decision after successful read -->
        <edge from="12" to="13" label="New Transaction"/>
        <edge from="12" to="14" label="Continuation"/>

        <!-- Fill screen → send screen -->
        <edge from="13" to="13a"/>
        <edge from="20a" to="20"/>

        <!-- Edit for delete -->
        <edge from="14" to="15"/>
        <edge from="15" to="15a" label="❌ Error Found"/>
        <edge from="15" to="16" label="✅ No Error"/>

        <!-- Delete database -->
        <edge from="16" to="17"/>
        <edge from="17" to="18" label="❌ Delete Failed"/>
        <edge from="17" to="19" label="✅ Delete Succeeded"/>

        <!-- Converge at send screen -->
        <edge from="18" to="18a"/>
        <edge from="19" to="20"/>
        <edge from="err" to="20a"/>

        <!-- Finish -->
        <edge from="20" to="21"/>
        <edge from="21" to="99"/>
    </edges>
</flowchart>