Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

to write first and last record of the file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: to write first and last record of the file.
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 Moderator


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

PostPosted: Thu Jul 13, 2006 12:55 am    Post subject:
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    Post subject: Re: to write first and last record of the file.
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 Moderator


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

PostPosted: Thu Jul 13, 2006 2:33 am    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Fri Sep 19, 2008 1:31 am    Post subject:
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:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 Tue May 16, 2017 2:20 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us