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

Need Header & detailed records in one file which have du


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

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Tue Nov 15, 2011 2:27 pm
Reply with quote

Hi,
I have an requirement as below.

A file have multiple headers under which have multiple detailed records will be present.

If we have duplicates from column 5-8, then the corresponding header and all the corresponding detailed records needs to be written in to an output file.

If we dont have duplicates from column 5-8, then the corresponding header and all the corresponding detailed records needs to be written in to another output file.

Sample input and output files below.



Input file:

Code:
----+----1--
HEADER1     
ABCD1234   
ABCD2345   
ABCD1234   
HEADER2     
ABCD4567   
ABCD8765   
ABCD1234   
HEADER3     
ABCD4567   
ABCD8765   
ABCD4567   


Expected Output1:

Code:
HEADER1
ABCD1234
ABCD2345
ABCD1234
HEADER3   
ABCD4567 
ABCD8765 
ABCD4567 


Output2:
Code:
HEADER2
ABCD4567
ABCD8765
ABCD1234
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: Wed Nov 16, 2011 3:01 am
Reply with quote

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has 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=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(81,8,ZD) ON(5,4,CH) FIRSTDUP USING(CTL1)
COPY JKFROM USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
    PUSH=(81:ID=8))
  OUTFIL FNAMES=T1,BUILD=(81,8)
/*
//CTL2CNTL DD *
  JOINKEYS F1=T1,FIELDS=(1,8,A),SORTED,NOSEQCK
  JOINKEYS F2=IN,FIELDS=(81,8,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F2
  REFORMAT FIELDS=(F2:1,80,?)
  OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'B'),BUILD=(1,80)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)
/*
//JNF2CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
    PUSH=(81:ID=8))
/*
Back to top
View user's profile Send private message
srajanbose

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Mon Nov 21, 2011 9:11 am
Reply with quote

Thanks Frank.Its working fine.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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
Search our Forums:

Back to Top