View previous topic :: View next topic
|
Author |
Message |
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi all,,
I have something odd to do..
I need to read hexadecimal value from two different files and compare those and carry out some operations.
When I use the below code,
Code: |
01 WS-VARIABLE.
05 WS-CONTOKEN1 PIC X(10).
05 WS-CONTOKEN1 PIC X(10). |
I end up in reading some junk values from those two files. So my IF condition always fails. Is there any ways to read the hexadecimal values in my COBOL code and compare those.
Basically those variables file will be something like this "º_ ±Õò"
So how can I proceed to read this from the file.
Please help me,
Cheers,
Neo |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi All,
To be more clear,
This is the value that is in the file - "º_ ±Õò"
And I tried displaying this in the COBOL as soon as I read the file and this was the value displayed - " ³6; A "
I dono what is causing this mismatch. I have used PIC X(10) in my COBOL. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
The code set used for the display that you view probably does not handle it the same as whatever utility you use to display the file. Always display the hex values. What you are seeing are the printable/displayable sets. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi Brenholtz ,
My code/logic does not require to display what is in the file. I just need to compare.
I have put that piece of information just for the understanding.
Appreciate if you can explain more.
Cheers,
Neo |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
3.4 browse the file and set hex on.....
In your program, define the value to compare to as hex instead of character..... |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi William
Can you explain on more how to define the value to compare as a HEX character.
Sorry to keep you disturbing..
Thanks
Neo |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
for example, your "º_ ±Õò" showed up as:
Code: |
º_ ±Õò
9648EC
BD0FFD |
so if you were going to compare a six byte filed that might or might not have "º_ ±Õò" in it,
Code: |
01 test pic X(6) value X'9B6D408FEFCD'.
if file-field = test-field
display 'EQUAL'. |
|
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi william,
Sorry that I mislead you.
I may not be knowing this value "º_ ±Õò" until I read the first file.
and the one more field to compare with will come from another file.
I need to compare these two unknown variables.
Thanks a lot for your help |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
As in?
Code: |
If file1-field = file2-field
display 'EQUAL'. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
You need to look at both files in hex (as suggested above - do this in tso/ispf). When you have looked at the "same" data field a record in both files, post the hex values you see here and we can tell you more about your data. This investigation will not need your program to run.
When you post the values here, please use the "Code" tab at the top of the Reply Panel. Use copy/paste rather than typing the info. This will ensure your data is more readable. After you enter what you want to post, click Preview and ensure your post looks the way you want it to look. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Yes I have to compare exactly like this,
Code: |
If file1-field = file2-field
display 'EQUAL'. |
But the thing is that this IF condition always fails. Dono why??
If I browse the file through 3.4 I see both the fields exactly same. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
This is the data from my file-1,
Code: |
| º_ ±Õò |
44129608EC44
F071BDEFFD0F |
And this is the data in my file-2,
Code: |
| º_ ±Õò |
44129608EC44
F071BDEFFD0F |
When I display the file-1 value using my COBOL code, (not able to find the hex chars for this as I am viewing this in the SPOOL)
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
How about showing us your data layout (working-storage) in your COBOL program. If indeed these are the same when you edit/view/browse them with HEX ON, then your address assignments for file1-field and file2-field are not what you think they are. |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
This is my IF condition,
Code: |
IF WS-CONTOKEN =
WS-ARRAY-CONTOKEN(RB-INDEX) |
The WS-CONTOKEN variable is in FD section of file-1.
Code: |
05 WS-CONTOKEN PIC X(08). |
The WS-ARRAY-CONTOKEN variable is declared as working storage variable in an array, (file-2 variable)
Code: |
10 WS-ARRAY-CONTOKEN PIC X(08). |
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
The basic truth, if both values are coming from file, don't do anything, just move the one to your array and compare the other to it....Who cares that it doesn't display right.....
IIRC, when in spool, hex on doesn't work, but set hex on does..... |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
I am sorry that this doesn't work in my case.
I am just comparing these two values from file-1 and file-2 but still then my IF fails |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
William Thompson,
That is what he is doing. He is moving 8 bytes from someplace to some array position. and comparing one or another of the array positions to somplace in a FD record description
feellikeneo's addressing (relative locations) is wrong.
We need to see the complete records from the FD section and his move code to see where his addressing is incorrect............................
A side note; feellikeneo, not that it is completely necessary, but why are you working in the FD Record description entries and not from work-areas (i.e. why are you not using a workarea option with your reads)? |
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
Have you tried defining the fields as COMP and comparing? |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
Hi Brenholtz ,
I tried moving both the values from file-1 to file-2 to working storage variable and then tried to compare. Still the same result.
Hi Socker_dad,
I tried COMP and sorry, no use |
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
OK, here's the my resort. Post your code and the file. Like this:
Code:
Code: |
IF AUDIT-D73
AND DL-AUDIT-SUSP-BATCH > SPACES
MOVE DL-AUDIT-SUSP-BATCH
TO CONSTANT-BATCHX.
|
Copybook definition:
Code: |
01 DL-AUDIT.
02 DL-AUDIT-PGM-ID PIC X(03).
88 MAINT-TO-FIXED-AREA VALUE 'D50'.
88 DIVR VALUE 'D51'.
88 MAINTENANCE VALUE 'D52' 'D53'.
88 MAINT VALUE 'D50' 'D52' 'D53'.
88 ISSUANCE-ENTRY VALUE 'D25'.
88 INCIDENT-CONTROL-PGM VALUE 'DES'.
88 SUSPENSION-REINSTATEMENT VALUE 'D73' 'D35'.
88 FR-CERTS VALUE 'D92'.
88 CONVICTION-ACCIDENT VALUE 'D43'.
88 COUNTY-CODE VALUE 'D57'.
88 AUDIT-D53 VALUE 'D53'.
88 AUDIT-D73 VALUE 'D73'.
...
02 DL-AUDIT-INPUT-SUSP-REIN-CD PIC X(01).
88 SUSP-ENTRY VALUE ' ' 'K' 'X'.
88 REIN-ENTRY VALUE 'F' 'B' 'P' 'T'
'R' 'A' 'Q' '2'
'3' 'G' 'H' 'U'
'9' 'V' 'C'.
02 DL-AUDIT-SUSP-BATCH PIC X(02).
02 DL-AUDIT-D56-FORCE-CODE1 PIC X(01).
|
File:
Code: |
File-AID - Browse - MVD.MV603.D78XXXB2.INPUT.LTH656 ------
COMMAND ===>
RECORD: 13
---- FIELD LEVEL/NAME ------- COLUMNS- ----+----1----+----
2 DL-AUDIT-PGM-ID 1 D73
...
RECORD: 13
---- FIELD LEVEL/NAME ------- COLUMNS- ----+----1-
2 DL-AUDIT-SUSP-BATCH 110 K3
2 DL-AUDIT-D56-FORCE-CODE1 112
2 DL-AUDIT-ACCIDENT-BATCH-CD 113
|
and the hexadecimal display for the same:
Code: |
----+
D7300
CFFFF
47300
...
+----1----+---
K3
44444DF4444444
00000230000000
|
Then we can see exactly with what we are dealing and make better informed suggestions. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
feellikeneo wrote: |
I am sorry that this doesn't work in my case.
I am just comparing these two values from file-1 and file-2 but still then my IF fails |
I hate to be amoung those to tell you, but if the eight byte fields are the same, they will compare equal....
Just before comparing them, display both as in:
DISPLAY '*' field1 '*' field2 '*'
and look at the spool after SET HEX ON....... |
|
Back to top |
|
|
feellikeneo
New User
Joined: 19 Mar 2007 Posts: 73 Location: Chennai
|
|
|
|
ok.. let me try and get back to you |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I'd suggest making sure that RB-INDEX has the correct value and also making sure the table was actually loaded - if the values were moved to the array, but the position in the array was not incremented, the "load" would execute, but the array would not have all of the values.
I'm also confused why
Code: |
| º_ ±Õò |
44129608EC44
F071BDEFFD0F |
does not align propperly. If the entire set was copy/pasted, all 3 lines should have the same width. . .
Is there some reason not to post the content of the 2 files (in hex)? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
William Thompson wrote: |
for example, your "º_ ±Õò" showed up as:
Code: |
º_ ±Õò
9648EC
BD0FFD |
|
Mine didn't align quite correctly either......... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
It should if it is copied from a browse with "hex on". . . .
That of course means the info needs to come from the actual data files rather than the sysout after it has been thru some amount of code. |
|
Back to top |
|
|
|