View previous topic :: View next topic
|
Author |
Message |
dalib123
New User
Joined: 14 Oct 2008 Posts: 7 Location: india
|
|
|
|
Please suggest a suitable method to read a VSAM KSDS file using partial key.
The key is of 40 bytes, and I have only data upto 7 byes.
with the help of this 7 byte I have to read the data(from 40 byte key file).
thanks |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
What does it say in the manuals, and what have you tried yourself and what errors did you receive. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Which language? CICS or batch? Can we assume the 7 bytes you have are the first 7 bytes of the key? What research have you done already? What isn't working that you need help with? |
|
Back to top |
|
|
dalib123
New User
Joined: 14 Oct 2008 Posts: 7 Location: india
|
|
|
|
hi robert
It is batch one and it is first 7 bytes of the key(40 bytes)
of the key7 bytes |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Use COBOL, move the 7 bytes to the key field, and do a START KEY GE then do READ NEXT. You'll need to check the key returned against your 7 bytes since START KEY GE may return a record with a different key if there's none that have the same first 7 bytes in the file. Since you're looking at just a piece of the key, be aware there could be multiple records in the file with the same first 7 bytes and code for the possibility. |
|
Back to top |
|
|
dalib123
New User
Joined: 14 Oct 2008 Posts: 7 Location: india
|
|
|
|
file structure for file BCA is
01 SVMBCA-BUS-CAT-ACTIVITY-RECORD.
03 BCA-KEY1.
05 BCA-LFI PIC X(1).
05 BCA-SUB-NO PIC X(7).
05 BCA-KEY2.
07 BCA-A-LFI PIC X(1).
07 BCA-BUS-CAT PIC X(2).
03 BCA-PERCENT PIC 9(3).
03 BCA-D-CR PIC 9(7) COMP-3.
03 BCA-D-UPD PIC 9(7) COMP-3.
03 BCA-UPD-SEQ PIC 9(3) COMP-3.
03 FILLER PIC X(11).
For read this with partial key
ZB-READ-BCA-FILE SECTION.
ZB000-ENTRY.
MOVE SUB-LFI TO BCA-LFI.
MOVE SUB-SUB-NO TO BCA-SUB-NO.
START BCA-FILE KEY IS GREATER OR EQUAL BCA-KEY1.
READ BCA-FILE
AT END SET WF-BCA-FILE-END TO TRUE
NOT AT END ADD +1 TO WW-BCA-READ
END-READ.
DISPLAY "BCA" ,SVMBCA-BUS-CAT-ACTIVITY-RECORD.
its displaying only value passed through SUB-LFI and BCA-SUB-NO only
not the whole record. |
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
From the code it seems that that Key length(key1 + key2) is 14 bytes & remaining 26 bytes is the value you are retreiving.
Can you try again just before START, give Low values to the remaning portion of the key BCA-KEY2? This should position the pointer where you want.
Also, Are you trying to read all records which are having 1st seven bytes of key value as what you have? If so then just a suggestion, AIX will be a good option. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You do a READ but don't say that SVMBCA-BUS-CAT-ACTIVITY-RECORD is the 01 in the FD; if this structure is in WORKING-STORAGE it will only reflect what you moved into it unless you do a READ INTO SVMBCA-BUS-CAT-ACTIVITY-RECORD.
aakar: note the level numbers. The key is all of the fields provided (plus a few more, I assume since the provided values only add up to 35 bytes). Also, AIX is overkill in this case -- START KEY IS GE will work fine for the first 7 bytes of the primary key. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Also, I would initialize the BCA-KEY2 value to LOW-VALUES since you otherwise do not know what the values in this part of the key are being set to (possibly already set to LOW-VALUES depending on LE storage settings, but possibly not). You very well could wind up not returning a key record due to the BCA-KEY2 fields being not matched even though the first two fields had matches. |
|
Back to top |
|
|
|