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

VSAM AIX read failing with return code 04


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kratos

New User


Joined: 02 Jul 2010
Posts: 5
Location: India

PostPosted: Wed Nov 17, 2010 4:03 pm
Reply with quote

Hi,

I am in the process of preparing myself for a VSAM related project set to take off by the year end. I have very little experience in VSAM and so spending some extra hours at office writing some simple VSAM codes. What I am trying now is to read a VSAM using the alternate index defined.
Code:


000100 ID DIVISION.                                                     
000200 PROGRAM-ID.   SPABC501.                                         
000600 DATE-WRITTEN. 11/17/2010.                                       
000700 DATE-COMPILED.                                                   
000100*---------------------------------------------------------------*
000110*---------------- PROGRAM DESCRIPTION --------------------------*
000120*---------------------------------------------------------------*
000220* PURPOSE & FLOW:                                               *
000230*   THIS BATCH PROGRAM IS WRITTEN TO SEE HOW KSDS FILE ACCESS   *
000240*   IS DONE                                                     *
000000*   THIS PROGRAM WILL READ KSDS FILE BASED ON THE AIX KEY (SSN) *
000000*   PROVIDED IN SYSIN AND DISPLAY THE RELATED INFORMATION       *
000410*---------------------------------------------------------------*
000420*---------------  PROGRAM MODIFICATION -------------------------*
000430*---------------------------------------------------------------*
000450* MOD-DATE PROGRAMMER  MOD DESCRIPTION                          *
000000* -------- ----------  -----------------------------------------*
000000* 20101117 XXXXXXX     INTIAL-VERSION                             
000550*---------------------------------------------------------------*
000000                                                                 
001100*---------------------------*                                     
001200 ENVIRONMENT DIVISION.                                           
001300*---------------------------*                                     
000000                                                                 
001400 CONFIGURATION SECTION.                                           
001500 INPUT-OUTPUT  SECTION.                                           
000000                                                                 
001600 FILE-CONTROL.                                                   
000000                                                                 
000000     SELECT EMP-SSN-FILE                                         
000000        ASSIGN TO ESALFILE                                       
000000        ORGANIZATION INDEXED                                     
000000        ACCESS MODE RANDOM                                       
000000        RECORD KEY ESSN-EMP-NBR                                   
000000        ALTERNATE KEY ESSN-EMP-SOCIALSECNBR                       
000000        FILE STATUS FS-ESSN.                                     
000000                                                                 
001700*---------------------------*                                     
001800 DATA DIVISION.                                                   
001900*---------------------------*                                     
001400                                                                 
001500 FILE SECTION.                                                   
001600                                                                 
000000 FD  EMP-SSN-FILE                                                 
000000     RECORD CONTAINS 80 CHARACTERS.                               
000000 01  ESSN-REC.                                                   
000000     05 ESSN-EMP-NBR             PIC  X(08).                     
000000     05 ESSN-EMP-NAME            PIC  X(40).                     
000000     05 ESSN-EMP-SOCIALSECNBR    PIC  X(12).                     
001700     05 ESSN-EMP-FILLER          PIC  X(20).                     
001800                                                                 
001400*---------------------------*                                     
001500 WORKING-STORAGE SECTION.                                         
001600*---------------------------*                                     
001800                                                                 
001400 01  WS-ESSN-FILE.                                               
000000     05 WS-ESSN-EMP-NBR          PIC  9(08).                     
000000     05 WS-ESSN-EMP-NAME         PIC  X(40).                     
000000     05 WS-ESSN-EMP-SOCIALSECNBR PIC  X(12).                     
000000     05 WS-ESSN-EMP-FILLER       PIC  X(20).                     
001500                                                                 
001400 01  WORKING-STORAGE-SECTION.                                     
000000     05 WS-CNT                   PIC S9(04) COMP.                 
000000     05 WS-SUB                   PIC S9(04) COMP.                 
000000     05 WS-MSG                   PIC  X(10).                     
000000     05 FS-ESSN                  PIC  9(02).                     
001500                                                                 
001400*---------------------*                                           
000000 PROCEDURE DIVISION.                                             
000000*---------------------*                                           
001500                                                                 
001800 0000-MAINLINE.                                                   
001900                                                                 
000000     PERFORM 1000-INITIALIZATION                                 
000000        THRU 1000-EXIT                                           
000000                                                                 
000000     PERFORM 2000-MAIN-PROCESS                                   
000000        THRU 2000-EXIT                                           
000000                                                                 
000000     PERFORM 3000-END-PROCESS                                     
000000        THRU 3000-EXIT                                           
000000                                                                 
000000     GOBACK.                                                     
000000/                                                                 
000000*------------------------------*                                 
000000 1000-INITIALIZATION.                                             
000000*------------------------------*                                 
000000                                                                 
000000     OPEN INPUT  EMP-SSN-FILE                                     
000000     IF FS-ESSN NOT EQUAL ZERO                                   
000000        DISPLAY 'FILE ERROR ON OPEN, STATUS -> ' FS-ESSN         
000000        PERFORM 9000-ABEND                                       
000000     END-IF                                                       
000000                                                                 
000000     INITIALIZE WS-ESSN-FILE                                     
000000                                                                 
000000     MOVE ZEROES              TO WS-CNT                           
000000                                 WS-SUB                           
000000     .                                                           
000000                                                                 
000000 1000-EXIT.                                                       
000000     EXIT.                                                       
000000/                                                                 
000000*------------------------------*                                 
000000 2000-MAIN-PROCESS.                                               
000000*------------------------------*                                 
000000                                                                 
000000     ACCEPT WS-ESSN-EMP-SOCIALSECNBR                             
000000                                                                 
000000     MOVE WS-ESSN-EMP-SOCIALSECNBR                               
000000                              TO ESSN-EMP-SOCIALSECNBR           
000000                                                                 
000000     READ  EMP-SSN-FILE KEY IS ESSN-EMP-SOCIALSECNBR             
000000     IF FS-ESSN NOT EQUAL ZERO                                   
000000        DISPLAY 'FILE ERROR ON READ, STATUS -> ' FS-ESSN         
000000        PERFORM 9000-ABEND                                       
000000     ELSE                                                         
000000        DISPLAY ESSN-REC                                         
000000     END-IF                                                       
000000     .                                                           
000000                                                                 
000000 2000-EXIT.                                                       
000000     EXIT.                                                       
000000/                                                                 
000000*------------------------------*                                 
000000 3000-END-PROCESS.                                               
000000*------------------------------*                                 
000000                                                                 
000000     CLOSE EMP-SSN-FILE                                           
000000                                                                 
000000     DISPLAY 'PROGRAM RUN SUCCESSFULLY'                           
000000     DISPLAY 'BYE-BYE'                                           
000000     .                                                           
000000                                                                 
000000 3000-EXIT.                                                       
000000     EXIT.                                                       
000000/                                                                 
000000*------------------------------*                                 
000000 9000-ABEND.                                                     
000000*------------------------------*                                 
000000                                                                 
000000     DISPLAY 'SPABC501 HAS ABENDED'                               
000000     DISPLAY 'BYE-BYE'                                           
000000     GOBACK                                                       
000000     .                                                           


