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

Syncsort - Group SORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Thu Feb 10, 2011 1:34 am
Reply with quote

My input file looks like -

Code:
HEADER
CUSTOMER1....................................
MAILING.............a.........................
a
b
c
CUSTOMER2....................................
MAILING........................................
a
b
c
CUSTOMER3....................................
MAILING.......................b...............
a
b
c
CUSTOMER4
MAILING.................................c.....
a
b
c
CUSTOMER5
MAILING.......................................
a
b
c
RQSTCNTL999999999....................
CUSTOMER6
MAILING.......................................
a
b
c
CUSTOMER7
MAILING....................a.................
a
b
c
RQSTCNTL888888888....................
TRAILER


Please see the description of above input file
1. after the header till RQSTCNTL is one group for a request
2. within a group of request, starting from CUSTOMER record till next CUSTOMER is a group for each customer
3. each customer has mailing record which may have value at fixed opsition let's say 35, 40 & 45


Now the requirement is -
1. I need to keep the header and trailer as it is.
2. I need to SORT it by RQSTCNTL (in this case goup of second RQSTCNT should come first since it has RQSTCNTL as 888888888).
3. Once it's sorted by RQSTCNTL (as a group) I need to SORT the customers based on the mailing record (position 35, 40 & 45)


Please see the sorted output -


Code:
HEADER
CUSTOMER6
MAILING.......................................
a
b
c
CUSTOMER7
MAILING....................a.................
a
b
c
RQSTCNTL888888888....................
CUSTOMER2....................................
MAILING........................................
a
b
c
CUSTOMER5
MAILING.......................................
a
b
c
CUSTOMER1....................................
MAILING.............a.........................
a
b
c
CUSTOMER3....................................
MAILING.......................b...............
a
b
c
CUSTOMER4
MAILING.................................c.....
a
b
c
RQSTCNTL999999999....................
TRAILER


Please note that Customer records have CUSTOMER (it's not unique, I just made it to avoid any confusion).
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Feb 10, 2011 4:26 am
Reply with quote

trilokdewangan,

The following DFSORT JCL will give you the desired results.

I assumed the following

1. Your input lrecl is 80 and recfm is FB
2. Every group has one RQSTCNTL in pos 1
3. Sorting of the customer data is identified by 'customer' in pos 1 and the sorting filed starts at pos 35 to 45 for a length of 11 bytes

Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//INA      DD DSN=Your input FB 80 lrecl file,DISP=SHR
//INB      DD DSN=Same input FB 80 lrecl file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  JOINKEYS F1=INA,FIELDS=(81,8,A),SORTED,NOSEQCK                       
  JOINKEYS F2=INB,FIELDS=(01,8,A),SORTED,NOSEQCK                       
  JOIN UNPAIRED,F1                                                     
  REFORMAT FIELDS=(F1:1,80,F2:9,9)                                     
 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'CUSTOMER'),             
        PUSH=(90:35,11)),                                             
  IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),OVERLAY=(81:20C'0')),             
  IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),OVERLAY=(81:20X'FF'))           
 
  SORT FIELDS=(81,20,CH,A),EQUALS
  OUTREC BUILD=(1,80)
//*                                   
//JNF1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,END=(1,8,CH,EQ,C'RQSTCNTL'),PUSH=(81:ID=8))
//*
//JNF2CNTL DD *                                                       
  INCLUDE COND=(1,8,CH,EQ,C'RQSTCNTL')                                 
  INREC BUILD=(SEQNUM,8,ZD,9,9)                                       
//*
Back to top
View user's profile Send private message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Fri Feb 11, 2011 1:14 am
Reply with quote

Thanks Kolusu.

I tried to run this in my shop but stuck with JCL error with :

"NO SORTIN DD STATMENT PROVIDED."

Is that possible to display following information at the same time into another file -

REQUEST# - (the list - starting from 9, length 9 of RQSTCNTL record)
NUMBER OF RECORDS : total records
NUMBER OF CUSTOMERS = count of CUSTOMER records
NUMBER OF REQUESTS = Number of RQSTCNTL records.

(Input file has LRECL = 2000, FB, Mailing records ("MAILING") sorting records start:343, length 32)
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 11, 2011 2:23 am
Reply with quote

trilokdewangan wrote:
Thanks Kolusu.

I tried to run this in my shop but stuck with JCL error with :

"NO SORTIN DD STATMENT PROVIDED."


You need to show me the complete SYSOUT messages so that I can determine the error

Quote:

Is that possible to display following information at the same time into another file -

