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
 

 

Extracting records between a header and trailer

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

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Thu Sep 22, 2011 6:33 pm    Post subject: Extracting records between a header and trailer
Reply with quote

I have an variable length input file of length 1040 bytes. The format of the file is

HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr2
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec

My requirement is, if the VersionNbr in HDRRec is 1, then all detail records (including Header and Trailer) under that Header Record needs to be extracted and written into a new file. So in this case the output will be

HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec




The Header record is identified by the keyword HDR which starts at position 1 and trailer record is identified by the keyword TRL which starts at position 1. The version number will be starting at position 41 and will be 8 bytes in length.

Can this be achieved using DFSORT?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Thu Sep 22, 2011 6:44 pm    Post subject: Reply to: Extracting records between a header and trailer
Reply with quote

Yes, I'm pretty sure it can.

If you look through the forum you'll get some good hints as to how, even.
Back to top
View user's profile Send private message
Indrajit_57
Warnings : 1

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Thu Sep 22, 2011 6:54 pm    Post subject:
Reply with quote

I had searched the forum and written the following sort card

OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1040:C'N')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR',AND,41,8,ZD,EQ,0001),
OVERLAY=(1041:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=(1041:C'9'),HIT=NEXT)

The problem I am facing is that the detail records are always getting marked with 'N' even if the header record is satisfying the conditions.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Sep 22, 2011 7:42 pm    Post subject:
Reply with quote

Code:

HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr2
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec

For your shown input I am really wondering what rules you want to apply to get below output(Shown by you)
Code:

HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
HDRRec VersionNbr1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec


Why below is not output?

Code:

HDRRec VersionNbr1
Detial Rec 1
Detail Rec 1
Detail Rec 2
Detail Rec 3
TRLRec
Back to top
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Thu Sep 22, 2011 8:22 pm    Post subject:
Reply with quote

Code:

INREC IFTHEN=(WHEN=INIT,OVERLAY=(1040:C'N')),
IFTHEN=(WHEN=(1,3,CH,EQ,C'HDR',AND,41,8,ZD,EQ,0001),
OVERLAY=(1041:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,3,CH,EQ,C'TRL'),
OVERLAY=(1041:C'9'),HIT=NEXT)


You are using a VB file, your header will not satisfy this condition.
Start from position 5 .
Back to top
View user's profile Send private message
elango_K

New User


Joined: 18 Aug 2011
Posts: 44
Location: India

PostPosted: Thu Sep 22, 2011 8:34 pm    Post subject:
Reply with quote

Try this:

Code:

//SYSIN    DD *                                         
  OPTION COPY                                           
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,3,CH,EQ,C'HDR',AND,
  41,8,ZD,EQ,1),END=(5,3,CH,EQ,C'TRL'),PUSH=(1041:ID=8))
  OUTFIL OMIT=(1041,1,CH,NE,C'0'),BUILD=(1,1040)       
 
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 22, 2011 10:03 pm    Post subject:
Reply with quote

Indrajit_57,
If you pad the group-id indicator at the end of a VB file you will ruin the very concept of VB files and make them all fixed block.

I assumed that your HDR value starts in pos 5 ( first 4 byte of RDW) and the number 1 starts in position 22. In order to retain the original lengths of the VB file, we pad a 1 byte space right after the RDW and use that for pushing the Group-id indicator. since we padded the space before the actual record , now your positions are incremented by 1. So the HDR is now at position 6 and the number is at position 23. While writing out we remove that field, there by retaining the original VB file lengths for each record.


Use the following DFSORT JCL.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=Your Input VB 1040 Lrecl file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,X,5)),                     
  IFTHEN=(WHEN=GROUP,BEGIN=(6,3,CH,EQ,C'HDR',AND,23,1,ZD,EQ,1), 
  END=(6,3,CH,EQ,C'TRL'),PUSH=(5:ID=1))                         
  OUTFIL OMIT=(5,1,CH,EQ,C' '),BUILD=(1,4,6)                     
//*
Back to top
View user's profile Send private message
Indrajit_57
Warnings : 1

New User


Joined: 27 Jun 2006
Posts: 60

PostPosted: Fri Sep 23, 2011 5:55 pm    Post subject:
Reply with quote

Thanks Skolusu. It is working fine for me.
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 Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


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