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

accessing the VSAM record using COBOL pgm


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kumar_ngl
Warnings : 1

New User


Joined: 05 Aug 2005
Posts: 50
Location: chennai

PostPosted: Fri Aug 05, 2005 11:22 am
Reply with quote

Hi all,

Can any one send me the COBOL code for reading the VSAM file..

regards,
kumar.p.v
Back to top
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Fri Aug 05, 2005 11:35 am
Reply with quote

Kumar,

Please let me know, if you are working with ESDS /KSDS / RRDS
and also, if its just COBOL batch or CICS?
Back to top
View user's profile Send private message
kumar_ngl
Warnings : 1

New User


Joined: 05 Aug 2005
Posts: 50
Location: chennai

PostPosted: Fri Aug 05, 2005 11:37 am
Reply with quote

hi thanks for your quick reply,

well that file is a KSDS??? and its a simple batch pgm, plz give me the full coding

thanx
kumar.p.v
Back to top
View user's profile Send private message
thanooz

New User


Joined: 28 Jun 2005
Posts: 99

PostPosted: Mon Aug 08, 2005 8:15 pm
Reply with quote

HI ACCESS VSAM IN COBOL


FILE-CONTROL SECTION.

SELECT I-FILE ASSIGN TO INDEXED-FILE
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS IFILE-RECORD-KEY
ALTERNATE RECORD KEY IS IFILE-ALTREC-KEY
FILE STATUS IS FSTAT-CODE VSAM-CODE.

YHANKS,
THANOOZ.
Back to top
View user's profile Send private message
kumar_ngl
Warnings : 1

New User


Joined: 05 Aug 2005
Posts: 50
Location: chennai

PostPosted: Mon Aug 08, 2005 8:56 pm
Reply with quote

thanx thanooz,

But that was not the answer i expect.. I want to know the COBOL coding in the Procedure-Division.

Your answer is abt the Environment division.

plz make me little clear abt this

kumar.p.v
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Mon Aug 08, 2005 11:29 pm
Reply with quote

READ file-name[into identifier]
[;key is dataname]
[;invalid key is imperative-stmt]

In general open u r files in the mode required.

move the key value to the key field.
compare the key-value to u r desired requirement and perform the operations u require.
Back to top
View user's profile Send private message
kumar_ngl
Warnings : 1

New User


Joined: 05 Aug 2005
Posts: 50
Location: chennai

PostPosted: Tue Aug 09, 2005 10:45 am
Reply with quote

thanks Vijay..

kumar.p.v
Back to top
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Wed Aug 10, 2005 8:41 pm
Reply with quote

===
here is the examples....

===


ID DIVISION.
PROGRAM-ID. VSAMKSDS.
AUTHOR. JZ1B0C.
INSTALLATION. MY OWN COMPANY.
DATE-WRITTEN. 08/05/05.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT VSAMINP ASSIGN TO INPFILE
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS INPUT-KEY
FILE STATUS IS WS-VSAM-STAT.
SELECT SEQOUT ASSIGN TO OUTFILE.
DATA DIVISION.
FILE SECTION.
FD VSAMINP.
01 INPUT-REC.
05 INPUT-KEY PIC X(10).
05 FILLER PIC X(90).

FD SEQOUT.
01 OUTPUT-REC PIC X(100).

******************************************************************
* WORKING STORAGE *
******************************************************************

WORKING-STORAGE SECTION.
*
01 WS01-WORK-AREA.
05 WS-EXIT-SW PIC X(01) VALUE ' '.
88 EOF-IND-YES VALUE 'Y'.
88 EOF-IND-NO VALUE 'N'.
05 WS-EXIT-SW PIC X(01) VALUE ' '.
88 EXIT-SW-YES VALUE 'Y'.
88 EXIT-SW-NO VALUE 'N'.
05 WS-SUB1 PIC S9(03) COMP-3 VALUE 0.
05 WS-VSAM-STAT PIC X(02).
*
/*****************************************************************

LINKAGE SECTION.

******************************************************************
******************************************************************

PROCEDURE DIVISION.

******************************************************************
* FUNCTION: INITIALIZE PROGRAM *
* PROCESS INPUT UNTIL EOF *
* FINAL PROCESSING ACTIVITIES *
******************************************************************
*
PERFORM 1000-INITIALIZE
THRU 1000-EXIT.
*
PERFORM 2000-PROCESS-MAIN
THRU 2000-EXIT
UNTIL EOF-IND-YES OR EXIT-SW-YES.
*
PERFORM 9000-TERMINATE
THRU 9000-EXIT.
*
GOBACK.
*
1000-INITIALIZE.
*
OPEN INPUT VSAMINP.
IF WS-VSAM-STAT = SPACES OR ZEROES
OPEN OUTPUT SEQOUT
ELSE
DISPLAY 'ERROR IN OPENING VSAM INPUT FILE: ' WS-VSAM-STAT
SET EXIT-SW-YES TO TRUE
GO TO 1000-EXIT.
*
MOVE LOW-VALUES TO INPUT-KEY.
*
START VSAMINP KEY IS GREATER THAN INPUT-KEY.
IF WS-VSAM-STAT = SPACES OR ZEROES
CONTINUE
ELSE
DISPLAY 'ERROR IN STARTBR VSAM INPUT FILE: ' WS-VSAM-STAT
SET EXIT-SW-YES TO TRUE
GO TO 1000-EXIT.
*
PERFORM 2100-READ-VSAM THRU 2100-EXIT.
*
1000-EXIT.
EXIT.
*
2000-PROCESS-MAIN.
MOVE INPUT-REC TO OUTPUT-REC.
WRITE OUTPUT-REC.
PERFORM 2100-READ-VSAM THRU 2100-EXIT.

2000-EXIT.
EXIT.

2100-READ-VSAM.

READ VSAMINP NEXT
AT END
SET EOF-IND-YES TO TRUE
GO TO 2100-EXIT
END-READ.

IF WS-VSAM-STAT = SPACES OR ZEROES
CONTINUE
ELSE
DISPLAY 'ERROR IN READING VSAM INPUT FILE'
SET EOF-IND-YES TO TRUE
SET EXIT-SW-YES TO TRUE
GO TO 2100-EXIT.

2100-EXIT.
EXIT.

*
9000-TERMINATE.
******************************************************************
* FUNCTION: CLOSE FILES *
******************************************************************
*
CLOSE VSAMINP
IF WS-VSAM-STAT = SPACES OR ZEROES
CONTINUE
ELSE
DISPLAY 'ERROR IN READING VSAM INPUT FILE'.
CLOSE SEQOUT.
*
9000-EXIT.
EXIT.
*
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top