Page 1 of 1

copy ps file to vsam index file

PostPosted: Wed May 11, 2011 7:23 pm
by Pumpkin
hi,
i try to use cobol read a ps file and write all the records to a VSAM indexed file. the cobol code compile is ok ,but when i use jcl to run it ,it cause abendu4038,as follow:

"IGZ0020S A logic error occurred. Neither FILE STATUS nor a declarative was spe FILE STATUS nor a declarative was specified for file OUTFILE in program
TEST012 at relative location X'05BE'. The status code was 48."

and my jcl is : (2 files already exits)
STER1 EXEC PGM=TEST012
STEPLIB DD DSN=userid.LIB.LOAD,DISP=SHR
OUTFILE DD DSN=userid.NEWFILE.KSDS,DISP=SHR
INFILE DD DSN=userid.NEWFILE,DISP=SHR

FILE-CONTROL.                               
      SELECT INFILE  ASSIGN TO INFILE.       
      SELECT OUTFILE ASSIGN TO OUTFILE       
                     ORGANIZATION IS INDEXED
                     ACCESS IS SEQUENTIAL   
                     RECORD KEY IS ID-NUM.   
*                                           
 DATA DIVISION.                             
 FILE SECTION.                               
*                                           
 FD  INFILE.                                 
 01  IN-FILE PIC X(80).                     
*                                           
 FD  OUTFILE.                               
 01  OUT-FILE.                               
     05 ID-NUM PIC X(3).                     
     05 FILLER PIC X(77).                   
*                                           
 WORKING-STORAGE SECTION.                   
 01  FILE-EOF-SWITCH PIC X VALUE "N".       
     88 FILE-EOF           VALUE "Y".       
 01  FILE-RECORDS PIC X(80).                 
*                                           
 PROCEDURE DIVISION.                 
*                                     
 000-CREATE-KSDS.                     
     OPEN INPUT INFILE               
              OUTPUT OUTFILE.             
     PERFORM 100-READ-RECORDS         
              UNTIL FILE-EOF.             
     CLOSE INFILE                     
                OUTFILE.                   
     STOP RUN.                       
 100-READ-RECORDS.                   
     READ  INFILE INTO FILE-RECORDS   
       AT END                         
           SET FILE-EOF TO TRUE.     
     IF NOT FILE-EOF                 
     WRITE OUT-FILE FROM FILE-RECORDS.

Re: cory ps file to vsam index file

PostPosted: Wed May 11, 2011 7:24 pm
by BillyBoyo
Look up FILE STATUS in the Cobol manual.

Re: copy ps file to vsam index file

PostPosted: Wed May 11, 2011 7:29 pm
by Robert Sample
I suspect your OPEN failed and since you didn't check the file status on the open, you did not know that.

Re: copy ps file to vsam index file

PostPosted: Thu May 12, 2011 10:09 am
by Pumpkin
i thought the code is short,so i didn't include the file status clause.
and i just add the file status clause to check the open and close, the code for open is 37,and 42 for close. i guess it must be problem with my ksds file ,so i delete it ,and recreate it, run the cobol code again ,it works.
althought i cann't figure out why my first ksds file can be opened, but i know i should include the file status clause with io all the time.
thanks !

Re: copy ps file to vsam index file

PostPosted: Thu May 12, 2011 12:11 pm
by BillyBoyo
Pumpkin wrote:i thought the code is short,so i didn't include the file status clause.
and i just add the file status clause to check the open and close, the code for open is 37,and 42 for close. i guess it must be problem with my ksds file ,so i delete it ,and recreate it, run the cobol code again ,it works.
althought i cann't figure out why my first ksds file can be opened, but i know i should include the file status clause with io all the time.
thanks !



You should check the file status of all file accesses, every time. Abend when you get something unexpected, with useful message/information.

It is always better to know exactly why something didn't work, rather than just try something and hope for the best. Now you'll never know why you got those codes. Look them up in the Cobol manual anyway, so you are aware of the sort of stuff it can tell you in the file status.

Re: copy ps file to vsam index file

PostPosted: Thu May 12, 2011 2:44 pm
by Robert Sample
i thought the code is short,so i didn't include the file status clause.
A professional programmer knows to include all possible aides, such as file status clauses, no matter how short -- or long -- the program is. You have to expect your program to fail -- then you'll be prepared to fix it when it does.

Back in my college days, one of my professors quoted a study that found the best chance of making a correct change to a program was when 5 lines were changed. And the chances of success were just over 20%. So a programmer has less than a one in four chance of successfully making a 5-line change; all other changes have lower chances of success.

Re: copy ps file to vsam index file

PostPosted: Fri May 13, 2011 11:20 am
by Pumpkin
thanks for the advice!