XML -> 进度 10 DB temp-table

XML -> Progress 10 DB temp-table

这是我正在尝试的方法,甚至还没有到查看温度的地步 table,甚至无法正确创建它:

4GL代码:

DEFINE VARIABLE cSourceType             AS CHARACTER NO-UNDO.
DEFINE VARIABLE cReadMode               AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL   NO-UNDO.
DEFINE VARIABLE cFile                   AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSchemaLocation         AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping       AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode       AS CHARACTER NO-UNDO.
DEFINE VARIABLE lRetOK                  AS LOGICAL   NO-UNDO.
DEFINE VARIABLE ttOrd                   AS HANDLE    NO-UNDO.

CREATE TEMP-TABLE ttOrd.
ASSIGN
  cSourceType             = "file"
  cFile                   = "ORD1.xml" 
  cReadMode               = "empty"
  cSchemaLocation         = "Orders.xsd"
  lOverrideDefaultMapping = ?
  cFieldTypeMapping       = ?
  cVerifySchemaMode       = ?.

lRetOK = ttOrd:READ-XML(cSourceType, cFile, cReadMode, cSchemaLocation,
  lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode).

我得到错误:

Invalid inner element name 'ORDER' for Temp-Table definition. (14748) Unable to create Temp-Table or dataset schema from XML Schema. (13032) Procedure complete. Press space bar to continue.

Orders.xsd 文件:

<?xml version="1.0" encoding="UTF-8"?>
   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <!-- XML Schema Generated from XML Document on Mon Mar 08 2021 10:09:16 GMT-0500 (Eastern Standard Time) -->
         <!-- with XmlGrid.net Free Online Service http://xmlgrid.net -->
         <xs:element name="EXPORTEDORDERS">
               <xs:complexType>
                     <xs:sequence>
                           <xs:element name="ORDERS">
                                 <xs:complexType>
                                       <xs:sequence>
                                             <xs:element name="ORDER" maxOccurs="unbounded">
                                                   <xs:complexType>
                                                         <xs:sequence>
                                                               <xs:element name="CUSTNO" type="xs:string"></xs:element>
                                                               <xs:element name="ORDERNO" type="xs:int"></xs:element>
                                                               <xs:element name="RELEASE_DT" type="xs:string"></xs:element>
                                                               <xs:element name="FULLNAME" type="xs:string"></xs:element>
                                                               <xs:element name="PONUM" type="xs:int"></xs:element>
                                                               <xs:element name="DESCR"></xs:element>
                                                               <xs:element name="TOT_AMT" type="xs:double"></xs:element>
                                                               <xs:element name="BO_AMT" type="xs:int"></xs:element>
                                                               <xs:element name="COMMITAMT" type="xs:int"></xs:element>
                                                               <xs:element name="TERMS" type="xs:string"></xs:element>
                                                               <xs:element name="STATUS" type="xs:string"></xs:element>
                                                               <xs:element name="SALESREP" type="xs:string"></xs:element>
                                                               <xs:element name="SALESEMAIL"></xs:element>
                                                               <xs:element name="INVNO"></xs:element>
                                                               <xs:element name="GROSS" type="xs:int"></xs:element>
                                                               <xs:element name="FREIGHT" type="xs:int"></xs:element>
                                                               <xs:element name="INS" type="xs:int"></xs:element>
                                                               <xs:element name="TAX" type="xs:int"></xs:element>
                                                               <xs:element name="COD_CHG" type="xs:int"></xs:element>
                                                               <xs:element name="ORDER_DT" type="xs:string"></xs:element>
                                                               <xs:element name="CLOSED_DT"></xs:element>
                                                               <xs:element name="POST_DT"></xs:element>
                                                               <xs:element name="INV_DT"></xs:element>
                                                               <xs:element name="SHIP_DT" type="xs:string"></xs:element>
                                                               <xs:element name="SHIP_METH" type="xs:string"></xs:element>
                                                               <xs:element name="WH_NUM"></xs:element>
                                                               <xs:element name="DIV_NUM" type="xs:int"></xs:element>
                                                               <xs:element name="SH_REL_DT"></xs:element>
                                                               <xs:element name="REL_WH_DT"></xs:element>
                                                               <xs:element name="CURR_CODE" type="xs:string"></xs:element>
                                                               <xs:element name="EXCH_RATE" type="xs:int"></xs:element>
                                                               <xs:element name="LAST_MOD_DT" type="xs:string"></xs:element>
                                                               <xs:element name="FLEX_FLD1" type="xs:int"></xs:element>
                                                               <xs:element name="FLEX_FLD2" type="xs:int"></xs:element>
                                                               <xs:element name="FLEX_FLD3" type="xs:int"></xs:element>
                                                               <xs:element name="FLEX_FLD4" type="xs:string"></xs:element>
                                                               <xs:element name="FLEX_FLD5"></xs:element>
                                                               <xs:element name="FLEX_FLD6"></xs:element>
                                                               <xs:element name="FLEX_FLD7"></xs:element>
                                                               <xs:element name="FLEX_FLD8"></xs:element>
                                                               <xs:element name="FLEX_FLD9"></xs:element>
                                                               <xs:element name="PENDING_NOTES"></xs:element>
                                                               <xs:element name="RELEASE_NOTES"></xs:element>
                                                         </xs:sequence>
                                                   </xs:complexType>
                                             </xs:element>
                                       </xs:sequence>
                                 </xs:complexType>
                           </xs:element>
                     </xs:sequence>
               </xs:complexType>
         </xs:element>
   </xs:schema>

