I'm new to Crystal Reports. I set up a report that obtains an identifier number and a name from an incoming file, and tries to match that to the names in the data base with the same identifier, but there are lots of names with identical identifiers, so we have to match on name also. It almost works pretty good, of course matching on the names there are a lot of mismatches because of variations in spelling, that is understood. I want to match on name up to the length of the shorter name. The problem is, the Len commands always return zero, even though the names are there, and they are not zero length. The formula is below. Can anyone tell me what am I doing wrong?
// get the incoming name to be matched to the name from the data base
stringvar DisProvName := UpperCase ({Disruption_.ProvNM});
stringvar MatchName;
stringvar LastName;
stringvar FirstName;
stringvar DisName;
stringvar DbName;
numberVar DisLen;
numberVar DbLen;
numberVar CompLen;
// if the name contains a comma, it is a last, first format, otherwise it is a company name
if instr(DisProvName,',') > 0 then
// obtain last, first format name from the data base
(
LastName := trim(Split (DisProvName,',')[1]);
FirstName := trim(Split(DisProvName,',')[2]);
FirstName := Replace(FirstName,' ',' ');
FirstName := Split(FirstName,' ')[1];
DisName := LastName + " " + FirstName;
DisName := Replace(DisName,' ',' ');
DbName := UpperCase ({Command.LAST_NAME} + " " + Split({Command.FIRST_NAME},' ')[1]);
)
else
// obtain company names from the data base
(
DisName := DisProvName;
DbName := UpperCase (Split({Command.ORGANIZATION_NAME},',')[1]);
);
// remove unwanted commas, periods, and hyphens from both names
DisName := trim(Replace(DisName,",",""));
DisName := trim(Replace(DisName,".",""));
DisName := trim(Replace(DisName,"-",""));
DbName :=trim(Replace(DbName,",",""));
DbName :=trim(Replace(DbName,".",""));
DbName :=trim(Replace(DbName,"-",""));
// find the length of the shorter name
DisLen=Len(DisName);
DbLen=Len(DbName);
if DisLen < DbLen then
CompLen=DisLen
else
CompLen=DbLen;
// compare the two names, but only up to the length of the shorter name
if Left(DbName,CompLen) = Left(DisName,CompLen) then
// when equal, consider it a match
// DbName
'"'+DisName+'" | "'+ToText(Dislen)+'" | "'+DbName+'" | "'+ToText(DbLen)+'"'
else
// when not equal, it is not a match, but display both names, and their lengths
'"'+DisName+'" | "'+ToText(Dislen)+'" | "'+DbName+'" | "'+ToText(DbLen)+'"';
For debugging purposes, both the then and else return the same thing.
Thanks for your help.
Dave K
// get the incoming name to be matched to the name from the data base
stringvar DisProvName := UpperCase ({Disruption_.ProvNM});
stringvar MatchName;
stringvar LastName;
stringvar FirstName;
stringvar DisName;
stringvar DbName;
numberVar DisLen;
numberVar DbLen;
numberVar CompLen;
// if the name contains a comma, it is a last, first format, otherwise it is a company name
if instr(DisProvName,',') > 0 then
// obtain last, first format name from the data base
(
LastName := trim(Split (DisProvName,',')[1]);
FirstName := trim(Split(DisProvName,',')[2]);
FirstName := Replace(FirstName,' ',' ');
FirstName := Split(FirstName,' ')[1];
DisName := LastName + " " + FirstName;
DisName := Replace(DisName,' ',' ');
DbName := UpperCase ({Command.LAST_NAME} + " " + Split({Command.FIRST_NAME},' ')[1]);
)
else
// obtain company names from the data base
(
DisName := DisProvName;
DbName := UpperCase (Split({Command.ORGANIZATION_NAME},',')[1]);
);
// remove unwanted commas, periods, and hyphens from both names
DisName := trim(Replace(DisName,",",""));
DisName := trim(Replace(DisName,".",""));
DisName := trim(Replace(DisName,"-",""));
DbName :=trim(Replace(DbName,",",""));
DbName :=trim(Replace(DbName,".",""));
DbName :=trim(Replace(DbName,"-",""));
// find the length of the shorter name
DisLen=Len(DisName);
DbLen=Len(DbName);
if DisLen < DbLen then
CompLen=DisLen
else
CompLen=DbLen;
// compare the two names, but only up to the length of the shorter name
if Left(DbName,CompLen) = Left(DisName,CompLen) then
// when equal, consider it a match
// DbName
'"'+DisName+'" | "'+ToText(Dislen)+'" | "'+DbName+'" | "'+ToText(DbLen)+'"'
else
// when not equal, it is not a match, but display both names, and their lengths
'"'+DisName+'" | "'+ToText(Dislen)+'" | "'+DbName+'" | "'+ToText(DbLen)+'"';
For debugging purposes, both the then and else return the same thing.
Thanks for your help.
Dave K