IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Display the group variable which has Comp-3 fields


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shalini_devi

New User


Joined: 28 Sep 2006
Posts: 7

PostPosted: Wed Dec 06, 2006 8:55 pm
Reply with quote

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
View user's profile Send private message
hariavinash

New User


Joined: 04 Jan 2006
Posts: 64

PostPosted: Wed Dec 06, 2006 11:03 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 07, 2006 2:24 am
Reply with quote

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
View user's profile Send private message
shalini_devi

New User


Joined: 28 Sep 2006
Posts: 7

PostPosted: Thu Dec 07, 2006 7:32 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Dec 07, 2006 7:56 am
Reply with quote

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!.... icon_rolleyes.gif

Need more info? Reply......
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 07, 2006 8:23 am
Reply with quote

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
View user's profile Send private message
shalini_devi

New User


Joined: 28 Sep 2006
Posts: 7

PostPosted: Thu Dec 07, 2006 8:43 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 07, 2006 8:50 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 09, 2006 9:09 pm
Reply with quote

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
View user's profile Send private message
Nighthawk750

New User


Joined: 04 Nov 2006
Posts: 20
Location: Amsterdam

PostPosted: Mon Dec 11, 2006 12:17 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top