Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

accessing the VSAM record using COBOL pgm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: accessing the VSAM record using COBOL pgm
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Re: accessing the VSAM record using COBOL pgm
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    Post subject: Hi
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    Post subject: Re: accessing the VSAM record using COBOL pgm
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts Underlying DB2 VSAM LDS - SMF recording vasanthz All Other Mainframe Topics 6 Thu Jan 05, 2017 4:20 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us