Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
KSDS and Index file in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
deepak14450

New User


Joined: 21 Dec 2017
Posts: 2
Location: India

PostPosted: Fri Dec 22, 2017 9:36 am    Post subject: KSDS and Index file in cobol
Reply with quote

Hi All,

I had a query of when do we use KSDS and index file in COBOL/CICS programs.Both of them look identical in terms of functionality to me. Are there any differences present in KSDS and index file and in which scenario what is to be used.

Please guide.

Thanks,
Deepak Kanar
Back to top
View user's profile Send private message

steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 664
Location: The Universe

PostPosted: Fri Dec 22, 2017 10:55 am    Post subject:
Reply with quote

  1. Get it through your head. There are NO "files" in MVS. NONE. MVS has "data sets." A data set may exist as a "file" on magnetic tape. And that is the sole proper use of "file" in MVS and z/OS.
  2. A VSAM KSDS (Keyed Sequential Data Set) exists as two paired data sets: the main data set and an index data set. The sole purpose of the index data set is to provide a fast lookup of the data in the data set. Other than the keys and lookup information, there is no data in the index data set.
Back to top
View user's profile Send private message
deepak14450

New User


Joined: 21 Dec 2017
Posts: 2
Location: India

PostPosted: Fri Dec 22, 2017 11:27 am    Post subject: Reply to: KSDS and Index file in cobol
Reply with quote

But when we create an indexed file using a COBOL program, we define RECORD key is data-name-1. And the same thing is done using KSDS too. We declare our unique key using IDCAMS. If both of them use the same functionality, then why was VSAM datasets introduced. Why cant we just deal with files is my question or what is the use of files if VSAM can do all the things
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2090
Location: UK

PostPosted: Fri Dec 22, 2017 4:29 pm    Post subject:
Reply with quote

Please take note of what is written - they are 'data sets' not 'files' so use the correct terminology. If they were 'files' it would be a KSF not a KSDS and FN= instead of DSN=.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8391
Location: Dubuque, Iowa, USA

PostPosted: Fri Dec 22, 2017 5:58 pm    Post subject:
Reply with quote

The ONLY indexed data sets you have been able to create on an IBM mainframe have been VSAM KSDS for many years. IBM used to support another indexed format, but that is long gone.

You use VSAM because IBM says if you want indexed records, you MUST use VSAM -- period. VSAM has some advantages over some of the earlier access methods.
Quote:
Why cant we just deal with files is my question
This question makes absolutely no sense because (1) the only files that exist on z/OS are in Unix System Services or on tape -- on disk they are called data sets and ONLY called data sets, and (2) you can use sequential data sets (or VSAM ESDS data sets), VSAM RRDS, or VSAM KSDS (VSAM linear data sets are rarely used by applications) -- you use VSAM because that is how you access them. COBOL does not have the tools available to handle the complexities of disk architecture directly; you must use some access method to read or write the data in COBOL.

I think it is about time to lock this topic -- you are asking questions which don't make sense nor do you use proper terminology. Perhaps you should move to Beginners and students forum as this forum is for professionals and you are asking rank beginner questions.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 714
Location: Pennsylvania

PostPosted: Fri Dec 22, 2017 6:32 pm    Post subject:
Reply with quote

I think you guys are overly harsh on the terminology in this regard.

I agree that DATASET is the correct term regarding the physical location of the data.

The term File however is also used often in MVS.

Look at the TSO ALLOCATE command. One of the parameters is FILE. This is equivalent to the DD name in the JCL.

In a COBOL program there is a FILE-SECTION and a FD (File Definition).

There is also the concept of a File Layout, which describes the individual elements of the data within a dataset.

My point is that while there is a difference between Dataset and File, from the conceptual standpoint they a very similar. They describe a collection of data.

Many of my associates, and myself use these terms interchangeably in conversation. We do not let the minor differences become a diversion from what we are talking about.

Just my own view.
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10515
Location: italy

PostPosted: Fri Dec 22, 2017 7:58 pm    Post subject: Reply to: KSDS and Index file in cobol
Reply with quote

Data Set Ready, an RS-232 signal used by a modem to indicate to the computer that it is ready to receive data

so "data set" might be an alternative name for a modem icon_cool.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2090
Location: UK

PostPosted: Fri Dec 22, 2017 9:04 pm    Post subject:
Reply with quote

From the program's point of view the data stream comes to the program (or leaves) via a file. The data is stored in a data set. The data set is connected to the file/data stream via the DD statement. The ddname matches to the file name in the program. So, from my point of view:
Code:
 filename in program --> ddname on dd statement --> dataset pointed to by DSN(AME)=data set name

But this only relates to data held on, or written to, a data set. Data from a modem, till, card reader, whatever may be a different data stream.

I am not trying to be pedantically correct here - it is simply how I view it as an application programmer (deceased). The world ain't going to stop just because we use the wrong terminology - but it goes along better if we do.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 714
Location: Pennsylvania

PostPosted: Fri Dec 22, 2017 9:13 pm    Post subject:
Reply with quote

Here is a couple of snippets of a Cobol program. Notice the number of occurrences of the word FILE. This is Cobol terms and names used by the programmer.

This program uses KSDS (datasets), but that word is never referenced.

So now you have this new poster using the term FILE, which is all you see in the Cobol. He gets pounded here saying THERE NO FILES ON MVS, NONE!

The above statement is not true. Files and Datasets are talking about the same thing, but from a different perspective.

Since you don't know the perspective of the poster (in this case you do because he mentioned Cobol in his post), please consider Files and Datasets both acceptable when referring to DATA.

Code:
INPUT-OUTPUT SECTION.
FILE-CONTROL.

    SELECT NA04FL-FILE-I-O ASSIGN TO NA04FL
       ORGANIZATION IS INDEXED
       ACCESS MODE IS DYNAMIC
       RECORD KEY IS NA4-KEY-GRP
       FILE STATUS IS FILE-STATUS.

DATA DIVISION.
FILE SECTION.

FD  NA04FL-FILE-I-O
    RECORD CONTAINS 4093 CHARACTERS
    DATA RECORD IS NA4-REC-GRP.
    COPY NA04FL.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1298
Location: Israel

PostPosted: Mon Dec 25, 2017 3:31 pm    Post subject:
Reply with quote

Now that we all agree about the terminology...

If I add the word "alternate" right before the word "index", the question could almost make sense,
but some of Deepak phrases are still a mystery:
Quote:
...
when can we use Index file (Non -VSAM) and when to use KSDS
...
when we create an indexed file using a COBOL program
...

What is a "non-VSAM index file created by a COBOL program" ? Could this be a sequential file ?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ISPF 3.4 edit of a ps file, disp use... Carrie Da Silva TSO/ISPF 3 Fri Sep 21, 2018 3:01 am
No new posts ICETOOL - Finding keys within a file nartcr DFSORT/ICETOOL 10 Mon Sep 17, 2018 6:39 am
No new posts Remove selected duplicate rows from t... hnharish DFSORT/ICETOOL 3 Wed Sep 05, 2018 3:11 am
No new posts Splitting one record in a file to 10 ... mf_123 DFSORT/ICETOOL 9 Tue Aug 21, 2018 8:51 pm
No new posts CLOB Column data to External File usi... lalitmehta12 DB2 9 Tue Aug 21, 2018 7:22 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us