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

        <node id="title" type="title" label="MBP OUTPUT PROCEDURE">
            <position x="280" y="20"/>
            <narrative>MBP OUTPUT PROCEDURE — logic flow diagram for the standard MAGEC-generated batch report output procedure, typically used after a SORT with INPUT PROCEDURE.</narrative>
        </node>

        <node id="subtitle" type="comment" label="Return, Break, Total, Print, End">
            <position x="280" y="75"/>
            <narrative>Returns sorted records from the SORT, performs control-break detection, rolls and adds totals, handles heading/line-count overflow, prints break lines, and ends the report cleanly through %RPTEND and EOJ.</narrative>
        </node>

        <node id="1" type="start" label="Begin">
            <position x="100" y="140"/>
            <narrative>Start of OUTPUT PROCEDURE.</narrative>
        </node>

        <node id="2" type="process" label="CA100-REPORT">
            <position x="100" y="240"/>
            <narrative>Entry paragraph of the OUTPUT PROCEDURE — checks whether the Input Procedure released any records to the sort before beginning the return loop. </narrative>
            <cobolparagraph>CA100-REPORT</cobolparagraph>
            <link/>
            <target>MAIN</target>
        </node>
        <node id="2zero" type="elbow" label=""><position x="615" y="350"/><narrative>no records released.; go to %RPTEND</narrative><target>MAIN</target><cobolparagraph>CA100-REPORT</cobolparagraph></node>

        <node id="3" type="decision" label="Any Records Sorted?">
            <position x="100" y="350"/>
            <narrative>Tests whether the Input Procedure produced any sorted records. ZERO RECORDS routes straight to end-of-report with no further processing. Otherwise the return loop begins.</narrative>
        </node>

        <node id="4" type="process" label="CA110-RETURN    %RETURN">
            <position x="100" y="460"/>
            <narrative>Top of the main return loop — retrieves the next sorted record from the SORT work file. NOTE: no anchor for %RETURN was found in the provided insertion-point index excerpt; the link field is left blank pending verification of the correct anchor number on insert_main.htm.</narrative>
            <cobolparagraph>CA110-RETURN</cobolparagraph>
            <link/>
            <target>MAIN</target>
        </node>

        <node id="5" type="decision" label="First Rec?- - EoF?"><position x="100" y="570"/><narrative>Tests the result of the RETURN. AT END means the sort is exhausted — routes directly to CA190-END (%RPTEND) to close out the report. Otherwise processing continues into control-break checking.</narrative></node>
        <node id="5first" type="elbow" label=""><position x="-30" y="570"/><narrative>first record returned, bypass breaks checking. </narrative><target>MAIN</target><cobolparagraph>CA100-REPORT</cobolparagraph></node>
        

        <node id="6" type="process" label="CA115-CHECK-FOR-BREAKS    %BREAKS"><position x="100" y="715"/><narrative>Compares the current record's control keys against the previously saved keys to detect a control-break condition.</narrative><link>insert_main.htm#insert001049</link><target>MAIN</target><cobolparagraph>CA115-CHECK-FOR-BREAKS</cobolparagraph></node>

        <node id="7" type="decision" label="Ctl Break?">
            <position x="100" y="790"/>
            <narrative>Evaluates the result of CA115-CHECK-FOR-BREAKS. A control break routes to DB100-BREAK to roll accumulators and print break lines. No break continues straight into key-saving and total accumulation.</narrative>
        </node>

        <node id="8first" type="elbow" label=""><position x="-30" y="900"/><narrative>first record, bypass control breaks.  save the key(s) </narrative><target>MAIN</target></node>
        <node id="8" type="process" label="CA120-SAVE-KEYS    %SVPREV"><position x="200" y="900"/><narrative>Saves the current record's control keys as the "previous" keys for the next break comparison.</narrative><link>insert_main.htm#insert001069</link><target>MAIN</target><cobolparagraph>CA120-SAVE-KEYS</cobolparagraph></node>

        <node id="9" type="process" label="CA130-ADD-TOTALS    %ADDTOT"><position x="200" y="1000"/><narrative>Adds the current record's values into the running total accumulators.</narrative><link>insert_main.htm#insert001048</link><target>MAIN</target><cobolparagraph>CA130-ADD-TOTALS</cobolparagraph></node>

        <node id="10" type="process" label="CA130-ADD-TOTALS    %MVTOPRT"><position x="200" y="1100"/><narrative>Moves the record's fields into the print line work area in preparation for detail printing.</narrative><link>insert_main.htm#insert001061</link><target>MAIN</target><cobolparagraph>CA130-ADD-TOTALS</cobolparagraph></node>

        <node id="11" type="decision" label="Line Ctr &gt; Max?"><position x="200" y="1200"/><narrative>Checks the current line counter against the page's maximum line count. If the counter has not exceeded the max, the detail line prints and the loop returns to CA110-RETURN. If it has, a new page heading is printed first via DA200-HDG.</narrative></node>
        <node id="11cont" type="elbow" label=""><position x="580" y="1200"/><narrative>the counter not &gt; the max, the detail line prints and the loop returns to CA110-RETURN. </narrative></node>

        <node id="12" type="process" label=" DA200-HDG- -%HDGPRT"><position x="200" y="1330"/><narrative>Prints report page headings and resets the line counter when the page overflows.</narrative><link>insert_main.htm#insert001055</link><target>MAIN</target><cobolparagraph>DA200-HDG</cobolparagraph></node>
        <node id="12cont" type="elbow" label=""><position x="580" y="1330"/><narrative>line counter was reset after printing headings</narrative><link>insert_main.htm#insert001055</link><target>MAIN</target><cobolparagraph>DA200-HDG</cobolparagraph></node>

        <node id="L1" type="elbow" label=""><position x="580" y="460"/><narrative>Routes the detail-print / post-heading loop back to the top of the return loop at CA110-RETURN.</narrative></node>
        
        <node id="14eof" type="elbow" label=""><position x="430" y="570"/><narrative>Routes the final breaks</narrative></node>
        <node id="14" type="process" label="DB100-BREAK - -%ROLLAC"><position x="430" y="790"/><narrative>Rolls the current-level accumulators into the next-level totals when a control break is detected.</narrative><link>insert_main.htm#insert001065</link><target>MAIN</target><cobolparagraph>DB100-BREAK</cobolparagraph></node>

        <node id="15" type="process" label="DC200-BREAK-PRINT    %BRKPRT"><position x="430" y="900"/><narrative>Prints the control-break total line(s) for the level(s) that just broke.</narrative><link>insert_main.htm#insert001050</link><target>MAIN</target><cobolparagraph>DC200-BREAK-PRINT</cobolparagraph></node>
        <node id="15eof" type="elbow" label=""><position x="615" y="900"/><narrative>on EOF go finish up</narrative><link>insert_main.htm#insert001050</link><target>MAIN</target><cobolparagraph>DC200-BREAK-PRINT</cobolparagraph></node>

        <node id="16zero" type="elbow" label=""><position x="615" y="1450"/><narrative>End-of-report processing — reached either when the return loop hits AT END, or after final break totals have printed. Finalizes any last totals/lines before job termination.</narrative><link>insert_main.htm#insert001066</link><target>MAIN</target><cobolparagraph>CA190-END</cobolparagraph></node>
        <node id="16" type="process" label=" CA190-END - -%RPTEND"><position x="100" y="1450"/><narrative>End-of-report processing — reached either when the return loop hits AT END, or after final break totals have printed. Finalizes any last totals/lines before job termination.</narrative><link>insert_main.htm#insert001066</link><target>MAIN</target><cobolparagraph>CA190-END</cobolparagraph></node>

        <node id="17" type="process" label="  ZZ900-EOJ - -%EOJ">
            <position x="100" y="1560"/>
            <narrative>End-of-job processing — closes files and performs final cleanup before the program terminates.</narrative>
            <cobolparagraph>ZZ900-EOJ</cobolparagraph>
            <link>insert_main.htm#insert001052</link>
            <target>MAIN</target>
        </node>

        <node id="99" type="end" label="End">
            <position x="100" y="1660"/>
            <narrative>End of OUTPUT PROCEDURE.</narrative>
        </node>
        <node id="999" type="comment" label="Figure 08 - MBP Output Procedure">
            <position x="350" y="1700"/>
            <narrative>Figure 08</narrative>
        </node>

    <node id="elbow1" type="elbow" label=""><position x="-50" y="1450"/></node><node id="elbow0" type="elbow" label="" width="10" height="10"><position x="-50" y="650"/></node></nodes>
    <edges>
        <!-- Main top-to-bottom path -->
        <edge from="1" to="2"/>
        <edge from="2" to="3"/>

        <!-- Zero-records short-circuit -->
        <edge from="3" to="2zero" label="❌ Zero Records Sorted (No Data)"/>
        <edge from="2zero" to="16zero"/>
        <edge from="16zero" to="16" label="❌ zero records from sort"/>
        <edge from="3" to="4" label="✅ Yes"/>

        <!-- Main return loop -->
        <edge from="4" to="5"/>
        <edge from="5" to="5first" label="First"/>
        <edge from="5first" to="8first" label="First"/>
        <edge from="8first" to="8"/>
        <edge from="elbow1" to="16" label="🔚 AT END"/>
        <edge from="5" to="6" label="Not EoF"/>
        <edge from="5" to="14eof" label=" EoF"/>
        <edge from="14eof" to="14" label="⚠️ Control Break"/>
        <!-- Control break check -->
        <edge from="6" to="7"/>
        <edge from="7" to="14" label="⚠️ Ctl Break"/>
        <edge from="7" to="8" label="No Break"/>
        <edge from="15" to="8" label="Not EoF"/>

        <!-- Totals / print prep -->
        <edge from="8" to="9"/>
        <edge from="9" to="10"/>
        <edge from="10" to="11"/>

        <!-- Line/page overflow decision -->
        <edge from="11" to="11cont" label="🔁 loop back"/>
        <edge from="11cont" to="L1" label=""/>
        <edge from="11" to="12" label="❌ Yes"/>
        <edge from="12" to="12cont" label="🔁 loop back"/>
        <edge from="12cont" to="11cont"/>
        <edge from="L1" to="4" label=""/>

        <!-- Break path -->
        <edge from="14" to="15"/>
        <edge from="15" to="15eof" label=" EoF"/>

        <!-- Finish -->
        <edge from="16" to="17"/>
        <edge from="17" to="99"/>
    <edge from="5" to="elbow0" label="end"/><edge from="elbow0" to="elbow1"/></edges>
</flowchart>