# Issue with comparing Alphanumeric field

**URL:** <https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [July 6, 2016, 1:09pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480 "2016-07-06T13:09:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarabjeet\_Pal](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@Sarabjeet\_Pal](https://techcommunity.softwareag.com/u/Sarabjeet_Pal)\
**Post date:** [July 6, 2016, 1:09pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/1 "2016-07-06T13:09:18Z")

</div>

Hi

I am using a USR module and want to compare 2 field as per below.Both are A32 field length

IF PRR-STRUCTURE-NAME NE PRR-FIELD-NAME  
do somthing  
END-IF

but the above code doesn’t work fine as the hex of both the fields are different and I am not able understand why?

PRR-STRUCTURE-NAME:-  
E2C1D9F0F0F0F2C160C9D5D7E4E34040  
40404040404040404040404040404000

PRR-FIELD-NAME:-  
E2C1D9F0F0F0F2C160C9D5D7E4E34040  
40404040404040404040404040404040

Could any one try to help me with this?

Thanks

Regards  
Sarabjeet Pal

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [July 6, 2016, 2:42pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/2 "2016-07-06T14:42:24Z")

</div>

HI Sarabjeet,  
Unfortunately, I’m not familiar with USR module(?), but it looks like your “do something” does not execute since those 2 (A32) fields are simply EQUAL.  
This is what I`ve done to test it:  
0010 DEFINE DATA LOCAL  
0020 1 #PRR-STRUCTURE-NAME-1 (A32)  
0030 1 #PRR-STRUCTURE-NAME-2 (A32)  
0040 END-DEFINE  
0050 #PRR-STRUCTURE-NAME-1 := H’E2C1D9F0F0F0F2C160C9D5D7E4E34040’  
0060 #PRR-STRUCTURE-NAME-2 := H’E2C1D9F0F0F0F2C160C9D5D7E4E34040’  
0070 IF #PRR-STRUCTURE-NAME-1 NE #PRR-STRUCTURE-NAME-2  
0080 WRITE ‘NOT RQUAL’  
0090 ELSE  
0100 WRITE ‘RQUAL’  
0110 END-IF  
0120 END

The result was ‘EQUAL’; Sorry if I don’t really follow you 🙂

---

<div class="post-metadata">

**Author:** ![Sarabjeet\_Pal](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@Sarabjeet\_Pal](https://techcommunity.softwareag.com/u/Sarabjeet_Pal)\
**Post date:** [July 6, 2016, 2:52pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/3 "2016-07-06T14:52:02Z")

</div>

Hi Nikolay

Thanks for your time, I guess you overlooked the 2 hex code I provided,It has last 2 digit as different one has 00 and other has 40, that is the reason I think it doesn’t match.

Regards  
Sarabjeet Pal

---

<div class="post-metadata">

**Author:** ![Todd\_Beckwith](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/todd_beckwith/32/388_2.png) [@Todd\_Beckwith](https://techcommunity.softwareag.com/u/Todd_Beckwith)\
**Post date:** [July 6, 2016, 3:30pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/4 "2016-07-06T15:30:05Z")

</div>

Using the following code, I get NOT EQUAL. I too am missing something. By USR module, are you referring to the SAG provided USR\* subprograms in the SYSEXT library? If so, which USR are you using?

```auto
DEFINE DATA LOCAL                                    
1 #A (A32) INIT<H'E2C1D9F0F0F0F2C160C9D5D7E4E34040' -
                H'40404040404040404040404040404000'> 
1 #B (A32) INIT<H'E2C1D9F0F0F0F2C160C9D5D7E4E34040' -
                H'40404040404040404040404040404040'> 
END-DEFINE                                           
PRINT '=' #A (EM=H(32)) / '=' #B (EM=H(32))          
IF #A NE #B                                          
  PRINT 'NOT EQUAL'                                  
ELSE                                                 
  PRINT 'EQUAL'                                      
END-IF                                               
END                                                  
```

```auto
#A: E2C1D9F0F0F0F2C160C9D5D7E4E3404040404040404040404040404040404000
#B: E2C1D9F0F0F0F2C160C9D5D7E4E3404040404040404040404040404040404040
NOT EQUAL                                                           
```

---

<div class="post-metadata">

**Author:** ![Sarabjeet\_Pal](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@Sarabjeet\_Pal](https://techcommunity.softwareag.com/u/Sarabjeet_Pal)\
**Post date:** [July 6, 2016, 3:32pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/5 "2016-07-06T15:32:20Z")

</div>

Hi Todd

I use USR8206N.

Thanks

Regards  
Sarabjeet Pal

---

<div class="post-metadata">

**Author:** ![Sarabjeet\_Pal](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@Sarabjeet\_Pal](https://techcommunity.softwareag.com/u/Sarabjeet_Pal)\
**Post date:** [July 6, 2016, 3:34pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/6 "2016-07-06T15:34:32Z")

</div>

The content in the variable in PRR-STRUCTURE-NAME and PRR-FIELD-NAME are same but the hex code are different.

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [July 6, 2016, 6:50pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/7 "2016-07-06T18:50:43Z")

</div>

Hi Sarabjeet,  
Indeed, I’ve missed the ending characters, sorry; after correction my program also tells me those strings are NOT EQUAL, which is absolutely natural to me 🙂  
However, our shop does not have USR8206N (the last one is  
USR8203N Get profile parameters from the Natural parameter module).  
Thus, I don`t see how I may help you in solving such a problem, sorry

---

<div class="post-metadata">

**Author:** ![Helmut\_Spichtinger](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@Helmut\_Spichtinger](https://techcommunity.softwareag.com/u/Helmut_Spichtinger)\
**Post date:** [July 8, 2016, 2:39pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/8 "2016-07-08T14:39:46Z")

</div>

In my opinion the API USR8206N (Read variable definitions from a cataloged Natural object) doesn’t return a correct value for field PRR-STRUCTURE-NAME (A32). On position 32 the returned value is always H’00’, even if the variable name is of lenght 32.

If have testet with this catalogued program:

DEFINE DATA LOCAL  
1 #GROUPXCVFRTGHZUJKILOPLKJUHGFR-W  
2 #A (A1)  
2 #B (A1)  
END-DEFINE  
END

The group name #GROUPXCVFRTGHZUJKILOPLKJUHGFR-W is shown both in PRR-STRUCTURE-NAME and PRR-FIELD-NAME.

The API returns:

PRR-FIELD-NAME:

#GROUPXCVFRTGHZUJKILOPLKJUHGFR-W  
7BC7D9D6E4D7E7C3E5C6D9E3C7C8E9E4D1D2C9D3D6D7D3D2D1E4C8C7C6D960E6

PRR-STRUCTURE-NAME:

#GROUPXCVFRTGHZUJKILOPLKJUHGFR-  
7BC7D9D6E4D7E7C3E5C6D9E3C7C8E9E4D1D2C9D3D6D7D3D2D1E4C8C7C6D96000

In PRR-STRUCTURE-NAME the last character W is missing. The last character on position 32 is H’00’.

hth  
Helmut Spichtinger

---

<div class="post-metadata">

**Author:** ![Sarabjeet\_Pal](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@Sarabjeet\_Pal](https://techcommunity.softwareag.com/u/Sarabjeet_Pal)\
**Post date:** [July 8, 2016, 2:51pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/9 "2016-07-08T14:51:33Z")

</div>

Exactly, that is reason I am using A31 character length to compare instead of 32 to serve my purpose.Thanks a lot for your time in investigating the issue.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:36pm UTC](https://techcommunity.softwareag.com/t/issue-with-comparing-alphanumeric-field/189480/10 "2021-04-02T15:36:26Z")

</div>

Closed on April 2, 2021, 3:36pm UTC