ORD1.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<EXPORTEDORDERS>
    <ORDERS>
        <ORDER>
            <CUSTNO>V70-50200022BL01</CUSTNO>
            <ORDERNO>297740</ORDERNO>
            <RELEASE_DT>09-24-2020</RELEASE_DT>
            <FULLNAME>GETPAID Administrator</FULLNAME>
            <PONUM>9010066064</PONUM>
            <DESCR></DESCR>
            <TOT_AMT>7066.50</TOT_AMT>
            <BO_AMT>0.00</BO_AMT>
            <COMMITAMT>0.00</COMMITAMT>
            <TERMS>NET 60</TERMS>
            <STATUS>APR-REL</STATUS>
            <SALESREP>NONE</SALESREP>
            <SALESEMAIL></SALESEMAIL>
            <INVNO></INVNO>
            <GROSS>3660.00</GROSS>
            <FREIGHT>0.00</FREIGHT>
            <INS>0.00</INS>
            <TAX>0.00</TAX>
            <COD_CHG>0.00</COD_CHG>
            <ORDER_DT>03-02-2020</ORDER_DT>
            <CLOSED_DT></CLOSED_DT>
            <POST_DT></POST_DT>
            <INV_DT></INV_DT>
            <SHIP_DT>04-21-2020</SHIP_DT>
            <SHIP_METH>WSI</SHIP_METH>
            <WH_NUM></WH_NUM>
            <DIV_NUM>0</DIV_NUM>
            <SH_REL_DT></SH_REL_DT>
            <REL_WH_DT></REL_WH_DT>
            <CURR_CODE>USD</CURR_CODE>
            <EXCH_RATE>0.00</EXCH_RATE>
            <LAST_MOD_DT>03-02-2020</LAST_MOD_DT>
            <FLEX_FLD1>0.00</FLEX_FLD1>
            <FLEX_FLD2>0.00</FLEX_FLD2>
            <FLEX_FLD3>0.00</FLEX_FLD3>
            <FLEX_FLD4>GLOVIA</FLEX_FLD4>
            <FLEX_FLD5></FLEX_FLD5>
            <FLEX_FLD6></FLEX_FLD6>
            <FLEX_FLD7></FLEX_FLD7>
            <FLEX_FLD8></FLEX_FLD8>
            <FLEX_FLD9></FLEX_FLD9>
            <PENDING_NOTES></PENDING_NOTES>
            <RELEASE_NOTES></RELEASE_NOTES>
        </ORDER>
    </ORDERS>
</EXPORTEDORDERS>

10.2...哎呀!

改用数据集。我认为它们可用。另外,我正在跳过架构。这真的没有任何帮助,最后我静态定义了数据集和 temp-table 因为它会让你的生活更轻松。

DEFINE VARIABLE cSourceType             AS CHARACTER NO-UNDO.
DEFINE VARIABLE cReadMode               AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL   NO-UNDO.
DEFINE VARIABLE cFile                   AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSchemaLocation         AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping       AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode       AS CHARACTER NO-UNDO.
DEFINE VARIABLE lRetOK                  AS LOGICAL   NO-UNDO.

DEFINE TEMP-TABLE ttOrders NO-UNDO SERIALIZE-NAME "ORDERS"
    FIELD parentid AS RECID SERIALIZE-HIDDEN. //Disregard this field

DEFINE TEMP-TABLE ttOrd NO-UNDO SERIALIZE-NAME "ORDER"
    FIELD parentid AS RECID SERIALIZE-HIDDEN
    FIELD custno   AS CHARACTER SERIALIZE-NAME "CUSTNO"
    /* Rest of fields here.... */.

