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
 

 

Sort excluding HDR & TRL and write duplicates to other f

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

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Thu Jan 31, 2013 12:09 pm    Post subject: Sort excluding HDR & TRL and write duplicates to other f
Reply with quote

Hi,

My requirement is to SORT the records based on key field (1, 11) Pos excluding header & trailer records and write the duplicate records to another file. I want this to be done in Single step only.

See ICETOOL I have created below:

I tried adding SUM FIELDS=NONE,XSUM but it gives syntax error. Can you please help me in writing the duplicates to another SORTXSUM file ? Thanks.


Code:
//STEP020  EXEC PGM=ICETOOL                                   
//TOOLMSG  DD SYSOUT=*                                         
//DFSMSG   DD SYSOUT=*                                         
//SYSPRINT DD SYSOUT=*                                         
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=TTYA.R.EDWUNF.PALSCR.MLY(0),DISP=SHR         
//SORTOUT  DD DSN=TTYA.PAS.SPLICE3(+1),                       
//            DISP=(,CATLG,DELETE),RECFM=FB,LRECL=1261,       
//            SPACE=(CYL,(100,50),RLSE)                       
//SORTXSUM DD DSN=TTYA.PAS.SPLICE2(+1),                       
//            DISP=(,CATLG,DELETE),RECFM=FB,LRECL=1261,       
//            SPACE=(CYL,(100,50),RLSE)                       
//TOOLIN DD *                                                 
   DATASORT FROM(SORTIN) TO(SORTOUT) HEADER TRAILER USING(CTL1)
