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
 

 

Rewriting a variable block file in cobol

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

New User


Joined: 13 Jan 2012
Posts: 20
Location: India

PostPosted: Tue Jul 31, 2012 10:44 am    Post subject: Rewriting a variable block file in cobol
Reply with quote

i Think i got something similar to this topic.

I have a variable lenght file flat file(LRECL=84) , what i want to do is to replace a record with another one.
Eg: I want to replace the first record with the second one.

Record 1: AAAAAAAAAAAAAAAAAAAAA
Record 2: BBBBBBBBBBBBBBBBBBBBBBBBBBBB

The Issue am facing is with file status 44 . I read through some documents and figured out its a issue with the record length. I feel rewrite option cannot be used if record length are different or is there any way that i can rewrite ?

I have used the below code as FD

FD STG-FILE
RECORD IS VARYING IN SIZE FROM 1 TO 80 CHARACTERS
DEPENDING ON WS-STG-REC-LEN
LABEL RECORDS ARE STANDARD
RECORDING MODE V
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS STG-FILE-REC.
01 STG-FILE-REC PIC X(80).

is it possible to rewrite if i pass the length value( larger Record value ) to WS-STG-REC-LEN and try to rewrite ? I tried this way but failed.

Job abend:
COMP CD=S000|U4038

Log:
IGZ0020S A logic error occurred. Neither FILE STATUS nor a declarative was specified for file STG in program
at relative location X'253E'. The status code was 44.


If there is no way then i will have to opt another way of doing this


Help me if you are free !! icon_smile.gif Thanks
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Jul 31, 2012 12:01 pm    Post subject:
Reply with quote

No - you create a new file. Your record has to use the space used by the previous record. If your new record was longer then it would start over-writing the next record. If your new record is shorter you may, just may, get away with it but I would have to read the manual on that.
Back to top
View user's profile Send private message
arjun.h

New User


Joined: 13 Jan 2012
Posts: 20
Location: India

PostPosted: Tue Jul 31, 2012 12:18 pm    Post subject:
Reply with quote

Nic,

I think you are right , if i replace record two with one as below it shouldn't throw any error.

Eg:

Record 1: AAAAAAAAA
Record 2: BBBB

The issue is when the second record is larger .

I cannot create a new file as i have to do the process on the same file, so What am planning to do is replace the record with space and then add it again with the new data .

I dont have a good feeling doing this way but i hope this is the only way out.

Thanks you very much icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jul 31, 2012 12:38 pm    Post subject: Reply to: Rewriting a variable block file in cobol - New
Reply with quote

arjun.h,

Please don't "tailgate" an old topic with a new question, but start a new topic. It is easy to refer to the old topic with the URL tags, if you feel that it helps.
Your post has been updated to the include the link where you made the reference.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jul 31, 2012 1:23 pm    Post subject: Reply to: Rewriting a variable block file in cobol - New
Reply with quote

Whilst updating a flat/QSAM/PS is possible, it is generally not good practice. If your program collapses, you have trashed your input file.

If you do want to go with the update despite that, you'll find you can't change the record-length - that is, neither bigger nor smaller.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Tue Jul 31, 2012 2:39 pm    Post subject:
Reply with quote

The COBOL REWRITE statement supports sequential direct access files, but, the kind of situation you put up front, it does not sound like a good choice for a solution. Having said that, if you tell us what and why you want to do this, there might be some feasible answers.
Back to top
View user's profile Send private message
arjun.h

New User


Joined: 13 Jan 2012
Posts: 20
Location: India

PostPosted: Tue Jul 31, 2012 3:11 pm    Post subject:
Reply with quote

Anuj,

I have two two file

File A : Action file
File B : This is the file on which i am trying to rewrite

File A will contain indicators and record identifiers which tells the program what action needs to be performed on which records( Eg rewrite , add , delete) has to be performed on file B.

File B is master file , having Data. Depending upon the action specified in File A file B needs to be Modified . Also to mention the Indicators in the file A are dependent on each other.

Eg: File A

Add AAAAAAAAAAAA
Delete AAAAAAAAAAAA

AAAAAAAAAAAA record needs to be added in the first step, after which if the indicator is Delete then i have to delete it . ( This doesn't sound logical , am just putting this up so that we understand the requirement)

Did i make some sense to you ?
Back to top
View user's profile Send private message
arjun.h

New User


Joined: 13 Jan 2012
Posts: 20
Location: India

PostPosted: Tue Jul 31, 2012 3:16 pm    Post subject: Re : Bill Woodger
Reply with quote

Bill,

I am updating a Temporary file before i copy it to the original file. I don't have issues if i my program abend. Infact i have condition when the program should abend . So if i restart my JCL i will have a new input file again to process.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Jul 31, 2012 4:29 pm    Post subject: Reply to: Rewriting a variable block file in cobol - New
Reply with quote

Fine, then, but you can't change the length.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Tue Jul 31, 2012 4:49 pm    Post subject:
Reply with quote

For every game there are some rules you need to abide by -- one can't make his/her own. If s/he insists, perhaps -- s/he choose or create a new game, depeding on the caliber. Said that, as Bill indicates, you can not change the length.

From the COBOL Language Reference 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.
Decide on what you want to do.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Tue Jul 31, 2012 4:53 pm    Post subject:
Reply with quote

arjun.h wrote:
Did i make some sense to you ?
I'm sorry but I don't follow you. What I've understood, based on that, I've already replied in.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jul 31, 2012 7:10 pm    Post subject:
Reply with quote

Hello,

Quote:
Did i make some sense to you ?
Yes, I believe almost all of us understand what you want to do and why.

Now you need to understand that you are working from a very bad design specification and this needs to be changed. There is no "good" reason to continue to pursue this.
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Tue Jul 31, 2012 9:19 pm    Post subject: Reply to: Rewriting a variable block file in cobol - New
Reply with quote

Good day to all!

Usually flat files are recreated specially if you are expanding record size. I think your best bet is to keep your original input file and create a new one from your input and the updated records.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


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