REQUEST# - (the list - starting from 9, length 9 of RQSTCNTL record)
NUMBER OF RECORDS : total records
NUMBER OF CUSTOMERS = count of CUSTOMER records
NUMBER OF REQUESTS = Number of RQSTCNTL records.

(Input file has LRECL = 2000, FB, Mailing records ("MAILING") sorting records start:343, length 32)


Yes it is possible but I need to see the level of DFSORT you are running.

Run the following sample job and show me the complete SYSOUT listing

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
Back to top
View user's profile Send private message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Fri Feb 11, 2011 9:30 pm
Reply with quote

See the SYSOUT from JCL:

Code:
1 SYNCSORT FOR Z/OS  1.3.2.1R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCS
                                          Prudential Financial   z/OS   1.11.0 
  SYNCSORT LICENSED FOR CPU SERIAL NUMBER 1AD35, MODEL 2097 606             LICE
  SYSIN :                                                                       
    JOINKEYS F1=INA,FIELDS=(2001,8,A),SORTED,NOSEQCK                           
             *                                                                 
    JOINKEYS F2=INB,FIELDS=(01,8,A),SORTED,NOSEQCK                             
             *                                                                 
    JOIN UNPAIRED,F1                                                           
    REFORMAT FIELDS=(F1:1,2000,F2:9,9)                                         
                                                                               
    INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'CUSTOMER'),                     
          PUSH=(2010:343,32)),                                                 
    IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),OVERLAY=(2001:20C'0')),                 
    IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),OVERLAY=(2001:20X'FF'))                 
                                                                               
    SORT FIELDS=(2001,20,CH,A),EQUALS                                           
    OUTFIL FNAMES=OUTAB                                                         
    OUTREC BUILD=(1,2000)                                                       

   OUTREC BUILD=(1,2000)                                       
 WER268A  JOINKEYS STATEMENT: SYNTAX ERROR                     
 WER268A  JOINKEYS STATEMENT: SYNTAX ERROR                     
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                 
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                 


SYSOUT of ICEMAN -

Code:
SYNCSORT FOR Z/OS  1.3.2.1R    U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                        Prudential Financial   z/OS   1.11.0   
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 1AD35, MODEL 2097 606             LICEN
SYSIN :                                                                       
  OPTION COPY                                                                 
WER276B  SYSDIAG= 103744, 2261881, 2261881, 4496025                           
WER415I  DSM FACILITY ACTIVE:  STORAGE ADJUSTED BY 0 BYTES                     
WER164B  9,052K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,             
WER164B     0 BYTES RESERVE REQUESTED, 272K BYTES USED                         
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                               
WER108I  SORTIN   : RECFM=FB   ; LRECL=    80; BLKSIZE=    80                 
WER110I  SORTOUT  : RECFM=FB   ; LRECL=    80; BLKSIZE=    80                 
WER410B  7,848K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,       
WER410B     0 BYTES RESERVE REQUESTED, 156K BYTES USED                         
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
WER416B  BSAM WAS USED FOR SORTIN                                             
WER416B  BSAM WAS USED FOR SORTOUT                                             
WER054I  RCD IN          1, OUT          1                                     
WER169I  RELEASE 1.3 BATCH 0506 TPF LEVEL 2.1                                 
WER052I  END SYNCSORT - TESTSORT,S1,,DIAG=C200,40CE,EAAE,00E6,8A52,6CC3,AAA8,0C
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Feb 11, 2011 9:59 pm
Reply with quote

From the messages posted You are Using Syncsort

Synsort and DFSORT are competitive products
Kolusu is a DFSORT Developer...
He will be glad to answer and solve issues on DFSORT!
You cannot expect Him to provide assistance on a competitor's product icon_biggrin.gif

topic moved where it belongs
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 12, 2011 12:37 am
Reply with quote

Hello,

Suggest you look in this JCL part of the forum for other Syncsort JOIN solutions. . .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Feb 14, 2011 1:40 pm
Reply with quote

trilokdewangan,

Here's a SYNCTOOL (untested) equivalent of Kolusu's above solution.
I have modified it as per the file attributes and field positions mentioned in your latest post.
Code:
//STEP0100 EXEC PGM=SYNCTOOL   
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*   
//INA      DD DSN=Your input FB 2000 lrecl file,DISP=SHR
//INB      DD DSN=Same input FB 2000 lrecl file,DISP=SHR
//CTL3JNF1 DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA
//CTL3JNF2 DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA
//OUT      DD DSN= Output FB 2000 lrecl file
//TOOLIN   DD *
  COPY FROM(INA)      TO(CTL3JNF1) USING(CTL1)                             
  COPY FROM(INB)      TO(CTL3JNF2) USING(CTL2)
  SORT FROM(CTL3JNF1) TO(OUT)      USING(CTL3)
