× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Glad to hear it.

Although I don't understand the String1 and 2 bit. 1 has data (City, zip, country) apparently not present in 2. Or were they defined so short that there wasn't
t room for them?


Jon P.

On Apr 16, 2024, at 3:59 PM, Greg Wilburn <gwilburn@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

I believe you may have it!
Inside my address validation service program, I was using a "title" procedure on the address lines and city (UPS returns everything in upper case).. The PI on the title procedure is CHAR not VARCHAR.

I added this code to debug:

string1 =
ups.name
+ ups.street
+ ups.street2
+ ups.street3
+ ups.city
+ ups.state
+ ups.zipcode
+ ups.cntry;

string2 =
upsSugg(x).name
+ upsSugg(x).street
+ upsSugg(x).street2
+ upsSugg(x).street3
+ upsSugg(x).city
+ upsSugg(x).state
+ upsSugg(x).zipcode
+ upsSugg(x).cntry;


STRING1 = Homer J Simpson22 Patton LnGrantsvilleMD21536US
STRING2 = Homer J Simpson22 Patton Ln Grantsville MD21536US


So I changed my service program to TRIM the results from the case change, and boom! It's fixed.

FWIW - I swear I could not "see" these spaces in debug (Notepad++ didn't see them either).

Thanks!

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jon Paris
Sent: Tuesday, April 16, 2024 12:02 PM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Comparing data in data structures

I've just had a "DOH" moment. SO mad that I didn't spot this before.

The cause of the problem has to be that one of the varchar fields contains trsiling blanks.

When RPG compares character fields it blank pads the shorter field with blanks before comparing the two. So a varchar loaded with 'ABC' and another loaded with 'ABC ' will test equal.

BUT when thoise fields are in a DS the whole DS is treated as a huge char lump and the binary length of the two fields alone (X'03' and X'05' in my example) make the two DS different - regardless of whether the back end of the arch contains spaces (as would normal in RPG) or garbage left lying around.

Hope this helps you to find the root cause - which is not your current code. Direct DS comparison is by far the best way to compare - as long as the data is good!


Jon P.

--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.