Exporter - What Data Is Posted

What exactly is posted to your page and the format of the data depends on the Http Post Mode you choose.

 

The options are:

 

Post each record individually
Each record will be posted to the server individually, this is the easiest method to set-up on your server as it requires the least amount of server side code and no specialized components are required. This method is the slowest to execute and can take some time when posting a large number of records.
 

Post all records in a single HTTP Post
All records are posted to the server in a single HTTP form post, this method is a little more complex to set-up on your server than the post individually option but is much faster to execute, only one request is made to the server as opposed to the multiple requests made using the  post individually option.
 

Upload XML file containing all records
All records are posted to the server as a single file upload, the uploaded file contains all the exported data in XML format, although this method can be used with any server programming language it is ideal for use with ASP.NET, the XML data can be loaded directly into a .NET DataSet using the LoadXml methods.
 

Upload Zipped XML file containing all records
This method is the same as the upload XML option, the only difference is the XML file is zipped to increase the upload time with large amounts of data, the uploaded file needs to be unzipped server side which may require specialized components.

 

There are sample files installed with the application showing all these options being used.

 

The details of what's posted and the format of the data for each of these options is outlined below. for a complete list of Sage tables that can be exported and their fields see Sage Tables

 

The following text assumes you have left the original Sage field names unaltered, if you have altered the field names using alias's you need to take this into account in any code you use in your page.

 

Common


The following post parameters are always include regardless which Http Post Mode is used.

 

PageUsername

The username value defined on the job editors Web URL screen

PagePassword

The password value defined on the job editors Web URL screen

PostMode

The Http Post Mode being used, this is posted as a numeric value, possible values are:

 

Post each record individually

2

Post all records in a single HTTP Post

4

Upload XML file containing all records

1

Upload Zipped XML file containing all records

3

 

 

 

Post each record individually


The following post parameters are include when Http Post Mode = Post each record individually

 

KeyColumn

The name of the primary key field if the sage table has one.

SageTable

The name of the source Sage table the posted record came from.

{ColumnValues}

for each field/column in the exported record a form parameter named the same as the field name is included.

 

 

 

Post all records in a single HTTP Post


The following post parameters are include when Http Post Mode = Post all records in a single HTTP Post

 

TableNames

A comma separated list of tables uploaded, for example STOCK,SALES_LEDGER

{TABLE}_RecordCount

For each table in the TableNames list a parameter for that tables record count is included, the parameter name is {TABLE}_RecordCount with the {TABLE} portion replaced with the table name, for example: STOCK_RecordCount

{TABLE}_ColumnNames

For each table in the TableNames list a parameter for that tables columns is included, it contains a comma separated list of columns uploaded for that particular table, the parameter name is {TABLE}_ColumnNames with the {TABLE} portion replaced with the table name, for example:

 

SALES_LEDGER_ColumnNames = ACCOUNT_REF,NAME,TELEPHONE

 

and

 

STOCK_ColumnNames = STOCK_CODE,DESCRIPTION,SALES_PRICE

{TABLE}_KeyColumn

For each table in the TableNames list a parameter containing the tables primary key column is included, if the table has no primary key this parameter will not contain a value, the parameter name is {TABLE}_KeyColumn with the {TABLE} portion replaced with the table name, for example:

 

SALES_LEDGER_KeyColumn = ACCOUNT_REF

 

and

 

STOCK_KeyColumn = STOCK_CODE

{TABLE}_{COLUMN}_{INDEX}

lets assume we are uploading updates containing data for both the customers and product tables, looking at the data in tabular form an example would look like the following:

 

Customers (SALES_LEDGER)

ACCOUNT_REF

NAME

TELEPHONE

A1D001

A1 Design Services

01742 876 234

ABS001

ABS Garages Ltd

0191 254 5909

 

Products (STOCK)

STOCK_CODE

DESCRIPTION

SALES_PRICE

CALC001

Calculator - Desktop

10

CALC002

Calculator - Pocket

6

 

for each cell in each table a post parameter is included and is named {TABLE}_{COLUMN}_{INDEX}

 

{TABLE} is replaced with the name of the table

{COLUMN} is replaced with the name of the column

{ROW} is replaced with the index number of the record/row

 

for example the parameter that holds the STOCK_CODE value for the second record in the STOCK table would be called:

 

STOCK_STOCK_CODE_1

 

note the rows collection is zero based, the first record index = 0, the second = 1 and so on.

 

This can seem quite complex the first time you read this, a useful aid to understanding the structure of the posted data is to see it at runtime, what to do is create a page with some code to output the post parameter names & values, then run an export targeting this page, if you select "Display the page after export" option you will see the names of posted parameters and their values  printed out on the page.

 

Sample Code to output the parameter names & values:

 

VB.NET

For Each Item As String In Request.Form

 Response.Write(Item & "=" & Request.Form(Item) & "<br>")

Next

 

C#.NET

foreach (string Item in Request.Form)

{

 Response.Write(Item + "=" + Request.Form[Item] + "<br>");

}

 

ASP VBScript

For Each Item In Request.Form

 Response.Write(Item & "=" & Request.Form(Item) & "<br>")

Next

 

An alternative method for .NET pages is to enable tracing on the page, simply add:

 

Trace="true"

 

to the page directive tag,  when the page is run .NET will output all the tracing information into the pages output including all posted form parameters & their values.

 

 

 

Upload XML file containing all records


This option uploads an XML file containing all the export data to the page, assuming you have not altered the file name expression the file name will be:

 

{category}-{jobname}.xml where {category} will be replaced with the job category name and {jobname} replaced with the job name, for example:

 

MyCategory-MyJob.xml

 

The layout of the uploaded XML file is 100% compatible with the .NET DataSets ReadXML and WriteXML methods, in fact the file is created using WriteXML, a basic sample of the file contents is shown below, only 2 products and 2 customer records have been exported to generate this sample.

 

<?xml version="1.0" standalone="yes"?>

<SageData>

   <PrimaryKeys>

       <Table>STOCK</Table>

       <KeyColumn>STOCK_CODE</KeyColumn>

   </PrimaryKeys>

   <PrimaryKeys>

       <Table>SALES_LEDGER</Table>

       <KeyColumn>ACCOUNT_REF</KeyColumn>

   </PrimaryKeys>

   <STOCK>

       <DESCRIPTION>Calculator - Desktop</DESCRIPTION>

       <SALES_PRICE>10</SALES_PRICE>

       <STOCK_CODE>CALC001</STOCK_CODE>

   </STOCK>

   <STOCK>

       <DESCRIPTION>Calculator - Pocket</DESCRIPTION>

       <SALES_PRICE>6</SALES_PRICE>

       <STOCK_CODE>CALC002</STOCK_CODE>

   </STOCK>

   <SALES_LEDGER>

       <ACCOUNT_REF>A1D001</ACCOUNT_REF>

       <NAME>A1 Design Services</NAME>

       <TELEPHONE>01742 876 234</TELEPHONE>

   </SALES_LEDGER>

   <SALES_LEDGER>

       <ACCOUNT_REF>ABS001</ACCOUNT_REF>

       <NAME>ABS Garages Ltd</NAME>

       <TELEPHONE>0191 254 5909</TELEPHONE>

   </SALES_LEDGER>

</SageData>

 

Please note that the primary key information is only included for those sage tables containing a dedicated primary key column.

 

 

Upload Zipped XML file containing all records


This option is the same as the Upload XML file containing all records option, the only difference is the XML file is zipped into a zip archive called the same name as the XML file and the zip archive is uploaded, depending on the server platform used special components may be required to un-zip the file server side.