//CTL1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=GROUP,END=(1,8,CH,EQ,C'RQSTCNTL'),PUSH=(2001:ID=8))
//*
//CTL2CNTL DD *                                                       
  INCLUDE COND=(1,8,CH,EQ,C'RQSTCNTL')                                 
  INREC BUILD=(SEQNUM,8,ZD,9,9)                                       
//*
//CTL3CNTL DD *                                                       
  JOINKEYS FILE=F1,FIELDS=(2001,8,A),SORTED
  JOINKEYS FILE=F2,FIELDS=(0001,8,A),SORTED
  JOIN UNPAIRED,F1                                                     
  REFORMAT FIELDS=(F1:1,2000,F2:9,9)                                     
 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'MAILING'),             
        PUSH=(2010:343,32)),                                             
  IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),OVERLAY=(2001:41C'0')),             
  IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),OVERLAY=(2001:41X'FF'))           
 
  SORT FIELDS=(2001,41,CH,A),EQUALS
  OUTREC BUILD=(1,2000)
//*
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Feb 14, 2011 1:53 pm
Reply with quote

Code:
BEGIN=(1,7,CH,EQ,C'MAILING')
might need to be changed to
Code:
BEGIN=(1,8,CH,EQ,C'CUSTOMER')
I am not sure what significance the 'MAILING' records have here.
Back to top
View user's profile Send private message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Mon Feb 14, 2011 8:58 pm
Reply with quote

Arun,

Here is the abend error -

Code:
WER276B  SYSDIAG= 356230, 1304350, 1304350, 2362575                           
WER415I  DSM FACILITY ACTIVE:  STORAGE ADJUSTED BY 14M BYTES                   
WER164B  1,204K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,             
WER164B     0 BYTES RESERVE REQUESTED, 1,176K BYTES USED                       
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                               
WER267A  SORT STATEMENT    : STATEMENT NOT FOUND                               
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 
******************************* BOTTOM OF DATA ********************************
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Feb 14, 2011 11:07 pm
Reply with quote

Quote:
WER267A SORT STATEMENT : STATEMENT NOT FOUND
Have you coded the SORT statement? Can you show the actual control cards used by your abended job run.
Back to top
View user's profile Send private message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Tue Feb 15, 2011 2:26 am
Reply with quote

I fixed the issue but got another one -

Code:
SYT001I  INITIAL PROCESSING MODE IS "STOP"                                     
SYT002I  "TOOLIN" INTERFACE BEING USED                                         
                                                                               
           COPY FROM(INA)      TO(CTL3JNF1) USING(CTL1)                         
SYT020I  SYNCSORT CALLED WITH IDENTIFIER "0001"                                 
SYT012E  SYNCSORT COMPLETED UNSUCCESSFULLY                                     
SYT030I  OPERATION COMPLETED WITH RETURN CODE 16                               
                                                                               
SYT015I  PROCESSING MODE CHANGED FROM "STOP" TO "SCAN" DUE TO OPERATION FAILURE
                                                                               
           COPY FROM(INB)      TO(CTL3JNF2) USING(CTL2)                         
SYT019I  STATEMENT VALID; NOT PROCESSED DUE TO "SCAN" PROCESSING MODE           
                                                                               
           SORT FROM(CTL3JNF1) TO(OUT)      USING(CTL3)                         
SYT019I  STATEMENT VALID; NOT PROCESSED DUE TO "SCAN" PROCESSING MODE           
                                                                               
SYT004I  SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 16                     
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 15, 2011 2:42 am
Reply with quote

Hello,

Is there some reason you did not post the complete job that caused the most recent error?

You need to post the complete info . . .
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Feb 15, 2011 10:47 am
Reply with quote

Quote:
You need to post the complete info . . .
including your DFSMSG output of the error run.
Back to top
View user's profile Send private message
trilokdewangan

New User


Joined: 19 Jun 2008
Posts: 39
Location: USA

PostPosted: Wed Feb 23, 2011 2:20 am
Reply with quote

Here is the SORT which I used -

