Hi Users,

This is Seshadri am doing a dataport, Is it possible to import data from a single CSV file in to 2 different tables.



yes it is possible i think, but really sorry i dont know to do it properly! so i will first check out whether what i think can be done ,then report back:)

between, what 2 table are you using?

i am really sorry seshadri, i know that we can do what you are asking. but i forgot the way. i am tring to recall,but to no wile.

you only need to define the table as record in global var, e.g. vdr - record - vendor
write your code in the onafterimportrecord(), something like:

vdr.“no.” := your_dataport_field_1;
. . . continue with assigning values, validating, etc …

Hi Seshadri,

You can have as many DataItem in your dataport. This DataItem is actually your source/target table.

But if you mean to say that you only have one DataItem and you want to split the data to two different tables, my question will be _won’t it be easier to create two dataports instead of creating a logic to split the text into different table?

Anyway, if you still want to do it; select Integer (or any table actually) as your DataItem. Set the AutoUpdate and AutoSave properties to NO. Go to Dataport Fields (Alt+V+D), and instead of taking the table’s field you need to create Global Vars as your SourceExpr. From there you need to create the logic to split the data into different tables.



Follow the below steps

1.Select your two data items for example



2.Create all the fileds of csv file as globla variable with appropriate dtat type for example

Name DataType Subtype Length
SalesOrderNo1 Code 30
CustomerNo1 Code 30
CustomerName1 Text 100
Item1 Code 30
Cost1 Decimal
Qty1 Decimal the global variables as your data port fields for Data item1 (Table1).(you cannot select you have to enter mannualy)

4.Place the below code at OnAfterImportRecord() of First Dtat item (Table1)

Table1.“Sales Order No”:=SalesOrderNo1;
Table1.“Customer No”:=CustomerNo1;
Table1.“Customer Name”:=CustomerName1;

Table2.“Sales Order No”:=SalesOrderNo1;
Table2.“Customer No”:=CustomerNo1;
Table2.“Customer Name”:=CustomerName1;


hi marshal,

thanks, i remembering doing something like this. but i dont remember typing any codes. so should i type all these codes in the OnAfterImportRecord?

Hi Shona

Yes you have to write code at OnAfterImportRecord().

The trigger is executed after the record is read from the table, but before it is inserted into the table. You can use this trigger to perform postprocessing that is required before the record is inserted.



oh thanks:)