View previous topic :: View next topic
|
Author |
Message |
arjun.h
New User
Joined: 13 Jan 2012 Posts: 20 Location: India
|
|
|
|
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 !! Thanks |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
arjun.h
New User
Joined: 13 Jan 2012 Posts: 20 Location: India
|
|
|
|
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 |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
arjun.h
New User
Joined: 13 Jan 2012 Posts: 20 Location: India
|
|
|
|
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 |
|
|
arjun.h
New User
Joined: 13 Jan 2012 Posts: 20 Location: India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Fine, then, but you can't change the length. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
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 |
|
|
|