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

How to check the trailer record for the corresponding header


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

New User


Joined: 22 Aug 2005
Posts: 2

PostPosted: Tue Jun 12, 2007 3:50 pm
Reply with quote

Hi Frank,

Please find the below requirement:

I have a file which has many headers and trailers. Certain header doesn't have a corresponding trailer. My requirement is to write the group of records which doesn't have a trailer into one file, some error file and the others to the output file.

The length of input, output and error file is 900. Recfm is FB.

Input:

MH01ABI.....
MM01.........
MM01.........
MT01ABI.....
MH01YQW.....
MM01.......
MM01......
MM01......
MH01POU....
MM01.....
MT01POU.....

where 'MH01' is the header record and 'MT01' is the trailer record. MM01 is the transaction record type.

The output file should be:

MH01ABI.....
MM01.........
MM01.........
MT01ABI.....
MH01POU....
MM01.....
MT01POU.....

and the error file should contain

MH01YQW.....
MM01.......
MM01......
MM01......

Please let me know how to proceed with this using ICETOOL. Also please suggest me some materials to learn icetool from basic.

Thanks.
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: Tue Jun 12, 2007 8:45 pm
Reply with quote

Sangee,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links

Here's a DFSORT job that will do what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN DD DSN=...  input file (FB/900)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T1,VOL=REF=*.T1,DISP=(OLD,PASS)
//    DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//OUT1 DD DSN=...  output file1 (FB/900)
//OUT2 DD DSN=...  output file2 (FB/900)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(OUT1) ON(903,8,ZD) KEEPNODUPS KEEPBASE -
  WITHALL WITH(1,901) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(903:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,4,CH,EQ,C'MH01'),
                OVERLAY=(903:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(911:SEQNUM,8,ZD,
                         903:903,8,ZD,SUB,911,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=T1,INCLUDE=(1,4,CH,EQ,C'MT01'),OVERLAY=(901:C'BB')
  OUTFIL FNAMES=T2,OVERLAY=(901:C'VV')
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT1,INCLUDE=(901,2,CH,EQ,C'VB'),
    BUILD=(1,900)
  OUTFIL FNAMES=OUT2,INCLUDE=(901,2,CH,EQ,C'VV'),
    BUILD=(1,900)
/*
Back to top
View user's profile Send private message
Sangee

New User


Joined: 22 Aug 2005
Posts: 2

PostPosted: Wed Jun 13, 2007 2:34 pm
Reply with quote

Hi Frank,

Thanks a lot. It is working fine.

I have some doubts regarding the above job,

I can understand that sequential numbers are added to the records but could not understand the control card functions clearly.

I am going through the documents suggested, meanwhile if you can explain me the job it would be of great help.

Thanks.
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 Jun 13, 2007 9:06 pm
Reply with quote

I'm using a variation of the "group" trick discussed in the "Include or omit groups of records" Smart DFSORT Tricks at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
sangee27

New User


Joined: 16 Mar 2007
Posts: 19
Location: Pune

PostPosted: Thu Jun 14, 2007 6:07 pm
Reply with quote

Hi,

Thanks for the reference given.

I have gone through the trick discussed in the above link.

But i am not still not clear with CTL1. Sequential number is added starting from position 903, also we are checking the condition for the position 901,902 whether the values are equal to 'VB' or 'VV'. But from where we are getting the value VB?

Also could you please explain the significance of the below step

IFTHEN=(WHEN=NONE,
OVERLAY=(911:SEQNUM,8,ZD,
903:903,8,ZD,SUB,911,8,ZD,M11,LENGTH=8))

Your explanation would help me to understand the icetool job better.

Thanks.
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 Jun 14, 2007 10:02 pm
Reply with quote

Quote:
where we are getting the value VB


From the "splice" of position 901 of the base (first) record and position 902 of the overlay (second) record. To understand this, you need to understand how SPLICE works. Complete details on SPLICE are at:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/6.13?DT=20060615185603

Also, see the "Create files with matching and non-matching records" Smart DFSORT Trick at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

As for the IFTHEN WHEN clause, let's break it down. Before the IFTHEN WHEN, the records look like this:

Code:

                     grpnum
MH01ABI.....         00000001   <--- header = start of group
MM01.........        00000002
MM01.........        00000003
MT01ABI.....         00000004
MH01YQW.....         00000002   <--- header = start of group
MM01.......          00000006
MM01......           00000007
...


WHEN=NONE skips the records that satisifed previous IFTHEN conditions - that would be the header record in this case because of the IFTHEN with WHEN=(1,4,CH,EQ,C'MH01').

After the:

Code:

        IFTHEN=(WHEN=NONE,
                OVERLAY=(911:SEQNUM,8,ZD)),


the records look like this:

Code:

                     grpnum  tempnum
MH01ABI.....         00000001
MM01.........        0000000200000001
MM01.........        0000000300000002
MT01ABI.....         0000000400000003
MH01YQW.....         00000002
MM01.......          0000000600000004
MM01......           0000000700000005
...


and finally after the:

Code:

903:903,8,ZD,SUB,911,8,ZD,M11,LENGTH=8))


The records look like this:

Code:

                     grpnum  tempnum
MH01ABI.....         00000001
MM01.........        0000000100000001
MM01.........        0000000100000002
MT01ABI.....         0000000100000003
MH01YQW.....         00000002
MM01.......          0000000200000004
MM01......           0000000200000005
...


This is just a trick to get group numbers by manipulating sequence numbers and doing a subtraction.
Back to top
View user's profile Send private message
sangee27

New User


Joined: 16 Mar 2007
Posts: 19
Location: Pune

PostPosted: Fri Jun 15, 2007 3:00 pm
Reply with quote

Hi Frank,

Thanks a lot for the explanation. It helped a lot.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top