Code:
//SORTSTEP EXEC PGM=ICETOOL                                 
//*                                                         
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//INA      DD DISP=SHR,                                     
//            DSN=XXXX.XXXX.XXXX                             
//INB      DD DISP=SHR,                                     
//            DSN=XXXX.XXXX.XXXX                             
//CTL3JNF1 DD DSN=ZZZZ.ZZZ.ZZZ,                                         
//        DISP=(NEW,CATLG,CATLG),                                       
//        UNIT=DASD,SPACE=(CYL,(100,10),RLSE),                         
//        LABEL=RETPD=60                                               
//CTL3JNF2 DD DSN=ZXC.ZXC.ZXC,                                         
//        DISP=(NEW,CATLG,CATLG),                                       
//        UNIT=DASD,SPACE=(CYL,(100,10),RLSE),                         
//        LABEL=RETPD=60                                               
//*----------------------------------------------------------
//*SORTOUT  DD SYSOUT=*                                     
//OUT      DD DISP=(NEW,CATLG,CATLG),                       
//        UNIT=DASD,SPACE=(CYL,(100,10),RLSE),               
//        LABEL=RETPD=60,                                   
//        DSN=YYYYY.YYYYY.YYYYY                             
//*                                                         
//*                                                         
//TOOLIN   DD *                                             
  COPY FROM(INA)      TO(CTL3JNF1) USING(CTL1)               

  COPY FROM(INB)      TO(CTL3JNF2) USING(CTL2)                   
  SORT FROM(CTL3JNF1) TO(OUT)      USING(CTL3)                   
//CTL1CNTL DD *                                                   
 INREC IFTHEN=(WHEN=GROUP,                                       
       END=(1,8,CH,EQ,C'RQSTCNTL'),                               
       PUSH=(2001:ID=8))                                         
//*                                                               
//CTL2CNTL DD *                                                   
  INCLUDE COND=(1,8,CH,EQ,C'RQSTCNTL')                           
  INREC BUILD=(SEQNUM,8,ZD,9,9)                                   
//*                                                               
//CTL3CNTL DD *                                                   
  JOINKEYS FILE=F1,FIELDS=(2001,8,A),SORTED                       
  JOINKEYS FILE=F2,FIELDS=(0001,8,A),SORTED                       
  JOIN UNPAIRED,F1                                               
  REFORMAT FIELDS=(F1:1,2000,F2:9,9)                             
                                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'MAILING'),         
        PUSH=(2010:343,32)),                                     

  IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),OVERLAY=(2001:41C'0')),           
  IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),OVERLAY=(2001:41X'FF'))           
                                                                       
  SORT FIELDS=(2001,41,CH,A),EQUALS                                     
  OUTREC BUILD=(1,2000)                                                 
//*                                                                     


When I execute excluding below SORT
Code:
SORT FIELDS=(2001,41,CH,A),EQUALS                                     
  OUTREC BUILD=(1,2000)     


I see the mailing record's detail doesn't overlayed to customer record (Position from 2010 length = 32) this is why after sorting, CUSTOMER records are misplaced. Here is the screen of output file from position 2010 (from Position 2010, first 9 - RQSTCNTL, rest are MAILING records Length 32) without the final sort (above) {first record - HEADER, 2nd - CUSTOMER, 3rd -MAILING, rest are the records from group}

Code:
00000000000000000000000000000000000000000
999999999                               
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999                       
99999999999999999


Do we need JOINKEY for MAILING records as well ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 23, 2011 3:06 am
Reply with quote

Hello,

I don't have any way to test this but what happens if you change this:
Code:
  SORT FROM(CTL3JNF1) TO(OUT)      USING(CTL3)
to:
Code:
  COPY FROM(CTL3JNF1) TO(OUT)      USING(CTL3)
then remove the problem "SORT" statement. . .

I seem to recall that a SORT cannot be specified within a COPY (but i could be confused).
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Feb 25, 2011 11:24 am
Reply with quote

Hi Dick,

I got busy over the week and could not check the forums. AFAIK JOINKEYS do need a SORT rather than a COPY.

trilokdewangan,

The SYNCTOOL job provided earlier assumes that the CUSTOMER record has the field (343,32) by which you want to sort each CUSTOMER group within an RQST group. But it seems like this is not what you want here. You need to explain clearly the sorting rule to be followed here.

Does CUSTOMER record have the field with which the CUSTOMER groups have to be sorted?
If not, is it the 'MAILING' record which has this field?
Is there only a single 'MAILING' record per 'CUSTOMER' group?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Feb 25, 2011 8:09 pm
Reply with quote

Hi Arun,

Thank you icon_smile.gif

d
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top