Dataport Query

Does anyone know how to switch between DataItems in a dataport. I want to import a comma delimited text file, with the first line going into Sales Shipment Header table and then the next line going into the Sales Shipment Line table - the first field of the text file determines what table the current line of the text file goes into. eg. SSH,RSHIP0007,477,477, … SSL,RSHIP0007,10000,477, … SSL,RSHIP0007,20000,477, … The first line should create a record in the Sales Shipment Header table and the next two lines should create records in the Sales Shipment Line table.

I’ve done similar dataports into the sales header and sales line table. I don’t think there is any way to switch between data items. My solution was to define global text varibles Field01, Field02, etc. and use these as the dataport fields. Then in the OnAfterImportRecord trigger I have somthing like the following. CASE Field01 of ‘SSH’ : … ; ‘SSL’ : … ; END; The code for each of the cases must convert the FieldXX variables into the appropriate data types, perform any necessary validations, assign them to the proper fields in the appropriate table, and finally insert the record into the appropriate table.

We have done quite a few dataports to do the same thing for uploading Purchase Invoices. Set the Dataitem to Integer and then in the OnAfterImportRecord Trigger do a COPYSTR of the first three characters to a variable. You can then use this variable in a simple CASE statement to update whatever record you want. >Recordtype := COPYSTR(InputString,1,3); >CASE RecordTypeCode OF > ‘SSH’: //Sales Shipment Header > BEGIN > // Update the Header > END; > ‘SSL’: //Sales Shipment Lines > BEGIN > // Do your Line update > END; >END; Hoper this helps Simon Godfrey

Your best bet in this situation is to write a nonprinting report. Basically, this report would call one of two parsing functions based on the first few characters. A second strategy would be to create a buffer table. The dataport would import a line of data into the buffer and then transfer the contents of the buffer table to the appropriate sales table. A third strategy, and this is kind of a cheap one, would be to filter all the input files through the MSDOS SORT filter and then add an extra line in the middle of the file. ------- Tim Horrigan

Thanks to you all for your replies. I took Tim’s advice and used the buffer table. Regards