On Wed, Aug 20, 2014 at 9:34 AM, TonyIcloud-OPERA <[email protected]>
wrote:
> I have a dataset that contains records with a field, by which I need to
> create a separate dataset that would contain all occurrences of that field.
> For example the file, FB100, looks like
>
> value1 other data.....
> value1 other data.....
> value1 other data.....
> value2 other data.....
> value2 other data.....
> value2 other data.....
> value3 other data.....
> value3 other data.....
> value3 other data.....
> value4 other data.....
> value4 other data.....
> value4 other data.....
>
> My final product must be a series of datasets:
>
> hlq.value1.records
> hlq.value2.records
> hlq.value3.records
> hlq.value4.records
>
> There may be hundreds/thousands of possible values, hence
> hundreds/thousands of datasets. I have accomplished this in 3 phases,
> first pass reads the data, uses ICETOOL OCCUR to list the values, second
> phase reads the OUTPUT and formats DD statements and OUTFIL OUTREC
> statements, the third phase reads the original data to create the numerous
> output files. I used a newly created PDSE as the output file whereupon the
> third phase created several thousand members.
>
> It works, after a fashion, but I'd like a more simple solution.
>
>
Well, assuming that performance is not an overriding concern, I would have
two steps. The first would be a DFSORT which sorts the records in order by
the field in question. The second step would be a REXX program which would
look something like:
/* REXX */
VALUE='';
DO FOREVER
"EXECIO DISKR 1 INPUT"
IF RC <> 0 THEN LEAVE /* LEAVE IF EOF */
PARSE PULL RECORD
NVALUE=WORD(RECORD,1) /* EXTRACT VALUE */
IF VALUE <> NVALUE THEN DO
"EXECIO 0 DISKW OUTPUT (FINIS"
ADDRESS TSO "FREE DDN(OUTPUT)"
ADDRESS TSO "ALLOC DDN(OUTPUT) DSN(hlq."VALUE".records) ",
"NEW CATALOG SPACE(a b) CYL RECFM(f) LRECL(lrecl) BLKSIZE(0)"
END
PUSH RECORD
"EXECIO DISKW 1 OUTPUT"
END
Of course, you need to customize the ALLOC command. And in my JCL, I would
have a //OUTPUT DD DUMMY
If you're really adventurous, I'll give you a UNIX solution. But most
people don't really want that.
--
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN