IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

to write first and last record of the file.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
foliater

New User


Joined: 06 Apr 2006
Posts: 31

PostPosted: Wed Jul 12, 2006 11:28 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jul 13, 2006 12:55 am
Reply with quote

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
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Thu Jul 13, 2006 1:51 am
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jul 13, 2006 2:33 am
Reply with quote

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
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Thu Jul 13, 2006 11:17 pm
Reply with quote

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
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Thu Jul 13, 2006 11:18 pm
Reply with quote

Frank's solution will do what is asked, mine not.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Sep 19, 2008 1:31 am
Reply with quote

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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 6
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top