JCL for the above program:
Code:

//SPAJC501 JOB (001),'BATCH RUN JCL',                                   
//             CLASS=A,MSGLEVEL=(1,1),MSGCLASS=A                       
//******************************************************************** 
//*SPABC500 TEST JCL                                                 * 
//******************************************************************** 
//* MODIFICATION LOG                                                 * 
//******************************************************************** 
//* 11/17/2010 XXXXXXX        INTIAL CREATION                        * 
//******************************************************************** 
//STEP010    EXEC PGM=SPABC501                                         
//STEPLIB     DD  DSN=A0.PCT.USER.BTCHLOAD,                             
//            DISP=SHR                                                 
//SYSIN       DD  *                                                     
103456089764                                                           
//SYSPRINT    DD  SYSOUT=*                                             
//ESALFILE    DD  DSN=T0.PCT.EMPL.SSN,                                 
//            DISP=SHR                                                 
//ESALFIL1    DD  DSN=T0.PCT.EMPL.SSN.AIX01,                           
//            DISP=SHR                           


Sysout:
Code:

FILE ERROR ON READ, STATUS -> 04                                               
SPABC501 HAS ABENDED                                                           
BYE-BYE                                                                         


vsam cluster definition
Code:


//STEP010    EXEC PGM=IDCAMS                                           
//SYSPRINT    DD  SYSOUT=*                                             
//SYSIN       DD *                                                     
  DEFINE      CLUSTER  (NAME(T0.PCT.EMPL.SSN)                -         
                        TRACKS (45 15)                       -         
                        RECORDSIZE (80 80)                   -         
                        FREESPACE (10 15)                    -         
                        KEYS (8 0)                           -         
                        INDEXED)                             -         
              DATA     (NAME (T0.PCT.EMPL.SSN.DATA)          -         
                        CISZ (8192)                          -         
                        VOLUMES (USR0AA))                    -         
              INDEX    (NAME (T0.PCT.EMPL.SSN.IDX)           -         
                        VOLUMES (TFD8D6))                               


aix definition:
Code:


//STEP010    EXEC PGM=IDCAMS                                   
//SYSPRINT    DD  SYSOUT=*                                     
//SYSIN       DD *                                             
  DEFINE      AIX      (NAME(T0.PCT.EMPL.SSN.AIX01)          -
                        VOLUMES(TFD8D6)                      -
                        RELATE(T0.PCT.EMPL.SSN)              -
                        UPGRADE                              -
                        TRACKS(10 1)                         -
                        KEYS(12 48)                          -
                        FREESPACE(20 10)                     -
                        SHAREOPTIONS(1)                      -
                        UNIQUEKEY)                           -
              DATA     (NAME(T0.PCT.EMPL.SSN.AIX01.DT))      -
              INDEX    (NAME(T0.PCT.EMPL.SSN.AIX01.IX))       



Not sure what I am missing out icon_redface.gif , ofcourse I have never tried this before either, so not sure what to try next. For now all I can think of is to get the VSAM file status also and see if that helps.
By the way I am able to read this file using the primary index (in another program) by changing nothing but the READ statement (and accepting a value for the emp number). So I am guessing something extra/different is needed for AIX read.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Nov 17, 2010 4:47 pm
Reply with quote

If you have not done so, you need to define a PATH for the AIX. Your JCL must have ESALFIL1 pointing to the PATH, not the AIX.
Back to top
View user's profile Send private message
kratos

New User


Joined: 02 Jul 2010
Posts: 5
Location: India

PostPosted: Wed Nov 17, 2010 10:54 pm
Reply with quote

Thanks, thats what I was doing wrong icon_sad.gif

Had defined the path, but was using the aix in JCL. Next I am planning to do sequential read using AIX, hope that goes well.

Tk,GB
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
Search our Forums:

Back to Top