I want import into Customer Table. I can write import Data Port. But some data is max customer table field length. So i wann to move that data to other field.
Eg.
“S007”,“Sino Holdings Pte Ltd-Mte Fund for Leonie Hill Residence”,"",“No.1 Jalan Berseh”,""#03-03",“New World Centre”",“Singapore”,“Singapore 209037”,“SG”,"","","","","","",“SGD”,"",“LOCAL”,“LOCAL”,“LOCAL”,“30 DAYS”
"Sino Holdings Pte Ltd-Mte Fund for Leonie Hill Residence" is length is over 50.
So i wann to save “name” field into 50 char. Another char save in “name2”.
Therefore you need to define a global variable of the type text with a size big enough to store the complete name (more than 50 characters.)
Then you assign this variable to the dataport fields and create code in the “OnAfterImportRecord” trigger which checks the sizes and assigns to the correct fields:
IF STRLEN(NameVar) > MAXSTRLEN(Name) THEN BEGIN
Name := COPYSTR(NameVar,1, MAXSTRLEN(Name));
"Name 2" := COPYSTR(NameVar,MAXSTRLEN(Name) + 1);
END ELSE
Name := NameVar;
Ashish, please try your code before posting it here. This dataport will not work because:
You should not do a manual INSERT in code before setting the “AutoSave” property of the dataitem to false - your code fails on the first line imported;
You should not call the INSERT statement twice - your code fails on the second line imported.
Additionally there are a few (smaller) issues with your code:
Since recent versions the length of the name fields in the customer table (and others as well) are changed from 30 to 50. Your code would not cater for that. Rather consider using the MAXSTRLEN function instead.
You should (before assigning any field to the new customer) call an INIT on the customer table to make sure that all fields are cleared/initialized propertly, according to the InitValue of the fields.
Thx for your reply. I wrote your way point. I declare global variable. Then i put that variable in “Dataport Fields”. But it is not work. It sho show error message like that " Sino Holdings Pte Ltd-Mte Fund for Leonie Hill Residence is max length."
I put your code at "OnAfterImportRecord".
IF STRLEN(NameVar) > MAXSTRLEN(Name) THEN BEGIN
Name := COPYSTR(NameVar,1, MAXSTRLEN(Name));
"Name 2" := COPYSTR(NameVar,MAXSTRLEN(Name) + 1);
END ELSE
Name := NameVar;
I don’t clear . How to get data in “NameVar”? It source is “NameVar” at “Dataport”. It length is show zero when i wrote message.
Please help & teach me
My Object Here:
OBJECT Dataport 50005 T - Customer - Export/Import
{
OBJECT-PROPERTIES
{
Date=03/17/09;
Time=[ 3:38:56 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
FieldStartDelimiter=;
FieldEndDelimiter=;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table50001;
DataItemTableView=SORTING(No.)
ORDER(Ascending)
WHERE(No.=FILTER(<>’’));
ReqFilterFields=No.,Name;
OnAfterImportRecord=BEGIN
IF STRLEN(NameVar) > MAXSTRLEN(Name) THEN BEGIN
Name := COPYSTR(NameVar,1, MAXSTRLEN(Name));
“Name 2” := COPYSTR(NameVar,MAXSTRLEN(Name) + 1);
END ELSE
Name := NameVar;
END;
S007,Sino Holdings Pte Ltd-Mte Fund for Leonie Hill Residence,No.1 Jalan Berseh,#03-03New World Centre,Singapore,Singapore 209037,SG,SGD,LOCAL,LOCAL,LOCAL,30 DAYS
You should use NameVar as second line in the dataport fields (instead of Name).
Additionally the size of this text variable must be big enough to store the complete content of the text. So I suggest to use a Text with a length of 100.