| View previous topic :: View next topic |
| Author |
Message |
Paul1983
Joined: 08 Jul 2008
Posts: 33
Location: bangy
|
| Posted: Wed Aug 20, 2008 5:07 pm Post subject: Rewrite a variable length file |
|
|
Hi,
Could you please let me know whether it is possible to rewrite a variable length file? I'm getting a FILE STATUS 39.
Thanks,
Paul |
|
| Back to top |
|
Robert Sample
Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA
|
| Posted: Wed Aug 20, 2008 5:23 pm Post subject: |
|
|
Yes, it is possible to rewrite a variable length file.
I thought 39 file status meant the OPEN failed, not the REWRITE. |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1639
Location: germany
|
| Posted: Wed Aug 20, 2008 5:48 pm Post subject: |
|
|
| as Robert indicated, your file-status error had nothing to do with the REWRITE instruction. Your DCB parms in JCL did not match your FD Select and File definitions. |
|
| Back to top |
|
Paul1983
Joined: 08 Jul 2008
Posts: 33
Location: bangy
|
| Posted: Wed Aug 20, 2008 5:50 pm Post subject: |
|
|
i want to rewrite the input file itself.So there is no DCB parms involved
Thanks,
Paul |
|
| Back to top |
|
Anuj D.
Joined: 22 Apr 2006
Posts: 2229
Location: Phoenix, AZ
|
| Posted: Wed Aug 20, 2008 5:56 pm Post subject: |
|
|
| Paul1983 wrote: i want to rewrite the input file itself.So there is no DCB parms involved Locate your file via ISPF 3.4, check for the RECFM there in Data Set Information, then check whether it is in sync with the FD entries of this file in your program.. |
|
| Back to top |
|
Robert Sample
Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA
|
| Posted: Wed Aug 20, 2008 5:57 pm Post subject: |
|
|
| Paul: who said anything about DCB parms -- besides, VSAM files use ACB parms not DCB parms? If the OPEN fails, the REWRITE isn't going to work no matter what you do. File status 39 means something doesn't match between your COBOL file definition and the actual physical file. For example: your COBOL program may have variable length records in the FD but the VSAM file is defined with RECORDSIZE (X X) which means it is NOT variable length. This could cause a 39 file status. |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1639
Location: germany
|
| Posted: Wed Aug 20, 2008 6:01 pm Post subject: |
|
|
Here, maybe this is easier to understand:
Your FD Select and File definitions do not match physical attributes of your 'existing file'.
To quote from our own Sherlock Holmes:
there is a difference between persistant and thick-headed. |
|
| Back to top |
|
Paul1983
Joined: 08 Jul 2008
Posts: 33
Location: bangy
|
| Posted: Wed Aug 20, 2008 6:10 pm Post subject: |
|
|
My file attributes are as follows
Record format . . . : VB
Record length . . . : 23472
Block size . . . . : 23476
in the FD section i declared it as
FD POL-CURR
BLOCK 0
RECORDING V
LABEL RECORDS STANDARD.
01 POL-CURR-REC PIC X(23472).
Is this correct?
Thanks,
Paul |
|
| Back to top |
|
Anuj D.
Joined: 22 Apr 2006
Posts: 2229
Location: Phoenix, AZ
|
| Posted: Wed Aug 20, 2008 6:52 pm Post subject: |
|
|
Hi,
Syntactically it looks correct, probably we are missing something which is not posted yet. Please post the SYSOUT of failed JOB & all the FD entries from your program (unless there are a lots of files).
Please use BBcode when posting SYSOUT & FD. |
|
| Back to top |
|
dbzTHEdinosauer
Joined: 20 Oct 2006
Posts: 1639
Location: germany
|
| Posted: Wed Aug 20, 2008 7:40 pm Post subject: |
|
|
01 POL-CURR-REC PIC X(23472).
I think this should be:
01 POL-CURR-REC PIC X(23468). |
|
| Back to top |
|
Bill O'Boyle
Joined: 14 Jan 2008
Posts: 345
Location: Orlando, FL, USA
|
| Posted: Wed Aug 20, 2008 7:52 pm Post subject: Re: Rewrite a variable length file |
|
|
Experiment with the following -
Code:
FD POL-CURR
BLOCK 0
RECORDING V
RECORD CONTAINS XXXXX TO 23472 CHARACTERS
DEPENDING ON WS-IN-LGTH
LABEL RECORDS STANDARD.
01 POL-CURR-REC PIC X(23472).
WORKING-STORAGE SECTION.
03 WS-IN-LGTH PIC 9(08) BINARY.
Change the XXXXX to the minimum record length with 23472 being the maximum.
After a READ, field WS-IN-LGTH will contain the actual length of the record just read. Note that this field's picture clause must be unsigned, with my preference being a binary-fullword, but display-numeric and packed-decimal can also be used.
If you are writing the record to another file, the same applies. Substitute with a field named WS-OUT-LGTH and populate this field with the actual record-length prior to the WRITE.
Note that this was introduced with COBOL2 4.0, many years ago.
HTH....
Bill |
|
| Back to top |
|
Robert Sample
Joined: 06 Jun 2008
Posts: 943
Location: Atlanta, GA
|
| Posted: Wed Aug 20, 2008 8:03 pm Post subject: |
|
|
From the LR manual: Quote: 6.2.31.4 Sequential files
For files in the sequential access mode, the last prior input/output statement executed for this file must be a successfully executed READ statement. When the REWRITE statement is executed, the record retrieved by that READ statement is logically replaced.
The number of character positions in record-name-1 must equal the number of character positions in the record being replaced.
The INVALID KEY phrase must not be specified for a file with sequential organization. An EXCEPTION/ERROR procedure can be specified.
Paul, if you're dealing with a sequential file REWRITE, as the manual quote indicates you cannot change the record length in the REWRITE. |
|
| Back to top |
|
Sambhaji
Joined: 16 Feb 2007
Posts: 267
Location: Pune, India
|
| Posted: Wed Aug 20, 2008 8:05 pm Post subject: |
|
|
Yes Dick Brenholtz is right.
for VB FILE 4 bytes are used for RDW
I tried your code its runing fine here... |
|
| Back to top |
|
Paul1983
Joined: 08 Jul 2008
Posts: 33
Location: bangy
|
| Posted: Wed Aug 20, 2008 8:36 pm Post subject: |
|
|
mine is a KSDS file.So the organization in the SELECT statement should be given as INDEXED with ACCESS MODE as sequential since
I need to update the header record of ths file. |
|
| Back to top |
|
Sambhaji
Joined: 16 Feb 2007
Posts: 267
Location: Pune, India
|
| Posted: Thu Aug 21, 2008 12:08 pm Post subject: |
|
|
have you tried giving IDCAMS --> VERIFY.
file may be already open.. |
|
| Back to top |
|
| |