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

        <node id="title" type="title" label="CHG Function">
            <position x="500" y="20"/>
            <narrative>CHG Function — Change Function processing flow.</narrative>
        </node>

        <node id="subtitle" type="comment" label="Change Function Processing"><position x="500" y="60"/><narrative>Normalize maintenance key, retrieve the target record, perform logical join validation, prepare or edit screen data, build the update record, execute database updates, send the resulting screen, and return to the caller.</narrative></node>

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

        <node id="2" type="process" label="AA100-CHECK-FUNCTION %PREINIT">
            <position x="210" y="130"/>
            <narrative>Check function code and perform pre-initialization processing. Modify function code, if desired.</narrative>
            <cobolparagraph>AA100-CHECK-FUNCTION</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001029</link>
            <target>MAIN</target>
        </node>
        <node id="2aside" type="aside" label=" Narrative of Steps - -CHG">
            <position x="480" y="130"/>
            <narrative>Narrative for function.</narrative>
            <link>https://www.magec.com/DOC/genmmp_main.htm#genmmp002005</link>
            <target>MAIN</target>
        </node>

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

        <node id="3" type="process" label="BA100-INIT-STORAGE %INIT">
            <position x="210" y="230"/>
            <narrative>Initialize working storage areas.</narrative>
            <cobolparagraph>BA100-INIT-STORAGE</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001015</link>
            <target>MAIN</target>
        </node>
        <node id="3aside" type="aside" label="Maintenance Mainline">
            <position x="480" y="230"/>
            <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 %PFKEYM" width="210">
  <position x="210" y="330"/>
  <narrative>Maintenance mainline processing; handle PF key logic.</narrative>
  <link>https://www.magec.com/DOC/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="330"/>
            <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 %INITTATB" width="210">
  <position x="210" y="430"/>
  <narrative>Initialize maintenance screen and table processing.</narrative>
  <link>https://www.magec.com/DOC/insert_main.htm#insert001017</link>
  <target>MAIN</target>
  <cobolparagraph>BA210-MAINT-SCREEN</cobolparagraph>
</node>
        <node id="5aside" type="aside" label="3270 Attributes">
            <position x="480" y="430"/>
            <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 %NORMKEY" width="210">
  <position x="210" y="530"/>
  <narrative>Normalize the maintenance key for lookup.</narrative>
  <link>https://www.magec.com/DOC/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="210" y="640"/>
            <narrative>Determines read path: New Transaction Mode reads by key (display), Continuation Mode reads by key for update (exclusive), Invalid Key blanks the screen.</narrative>
        </node>


        <node id="7b" type="elbow" label="">
            <position x="550" y="640"/>
            <narrative>Invalid key entered in SKEY.</narrative>
        </node>

        <node id="8" type="process" label="AAM410-READ-BY-KEY %REDKY" width="210">
  <position x="330" y="760"/>
  <narrative>Read record by key (display/inquiry mode — new transaction).</narrative>
  <link>https://www.magec.com/DOC/insert_main.htm#insert001031</link>
  <target>MAIN</target>
  <cobolparagraph>AAM410-READ-BY-KEY</cobolparagraph>
