Want to access a VSAM file through COBOL program



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

Want to access a VSAM file through COBOL program

Postby marun » Mon Jun 23, 2008 10:43 am

Hi all,

I just want to access a VSAM file through COBOL program.The problem is i am not aware of the key :(.
The account number(CUST-ACCT)is known but it is not unique.
A field is set as Index for the VSAM file. This value is unique (but not maintained as key but only as index). I know only the partial value of this field. Is it possible to fetch a record only by knowing the partial value of the indexed field.
How do we give the File Control section with this Index and the corresponding read statement.


This is the VSAM file layout;

01 VSAM-UHF-RECORD.
05 VSAM-KEY.
10 VSAM-CYCLE-NUM PIC 9(5).
10 VSAM-BATCH-NUM PIC 9(3).
10 VSAM-BATCH-REC-NUM PIC 9(9).
10 FILLER PIC X(10).
05 NON-VSAM-KEY.
10 LOCAL-REJECT-CODE PIC X(2).
10 TRANSACTION-STATUS PIC X(4).
10 SO-NUMBER.
15 CK-DIGIT PIC X(1).
15 ORDER-TYPE PIC X(1).
15 BO-CODE PIC X(2).
15 DIG-NUMBER PIC X(5).
10 NEW-NON-ADDRESS-LINES PIC X(1).
10 FILLER PIC X(19).
05 NON-VSAM-KEY.
10 LOCAL-REJECT-CODE PIC X(2).
10 TRANSACTION-STATUS PIC X(4).
10 SO-NUMBER.
15 CK-DIGIT PIC X(1).
15 ORDER-TYPE PIC X(1).
15 BO-CODE PIC X(2).
15 DIG-NUMBER PIC X(5).
10 NEW-NON-ADDRESS-LINES PIC X(1).
10 FILLER PIC X(19).
05 UPDT-REJ-REC-IMAG.
10 CUST-ACCT PIC X(20).
10 ADDR-TYPE PIC X(1).
10 REG-PROVD-ID PIC X(2).
10 STANDARD-DIV-CODE PIC X(1).
10 RAO PIC X(3).
10 ADDR-UPDT-CODE PIC X(1).
10 EFFECTIVE-DATE PIC X(8).
10 ADDR-CLEANSING-DATE PIC X(8).
10 OLD-MAIL-NAME1 PIC X(30).
10 OLD-MAIL-NAME1-OFL PIC X(30).
10 OLD-NAME-ADDR2 PIC X(30).
10 OLD-NAME-ADDR2-OFL PIC X(30).
10 OLD-NAME-ADDR3 PIC X(30).
10 OLD-NAME-ADDR3-OFL PIC X(30).
10 OLD-MAIL-ADDR4 PIC X(30).
10 OLD-MAIL-ADDR4-OFL PIC X(30).
10 OLD-PO PIC X(30).
10 OLD-PO-OFL PIC X(30).
10 OLD-NON-ADDR-LINES PIC X(1).
10 OLD-CITY PIC X(28).
10 OLD-CITY-OFL PIC X(23).
10 OLD-STATE PIC X(2).
10 OLD-ZIP5 PIC X(5).
10 OLD-PLUS4 PIC X(4).
10 OLD-FORGN-ADDR-IND PIC X(1).
10 OLD-COUNTRY PIC X(20).
10 NEW-MAIL-NAME1 PIC X(30).
10 NEW-MAIL-NAME1-OFL PIC X(30).
10 NEW-NAME-ADDR2 PIC X(30).
10 NEW-NAME-ADDR3 PIC X(30).
10 NEW-ADDR4 PIC X(30).
10 NEW-PO PIC X(30).
10 NEW-NON-ADDR-LINES PIC X(1).
10 NEW-CITY PIC X(28).
10 NEW-STATE PIC X(2).
10 NEW-ZIP5 PIC X(5).
10 NEW-PLUS4 PIC X(4).
10 NEW-FORGN-ADDR-IND PIC X(1).
10 NEW-COUNTRY PIC X(20).
10 BYPASS-COMP-LOGIC PIC X(1).
10 RESPONSIBLE-PARTY PIC X(6).
10 UPDATE-CATEGORY PIC X(1).
10 UPDATE-REASON PIC X(37).
10 VSAM-REJECT-REASON-CODE PIC X(1).
10 ADDRESS-CODE PIC X(2).
10 CASS-STATUS-CD PIC X(6).
10 FILLER PIC X(402).

The key field is VSAM-KEY. The index is SO-NUMBER. The value for only DIG-NUMBER is known. Finally I need to fetch the NEW-PO value. Is it possible... kindly clarify


Thanks in advance,
Marun
marun
 
Posts: 8
Joined: Fri Jun 20, 2008 9:59 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM ACCESS DOUBT!!!!

Postby dick scherrer » Mon Jun 23, 2008 12:00 pm

Hello,

You can read the file from beginning to end to get what you want. You cannot get it directly.

I do not understand the multiple entries for NON-VSAM-KEY. . .

You could consider adding a new alternate index for the DIG-NUMBER.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: VSAM ACCESS DOUBT!!!!

Postby marun » Mon Jun 23, 2008 4:01 pm

Hi,

Can u just lemme know whether the syntax below is rite?

FILE-CONTROL.
SELECT INPUT-VSAM-UHFFILE
ASSIGN TO UT-S-VSAMUHF
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD KEY IS VSAM-KEY
ALTERNATE RECORD KEY IS WS-REQ-SO-NUM WITH DUPLICATES
FILE STATUS IS FILE-STATUS.
.
.
.

P35231-READ-VSAMUHF-FILE.

//*WS-FINAL-UPDSO====VALUE TO BE SEARCHED.

MOVE WS-FINAL-UPDSO TO WS-REQ-SO-NUM
READ INPUT-VSAM-UHFFILE
KEY IS WS-REQ-SO-NUM
AT END
MOVE ‘Y’ TO WS-UHF-EOF
GO TO P35231-READ-VSAMUHF-FILE-X.
MOVE NEW-PO TO WS-ERMI-NEW-PO.
marun
 
Posts: 8
Joined: Fri Jun 20, 2008 9:59 am
Has thanked: 0 time
Been thanked: 0 time

Re: VSAM ACCESS DOUBT!!!!

Postby dick scherrer » Mon Jun 23, 2008 11:52 pm

Hello,

Can u just lemme know whether the syntax below is rite?
No, it is not.

Please re-read my earlier reply and write your code that way or add another alternate index so the record(s) can be retrieved randomly rather than sequentially.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post