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
 

 

Need Header & detailed records in one file which have du

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
srajanbose
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Tue Nov 15, 2011 2:27 pm    Post subject: Need Header & detailed records in one file which have du
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 Moderator


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

PostPosted: Wed Nov 16, 2011 3:01 am    Post subject:
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
Warnings : 1

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Mon Nov 21, 2011 9:11 am    Post subject:
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    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 10 Tue May 16, 2017 2:20 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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