DEFINE DATASET dsExportOrders SERIALIZE-NAME "EXPORTEDORDERS"
    FOR ttOrders, ttOrd
    PARENT-ID-RELATION FOR ttOrders, ttOrd PARENT-ID-FIELD parentId.
    
 
ASSIGN
  cSourceType             = "file"
  cFile                   = "c:\temp\ORD1.xml" 
  cReadMode               = "empty"
  //cSchemaLocation         = "c:\temp\Orders.xsd"
  lOverrideDefaultMapping = ?
  cFieldTypeMapping       = ?
  cVerifySchemaMode       = ?.


lRetOK = DATASET dsExportOrders:READ-XML(cSourceType, cFile, cReadMode, cSchemaLocation,
  lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode).
  
FOR EACH ttOrd:
    DISPLAY ttOrd.
END.

在 10.1c 中,这现在可以正常工作了:

DEFINE VARIABLE cSourceType             AS CHARACTER NO-UNDO.
DEFINE VARIABLE cReadMode               AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOverrideDefaultMapping AS LOGICAL   NO-UNDO.
DEFINE VARIABLE cFile                   AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSchemaLocation         AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFieldTypeMapping       AS CHARACTER NO-UNDO.
DEFINE VARIABLE cVerifySchemaMode       AS CHARACTER NO-UNDO.
DEFINE VARIABLE lRetOK                  AS LOGICAL   NO-UNDO.

DEFINE TEMP-TABLE ORDERS NO-UNDO 
   FIELD parentid AS RECID 
. 

DEFINE TEMP-TABLE ORDER
  FIELD parentid AS RECID 
  FIELD custno   AS CHARACTER 
  FIELD ORDERNO as CHARACTER 
  FIELD RELEASE_DT as CHARACTER 
  FIELD FULLNAME as CHARACTER 
  FIELD PONUM as CHARACTER 
  FIELD DESCR as CHARACTER 
  FIELD TOT_AMT as decimal 
  FIELD BO_AMT as decimal 
  FIELD COMMITAMT as decimal 
  FIELD TERMS as CHARACTER 
  FIELD STATUS1 as CHARACTER 
  FIELD SALESREP as CHARACTER 
  FIELD SALESEMAIL as CHARACTER 
  FIELD INVNO as CHARACTER 
  FIELD GROSS as decimal 
  FIELD FREIGHT as decimal 
  FIELD INS as decimal 
  FIELD TAX as decimal 
  FIELD COD_CHG as decimal 
  FIELD ORDER_DT as CHARACTER 
  FIELD CLOSED_DT as CHARACTER 
  FIELD POST_DT as CHARACTER 
  FIELD INV_DT as CHARACTER 
  FIELD SHIP_DT as CHARACTER 
  FIELD SHIP_METH as CHARACTER 
  FIELD WH_NUM as CHARACTER 
  FIELD DIV_NUM as int 
  FIELD SH_REL_DT as CHARACTER 
  FIELD REL_WH_DT as CHARACTER 
  FIELD CURR_CODE as CHARACTER 
  FIELD EXCH_RATE as decimal 
  FIELD LAST_MOD_DT as CHARACTER 
  FIELD FLEX_FLD1 as CHARACTER 
  FIELD FLEX_FLD2 as CHARACTER 
  FIELD FLEX_FLD3 as CHARACTER 
  FIELD FLEX_FLD4 as CHARACTER 
  FIELD FLEX_FLD5 as CHARACTER 
  FIELD FLEX_FLD6 as CHARACTER 
  FIELD FLEX_FLD7 as CHARACTER 
  FIELD FLEX_FLD8 as CHARACTER 
  FIELD FLEX_FLD9 as CHARACTER 
  FIELD PENDING_NOTES as CHARACTER 
  FIELD RELEASE_NOTES as CHARACTER 
.  

DEFINE DATASET dsExportedOrders FOR ORDERS, ORDER
   DATA-RELATION drOrderLine FOR ORDERS, ORDER RELATION-FIELDS (parentid, parentid)
.

ASSIGN
   cSourceType             = "file"
   cFile                   = "ORD2.xml" 
   cReadMode               = "empty"
   lOverrideDefaultMapping = ?
   cFieldTypeMapping       = ?
   cVerifySchemaMode       = ?
.

lRetOK = DATASET dsExportedOrders:READ-XML(cSourceType, cFile, cReadMode, cSchemaLocation,
  lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode).
    
FOR EACH ORDER:
   Display 
      custno
      orderno
      status1
   .   
END.