/* pi-tfx-ttSetup-7.i */
/* Creates two static temp-tables for use in a ProDataSet. */ /* Definition for temp-table ttCustomer */ DEFINE TEMP-TABLE ttCustomer NO-UNDO BEFORE-TABLE ttCustBefore FIELD CustNum LIKE Customer.CustNum FIELD Name LIKE Customer.Name FIELD Country LIKE Customer.Country FIELD Comments LIKE Customer.Comments FORMAT "x(40)" INDEX CustNum IS PRIMARY UNIQUE CustNum INDEX Name Name INDEX Comments IS WORD-INDEX Comments. /* Definition for temp-table ttOrder */ DEFINE TEMP-TABLE ttOrder NO-UNDO FIELD OrderNum LIKE Order.OrderNum FIELD CustNum LIKE Order.CustNum FIELD OrderDate LIKE Order.OrderDate INDEX OrderNum IS PRIMARY UNIQUE OrderNum INDEX CustOrder IS UNIQUE CustNum OrderNum INDEX OrderDate OrderDate. |
<?xml version="1.0"?>
<dsCustomerOrders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ttCustomer> <CustNum>1</CustNum> <Country>USA</Country> <Name>Lift Tours</Name> <Address>276 North Drive</Address> <Address2/> <City>Burlington</City> <State>MA</State> <PostalCode>01730</PostalCode> <Contact>Gloria Shepley</Contact> <Phone>(617) 450-0086</Phone> <SalesRep>HXM</SalesRep> <CreditLimit>66700.0</CreditLimit> <Balance>903.64</Balance> <Terms>Net30</Terms> <Discount>35</Discount> <Comments>This customer is on credit hold.</Comments> <Fax/> <EmailAddress/> <ttOrder> <Ordernum>6</Ordernum> <CustNum>1</CustNum> <OrderDate>1998-02-11</OrderDate> <ShipDate>1998-02-16</ShipDate> <PromiseDate>1998-02-16</PromiseDate> <Carrier>Standard Mail</Carrier> <Instructions/> <PO/> <Terms>Net30</Terms> <SalesRep>HXM</SalesRep> <BillToID>0</BillToID> <ShipToID>0</ShipToID> <OrderStatus>Shipped</OrderStatus> <WarehouseNum>0</WarehouseNum> <Creditcard>American Express</Creditcard> </ttOrder> . . . |
/* pi-tfx-read-7.p */
/* Populates a static ProDataSet with records from an XML file. */ {pi-tfx-parameterVarDefs.i} {pi-tfx-ttSetup-7.i} DEFINE VARIABLE hPDS AS HANDLE NO-UNDO. DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO. DEFINE DATASET dsCustomerOrders FOR ttCustomer, ttOrder DATA-RELATION custOrd FOR ttCustomer, ttOrder RELATION-FIELDS(CustNum, CustNum) NESTED. hPDS = DATASET dsCustomerOrders:HANDLE. ASSIGN cSourceType = "FILE" cFile = "dsCustomerOrders.xml" cReadMode = "EMPTY" cSchemaLocation = ? lOverrideDefaultMapping = NO. lReturn = hPDS:READ-XML (cSourceType, cFile, cReadMode, cSchemaLocation, lOverrideDefaultMapping). IF lReturn THEN DO: FOR EACH ttCustomer BY ttCustomer.CustNum: FOR EACH ttOrder WHERE ttOrder.CustNum = ttCustomer.CustNum: DISPLAY ttCustomer.CustNum ttCustomer.Name FORMAT "x(30)" ttOrder.OrderNum. END. END. END. |
/* pi-tfx-read-8.p */
/* Populates an empty dynamic ProDataSet with XML Schema and records from an XML document. */ {pi-tfx-parameterVarDefs.i} DEFINE VARIABLE hPDS AS HANDLE NO-UNDO. DEFINE VARIABLE hQuery AS HANDLE NO-UNDO. DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO. CREATE DATASET hPDS. ASSIGN cSourceType = "FILE" cFile = "Dept400-2.xml" cReadMode = "EMPTY" cSchemaLocation = "Dept400-2.xsd" lOverrideDefaultMapping = ? cFieldTypeMapping = ? cVerifySchemaMode = ?. lReturn = hPDS:READ-XML(cSourceType, cFile, cReadMode, cSchemaLocation, lOverrideDefaultMapping, cFieldTypeMapping, cVerifySchemaMode). IF lReturn THEN DISPLAY SKIP "How many temp-table buffers in the ProDataSet?" hPDS:NUM-BUFFERS SKIP "How many data-relations in the ProDataSet?" hPDS:NUM-RELATIONS SKIP(2). CREATE QUERY hQuery. hQuery:SET-BUFFERS(hPDS:GET-BUFFER-HANDLE("ttEmp")). hQuery:QUERY-PREPARE("FOR EACH ttEmp"). hQuery:QUERY-OPEN( ). hQuery:GET-FIRST( ). DISPLAY "Displaying Employee Roster..." SKIP(2) "Employee No. Last Name First Name". REPEAT WHILE NOT hQuery:QUERY-OFF-END: DISPLAY hPDS:GET-BUFFER-HANDLE("ttEmp"):BUFFER-FIELD("EmpNum"):BUFFER-VALUE hPDS:GET-BUFFER-HANDLE("ttEmp"):BUFFER-FIELD("LastName"):BUFFER-VALUE hPDS:GET-BUFFER-HANDLE("ttEmp"):BUFFER-FIELD("FirstName"):BUFFER-VALUE. hQuery:GET-NEXT( ). END. /* REPEAT */ |