problem with aix



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

problem with aix

Postby Pumpkin » Sat May 14, 2011 8:41 am

hi,
i meet a problem with aix, i intend to read a ksds file through alternate key and print it out.
the compile is ok,and the run jcl as below:

//STER1 EXEC PGM=USEAIX
//STEPLIB DD DSN=userid.LIB.LOAD,DISP=SHR
//TRANS DD DSN=userid.TRANS.KSDS,DISP=SHR
[userid.TRANS.KSDS (it is cluster)]

when i ran this, rc=0, but file status code is 35,which means "then program attempted to open a nonexistent file in i-o,input,or extend mode" ,and no record display.
but i try this code,change to use primary key, the same jcl ,it works fine. pls help check the problem,.thanks!


INPUT-OUTPUT SECTION.                       
FILE-CONTROL.                               
    SELECT TRANS ASSIGN TO TRANS             
                 ORGANIZATION IS INDEXED     
                 ACCESS IS RANDOM           
                 RECORD  KEY IS ID-NUM1     
                 ALTERNATE KEY IS ID-NUM2   
                 WITH DUPLICATES             
                 FILE STATUS IS STATUS-FIELD.
                                             
DATA DIVISION.                               
                                             
FILE SECTION.                               
FD  TRANS                                   
    RECORD CONTAINS 80 CHARACTERS.           
01  TRANS-FILE.                             
    05 ID-NUM1 PIC XXX.                     
    05 ID-NUM2 PIC XX .                     
    05 OTHERS  PIC X(75).                   
                                             
WORKING-STORAGE SECTION.                     
01  STATUS-FIELD PIC XX.                     
01  FILE-RECORDS PIC X(80).                 
                                             
PROCEDURE DIVISION.                       
    OPEN INPUT TRANS.               
    DISPLAY STATUS-FIELD.           
    MOVE "12" TO  ID-NUM2.         
    READ TRANS INTO FILE-RECORDS   
       KEY IS ID-NUM2               
       INVALID KEY                 
           DISPLAY "KEY NOT FOUND".
    DISPLAY FILE-RECORDS.           
    CLOSE TRANS.                   
    STOP RUN.                       
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: problem with aix

Postby Robert Sample » Sat May 14, 2011 4:57 pm

Assuming you meant "alternate index" by the term "aix" in your post, and not AIX the IBM computer -- terminology is critical in IT since similar terms may mean very different things, and until you know the terms to use you should not be making up your own abbreviations -- your JCL is missing the alternate index access

//TRANS1 DD DISP=SHR,DSN=<alternate.index.path.name>
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: problem with aix

Postby Pumpkin » Sat May 14, 2011 6:17 pm

thanks! Mr.Sample.
i also have found the reference in the jcl book.
actually, i have read this before,but long time before now i really need to use it, so totally forgotten. :)
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: problem with aix

Postby BillyBoyo » Sun May 15, 2011 2:58 pm

Pumpkin, still no file-status checking I see.

Why don't you make a program with the file-status checking in, then see how many of the statuses you can cope with, with useful information, when you change the JCL (V instead of F, VSAM, no AIX, etc)? Then you'll know how to use them, and use them each time. Generally, we never "write" a program. We just copy a program which already has all the "boring" bits in (which work) and then add in the specific logic for the specific requirement we have this time. That way we do all the "right" things without having to actually code them each time (and introduce errors while coding them each time).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: problem with aix

Postby Pumpkin » Sun May 15, 2011 3:21 pm

hi, Billy
thanks for reply.
i use display file status code after the open, or other io statement. clearly, it is not the right way to check it.
i am not sure about this, is this the right way to use condition statement,something like below:
-----------------------------------------------------
01 file-status-fields.
05 newmast-file-status pic xx.
88 newmast-successful value "00".
.
.
write new-master-record .
if not newmast-successful
dislplay "file status code is " newmast-file-status
set all-records-processed to true.
-------------------------------------------------------------------------
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: problem with aix

Postby BillyBoyo » Sun May 15, 2011 3:37 pm

01  file-status-fields.
    05  newmast-file-status pic xx.
         88  newmast-successful value "00".
.
.
write new-master-record

if not newmast-successful
    dislplay "file status code is " newmast-file-status
    set all-records-processed to true
end-if
.


OK, starting to get there. For OPEN/CLOSE the name of the file and the status are going to be enough. For a write or read, some more information is useful. Like, if a keyed read/write, the key. If not keyed, all or the start of the record (for the write). For a sequential read, not much to go wrong (except after POINT, in which case, the key again like a keyed read).
File-status "10" is end-of-file. For a write for a file with an alternate index, "02" is duplicate keys on a file where they are allowed. Look up the statuses in the Cobol manual. Understand them all (ask if you don't) and practice trying to create some. Will give you clues as to what is best to display.

Did I ever tell you about ">" and "<" when you display? If I did, I won't tell you again. If I didn't, it is very useful to put these "around" each field you display so you can see not only the content but the displayable length. Any "spaces" or "dots" you see inside are really there. DISPLAY "Field A>" A "< Field B>" B "<". Something like that. It is a preference, but many times it has helped me. If it helps many times, it means is saved me a lot of time.

And try to use the CODE tags (grey oblong, says Code, above the entry form). Makes things look nicer for answering q's.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: problem with aix

Postby Robert Sample » Sun May 15, 2011 6:21 pm

Pumpkin: if you're using a VSAM file, both file status 00 and file status 97 are good codes for the OPEN statement. The 97 indicates the VSAM file was not properly closed but a VERIFY was automatically run on the file and it is now OK to use.
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: problem with aix

Postby BillyBoyo » Sun May 15, 2011 8:46 pm

Good point Robert. These codes are a "status" not an error-code, as I was trying to indicate with "10" and "02". Mostly the status is an error, but not always.

We used to treat non-zero as error on open where I've worked. Considered too problematic if we were then reading what might be a partially updated file.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: problem with aix

Postby Pumpkin » Mon May 16, 2011 10:52 am

thanks,Billy and Robert.
i am going to run some codes to practice the file status code, and

about ">" and "<" when you display


it is a useful and practical way to display,thanks.
-------------------
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