Table Name Interaction with Syntax

LawnyToast

New Member
Hello All! Happy Wednesday! I have an interesting problem to present today. I am sure the collective Openedge ABL brain has encountered it before, and could possibly offer a solution.

The ERP I am maintaining is interacting with another software and needs to import from another database via XML files. I am using the following code and running into some compilation errors. We operate on OE 10.2B. Right now, I assume there is a conflict in Syntax between the name of the field in the XML file and what I am allowed name a field inside of the temp table. Below are a few important snippets of code and the compilation error.

To my knowledge, when importing from an XML to a temp table directly, the temp table fields must coincide with the XML fields. Any suggestions for altering the temp table field names, or getting around this pesky issue?

Code:
def temp-table row
   field id_op_period      as char
   field available         as char
   field contract          as char
   field interval          as char
   field interval_date     as char
   field load              as char
   field sched_mach        as char
   field sched_wc          as char.

I am using the temp-table read from XML function:

Code:
assign v-sourcetype         = "FILE"
       v-read-xml           = "interval.xml"
       v-read-xml-path      = "\\srvdata\EXPORT\" + v-read-xml
       v-readmode           = "EMPTY"
       v-schemapath         = ?
       v-override-def-map   = ?
       v-field-type-map     = ?
       v-verify-schema-mode = ?
       .

TEMP-TABLE row:READ-XML(v-sourcetype, v-read-xml-path , v-readmode, v-schemapath, v-override-def-map, v-field-type-map, v-verify-schema-mode).

This is the main error when attempting to compile and my main hint as to the syntax issues. I don't believe I am able to name a field "availble", as it is a very popular syntax within several functions:

Code:
** Unable to understand after -- "as char  field". (247)
** Unable to understand DEFINE statement. (267)

And finally, here is an example of a single record from the XML:

Code:
<row ID="qwer\86791-002\86791-002\50\\19616.5395833333\" >
<id_op_period>qwer\86791-002\86791-002\50\\19616.5395833333\</id_op_period>
<available>45</available>
<contract>qwer</contract>
<interval>168</interval>
<interval_date>14 SEP 2021 07:00</interval_date>
<load>0.25</load>
<sched_mach>A2SHIP1-M1</sched_mach>
<sched_wc>A2SHIP1</sched_wc>
</row>
 

TomBascom

Curmudgeon
Your temp-table name of "row" is an abbreviation of ROWID. Thus the initial syntax error...

I'm not sure how much of this applies to something as old as 10.2B but the full syntax for DEFINE TEMP-TABLE is:

Code:
DEFINE {[[ NEW [ GLOBAL ]] SHARED ]| 
            [ PRIVATE | PROTECTED ][ STATIC ]
            [ SERIALIZABLE | NON-SERIALIZABLE ]}
  TEMP-TABLE temp-table-name[ NO-UNDO ] 
  [ NAMESPACE-URI namespace][ NAMESPACE-PREFIX prefix]
  [ XML-NODE-NAME node-name][ SERIALIZE-NAME serialize-name ] 
  [ REFERENCE-ONLY ]
  [ LIKE table-name
      [ VALIDATE ]
      [ USE-INDEX index-name[ AS PRIMARY ]]...]
  [ LIKE-SEQUENTIAL table-name
      [ VALIDATE ]
      [ USE-INDEX index-name[ AS PRIMARY ]]...]
  [ RCODE-INFORMATION ] 
  [ BEFORE-TABLE before-table-name] 
  [ FIELD field-name
      { AS data-type|  LIKE field[ VALIDATE ]}
  [field-options]
  ]...
  [ INDEX index-name
      [[ AS | IS ][ UNIQUE ][ PRIMARY ][ WORD-INDEX ]]
      {index-field[ ASCENDING | DESCENDING ]}...
  ]...

SERIALIZE-NAME allows you to map the names within XML (or JSON) to your TT names (both the table name and the field names) so, if it is available for 10.2B that is probably what you are looking for.

For more information: https://docs.progress.com/bundle/openedge-abl-reference-117/page/DEFINE-TEMP-TABLE-statement.html
 
Top