View previous topic :: View next topic
|
Author |
Message |
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi all,
Is there any way to insert a record into a VSAM file(KSDS).
Example:
file:
1 aaaa
2 dddd
5 cccc
Now i want to insert '3 eeee' after the record '2 dddd'.
Is this possible.If so ,how can i do it?
Please help me.
Regards,
Push. |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
yes it is possible
if your ksds file key is record number
you can access ksds file in random mode
the pass 3 into that key field.
write rec.
thanooz |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi thanooz,
Yes,the record numbers (1,2,5) in above example are
the key fields.
But i am getting "OUT OF SEQUENCE" error.
What can I do?
In what mode should I open the file? |
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
try the i-o mode or extend mode
any comments please.... |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi VM,
After your reply.I tried all the combinations.
But no result.
Then what the people are doing if such this has to be done.
I wonder? |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi all,
I could insert such values when i tried
with jcl(IDCAMS-REPRO).
But i couldnt do with cobol FILE operations normally.
So if we have to insert,we can just repro the content.
(But I think we should have created the VSAM with REUSE
option).
Correct me if I am wrong anywhere.
Thanks for members who helped me. |
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
The syntax would be
move value into key
read record
---
write_record. |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi
pushpagiri
your access mode is in random or dyanmic
you open your file in i-0 mode.
move 3 to key value
write record
thanooz |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Push,
Adding a rec to a VSAM file is trivial, but there can be a variety of reasons for why you're having trouble. Since you don't provide the pertinent code (select stmt, FD, open, R/W stmts), jcl, and IDCAMS data it's difficult to guess at the reason for the problem.
BTW, did you allocate freespace? And please confine your request to ONE thread. |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi,
this is the cobol prog i used :
(PLS SEE THE HIGHLIGHTED CODES)
INKSDS = FILE FOR INSERTING NEW RECORD.
INSEQ = FILE FROM WHERE INSERTING RECORDS ARE TAKEN FROM.
IDENTIFICATION DIVISION.
PROGRAM-ID. INSKSDS.
AUTHOR. PUSHPAGIRI.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INKSDS ASSIGN TO INVSAMF
ACCESS IS SEQUENTIAL
ORGANIZATION IS INDEXED
RECORD KEY IS SLNO
FILE STATUS IS FSTAT-VSAM.
SELECT INSEQ ASSIGN TO INSEQF
ACCESS IS SEQUENTIAL
ORGANIZATION IS SEQUENTIAL
FILE STATUS IS FSTAT-SEQ.
DATA DIVISION.
FILE SECTION.
FD INKSDS.
01 IN-KSDS-REC.
05 SLNO PIC X(1).
05 FILLER PIC X(1).
05 DATA1 PIC X(4).
05 FILLER PIC X(74).
FD INSEQ RECORDING MODE IS F.
01 IN-SEQ-REC.
05 IN-SEQ-SLNO PIC X(1).
05 FILLER PIC X(1).
05 IN-SEQ-DATA1 PIC X(4).
05 FILLER PIC X(74).
WORKING-STORAGE SECTION.
77 FSTAT-VSAM PIC X(2).
77 FSTAT-SEQ PIC X(2).
01 WS-FEOF.
05 WS-KSDS-FEOF PIC 9 VALUE 0.
05 WS-SEQ-FEOF PIC 9 VALUE 0.
05 LNK-ERROR-DATA PIC X(6).
PROCEDURE DIVISION.
MAINLINE-SECTION.
OPEN EXTEND INKSDS.
DISPLAY "OPEN STAT : " FSTAT-VSAM.
OPEN INPUT INSEQ.
MOVE 0 TO WS-SEQ-FEOF.
PERFORM READ-PROCESS UNTIL WS-SEQ-FEOF = 1.
CLOSE INSEQ.
CLOSE INKSDS.
STOP RUN.
READ-PROCESS.
READ INSEQ AT END MOVE 1 TO WS-SEQ-FEOF.
IF WS-SEQ-FEOF = 0 THEN
MOVE IN-SEQ-SLNO TO SLNO
MOVE IN-SEQ-DATA1 TO DATA1
WRITE IN-KSDS-REC
DISPLAY "WRITE STAT : " FSTAT-VSAM
END-IF. |
|
Back to top |
|
|
shobam
New User
Joined: 18 Jul 2005 Posts: 34 Location: CN
|
|
|
|
Sorry , If I am asking you a stupid question.
I think you are just copying the contents of the sequential file to the KSDS file. Where you are trying to INSERT the record "3 eeee" ?.
The file being copied to KSDS has to be in SORTED order.So the input sequential files should have the records in sorted order. If not you will get the OUT OF SEQUENCE error to my knowledge. |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
Hi Shobam,
The sequential file contains the record '3 eeee' (assume like this)
And if i have to insert that record into inksds file,what can i do?
Please give your suggestion. |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 418 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
heed thanooz advice on random and I/O
you are attempting to load file rather than insert.
Dave |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi pushp
you need to opemn your file in input and output mode
and access mode is random thn only you can solve that problem other wise you can't solve.
because in above your open a file in extend means it is appending records at end.if you want insert record in middle means it gives what you have mentioned that error becuse after 4 you want write 3 rd record means that is at end it gives out of seqence error. to solve that proble means first you write one record into the file then waht i have mentiond above you have to do like that only. |
|
Back to top |
|
|
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi
befor inserting record into vsam ksds you have to sort the input file then
apply what you have writen that cobol logic only inthis time never gives warnings.
thanooz |
|
Back to top |
|
|
saanjieev
New User
Joined: 25 Jul 2005 Posts: 4 Location: Mumbai, India
|
|
|
|
Hi Pushpagiri,
It helps to reply fast if we have precise information available. If you could provide all the inforamtion at first, it could save your time and efforts.
Well! simply, always check FILE CONTROL stmts for access mode, if you get problem in reading or writing a file. If it's right then OPEN mode can be in error. Already it has been suggested by thanooz and others.
Well! sequential access can be used for writing a KSDS only when we write in ascending order of key. So, it is required to have your input file SORTed. If you don't want to SORT input file, change the KSDS access mode to RANDOM. And as you want to write only, open mode OUTPUT is enough.
Reading a record and then updating the same record needs Input/Output OPEN mode. Or reading a record and writing another record in same KSDS needs Input/Output OPEN mode.
And it can help you a lot, if you collect the details of error message. |
|
Back to top |
|
|
pushpagiri
New User
Joined: 07 Jul 2005 Posts: 51
|
|
|
|
hi,
Finally my fault is in the access mode and open mode.
So in order to insert a record I have to
ACCESS in RANDOM mode
and OPEN in I-O mode.
Thankz to all who have helped me. |
|
Back to top |
|
|
praveendon
New User
Joined: 09 Jul 2005 Posts: 2
|
|
|
|
Can u please say How can a JOB be abended thru COBOL program.
Advance thanks for u r help
Bye
Praveen |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi praveendon,
The forum rules state that a new topic be generated for each new ques.
Press the "new topic" button below the text window and re-enter your ques. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Push,
Congratulations on getting an ans to your problem. On 7/21 you decribed your problem (see the quote)
Quote: |
But i am getting "OUT OF SEQUENCE" error.
What can I do?
In what mode should I open the file?
|
No luck until you sent your pgm code on 7/25. Seven hrs later you had your ans.
Point taken? (see below) |
|
Back to top |
|
|
|