Importing CSV file

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

Yes… I don’t think you want to use the SELECTSTR statement for this. Please read the Navision help file. The following comment is in it : Comments SELECTSTR treats string values as OPTIONS. This means that identical values in different strings are not allowed. Please explain why you use SELECTSTR. There must be a other solution for what you want to do.

Being a fan of the “dumb and simple” school of programming, I would be tempted to just use an IF statement and an Assign to handle this situation (IF InputDataText = ‘YES’ THEN BooleanOutputField := TRUE;).

Why are you using a codeunit and not a dataport? SELECTSTR is annoying like that - but when it was neccesarry to use it I wrote a little piece of code that found each comma-seperator and added a unique number (always 3 chars so I could easily remove it later)…

Always use Text format file which is less in size and easy to Import, Also make dataport for Importing that file and add all selected fields in same format, Will auotmatically pickup without giving any problem Thanks

SELECTSTR cannot handle a [standard]CSV-file! And I cannot not imagine that to be an intention with that function. If e.g. one of the fields contains a comma, this comma will act as a field-separator - and the one field will be separated. Quotation-marks is a “standard-ingredient” in CSV - SELECTSTR doesn’t handle that either.

CSV is a pain. Some of the programs which are commonly used to create CSV files (e.g, Excel) put quotes around some fields and not around others. The standard dataport functionality in Navision knows what to do if every field has quotes, and what to do if no fields have quotes— but it can’t easily handle the situation where quotes may or may not be present. The big problem with CSV is of course that you will eventually want to import data where some fields might contain commas (and/or quotataion marks.) I recommend using tab-delimited format wherever possible, because you will (almost) never want to import data with tabs embedded in it.

Try the following code. Works fine for me: GetFieldContent(parFieldNo : Integer;parTxt : Text[1024]) : Text[1024] ReturnString := ''; FieldsFound := 1; boo := -1; REPEAT CounterPOS += 1; IF parTxt[CounterPOS] = '"' THEN boo *= -1 ELSE BEGIN IF (parTxt[CounterPOS] = ',') AND (boo = -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);