/* pi-tfx-writeSetup-6.i */
/* Creates two new static temp-tables and a ProDataSet. */ /* Definition for Temp-Table ttCustomer */ DEFINE TEMP-TABLE ttCustomer NO-UNDO BEFORE-TABLE ttCustBef FIELD CustNum LIKE Customer.CustNum FIELD Name LIKE Customer.Name COLUMN-LABEL "Loyal Customer" XML-NODE-TYPE "Attribute" 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 BEFORE-TABLE ttOrdBef 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. DEFINE DATASET dsCustomerOrders FOR ttCustomer, ttOrder DATA-RELATION custOrd FOR ttCustomer, ttOrder REPOSITION RELATION-FIELDS (CustNum, CustNum) NESTED. |
/* pi-tfx-write-6a.p */
/* Writes data from a static ProDataSet to an XML file. This demonstrates the first half of a persistent storage mechanism through XML. */ {pi-tfx-parameterVarDefs.i} {pi-tfx-writeSetup-6.i} DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO. DEFINE VARIABLE hPDS AS HANDLE NO-UNDO. hPDS = DATASET dsCustomerOrders:HANDLE. /* Before the method call, your application does work with its data. */ ASSIGN cTargetType = "FILE" cFile = "dsCustomerOrder.xml" lFormatted = YES cEncoding = ? cSchemaLocation = ? lWriteSchema = YES lMinSchema = FALSE lWriteBeforeImage = TRUE. lReturn = hPDS:WRITE-XML (cTargetType, cFile, lFormatted, cEncoding, cSchemaLocation, lWriteSchema, lMinSchema, lWriteBeforeImage). IF lReturn = FALSE THEN DO: MESSAGE "WRITE-XML on ProDataSet failed!" VIEW-AS ALERT-BOX. RETURN. END. ELSE MESSAGE "Successful WRITE-XML on : " hPDS:NAME VIEW-AS ALERT-BOX. |
/* pi-tfx-write-6b.p */
/* Reads and writes the data to and from a static ProDataSet to an XML file. */ {pi-tfx-parameterVarDefs.i} {pi-tfx-writeSetup-6.i} DEFINE VARIABLE hPDS AS HANDLE NO-UNDO. DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO. hPDS = DATASET dsCustomerOrders:HANDLE. ASSIGN cSourceType = "FILE" cFile = "dsCustomerOrders.xml" cReadMode = ? cSchemaLocation = ? lOverrideDefaultMapping = FALSE. lReturn = hPDS:READ-XML(cSourceType, cFile, cReadMode, cSchemaLocation, lOverrideDefaultMapping). IF NOT lReturn THEN DO: MESSAGE "READ-XML on ProDataSet failed!" VIEW-AS ALERT-BOX. RETURN. END. ELSE MESSAGE "Successful READ-XML on:" hPDS:NAME VIEW-AS ALERT-BOX. /* After the method call, your application does work with its data. */ |