View previous topic :: View next topic
|
Author |
Message |
shalini_devi
New User
Joined: 28 Sep 2006 Posts: 7
|
|
|
|
Can someone help me with the below prob.
01 WS-KEY-FIELD.
03 WS-KEY1 S999 COMP-3 VALUE +0.
03 WS-KEY2 S999 COMP-3 VALUE +0.
03 WS-KEY3 S9(16) COMP-3.
MOVE WS-KEY3-NO TO WS-KEY3.
MOVE WS-KEY-FIELD TO KEY-FIELD.
DISPLAY 'KEY1: ' KEY1
DISPLAY 'KEY2: ' KEY2
DISPLAY 'KEY3: ' KEY3
DISPALY 'WHOLE KEY:' KEY-FIELD
DISPALY 'WHOLE KEY:' WS-KEY-FIELD
When i displayed KEY1, KEY2 and KEY3, it is displaying as:-
000
000
1234567891234567
but when i try to display key-field and ws-key-field the result is junk value.
Why it is not displaying the below value:-
0000001234567891234567
Thanks. |
|
Back to top |
|
|
hariavinash
New User
Joined: 04 Jan 2006 Posts: 64
|
|
|
|
you will have to move the comp-3 field to a alpha/numric field to get this displayed in readable way.
cheers |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
To work corrently, the DISPLAY statement needs elementary items (it will convert packed and binary number fields to diaplayable data) or group items that contain "printable" characters.
Your group field has nothing that will be properly visable when displayed. What you are seeing is the "printable" version of the hex values in those bytes. |
|
Back to top |
|
|
shalini_devi
New User
Joined: 28 Sep 2006 Posts: 7
|
|
|
|
But the problem is, the key is in comp field, i need to read the VSAM file with this key.
The VSAM key feild will be as below. So i m moving the numeric value(WS-KEY3-NO ) into the ws-key3(comp field) and move into the key-field to read in the VSAM file.
01 KEY-FIELD.
03 KEY1 S999 COMP-3 VALUE +0.
03 KEY2 S999 COMP-3 VALUE +0.
03 KEY3 S9(16) COMP-3. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Throwing my last two bits in,,,
VSAM does not give a dang what the key is, if yow use packed data a part of the key, then it is on your head to keep providing the same bit pattern for that key!....
Need more info? Reply...... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
This should not be a problem for reading via the key - you just won't be able to do the group DISPLAY.
If there is any way to redefine the VSAM file it would be advisable to not use signed or packed numerics as keys. |
|
Back to top |
|
|
shalini_devi
New User
Joined: 28 Sep 2006 Posts: 7
|
|
|
|
Ohh ok. So group display is not allowed.
How should i code if i want to read the vsam file with only the KEY3.
I doesn't have KEY1 and KEY2 but i have only KEY3.
Is this code will work:-
The KEY-FILE layout
01 KEY-FIELD.
03 KEY1 S999 COMP-3 VALUE +0.
03 KEY2 S999 COMP-3 VALUE +0.
03 KEY3 S9(16) COMP-3.
Program:-
01 WS-KEY-FIELD.
03 WS-KEY1 S999 COMP-3 VALUE +0.
03 WS-KEY2 S999 COMP-3 VALUE +0.
03 WS-KEY3 S9(16) COMP-3.
MOVE WS-KEY3-NO TO WS-KEY3.
MOVE WS-KEY1 TO KEY1.
MOVE WS-KEY2 TO KEY2.
MOVE WS-KEY3 TO KEY3.
START KEY-FILE KEY GREATER THAN KEY-FIELD.
IF KEYFILE-STATUS = 0
READ KEY-FILE
IF KEYFILE-STATUS = 0
IF WS-KEY-FIELD = KEY-FIELD
MOVE NAME TO WS-NAME
ELSE
GO TO 2-EXIT
END-IF
END-IF
END-IF. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Not to sound too picky, but you cannot read the file with "only" key 3 as you've described the situation. The key1 and key2 fields had some value in them when the record was added and to directly retrieve it via the 3-field key, you must provide the same value that was used when the record was added.
If the record(s) were added without control over the values in key1 and key2, you might consider at least rebuilding the file with known initial values.
If you just don't care about what values are in key1 and key2, but want to read ALL records that match the value you specify for key3 you could define an ALTERNATEINDEX for the key3 field. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Just to keep things straight: group displays ARE allowed. They just display what you ASKED FOR not what you WANT.
I display a group when I want to see what is ACTUALLY in the field(s) because DISPLAY will NOT attempt to CONVERT what's in the field(s) when displaying a group. |
|
Back to top |
|
|
Nighthawk750
New User
Joined: 04 Nov 2006 Posts: 20 Location: Amsterdam
|
|
|
|
mmwife wrote: |
Just to keep things straight: group displays ARE allowed. They just display what you ASKED FOR not what you WANT.
I display a group when I want to see what is ACTUALLY in the field(s) because DISPLAY will NOT attempt to CONVERT what's in the field(s) when displaying a group. |
And if can add a small thing (hope it is not an open door :) )
: you can always switch to HEX ON....then the "printed rubbish" can be read. |
|
Back to top |
|
|
|