<flowchart 
  name="LOC/SCN/FND Function" 
  description="LOCATE / SCAN / FIND Function - Browse and selection logic with continuation and new transaction modes.">
  
  <note>The %SELECT code sets a flag to process, bypass, or simulate EOF for each item read for any LOC, SCN, or FND function. The SCN and FND functions also do further selection matching afterwards.</note>

  <!-- Main Flow -->
  <step id="AA100" paragraph="AA100-CHECK-FUNCTION" insertion-point="%PREINIT">
    <next>BA100</next>
  </step>

  <step id="BA100" paragraph="BA100-INIT-STORAGE" insertion-point="%LOCINIT">
    <next>AAL200</next>
  </step>

  <step id="AAL200" paragraph="AAL200-BROWSE-MAINLINE" insertion-point="%PFKEYL">
    <!-- Decision branches -->
    <branch type="decision" condition="CURSOR SELECTION WAS MADE?">
      <target>VALID_SELECTION_PATH</target>
    </branch>
    <branch type="decision" condition="CONTINUATION MODE?">
      <target>BA300</target>
    </branch>
    <branch type="decision" condition="NEW TRANSACTION MODE?">
      <target>BA300</target>
    </branch>
    <branch type="decision" condition="TEST KEY = SPACE?">
      <target>BA300</target>
    </branch>
  </step>

  <!-- Key Normalization -->
  <step id="BA300" paragraph="BA300-NORMALIZE-KEY" insertion-point="%NKLOC">
    <branch type="decision" condition="KEY ERROR FOUND">
      <target>AA800</target>
    </branch>
    <next>AAL410</next>
  </step>

  <!-- Set Starting Position -->
  <step id="AAL410" paragraph="AAL410-SET-STARTING-POSITION" insertion-point="%LOCKY">
    <next>AAL430</next>
  </step>

  <!-- Read Next Record -->
  <step id="AAL430" paragraph="AAL430-READ-NEXT-RECORD" insertion-point="%REDNX">
    <next>JA100</next>
  </step>

  <!-- Logical Join -->
  <step id="JA100" paragraph="JA100-LOGICAL-JOIN" insertion-point="%JOIN">
    <branch type="decision" condition="NOT FOUND">
      <target>AA800</target>
    </branch>
    <branch type="decision" condition="EOF INDICATED">
      <target>AA800</target>
    </branch>
    <next>CA700</next>
  </step>

  <!-- Move to Work Area & Select -->
  <step id="CA700" paragraph="CA700-MOVE-TO-WORK-AREA" insertion-point="%SELECT">
    <branch type="decision" condition="YES BYPASS?">
      <target>AAL430</target>
    </branch>
    <branch type="decision" condition="NO">
      <target>CA800</target>
    </branch>
    <branch type="decision" condition="REJECT">
      <target>AAL430</target>
    </branch>
  </step>

  <!-- Build Skey -->
  <step id="CA800" paragraph="CA800-BUILD-SKEY" insertion-point="%SKEYBLD">
    <branch type="decision" condition="EOF">
      <target>AA800</target>
    </branch>
    <branch type="decision" condition="NOT EOF &amp; NOT SCREEN FULL">
      <target>AAL430</target>
    </branch>
    <branch type="decision" condition="SCREEN FULL">
      <target>AA800</target>
    </branch>
  </step>

  <!-- Valid Cursor Selection Path -->
  <step id="VALID_SELECTION_PATH" paragraph="VALID CURSOR SELECTION" description="Cursor positioned on valid record">
    <next>AA800</next>
  </step>

  <!-- Send Screen (Common) -->
  <step id="AA800" paragraph="AA800-SEND-SCREEN" insertion-point="%SNDSCRN">
    <next>AA900</next>
  </step>

  <!-- End -->
  <step id="AA900" paragraph="AA900-GOBACK" insertion-point="%GOBACK" type="terminal" />

  <!-- Flow Structure Summary -->
  <structure>
    <path name="Normal Browse / Continuation Path">
      AA100 → BA100 → AAL200 → BA300 → AAL410 → AAL430 → JA100 → CA700 → CA800 → (loop or AA800) → AA900
    </path>
    <path name="Cursor Selection Path">
      AAL200 → (CURSOR SELECTION) → AA800 → AA900
    </path>
  </structure>

</flowchart>