MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VSAM Key Representation in COBOL
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
ksvenky
Beginner


Joined: 18 Nov 2005
Posts: 5
Topics: 1

PostPosted: Fri Nov 18, 2005 4:51 am    Post subject: VSAM Key Representation in COBOL Reply with quote

I have a doubt regarding VSAM file usage in COBOL. I have a KSDS VSAM file.
Is it necessary that the Key value should be represented as Alphanumeric only in the COBOL program?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 18, 2005 5:22 am    Post subject: Reply with quote

ksvenky,

As Far as I know there is no such restriction.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ksvenky
Beginner


Joined: 18 Nov 2005
Posts: 5
Topics: 1

PostPosted: Fri Nov 18, 2005 5:34 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for the reply.
Actually we are converting some programs from Easytrieve Classic to COBOL. In that the programs handling KSDS VSAM files with key numeric threw some error saying Key cannot be a numeric value.

Also from one document, I got
"COBOL requires that an alphanumeric VSAM file key for KSDS files is named in the FD statement."

Here are some more doubts:

I have the following doubts with respect to Easytrieve Classic.

1) I would like to know the usage of the '&' symbol. It is used a prefix to some variables. Is there any alternative to that?

2) There is statement called UPDATE. I would like to know what would be its COBOL equivalent (or) how the UPDATE statement in Easytrieve Classic would be represented in COBOL?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 18, 2005 5:45 am    Post subject: Reply with quote

Quote:

1) I would like to know the usage of the '&' symbol. It is used a prefix to some variables. Is there any alternative to that?

ksvenky,

Can you post some examples

Quote:

2) There is statement called UPDATE. I would like to know what would be its COBOL equivalent (or) how the UPDATE statement in Easytrieve Classic would be represented in COBOL?


Look Up the Rewrite statement in cobol

Check this link which explains in detail about processing vsam files in cobol

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.10?DT=20020923143836

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ksvenky
Beginner


Joined: 18 Nov 2005
Posts: 5
Topics: 1

PostPosted: Fri Nov 18, 2005 6:16 am    Post subject: Reply with quote

Hi Kolusu,

Thanks a lot for that reply.

Here are some examples for the variable with '&' sign

IF &BEGINYY GQ 60
BEGINCC EQ 19
BEGINYY EQ &BEGINYY
---------------------------
IF &ENDYY GQ 60
ENDCC EQ 19
ENDYY EQ &ENDYY
A*ENDCY EQ ENDCCYY

where BEGINYY and ENDYY are Working Storage Variables
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Fri Nov 18, 2005 6:24 am    Post subject: Reply with quote

Quote:

IF &BEGINYY GQ 60



&BEGINYY doesn't look like a cobol variable. Look at the compilation listing to see how are they resolved.
Back to top
View user's profile Send private message Send e-mail
ksvenky
Beginner


Joined: 18 Nov 2005
Posts: 5
Topics: 1

PostPosted: Fri Nov 18, 2005 7:22 am    Post subject: Reply with quote

Hi Dibakar,

The code i had mentioned is not COBOL. It is a easytrieve classic code.
I would like to know whether '&' is valid in easytrieve classic. If not, then how can it be replaced in my code?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 18, 2005 8:27 am    Post subject: Reply with quote

ksvenky,


& is used in macros, like when you want to pass a variable in the macro. Looking at the code , I see that it is used to populate the century portion for the date.

You can use the macro DATECONV to do that.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ksvenky
Beginner


Joined: 18 Nov 2005
Posts: 5
Topics: 1

PostPosted: Fri Nov 18, 2005 10:02 am    Post subject: Reply with quote

Hi Kolusu,

So, variables beginning with '&' sign are valid in Easytrieve classic, right?

Actually in our program, a CLIST calls a TSO Panel and the input given to Panel are then used to trigger a Easytrieve classic program. Hence the &BEGINYY is a value entered through Panel.

Now what is happening is we are converting all our Easytrieve classic programs to COBOL. Hence facing problem with '&' varaibles.


Can you please provide me a sample JCL to execute a simple easytrieve classic program?

Regards
Venky
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Nov 18, 2005 10:23 am    Post subject: Reply with quote

Quote:

Now what is happening is we are converting all our Easytrieve classic programs to COBOL. Hence facing problem with '&' varaibles.


venky,

How are you planning to populate the variables Beginyy in cobol?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Nov 28, 2005 10:11 am    Post subject: Reply with quote

Hi,

I encountered a strange problem last weekend. I was doing some code changes for another project and I was converting couple of flat files to a VSAM (we eliminated dups if any on the key field).

One VSAM was defined with Key Offset: 0 and Key Length: 8. The field used as is actually 9(15)V COMP-3 (8 bytes - compressed). Now when the program ran, whatever be the data we pass to this key field, everything was thrown out as "INVALID KEY".

Code:

READ
     vsam-file
KEY IS
     key-field-PD-8
INVALID KEY
     DISPLAY 'KEY INVALID: ' key-field-PD-8
NOT INVALID-KEY
     ADD +1 TO WS-READ-COUNTER
END-READ


This was the read statement that I used and everytime the control went into the "INVALID KEY" phrase and displayed the value. When verified in File-Aid the vsam had a record with the errored out key.

Can someone investigate and let me know if a "Numeric" field (Singleton - no composites) can be used as a Key.

Compiler listing had a "Information" message saying that "Primary" / "Alternate Key" defined for the VSAM file is "NOT ALPHANUMERIC". Compiler treats that "Alphanumeric". (I don't rememeber the exact phrase but this was what it looks like).

Thanks,
Phantom
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Nov 28, 2005 12:40 pm    Post subject: Reply with quote

Using a PD for a binary field for a key is NOT A GOOD idea. It is not difficult to see why.

Consider +1 which is X'001C' and -1 which is X'001D'. Now, -1 < +1. But, X'001C' < X'001D' from a purely hexa-decimal point of view. From a PD point of view, X'001C' < X'001D' means, +1 < -1 !
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Mon Nov 28, 2005 12:49 pm    Post subject: Reply with quote

BTW, the values of C and D in the last nibble is not really universal. Other values are also possible to denote positive and negative values.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Nov 30, 2005 3:56 am    Post subject: Reply with quote

Cogito,

Apologize for the late response. Excellent Explantion ! Thanks a ton.

Quote:

Using a PD for a binary field for a key is NOT A GOOD idea. It is not difficult to see why.


I'm hearing something new here ! - definitely a problem with the basics. How does the VSAM key matching take place ? - Is it pure Binary ? (irrespective of the key field declaration in COBOL copybook)

And are there any other restrictions on the type of field to be used as VSAM Key ??? (apart from Packed Decimal).

Thanks a lot,

Regards,
Phantom
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Nov 30, 2005 5:08 am    Post subject: Reply with quote

Quote:
How does the VSAM key matching take place ? - Is it pure Binary ? (irrespective of the key field declaration in COBOL copybook)

Yes.

Well, as it is pure binary comparision, that tells pretty much what/what not can be the keys.

If you really want to extrapolate this, you can have names of employees as keys (so long there are no duplicates.) But, if your names are in Japanese (stored in DBCS), then the lexicographical sort would not match with hexadecimal sort.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group