I have a csv file I am importing data to update customer records using a codeunit.
I have successfully completed this task in the past but these records contain several boolean fields.
It seems that when I import the first record and attempt to assign the first field of data using SELECTSTR(1, TrainingInfoLine) it gives me the following message 'STRSET' cannot contain 'TRUE' more than once.
I wouldn't think this would normally cause a problem.
Any suggestions would be helpful. :?
I am running Financial 26e on a sql server 2000
0
Comments
This works for me
Alastair
And by the way: Your post shows that it is a good idea to search the forum before posting new questions...
am trying to instream a csv file that has 7 comma separated subtrings eg.
ABL,1480,1480,1480,2501,07/11/05,5456.79
this is how the code in the codeunit looks like:
OnRun()
Data.OPEN('C:\Rates.txt');
Data.CREATEINSTREAM(InS);
code := 1;
WHILE NOT (InS.EOS()) DO
BEGIN
InS.READTEXT(Txt);
Table.INIT;
Table."Equity Code" := GetFieldContent(1, Txt);
Table."Closing Price" := GetFieldContent(2, Txt);
Table."Opening Price" := GetFieldContent(3, Txt);
Table."Current Price" := GetFieldContent(4, Txt);
Table."Session No." := GetFieldContent(5, Txt);
Table."Date of Price Change" := GetFieldContent(6, Txt);
Table."GSE Index" := GetFieldContent(7, Txt);
Table.INSERT;
code := code + 1;
END;
Data.CLOSE();
MESSAGE('Records have been written');
and the
GetFieldContent(parFieldNo : Integer;parTxt : Text[1024]) : Text[1024]
ReturnString := '';
FieldsFound := 1;
int := -1;
REPEAT
CounterPOS += 1;
IF parTxt[CounterPOS] = '"' THEN
int *= -1
ELSE BEGIN
IF (parTxt[CounterPOS] = ',') AND (int = -1) THEN
FieldsFound += 1
ELSE
IF FieldsFound = parFieldNo THEN
ReturnString := ReturnString + COPYSTR(parTxt,CounterPOS,1);
END;
UNTIL (CounterPOS = STRLEN(parTxt)) OR (FieldsFound > parFieldNo);
EXIT(ReturnString);
please help out i need cos i need it badly.thank u ](*,)
You could try this
Table."Equity Code" := COPYSTR(Txt,1,strpos(Txt,',') - 1);
Txt := COPYSTR(Txt,strpos(Txt,',') + 1);
Table."Closing Price" := COPYSTR(Txt,1,strpos(Txt,',') - 1);
Txt := COPYSTR(Txt,strpos(Txt,',') + 1);
etc for all the fields that are used.
Hope this helps
Albert
you can use this for every element in the CSV-file
guys Albertvh code worked for me thanks so much .Frankie i will try yours later to see how it goes.Thanks everyone u saved the day.i guess navision with tyme will become as easy as ABC . this an appluase for all the help =D>