View previous topic :: View next topic
|
Author |
Message |
Nirav721
New User
Joined: 11 Feb 2008 Posts: 53 Location: NJ
|
|
|
|
Hi,
I am having an issue rewriting a record to VSAM file from a variable block sequential file. My vsam file can have up to 5000 byte record.
Here is the scenario:
I am reading in a 800 byte record from variable block sequential file. Then, I read a vsam record with the key I need to replace (record will always be present). Then I overlay my vsam record area with my sequential file area for the length of the sequential record I just read in, and then perform rewrite. This works, but I end up with X'40' after 800 bytes... 801-5000 bytes contain X'40'.
Is there an option I am missing?
My VSAM def. is:
Code: |
SELECT INVSAM-FILE
********************************************
ASSIGN TO INVSAM
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS ID-NO
FILE STATUS IS F-STAT, VSAM-STATUS. |
Code: |
FD INVSAM-FILE
DATA RECORD IS INVSAM-REC. |
My sequential def. is:
Code: |
FD INREC
RECORDING MODE IS V
RECORD IS VARYING FROM 1 TO 4996 DEPENDING ON REC-LENGTH
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
DATA RECORD IS INREC-REC.
|
My move statement is:
Code: |
MOVE INREC-REC(1:REC-LENGTH) TO INVSAM-REC
REWRITE INVSAM-REC |
Any help would be great!
Thanks! |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
This is important, how are the 01 and lower levels of the FDs defined? For both input and output....
Please post them. |
|
Back to top |
|
|
Nirav721
New User
Joined: 11 Feb 2008 Posts: 53 Location: NJ
|
|
|
|
Thank you for looking into this...
Sequential file layout:
Code: |
01 INREC-REC.
05 INREC-KEY.
10 VSAM-KEY PIC X(8).
10 VSAM-INDEX PIC X(6).
05 INREC-REST.
10 REM-RECORD PIC X(4982).
05 INCMR-SEQ REDEFINES INREC-REST.
10 FILLER PIC X(49).
10 SEQ-KEY PIC X(8).
10 FILLER PIC X(4925). |
INVSAM-REC def...
Code: |
01 INVSAM-REC.
05 ID-NO.
10 KEY-recNO PIC X(8).
10 KEY-INDEX PIC X(6).
05 ID-K REDEFINES ID-NO.
10 KEY-K PIC X(14).
05 ID-DISPLAY-KEY REDEFINES ID-NO.
10 TERM-DIGIT PIC X(4).
10 FRNT-DIGIT PIC X(4).
10 FILLER PIC X(6).
05 KEY-O PIC X(4982). |
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Nirav721 wrote: |
Code: |
01 INREC-REC.
05 INREC-KEY.
10 VSAM-KEY PIC X(8).
10 VSAM-INDEX PIC X(6).
05 INREC-REST.
10 REM-RECORD PIC X(4982).
05 INCMR-SEQ REDEFINES INREC-REST.
10 FILLER PIC X(49).
10 SEQ-KEY PIC X(8).
10 FILLER PIC X(4925). |
|
Where is the 'variableness' of this?
Quote: |
Code: |
01 INVSAM-REC.
05 ID-NO.
10 KEY-recNO PIC X(8).
10 KEY-INDEX PIC X(6).
05 ID-K REDEFINES ID-NO.
10 KEY-K PIC X(14).
05 ID-DISPLAY-KEY REDEFINES ID-NO.
10 TERM-DIGIT PIC X(4).
10 FRNT-DIGIT PIC X(4).
10 FILLER PIC X(6).
05 KEY-O PIC X(4982). |
|
And where is the 'variableness' of this?
How do you know what the actual length of the input is and how do you specify the length of the output? |
|
Back to top |
|
|
Nirav721
New User
Joined: 11 Feb 2008 Posts: 53 Location: NJ
|
|
|
|
Thanks...I was under the impression VSAM calcs length on its own based on input specified? For the sequential, it is based on FD definition - REC-LENGTH.... which is what I am using to move data into VSAM...
Doesn't VSAM use RDF (sorry, don't remember it exactly) and not the first four bytes?? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How about RDW (record Descriptor Word). There should be no rdw for a Fixed length file. . .
The short move to the long field causes the trailing spaces, but the re-write is the length of the vsam data. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Nirav721 wrote: |
Code: |
FD INVSAM-FILE
DATA RECORD IS INVSAM-REC.
01 INVSAM-REC.
05 ID-NO.
10 KEY-recNO PIC X(8).
10 KEY-INDEX PIC X(6).
05 ID-K REDEFINES ID-NO.
10 KEY-K PIC X(14).
05 ID-DISPLAY-KEY REDEFINES ID-NO.
10 TERM-DIGIT PIC X(4).
10 FRNT-DIGIT PIC X(4).
10 FILLER PIC X(6).
05 KEY-O PIC X(4982). |
My sequential def. is:
Code: |
FD INREC
RECORDING MODE IS V
RECORD IS VARYING FROM 1 TO 4996 DEPENDING ON REC-LENGTH
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
DATA RECORD IS INREC-REC.
01 INREC-REC.
05 INREC-KEY.
10 VSAM-KEY PIC X(8).
10 VSAM-INDEX PIC X(6).
05 INREC-REST.
10 REM-RECORD PIC X(4982).
05 INCMR-SEQ REDEFINES INREC-REST.
10 FILLER PIC X(49).
10 SEQ-KEY PIC X(8).
10 FILLER PIC X(4925). |
My move statement is:
Code: |
MOVE INREC-REC(1:REC-LENGTH) TO INVSAM-REC
REWRITE INVSAM-REC |
|
How about an additional 01 for the output?
Code: |
FD INVSAM-FILE
RECORDING MODE IS V .
01 INVSAM-REC.
05 ID-NO.
10 KEY-recNO PIC X(8).
10 KEY-INDEX PIC X(6).
05 ID-K REDEFINES ID-NO.
10 KEY-K PIC X(14).
05 ID-DISPLAY-KEY REDEFINES ID-NO.
10 TERM-DIGIT PIC X(4).
10 FRNT-DIGIT PIC X(4).
10 FILLER PIC X(6).
05 KEY-O PIC X(4982).
01 INVSAM-VAR-REC PIC X OCCURS 1 TO 4996 DEPENDING ON REC-LENGTH. |
Code: |
(possiblely)
MOVE REC-LENGTH TO REC-LENGTH
(an old hold back....grin.....)
MOVE INREC-REC(1:REC-LENGTH) TO INVSAM-REC.
or
MOVE INREC-REC(1:REC-LENGTH) TO INVSAM-VAR-REC.
or
MOVE INREC-REC TO INVSAM-REC.
or
MOVE INREC-REC TO INVSAM-VAR-REC.
But this one is important....
REWRITE INVSAM-VAR-REC |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
So your VSAM file FD has one 01 fixed with 5000 bytes. Your VSAM FD does not have RECORD VARYING. Therefore, your program is telling VSAM to write 5000 bytes each and every time. You can:
1. Use OCCURS DEPENDING ON in the 01 for the VSAM FD.
2. Use multiple 01's in the VSAM FD, one have 800 bytes and one having 5000 bytes (more could be used if needed), then REWRITE the appropriate 01 level.
3. Add RECORD VARYING to the VSAM FD and set that variable to the correct length before attempting to do the write.
But as your code is constituted, you are not writing a variable length record -- you are writing a fixed length 5000 byte record. |
|
Back to top |
|
|
Nirav721
New User
Joined: 11 Feb 2008 Posts: 53 Location: NJ
|
|
|
|
Thank you everyone for your support. Using 'depending on' and adding one more '01' level to FD, I was able to get what I want!
Much appreciated! As you can probably tell..I am fairly new to cobol vsam programming world and sorry if it made anyone think 'what a wash this guy is!' :-) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
Quote: |
sorry if it made anyone think 'what a wash this guy is!' |
Not to worry
Good to hear your question is answered - thanks for letting us know.
When there are other "opportunities", someone will be here,
d |
|
Back to top |
|
|
|