copy ps file to vsam index file



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

copy ps file to vsam index file

Postby Pumpkin » Wed May 11, 2011 7:23 pm

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.
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: cory ps file to vsam index file

Postby BillyBoyo » Wed May 11, 2011 7:24 pm

Look up FILE STATUS in the Cobol manual.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: copy ps file to vsam index file

Postby Robert Sample » Wed May 11, 2011 7:29 pm

I suspect your OPEN failed and since you didn't check the file status on the open, you did not know that.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: copy ps file to vsam index file

Postby Pumpkin » Thu May 12, 2011 10:09 am

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 !
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy ps file to vsam index file

Postby BillyBoyo » Thu May 12, 2011 12:11 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: copy ps file to vsam index file

Postby Robert Sample » Thu May 12, 2011 2:44 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: copy ps file to vsam index file

Postby Pumpkin » Fri May 13, 2011 11:20 am

thanks for the advice!
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post