</node>

        <node id="9" type="process" label="AAM420-READ-BY-KEY-FOR-UPDAT %RDUKY" width="210">
  <position x="80" y="760"/>
  <narrative>Read record by key for exclusive update (continuation mode).</narrative>
  <link>https://www.magec.com/DOC/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 %JOIN">
            <position x="210" y="870"/>
            <narrative>Perform logical join validation across related data classes.</narrative>
            <cobolparagraph>JA100-LOGICAL-JOIN</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001018</link>
            <target>MAIN</target>
        </node>

        <node id="11" type="decision" label="Join Result?">
            <position x="210" y="980"/>
            <narrative>Determines continuation mode versus new transaction mode after join. NOT_FOUND routes to blank screen.</narrative>
        </node>

        <node id="12" type="process" label="BB200-FILL-SCREEN %COMP">
            <position x="550" y="1090"/>
            <narrative>Fill screen with data for new transaction mode display.</narrative>
            <cobolparagraph>BB200-FILL-SCREEN</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001005</link>
            <target>MAIN</target>
        </node>

        <node id="12a" type="elbow" label="">
            <position x="700" y="1090"/>
            <narrative>Send filled screen to terminal.</narrative>
            <cobolparagraph/>
        </node>

        <node id="12b" type="elbow" label="">
            <position x="700" y="1590"/>
            <narrative>Send filled screen to terminal.</narrative>
            <cobolparagraph/>
        </node>

        <node id="13" type="process" label="BB500-SCREEN-EDIT %EDIT">
            <position x="80" y="1090"/>
            <narrative>Perform first-pass screen editing for continuation mode.</narrative>
            <cobolparagraph>BB500-SCREEN-EDIT</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001009</link>
            <target>MAIN</target>
        </node>
        <node id="19a" type="elbow" label="">
            <position x="300" y="1090"/>
            <narrative/>
            <cobolparagraph>BB500-SCREEN-EDIT</cobolparagraph>
        </node>
        <node id="19b" type="elbow" label="">
            <position x="300" y="1190"/>
            <narrative/>
            <cobolparagraph>BB500-SCREEN-EDIT</cobolparagraph>
        </node>
        <node id="19c" type="elbow" label="">
            <position x="300" y="1290"/>
            <narrative/>
            <cobolparagraph>BB500-SCREEN-EDIT</cobolparagraph>
        </node>

        <node id="14" type="process" label="BB500-SCREEN-EDIT %EDIT2">
            <position x="80" y="1190"/>
            <narrative>Perform second-pass screen editing.</narrative>
            <cobolparagraph>BB500-SCREEN-EDIT</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001010</link>
            <target>MAIN</target>
        </node>

        <node id="15" type="process" label="BB600-BUILD-REC %CALC">
            <position x="80" y="1290"/>
            <narrative>Build the update record from screen data. Note: RULPROC business rules may be inserted here; ERROR-FOUND condition may cause bypass of update path.</narrative>
            <cobolparagraph>BB600-BUILD-REC</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001004</link>
            <target>MAIN</target>
        </node>

        <node id="16" type="process" label="AAM720-UPDATE-DATABASE %UPDAT" width="210">
  <position x="80" y="1390"/>
  <narrative>Execute the database update.</narrative>
  <link>https://www.magec.com/DOC/insert_main.htm#insert001043</link>
  <target>MAIN</target>
  <cobolparagraph>AAM720-UPDATE-DATABASE</cobolparagraph>
</node>

        <node id="17" type="process" label="AAM753-GOODCHG %GOODCHG">
            <position x="80" y="1490"/>
            <narrative>Process successful change completion.</narrative>
            <cobolparagraph>AAM753-GOODCHG</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001014</link>
            <target>MAIN</target>
        </node>

        <node id="18" type="process" label="AAM751-UPDERR %UPDERR">
            <position x="380" y="1390"/>
            <narrative>Handle update error condition.</narrative>
            <cobolparagraph>AAM751-UPDERR</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001044</link>
            <target>MAIN</target>
        </node>
        
        <node id="18a" type="elbow" label="">
            <position x="380" y="1590"/>
            <narrative>Handle update error condition.</narrative>
            <cobolparagraph>AAM751-UPDERR</cobolparagraph>
        </node>

        <node id="19" type="process" label="AAM740-RELEASE-EXCL-CONT %RELES" width="210">
  <position x="550" y="1290"/>
  <narrative>Release exclusive control of the record; route to send screen on error paths.</narrative>
  <link>https://www.magec.com/DOC/insert_main.htm#insert001034</link>
  <target>MAIN</target>
  <cobolparagraph>AAM740-RELEASE-EXCL-CONT</cobolparagraph>
