<?xml version="1.0" encoding="UTF-8"?>
<!--
  MAGEC RAD - REF File Relationships
  ====================================
  Source: CH12FIG01.png (Documentation Reference Manual, Chapter 12)
  Purpose: Models the REF file cross-reference structure that connects
           DOC file Topics to external entities (online functions and
           batch programs) for the MAGEC HELP key (PF1) facility.

  REF File key structure (from MAGEC Installation Guide):
    Key Displacement: 36   Key Length: 64
    Record Length:   100   CI Size:  2048

  REF record key = Keyword (or key phrase) + Type + Topic
    Type values used here:
      FUNC  = Online MMP function code
      BPGM  = Batch program (MBP)

  Documentation source:
    https://www.magec.com/DOC/docu_main.htm  (Documentation Reference Manual)
    https://www.magec.com/DOC/install_main.htm (Installation Guide - REF file spec)
    https://www.magec.com/DOC/libr_main.htm   (Librarian - prime reference rules)
-->

<magec-ref-relationships
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0"
    description="REF file cross-references: DOC Topics to Entities">

  <!-- ============================================================
       DOC FILE TOPICS
       Each topic resides on the DOC file and is identified by its
       topic name. A "prime reference" entry on the REF file is
       automatically created by MAGECLBR when a topic is added,
       ensuring every topic has at least one REF entry.
  ============================================================ -->
  <topics>
    <topic id="TOPIC-CUSTOMER-DATA"    name="Customer Data"/>
    <topic id="TOPIC-ONLINE-UPDATING"  name="Online Updating"/>
    <topic id="TOPIC-ADDING-DATA"      name="Adding Data"/>
  </topics>

  <!-- ============================================================
       EXTERNAL ENTITIES
       Entities that reference DOC topics via REF file entries.
       Type FUNC = online MMP function code (invokes HELP via PF1).
       Type BPGM = batch program (MBP).
  ============================================================ -->
  <entities>
    <entity id="ENT-CUSCHG-FUNC" keyword="CUSCHG" type="FUNC"
            description="Online function CUSCHG (Customer Change MMP)"/>
    <entity id="ENT-CUSCHG-BPGM" keyword="CUSCHG" type="BPGM"
            description="Batch program CUSCHG (Customer Change MBP)"/>
    <entity id="ENT-IVCADD-FUNC" keyword="IVCADD" type="FUNC"
            description="Online function IVCADD (Invoice Add MMP)"/>
  </entities>

  <!-- ============================================================
       REF FILE ENTRIES
       Each entry is one record on the REF file.
       Key = Keyword + Type + Topic  (total 64 chars per spec).
       Multiple entities may reference the same topic (e.g.
       "Customer Data" is referenced by both CUSCHG FUNC and
       CUSCHG BPGM).  An entity may reference multiple topics
       (e.g. CUSCHG FUNC references both "Customer Data" and
       "Online Updating").
  ============================================================ -->
  <ref-entries>

    <!-- CUSCHG online function → Customer Data topic -->
    <ref-entry id="REF-001"
               entity-ref="ENT-CUSCHG-FUNC"
               topic-ref="TOPIC-CUSTOMER-DATA"
               keyword="CUSCHG"
               type="FUNC"
               topic="Customer Data"
               note="PF1 HELP from CUSCHG online function displays Customer Data topic"/>

    <!-- CUSCHG online function → Online Updating topic -->
    <ref-entry id="REF-002"
               entity-ref="ENT-CUSCHG-FUNC"
               topic-ref="TOPIC-ONLINE-UPDATING"
               keyword="CUSCHG"
               type="FUNC"
               topic="Online Updates"
               note="PF1 HELP from CUSCHG online function also displays Online Updating topic"/>

    <!-- CUSCHG batch program → Customer Data topic -->
    <ref-entry id="REF-003"
               entity-ref="ENT-CUSCHG-BPGM"
               topic-ref="TOPIC-CUSTOMER-DATA"
               keyword="CUSCHG"
               type="BPGM"
               topic="Customer Data"
               note="Batch program CUSCHG references same Customer Data topic"/>

    <!-- IVCADD online function → Adding Data topic -->
    <ref-entry id="REF-004"
               entity-ref="ENT-IVCADD-FUNC"
               topic-ref="TOPIC-ADDING-DATA"
               keyword="IVCADD"
               type="FUNC"
               topic="Adding Data"
               note="PF1 HELP from IVCADD online function displays Adding Data topic"/>

  </ref-entries>

  <!-- ============================================================
       SUMMARY OF RELATIONSHIPS (for readability)
       Demonstrates that:
         1. A Topic can be referenced by multiple entities.
         2. An entity can reference multiple Topics.
  ============================================================ -->
  <relationship-summary>
    <topic-summary topic-ref="TOPIC-CUSTOMER-DATA" name="Customer Data"
                   referenced-by-count="2"
                   referenced-by="ENT-CUSCHG-FUNC ENT-CUSCHG-BPGM"/>
    <topic-summary topic-ref="TOPIC-ONLINE-UPDATING" name="Online Updating"
                   referenced-by-count="1"
                   referenced-by="ENT-CUSCHG-FUNC"/>
    <topic-summary topic-ref="TOPIC-ADDING-DATA" name="Adding Data"
                   referenced-by-count="1"
                   referenced-by="ENT-IVCADD-FUNC"/>

    <entity-summary entity-ref="ENT-CUSCHG-FUNC" keyword="CUSCHG" type="FUNC"
                    topics-referenced-count="2"
                    topics-referenced="TOPIC-CUSTOMER-DATA TOPIC-ONLINE-UPDATING"/>
    <entity-summary entity-ref="ENT-CUSCHG-BPGM" keyword="CUSCHG" type="BPGM"
                    topics-referenced-count="1"
                    topics-referenced="TOPIC-CUSTOMER-DATA"/>
    <entity-summary entity-ref="ENT-IVCADD-FUNC" keyword="IVCADD" type="FUNC"
                    topics-referenced-count="1"
                    topics-referenced="TOPIC-ADDING-DATA"/>
  </relationship-summary>

</magec-ref-relationships>