|
|
| Author |
Message |
foliater
New User
Joined: 06 Apr 2006 Posts: 23
|
|
|
|
hi,
i want to write the first and last record of file1, file2 and file3 into
the same file, file4.
this must be done in a single step.
it will look like,
file1 dd --------------------------
file2 dd --------------------------
file3 dd --------------------------
{some condition}
file4 dd --------------------------(6 records), disp = mod
can anyone help me on this.... |
|
| Back to top |
|
 |
References
|
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4613 Location: San Jose, CA
|
|
|
|
You can use a DFSORT/ICETOOL job like this to write the first and last record of each input file to the MOD output file. I assumed that your input files have RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//IN3 DD DSN=... input file3 (FB/80)
//OUT DD DISP=MOD,DSN=... output file (FB/80)
//TOOLIN DD *
COPY FROM(IN1) TO(OUT) USING(CTL1)
SORT FROM(IN1) USING(CTL2)
COPY FROM(IN2) TO(OUT) USING(CTL1)
SORT FROM(IN2) USING(CTL2)
COPY FROM(IN3) TO(OUT) USING(CTL1)
SORT FROM(IN3) USING(CTL2)
/*
//CTL1CNTL DD *
* WRITE FIRST RECORD TO OUTPUT FILE
OPTION STOPAFT=1
/*
//CTL2CNTL DD *
* WRITE LAST RECORD TO OUTPUT FILE
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTFIL FNAMES=OUT,ENDREC=1,BUILD=(1,80)
/*
|
|
|
| Back to top |
|
 |
Alain Benveniste
Active User
Joined: 14 Feb 2005 Posts: 90
|
|
|
|
Frank,
I can't test it now, but I would test something to make it in 1 pass this way :
- inrec seqnum all the records
- outfil with trailer3 + sections
- extract the 1st record with MIN= on seqnum
- extract the last record with MAX= on seqnum
Alain |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4613 Location: San Jose, CA
|
|
|
|
Alain,
Not sure how that would work. There's nothing in the three separate files to identify which files a record came from. So how would you identify the first and last record from each file? Also, if you're trying to use three different OUTFILs, then you'd need to write them to three separate files and then copy them back together. OUTFIL output files are written in parallel so you can't MOD them to one file. |
|
| Back to top |
|
 |
Alain Benveniste
Active User
Joined: 14 Feb 2005 Posts: 90
|
|
|
|
Frank,
Well, I didn?t tell you I thought to code 1 pass for each input file as follow :
| Code: |
//STEP0001 EXEC PGM=ICETOOL
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) USING(ICE0)
COPY FROM(IN2) USING(ICE0)
COPY FROM(IN3) USING(ICE0)
/*
//IN1 DD *
A
B
/*
//IN2 DD *
A
B
C
/*
//IN3 DD *
A
B
C
D
/*
//OUTX DD SYSOUT=*
//ICE0CNTL DD *
OUTREC IFTHEN=(WHEN=INIT,BUILD=(1,10,X,SEQNUM,5,ZD)),IFOUTLEN=10
OUTFIL FNAMES=OUTX,
TRAILER1=(1,10,MIN=(12,5,ZD),/,
1,10,MAX=(12,5,ZD)),
NODETAIL,
REMOVECC
/*
|
I confused 2 ideas that coding MIN= will not select the first record, MAX the last one. TRAILERx always select the last record. Even if HEADERx supported MIN=,MAX= & others, even if it worked, I think there is no way to remove the seqnum after TRAILERx as I tested it with IFOUTLEN. The error msg I received was :
| Code: |
ICE027A 9 END OF OUTX FIELD BEYOND MAXIMUM RECORD LENGTH
|
Alain |
|
| Back to top |
|
 |
Alain Benveniste
Active User
Joined: 14 Feb 2005 Posts: 90
|
|
|
|
| Frank's solution will do what is asked, mine not. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4613 Location: San Jose, CA
|
|
|
|
You can now do this kind of thing more easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/80)
//IN2 DD DSN=... input file2 (FB/80)
//IN3 DD DSN=... input file3 (FB/80)
//OUT DD DISP=MOD,DSN=... output file (FB/80)
//TOOLIN DD *
SUBSET FROM(IN1) TO(OUT) INPUT KEEP FIRST LAST
SUBSET FROM(IN2) TO(OUT) INPUT KEEP FIRST LAST
SUBSET FROM(IN3) TO(OUT) INPUT KEEP FIRST LAST
/*
|
For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:
www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/ |
|
| Back to top |
|
 |
|
|
|