/*                                                             
//CTL1CNTL DD *                                               
  SORT FIELDS=(1,11,CH,A)                                     
  SUM FIELDS=NONE                   
/*                                 
//*
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jan 31, 2013 12:18 pm    Post subject:
Reply with quote

Quote:
Joined: 24 Jul 2007


Being in forum for 6+ yrs you could do better in explaining

What is the error you got?

But I believe XSUM is a SYNCSORT thing and not DFSORT

Paste your error in code tags for better suggestions
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Thu Jan 31, 2013 12:26 pm    Post subject:
Reply with quote

Error log attached for reference:


0 IDENTIFIER FROM CALLING PROGRAM IS 0001
0 JOBNAME: TTYAGMK1 , STEPNAME: STEP020
0 BLOCKSET TECHNIQUE IN CONTROL
0 BLOCKSET SORT TECHNIQUE SELECTED
0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 06:30 ON THU JA
SORT FIELDS=(1,11,CH,A)
SUM FIELDS=NONE,XSUM
£
E XSUM IS NOT SUPPORTED - USE ICETOOL SELECT IF APPROPRIATE
0 END OF STATEMENTS FROM CTL1CNTL - PARAMETER LIST STATEMENTS FOLLOW
DEBUG NOABEND,ESTAE
OPTION MSGDDN=DFSMSG,LIST,MSGPRT=ALL,RESINV=0,SORTDD=CTL1,SORTIN=SORTI
,SORTOUT=SORTOUT,DYNALLOC,EQUALS,NOCHECK
MODS E15=(ICE15DU,12288),E35=(ICE35DU,12288)
SORT FIELDS=COPY
SORT FIELDS=COPY
C5-K62149 C6-K90026 C7-K58148 C8-K67572 E7-K70685
END OF DFSORT
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Jan 31, 2013 12:43 pm    Post subject:
Reply with quote

Did you read your error atleast once?
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Thu Jan 31, 2013 1:57 pm    Post subject:
Reply with quote

Try this instead..
I have assumed that you have a input LRECL 100 and your header and trailer has 'HEAD' and 'TRAI' respectively in positions 1 thru 4 in them.
Code:

//STEP010  EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
HEADER                                                             
123456789                 A1B1C1D  12345678910111        123456789 
123456789                 A1B1C1D  12345678910112        123456789 
123456789                 A1B1C1D  12345678910113        123456789 
987654321                 E1F1G1H  09876543222144        123456789 
987654321                 E1F1G1H  09876543222144        123456789 
987654321                 E1F1G1H  09876543222144        123456789 
987654321                 YYYYYYY  09876543222144        123456789 
TRAILER                                                             
//SORT1 DD  DSN=XXXXXX,         ---->> Without dupes                   
//      DISP=(,CATLG,DELETE),                                       
//      SPACE=(CYL,(2,2),RLSE),                                     
//      RECFM=FB                                                   
//SORT2 DD  DSN=XXXXXXX,        ------>> Dupes                       
//      DISP=(,CATLG,DELETE),                                       
//      SPACE=(CYL,(2,2),RLSE),                               
//      RECFM=FB                                             
//SYSIN    DD *                                               
     SORT FIELDS=(1,11,CH,A)                                 
    INREC IFTHEN=(WHEN=INIT,                                 
              OVERLAY=(101:SEQNUM,9,ZD,RESTART=(1,11))),     
       IFTHEN=(WHEN=(1,4,CH,EQ,C'HEAD',OR,1,4,CH,EQ,C'TRAI'),
              OVERLAY=(101:C'000000002'))                   
    OUTFIL FNAMES=SORT1,INCLUDE=(101,9,ZD,EQ,1),BUILD=(1,100)
    OUTFIL FNAMES=SORT2,SAVE,BUILD=(1,100)                                 
//*                                                           



Thanks,
Ashwin.
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Thu Jan 31, 2013 2:20 pm    Post subject:
Reply with quote

My apologies...please try this sysin card instead.

Code:


//SYSIN    DD *                                                     
    SORT FIELDS=(1,11,CH,A)                                         
    INREC IFTHEN=(WHEN=INIT,                                         
              OVERLAY=(101:SEQNUM,9,ZD,RESTART=(1,11))),             
       IFTHEN=(WHEN=(1,4,CH,EQ,C'HEAD',OR,1,4,CH,EQ,C'TRAI'),       
              OVERLAY=(101:C'000000000',111:C'X'))                   
    OUTFIL FNAMES=SORT1,INCLUDE=(101,9,ZD,EQ,1),BUILD=(1,100)       
    OUTFIL FNAMES=SORT2,INCLUDE=(101,9,ZD,GT,1,AND,111,1,CH,NE,C'X'),
              BUILD=(1,100)                                         
//*                                                                 


Thanks,
Ashwin.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Feb 01, 2013 12:03 am    Post subject: Reply to: Sort excluding HDR & TRL and write duplicates
Reply with quote

hailashwin,

I appreciate your enthusiasm to help but you need to understand the order of processing. You already have the data sorted on the key and hence your job worked even though you are using INREC to number the duplicates. Run your job with the following data and see how you get incorrect results.
Code:

HEADER                           
123456789                 A1B1C1D
987654321                 E1F1G1H
987654321                 E1F1G1H
123456789                 A1B1C1D
987654321                 E1F1G1H
987654321                 YYYYYYY
123456789                 A1B1C1D
TRAILER                         


The order of DFSORT processing is explained here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/1.5.4

puneetvirmani143,

You cannot use XSUM and the message ICE172A is pretty self explanatory. Here is the complete description of the message

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ice1cm60/2.2.165

You can do either do another pass to get the desired results or alternatively there is a trick to get the desired results in the same pass even if there is nothing to identify the header and trailer.

Please provide us the DCB properties of the input file. Do you have anything to identify the header and trailer? If there is then we just need to slightly modify hailashwin's solution. If not then I will show you the trick to get it done in 1 pass.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Fri Feb 01, 2013 2:07 am    Post subject: Reply to: Sort excluding HDR & TRL and write duplicates
Reply with quote

Puneet

If there is an easy way to identify the header and trailer records then I suggest to use the icetool SELECT statement with a USING parm like so:
Code:
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) DISCARD(DUPL) USING(ICED) ON(1,11) FIRST

//ICEDCNTL DD *
OMIT COND=(1,3,CH,EQ,C'HDR',OR,1,3,CH,EQ,C'TRL')


This is just the basic syntax. I haven't tested it. dd OUT will contain the non-duplicates and dd DUPL will contain just the duplicates
Back to top
View user's profile Send private message
puneetvirmani143

New User


Joined: 24 Jul 2007
Posts: 55
Location: noida

PostPosted: Fri Mar 08, 2013 7:39 pm    Post subject:
Reply with quote

Hi Jerryte,

Above code is throwing error
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Fri Mar 08, 2013 8:24 pm    Post subject:
Reply with quote

puneetvirmani143 wrote:
Hi Jerryte,

Above code is throwing error

What is the error message?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Mar 08, 2013 8:39 pm    Post subject: Reply to: Sort excluding HDR & TRL and write duplicates
Reply with quote

Probably OMIT starting in column one.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Sat Mar 09, 2013 12:13 am    Post subject:
Reply with quote

And it ain't throwing an error but issuing an error.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Mar 09, 2013 6:29 am    Post subject: Reply to: Sort excluding HDR & TRL and write duplicates
Reply with quote

The ON statement is mislocated, once that is corrected the OMIT in column one is spotted,

Since the header and trailer are needed, the code won't work anyway.

Working on the other code provided:

Code:
//STEP010  EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
HEADER
987654321                 YYYYYYY  09876543222144        123456789
123456789                 A1B1C1D  12345678910111        123456789
987654321                 E1F1G1H  09876543222144        123456789
123456789                 A1B1C1D  12345678910113        123456789
987654321                 E1F1G1H  09876543222144        123456789
987654321                 E1F1G1H  09876543222144        123456789
123456789                 A1B1C1D  12345678910112        123456789
TRAILER
//SORT1 DD  SYSOUT=*
//SORT2 DD  SYSOUT=*
//SYSIN    DD *
                                                                 
    INREC IFTHEN=(WHEN=(1,8,CH,EQ,C'HEADER '),
            OVERLAY=(81:C'0')),
          IFTHEN=(WHEN=(1,9,CH,EQ,C'TRAILER '),
            OVERLAY=(81:C'9')),
          IFTHEN=(WHEN=NONE,
            OVERLAY=(81:C'5'))
                                                                 
    SORT FIELDS=(81,1,CH,A,1,11,CH,A)
                                                                 
    OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,11),
              PUSH=(81:SEQ=5))
                                                                 
    OUTFIL FNAMES=SORT1,INCLUDE=(81,5,ZD,EQ,1),BUILD=(1,80)
                                                                 
    OUTFIL FNAMES=SORT2,SAVE,BUILD=(1,80)
                                                                 
//*


There is a "pre-sort" which is simply 0 for header, 5 for data, and 9 for trailer, then the actual sort on the key.

The "first" record is INCLUDED by using WHEN=GROUP, with KEYBEGIN and PUSHing a sequence number for the group.

A similar approach to ICETOOL's SELECT "works", as in my single test-run gives the same results, but since the manual specifies that the high-order sort key should be any and all ON values, in the order specified on the SELECT which can be followed by additional keys, I'd not rely on it working.
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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