<?xml version="1.0" encoding="UTF-8"?>
<functionDiagram
    file="ch05fig05.xml"
    sourceGraphic="ch05fig05"
    functionCode="CHG"
    title="CHG Function">

    <metadata>
        <description>
            Change Function processing flow including key normalization,
            record retrieval, logical join validation, screen editing,
            database update, and screen return processing.
        </description>

        <documentationStatus>
            URL anchors must be populated from the MAGEC master index.
        </documentationStatus>

        <note>
            The business rule (RULPROC) pertaining to any of the MMP's
            elements from the primary Data Class will be inserted
            immediately after the %CALC logic. It could set the
            ERROR-FOUND condition causing the program to take the error
            path, bypassing the updates.
        </note>
    </metadata>

    <nodes>

        <paragraph id="AA100-CHECK-FUNCTION">
            <name>AA100-CHECK-FUNCTION</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="PREINIT">
            <name>%PREINIT</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BA100-INIT-STORAGE">
            <name>BA100-INIT-STORAGE</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="INIT">
            <name>%INIT</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM200-MAINTENANCE-MAINLINE">
            <name>AAM200-MAINTENANCE-MAINLINE</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="PFKEYM">
            <name>%PFKEYM</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BA210-MAINT-SCREEN">
            <name>BA210-MAINT-SCREEN</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="INITTATB">
            <name>%INITTATB</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BA400-NORMALIZE-MAINT-KEY">
            <name>BA400-NORMALIZE-MAINT-KEY</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="NORMKEY">
            <name>%NORMKEY</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM410-READ-BY-KEY">
            <name>AAM410-READ-BY-KEY</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="REDKY">
            <name>%REDKY</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM420-READ-BY-KEY-FOR-UPDAT">
            <name>AAM420-READ-BY-KEY-FOR-UPDAT</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="RDUKY">
            <name>%RDUKY</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="JA100-LOGICAL-JOIN">
            <name>JA100-LOGICAL-JOIN</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="JOIN">
            <name>%JOIN</name>
            <documentationLink/>
        </insertionPoint>

        <decision id="JOIN-RESULT">
            <description>
                Determines continuation mode versus new transaction mode.
            </description>
        </decision>

        <paragraph id="BB200-FILL-SCREEN">
            <name>BB200-FILL-SCREEN</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="COMP">
            <name>%COMP</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BB100-BLANK-SCREEN">
            <name>BB100-BLANK-SCREEN</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="BLNKSCR">
            <name>%BLNKSCR</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BB500-SCREEN-EDIT">
            <name>BB500-SCREEN-EDIT</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="EDIT">
            <name>%EDIT</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BB500-SCREEN-EDIT-2">
            <name>BB500-SCREEN-EDIT</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="EDIT2">
            <name>%EDIT2</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="BB600-BUILD-REC">
            <name>BB600-BUILD-REC</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="CALC">
            <name>%CALC</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM740-RELEASE-EXCL-CONT">
            <name>AAM740-RELEASE-EXCL-CONT</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="RELES">
            <name>%RELES</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM720-UPDATE-DATABASE">
            <name>AAM720-UPDATE-DATABASE</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="UPDAT">
            <name>%UPDAT</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM751-UPDERR">
            <name>AAM751-UPDERR</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="UPDERR">
            <name>%UPDERR</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AA800-SEND-SCREEN">
            <name>AA800-SEND-SCREEN</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="SNDSCRN">
            <name>%SNDSCRN</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AAM753-GOODCHG">
            <name>AAM753-GOODCHG</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="GOODCHG">
            <name>%GOODCHG</name>
            <documentationLink/>
        </insertionPoint>

        <paragraph id="AA900-GOBACK">
            <name>AA900-GOBACK</name>
            <documentationLink/>
        </paragraph>

        <insertionPoint id="GOBACK">
            <name>%GOBACK</name>
            <documentationLink/>
        </insertionPoint>

    </nodes>

    <flow>

        <step from="AA100-CHECK-FUNCTION" to="PREINIT"/>
        <step from="PREINIT" to="BA100-INIT-STORAGE"/>
        <step from="BA100-INIT-STORAGE" to="INIT"/>
        <step from="INIT" to="AAM200-MAINTENANCE-MAINLINE"/>
        <step from="AAM200-MAINTENANCE-MAINLINE" to="PFKEYM"/>
        <step from="PFKEYM" to="BA210-MAINT-SCREEN"/>
        <step from="BA210-MAINT-SCREEN" to="INITTATB"/>
        <step from="INITTATB" to="BA400-NORMALIZE-MAINT-KEY"/>
        <step from="BA400-NORMALIZE-MAINT-KEY" to="NORMKEY"/>

        <branch from="NORMKEY" condition="NEW_TRANSACTION_MODE">
            <to>AAM410-READ-BY-KEY</to>
        </branch>

        <branch from="NORMKEY" condition="CONTINUATION_MODE">
            <to>AAM420-READ-BY-KEY-FOR-UPDAT</to>
        </branch>

        <branch from="NORMKEY" condition="INVALID_KEY">
            <to>BB100-BLANK-SCREEN</to>
        </branch>

        <step from="AAM410-READ-BY-KEY" to="REDKY"/>
        <step from="AAM420-READ-BY-KEY-FOR-UPDAT" to="RDUKY"/>

        <step from="RDUKY" to="JA100-LOGICAL-JOIN"/>
        <step from="REDKY" to="JA100-LOGICAL-JOIN"/>
        <step from="JA100-LOGICAL-JOIN" to="JOIN"/>

        <branch from="JOIN" condition="NOT_FOUND">
            <to>BB100-BLANK-SCREEN</to>
        </branch>

        <branch from="JOIN-RESULT" condition="CONTINUATION_MODE">
            <to>BB500-SCREEN-EDIT</to>
        </branch>

        <branch from="JOIN-RESULT" condition="NEW_TRANSACTION_MODE">
            <to>BB200-FILL-SCREEN</to>
        </branch>

        <step from="BB200-FILL-SCREEN" to="COMP"/>

        <branch from="COMP" condition="NORMAL">
            <to>AA800-SEND-SCREEN</to>
        </branch>

        <branch from="COMP" condition="ERROR_FOUND">
            <to>AAM740-RELEASE-EXCL-CONT</to>
        </branch>

        <step from="BB500-SCREEN-EDIT" to="EDIT"/>

        <branch from="EDIT" condition="ERROR_FOUND">
            <to>AAM740-RELEASE-EXCL-CONT</to>
        </branch>

        <step from="EDIT" to="BB500-SCREEN-EDIT-2"/>
        <step from="BB500-SCREEN-EDIT-2" to="EDIT2"/>

        <branch from="EDIT2" condition="ERROR_FOUND">
            <to>AAM740-RELEASE-EXCL-CONT</to>
        </branch>

        <step from="EDIT2" to="BB600-BUILD-REC"/>
        <step from="BB600-BUILD-REC" to="CALC"/>

        <branch from="CALC" condition="ERROR_FOUND">
            <to>AAM740-RELEASE-EXCL-CONT</to>
        </branch>

        <step from="CALC" to="AAM720-UPDATE-DATABASE"/>
        <step from="AAM720-UPDATE-DATABASE" to="UPDAT"/>
        <step from="UPDAT" to="AAM751-UPDERR"/>
        <step from="AAM751-UPDERR" to="UPDERR"/>
        <step from="UPDERR" to="AA800-SEND-SCREEN"/>

        <step from="AAM740-RELEASE-EXCL-CONT" to="RELES"/>
        <step from="RELES" to="AA800-SEND-SCREEN"/>

        <step from="BB100-BLANK-SCREEN" to="BLNKSCR"/>
        <step from="BLNKSCR" to="AA800-SEND-SCREEN"/>

        <step from="AA800-SEND-SCREEN" to="SNDSCRN"/>
        <step from="SNDSCRN" to="AA900-GOBACK"/>
        <step from="AA900-GOBACK" to="GOBACK"/>

        <step from="UPDAT" to="AAM753-GOODCHG"/>
        <step from="AAM753-GOODCHG" to="GOODCHG"/>

    </flow>

    <narrative>
        <summary>
            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.
        </summary>
    </narrative>

</functionDiagram>