Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Rewrite a variable length file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Paul1983

New User


Joined: 08 Jul 2008
Posts: 37
Location: bangy

PostPosted: Wed Aug 20, 2008 5:07 pm    Post subject: Rewrite a variable length file
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Aug 20, 2008 5:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 20, 2008 5:48 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Paul1983

New User


Joined: 08 Jul 2008
Posts: 37
Location: bangy

PostPosted: Wed Aug 20, 2008 5:50 pm    Post subject:
Reply with quote

i want to rewrite the input file itself.So there is no DCB parms involved

Thanks,
Paul
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Aug 20, 2008 5:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Aug 20, 2008 5:57 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 20, 2008 6:01 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Paul1983

New User


Joined: 08 Jul 2008
Posts: 37
Location: bangy

PostPosted: Wed Aug 20, 2008 6:10 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Aug 20, 2008 6:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 20, 2008 7:40 pm    Post subject:
Reply with quote

01 POL-CURR-REC PIC X(23472).

I think this should be:
01 POL-CURR-REC PIC X(23468).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Aug 20, 2008 7:52 pm    Post subject: Re: Rewrite a variable length file
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Aug 20, 2008 8:03 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Aug 20, 2008 8:05 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Paul1983

New User


Joined: 08 Jul 2008
Posts: 37
Location: bangy

PostPosted: Wed Aug 20, 2008 8:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 21, 2008 12:08 pm    Post subject:
Reply with quote

have you tried giving IDCAMS --> VERIFY.
file may be already open..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us