View previous topic :: View next topic
|
Author |
Message |
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
What DickB pointed out earlier, would solve the problem.
My understanding is that the WS-FLDCNT, in the read record, will tell you the actual occurances of the WS-LAYOUT in the read record.
This value is stored here when the record was written.
When the translator finds the INTO(WS-DMAPKSDS) and no length supplied, is creates the LENGTH(Length if DMAPKSDS), which is dependant on a value in WS-FLDCNT, which is "unknown" at the time of the Read, and will produce an invalid result.
My suggestion is that you simply remove the DEPENDING ON WS-FLDCNT, and the outcome of the Length of... will always be 80.
What will be read is the actual length of the record in the file, and the indicator WS-FLDCNT will tell you the actual number of occurances in this record.
Next time you read, the value might change, but implicit LENGTH will always be 80, which is always sufficient. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
good heavens, people!
1. stay out of linkage. keep your vsam record structure in working-storage.
2. populate ws-fldcnt with 17 prior to the LENGTH OF of RECOR statement,
then you will have a length of 80 prior to the read.
and you can do this. you are changing nothing in the real record,
since you have not read it yet.
all you are trying to do is generate an 80 from the LENGTH OF statement,
and unless ws-fldcnt contains 17, you will not be able to do so.
3. do not remove the DEPENDING ON portion of the OCCURS clause,
you will no longer have variable length records. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You have two basic choices. Set the ODO to 17. Or just remove the ODO.
The removal of the ODO won't affect the reading of the file, but, as dbz has pointed out, you'd not have a variable-length record any more for a write.
Forget for a moment that it is all impossible, and just try it. Let us know. If you don't try it, I can't see what further help we can offer.
Either will "fix" your problem. Retaining the ODO probably would mean the rest of the program works in relation to the length of the VSAM record without you having to do anything. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
removing the ODO also means a SEARCH ALL will not function properly. |
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
Neither any Search or Write was part of the initial post!
Binary Search cant ge performed on this "simple" table, as it is not defined for that.
Whats wrong with Linkage Section for a program that reads a file!? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Whats wrong with Linkage Section for a program that reads a file!? |
considering the competence of the poster,
obviously confusing and an unnecessary complication
plus, why use linkage? not a good habit.
it is the same as using the FD for a file record.
though in the case of CICS,
i believe CICS issues a GETMAIN for the structure
and moves the data to the newly acquired storage
and must set a POINTER.
a lot of overhead to save 80 bytes in working-storage.
have to use working-storage for a rewrite if length is changed anyway.
if there is a problem, the dump also has to include the GETMAINed storage
else you don't have the record
whereas if it is in working-storage,
there is a chance that it can be found.
it may be your habit,
but i do not consider it good programming practice. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I haven't coded for a while, but I'd like to throw this into the mix as a possibility and DBZ may not like this.
Define an 01 area in LINKAGE (length of 256 to be safe), define a WS halfword-length and set it to ZERO.
Issue the READ with a SET(ADDRESS OF 01 LINKAGE AREA) and the actual record-length will be set in the halfword.
Move the 01 LINKAGE area to the 01 WORKING-STORAGE area, using reference modification, based upon the halfword-length.
Then, calculate the ODO based upon the halfword-length. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
as a final thought,
Peter,
the only reason we are having this discussion
(and yes,
in CICS modules
I occasionally use linkage and do getmains
but still consider it poor programming practice,
because it takes a competent person to follow me
when I code that way)
is because the TS is a poorly trained, inexperienced COBOL programmer. |
|
Back to top |
|
|
|