<?xml version="1.0" encoding="UTF-8"?>
<!-- OBOE release 3.4.0 (alpha)  -->
<process openAS2Directory="c:/openAS2/outgoing" mode="outbound" delimiters="!@#">
  <connect driverClass="com.mysql.jdbc.Driver" dbConnection="jdbc:mysql://localhost/edi_control">
    <!--connect driverClass="COM.ibm.db2.jdbc.app.DB2Driver" dbConnection="jdbc:db2:edi"-->
    <set name="sendto">PUBLIC</set>
    <envelope format="x12">
      <select fields="nextAvail" table="controlnumber" where="id='ISA'">
        <compute name="nextAvail">nextAvail+1</compute>
        <update table="controlnumber" fields="nextAvail" values="${nextAvail}" where="id='ISA' and nextAvail = ${nextAvail}-1"/>
        <break/>
      </select>
      <segment id="ISA">
        <element position="1">00</element>
        <element position="2"> </element>
        <element position="3">00</element>
        <element position="4"> </element>
        <element position="5">ZZ</element>
        <element position="6">DMCOGDEN       </element>
        <element position="7">ZZ</element>
        <element position="8">${sendto}</element>
        <element position="9">@com.americancoders.util.Util.currentDate@</element>
        <element position="10">@com.americancoders.util.Util.currentTime@</element>
        <element position="11">U</element>
        <element position="12">00401</element>
        <element position="13">${nextAvail}</element>
        <element position="14">1</element>
        <element position="15">T</element>
        <element position="16">&lt;</element>
      </segment>
      <functionalgroup>
        <select fields="nextAvail" table="controlnumber" where="id='GS'">           <compute name="nextAvail">nextAvail+1</compute>
          <update table="controlnumber" fields="nextAvail" values="${nextAvail}" where="id='GS' and nextAvail = ${nextAvail}-1"/>
          <break/>
        </select>
        <segment id="GS">
          <element position="1">RQ</element>
          <element position="2">HILLGW201401</element>
          <element position="3">${sendto}</element>
          <element position="4">@com.americancoders.util.Util.currentDate@</element>
          <element position="5">@com.americancoders.util.Util.currentTime@</element>
          <element position="6">${nextAvail}</element>
          <element position="7">X</element>
          <element position="8">004010</element>
        </segment>
        <select fields="quote_number, quote_date, contactname, contactnumber" table="porqst" where='vendor="${sendto}"'>
          <transactionset id="840">
            <table section="header">
              <select fields="nextAvail" table="controlnumber" where="id='ST'">
                <compute name="nextAvail">nextAvail+1</compute>
                <update table="controlnumber" fields="nextAvail" values="${nextAvail}" where="id='ST840' and nextAvail = ${nextAvail}-1"/>
                <break/>
              </select>
              <segment id="ST">
                <element position="1">840</element>
                <element position="2">${nextAvail}</element>
              </segment>
              <segment id="BQT">
                <element position="1">00</element>
                <element position="2">${quote_number}</element>
                <element position="3">${quote_date}</element>
                <element position="4">106</element>
                <element position="5">@com.americancoders.util.Util.currentDate@</element>
              </segment>
              <segment id="PER">
                <element position="1">RE</element>
                <element position="2">${contactname}</element>
                <element position="3">TE</element>
                <element position="4">${contactnumber}</element>
              </segment>
              <segment id="FOB">
                <element position="1">DF</element>
                <element position="2">DE</element>
              </segment>
              <select fields="quoteID, quoteText, quoteDate" table="quoteDescription" where="quote_number='${quote_number}'">
                <loop id="N9">
                  <segment id="N9">
                    <element position="1">CJ</element>
                    <element position="2">${quoteID}</element>
                    <if test='${quoteDate}' operator='ne' to='0000-00-00'>
                    <element position="4">${quoteDate}</element>
                    </if>
                  </segment>
                  <segment id="MSG">
                    <element position="1">${quoteText}</element>
                  </segment>
                </loop>
              </select>
            </table>
            <table section="detail">
              <select fields="itemCNT, itemUnitCode, unitType, ProdId, PORequisitionNo, NeedDt, NeedWhere, NeedId" table="quoteDetail" where="quote_number='${quote_number}'">                 <set name="pocnt">0</set>
                <loop id="PO1">
                  <compute name="pocnt">${pocnt}+1</compute>
                  <segment id="PO1">
                    <element position="1">${pocnt}</element>
                    <element position="2">${itemCNT}</element>
                    <element position="3">${itemUnitCode}</element>
                    <element position="6">${unitType}</element>
                    <element position="7">${ProdId}</element>
                  </segment>
                  <select fields="prodIdCode, prodDescription" table="itemDetail" where="prodIdCode='${ProdId}'">
                    <loop id="PID">
                        <log level="DEBUG">
                        <segment id="PID">
                          <element position="1">F</element>
                          <element position="5">${prodDescription}</element>
                        </segment>
                        </log>
                      <atEnd>
                        <select fields="msrCode, msrMin, msrMax" table="itemSpecifics" where="prodIdCode='${prodIdCode}'"/>
                        <segment id="MEA">
                          <element position="1">${msrCode}</element>
                          <element position="2">PO</element>
                          <composite position="4">
                            <element position="1">P1</element>
                          </composite>
                          <element position="5">${msrMin}</element>
                          <element position="6">${msrMax}</element>
                        </segment>
                      </atEnd>
                    </loop>
                  </select>
                  <segment id="REF">
                    <element position="1">RQ</element>
                    <element position="2">${PORequisitionNo}</element>
                    <element position="3">${quoteCNT}</element>
                  </segment>
                  <loop id="SCH">
                    <segment id="SCH">
                      <element position="1">${itemCNT}</element>
                      <element position="2">${itemUnitCode}</element>
                      <element position="5">002</element>
                      <element position="6">${NeedDt}</element>
                    </segment>
                  </loop>
                  <loop id="N1">
                    <segment id="N1">
                      <element position="1">ST</element>
                      <element position="2">${NeedWhere}</element>
                      <element position="3">16</element>
                      <element position="4">${NeedId}</element>
                    </segment>
                  </loop>
                </loop>
              </select>
            </table>
            <table section="summary">
              <segment id="CTT">
                <element position="1">${pocnt}</element>
              </segment>
              <segment id="SE"/>
            </table>
          </transactionset>
        </select>
        <segment id="GE"/>
      </functionalgroup>
      <segment id="IEA"/>
    </envelope>
  </connect>
</process>