View previous topic :: View next topic
|
Author |
Message |
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
Hi all,
how can I identify pd fields in a file?
The file has many type of records...
and pd fields are in a different positions.
I need to write a file with a zd number!
Is there a better way than inspect all file?
Thanks.
S. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Is there any binary-data in the file? If not, then this will make things easier, but certainly not simple.
Are you planing on using a COBOL INSPECT?
What you may consider is an INSPECT using the REVERSE FUNCTION using the TALLY Special-Register or a field of your own, initialised to ZERO.
What sign-nibble will be in the packed-decimal data? X'C', X'D' and/or X'F'?
You can see how difficult this would be to isolate packed-decimal data if the file contained binary-data as you'd have a dilemma.
Regards, |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
how can I identify pd fields in a file? |
You cannot identify an arbitrary bit pattern as a PD value
( too many false positives )
would x'000c' be a PD 0 or a binary 12 ?
You can anyway verify if a field matches a PD pattern
0-9 for any half byte a sign for the last half byte. |
|
Back to top |
|
|
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
Thanks for the reply.
Packed filds are positive and 4 byte long.
I have to find:
x'0000999C' and x'0000001C'
I'm looking for the fields next this packed... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You can use INSPECT with a hex literal (X'0000001C' for example) but it seems strange that a bit pattern occurring at any of all positions is what you want. |
|
Back to top |
|
|
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
in fact I'm using an inspect for each fields...
but I was hoping there was a better way...
Thanks all. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If the fields are named, simply compare the fields that are packed-decimal against the value(s) you are working with. When you find "the value" in a field, the next field is the one you want (if i understand).
Not sure why an INSPECT is considered . . . |
|
Back to top |
|
|
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
The fields are not named.
I think the inspect command is the only way for solve this problem.
I inspect all rec input and with TALLING i take the number of characters before initial x'0000999C' in variabile x.
by adding 4 to variabile x i have the initial position of the field (K) i'm looking for.
I know K is long 15 characters...
Thanks all. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
The fields are not named. |
does this mean that you do not have a record layout?
if so, i would suggest using sort's SS command. |
|
Back to top |
|
|
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
Hi dbz.
Exactly, i don't have layout.
I only know in the file input there is a tag in packed form x'0000999c'.
Immediately after there is the field i'm lookiing for. It is 15 char long.
I have already use sort's ss command for take the only record with tag x'000099c' from inital file (approximately 25% of total).
Then i'm sure every record has the tag.
Thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If the field you want is immediately after those PD values, use PARSE with STARTAFT= and the X'0000001C'. FIXLEN=15. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
I suppose i'm way out in left field, but it does get my attention when there is data in a file and there is no record layout for this file . . . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
dick scherrer wrote: |
Hello,
I suppose i'm way out in left field, but it does get my attention when there is data in a file and there is no record layout for this file . . . |
silly situations like this are another reason why the this forum exists.
obviously Seppe has not performed the necessary research to find a layout
of a production file.
the only credible reason for such a requirement as his,
this is a student project. |
|
Back to top |
|
|
Seppe
New User
Joined: 01 Apr 2009 Posts: 33 Location: Rome - Italy
|
|
|
|
not really...
I usually use on-line files for a particular process.
these files are saved for one year.
Today i must recover old data (2010).
I don't have my saved input...
but I have the saved output of a following process (saved for five years) that contains the data i'm looking for.
Certainly exists a layout relatively to the type of records...
But i think this wasn't faster.
dbz as you can see there is another reason... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Going forward, i suggest that any data that is worth keeping for several years has the corresponding record layouts, processing code, and documentation stored until it can All be purged. |
|
Back to top |
|
|
Gary McDowell
Active User
Joined: 15 Oct 2012 Posts: 139 Location: USA
|
|
|
|
For no record layout, maybe use Reference Modification.
Possibly make the "from" RM a variable and increment 1 by 1. When found, add 4 to "from" count to get the 15-byte field.
IF input-rec (1:4) = X'0000999C'
MOVE input-rec (5:15) to output.
IF input-rec (ws-var:4) = X'0000999C'
add 4 to ws-var
MOVE input-rec (ws-var:15) to output. |
|
Back to top |
|
|
|