</node>

        <node id="20" type="process" label="BB100-BLANK-SCREEN %BLNKSCR">
            <position x="550" y="980"/>
            <narrative>Blank the screen for invalid key or record not found conditions.</narrative>
            <cobolparagraph>BB100-BLANK-SCREEN</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001003</link>
            <target>MAIN</target>
        </node>

        <node id="21b" type="elbow" label="">
            <position x="820" y="1290"/>
            <narrative>Send the resulting screen back to the terminal.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
        </node>

        <node id="21c" type="elbow" label="">
            <position x="820" y="1590"/>
            <narrative>Send the resulting screen back to the terminal.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
        </node>

        <node id="21a" type="elbow" label="">
            <position x="820" y="980"/>
            <narrative>Send the resulting screen back to the terminal.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
        </node>

        <node id="21" type="process" label="AA800-SEND-SCREEN %SNDSCRN">
            <position x="80" y="1590"/>
            <narrative>Send the resulting screen back to the terminal.</narrative>
            <cobolparagraph>AA800-SEND-SCREEN</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001039</link>
            <target>MAIN</target>
        </node>

        <node id="22" type="process" label="AA900-GOBACK %GOBACK">
            <position x="80" y="1690"/>
            <narrative>Return control to the caller (GOBACK).</narrative>
            <cobolparagraph>AA900-GOBACK</cobolparagraph>
            <link>https://www.magec.com/DOC/insert_main.htm#insert001012</link>
            <target>MAIN</target>
        </node>

        <node id="99" type="end" label="End">
            <position x="80" y="1790"/>
            <narrative>CHG Function processing complete. Default logic will fetch the SEE Function to display the newly modified record.</narrative>
        </node>
        
        <node id="999" type="comment" label="Figure 05 - CHG">
            <position x="350" y="1840"/>
            <narrative>Figure 05 - CHG Function </narrative>
        </node>        
        
    </nodes>
    <edges>
        <!-- Main happy 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 branches -->
        <edge from="7" to="8" label="New Trans."/>
        <edge from="7" to="9" label="Continuation"/>
        <edge from="7" to="7b" label="❌ Invalid Key"/>
        <edge from="7b" to="20" label=""/>

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

        <!-- Join Result decision -->
        <edge from="11" to="12" label="New Transaction"/>
        <edge from="11" to="13" label="Continuation"/>
        <edge from="11" to="20" label="❌ Not Found"/>

        <!-- Fill screen (new transaction) -->
        <edge from="12" to="19" label="❌ Error Found"/>
        <edge from="12" to="12a" label="✅ Normal"/>
        <edge from="12a" to="12b" label=""/>
        <edge from="12b" to="21" label=""/>

        <!-- Screen edit path (continuation) -->
        <edge from="13" to="19a" label="❌ Error Found"/>
        <edge from="19a" to="19b"/>
        <edge from="19b" to="19c"/>
        <edge from="13" to="14"/>
        <edge from="14" to="19b" label="❌ Error Found"/>
        <edge from="14" to="15"/>

        <!-- Build record / calc -->
        <edge from="15" to="19c" label="❌ Error Found"/>
        <edge from="19c" to="19"/>
        <edge from="15" to="16"/>

        <!-- Update database -->
        <edge from="16" to="17" label="✅ Good Change"/>
        <edge from="16" to="18" label="❌ Update Error"/>
        <edge from="17" to="21"/>
        <edge from="18" to="18a"/>
        <edge from="18a" to="21"/>

        <!-- Release exclusive control (error paths) -->
        <edge from="19" to="21b"/>

        <!-- Blank screen path -->
        <edge from="20" to="21a"/>
        <edge from="21b" to="21c"/>
        <edge from="21c" to="21"/>
        <edge from="21a" to="21b"/>
        

        <!-- Send screen → GOBACK → End -->
        <edge from="21" to="22"/>
        <edge from="22" to="99"/>
    </edges>
</flowchart>