<?xml version="1.0" encoding="UTF-8"?>
<!-- OBOE release -->
<process openAS2Directory="c:\\openAS2"
   openAS2BackupDirectory="c:\\backup\\openAS2"
   mode="inbound">
  <connect driverClass="com.mysql.jdbc.Driver" dbConnection="jdbc:mysql://localhost/edi_control">
  <envelope format="X12">
  <log level="DEBUG">
    <segment id="ISA">
      <element position="6">${ISA6}</element>
            <if test="${ISA6}" operator="ne" to="DMCOGDEN       ">
              Unknown incoming id (ISA6 = ${ISA6}) process terminating
              <exit/>
            </if>
    </segment>
    <functionalgroup>
      <segment id="GS">
        <element position="2">${GS2}</element>
            <if test="${GS2}" operator="ne" to="HILLGW201401">
              Unknown incoming id (GS2 = ${GS2}) process terminating
              <exit/>
            </if>
      </segment>
       <set name="custID">not found</set>
      <select fields="custID" table="quotedCustomers" where="custGS2='${GS2}'"/>
     
      <if test="${custID}" operator="eq" to="not found">
              Unknown incoming id (GS2 = ${GS2}) process terminating
              <exit/>
            </if>
      Processing customer ${custID} 
      <transactionset id="840">
        <table section="header">
          <segment id="ST">
            <element position="2">${custControlNumber}</element>
          </segment>
      <!-- this would be a logical place to check to see if this customer has
           already sent this transaction record by checking a table using custid and the ST2 fields -->
          <segment id="BQT">
            <element position="2">${custQuoteNumber}</element>
            <element position="3">${custQuoteDate}</element>
          </segment>
          <insert table="custQuoteRequest" fields="custID, ControlNumber, QuoteNumber, QuoteDate" values="${custID}, ${custControlNumber}, ${custQuoteNumber},
                          ${custQuoteDate}"/>
      <!-- this also would be a logical place to check to see if this customer has
           already sent this request by checking a table using custid and the quotenumber fields -->
          <segment id="PER">
            <element position="2">${custContact}</element>
            <element position="4">${custContactPhone}</element>
          </segment>
          <set name="msgcnt">0</set>
          <loop id="N9">
            <segment id="N9">
              <element position="4">${N94}</element>
            </segment>
            <segment id="MSG">
              <element position="1">${MSG1}</element>
            </segment>
            <compute name="msgcnt">${msgcnt}+1</compute>
            <insert table="custquoteDescription"
              fields="custandquoteNumber, cnt, quoteDate, quoteText"
              values="${custID}${custQuoteNumber}, ${msgcnt}, ${N94}, ${MSG1}"/>
          </loop>
        </table>
        <table section="detail">
          <loop id="PO1">
            <segment id="PO1">
              <element position="1">${PO11}</element>
              <element position="2">${PO12}</element>
              <element position="3">${PO13}</element>
              <element position="6">${PO16}</element>
              <element position="7">${PO17}</element>
            </segment>
            <loop id="PID">
              <segment id="PID">
                <element position="1">${PID1}</element>
                <element position="5">${PID5}</element>
              </segment>
              <segment id="MEA">
                <element position="1">${MEA1}</element>
                <element position="2">${MEA2}</element>
                <composite position="4">
                  <element position="1">${C0011}</element>
                </composite>
                <element position="5">${MEA5}</element>
                <element position="6">${MEA6}</element>
              </segment>
            </loop>
            <segment id="REF">
              <element position="1">${REF1}</element>
              <element position="2">${REF2}</element>
              <element position="3">${REF3}</element>
            </segment>
            <loop id="SCH">
              <segment id="SCH">
                <element position="1">${SCH1}</element>
                <element position="2">${SCH2}</element>
                <element position="5">${SCH5}</element>
                <element position="6">${SCH6}</element>
              </segment>
            </loop>
            <loop id="N1">
              <segment id="N1">
                <element position="1">${N11}</element>
                <element position="2">${N12}</element>
                <element position="3">${N13}</element>
                <element position="4">${N14}</element>
              </segment>
              <segment id="NTE">
                <element position="1">${NTE1}</element>
                <element position="2">${NTE2}</element>
              </segment>
            </loop>
          </loop>
        </table>
      </transactionset>

    </functionalgroup>
   
    </log>
  </envelope>
  </connect>
</process>