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

Syncsort - Report from reading different rows and grouping


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

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Mon Apr 27, 2009 9:18 pm
Reply with quote

In the below first 3 byte determine the record-type and remaining all are different field values.A report is to be generated reading HDR record until next HDR record encountered. Read each of GRP record for first 3 field values followed by next associated SUB records until next GRP record encountered. In the SUB record consider last 2 field value for the report.In the report, Page number to be incremented only within HDR to TRL, as soon as another HDR encountered,Page number to be restarted from 1 again.

Pls let me know if anything unclear.

Thanks in advance for your help,
Raj.

Code:

INPUT:
~~~~~~
HDR TZ100PQRTK200
GRP YAHOO  1000 CAR     XXXXX
SUB MARY  SMITH HONDA  ACCORD
SUB JOHN  SMITH TOYOTA CAMRY
SUB ALEX  SMITH NISSAN MAXIMA
GRP INFY   3114 MINIVAN YYYYY
SUB ANNY  LEADS TOYOTA INNOVA
TRL00006
HDR TZ400PQRTQ300
GRP MICTEK 3111 CAR     ZZZZZ
SUB RAJ   PATEL HONDA  CIVIC
SUB MOHAN JOHN  FORD   MUSTANG
TRL 00003


Output expected:
~~~~~~~~~~~~~~~~

              TZ100PQRTK200         PAGE : 1 
             
ROWHDR1   ROWHDR2    ROWHDR3   ROWHDR4  ROWHDR5
~~~~~~~   ~~~~~~~    ~~~~~~~   ~~~~~~~  ~~~~~~~
YAHOO      1000        CAR      HONDA    ACCORD
YAHOO      1000        CAR      TOYOTA   CAMRY
YAHOO      1000        CAR      NISSAN   MAXIMA
INFY       3114      MINIVAN    TOYOTA   INNOVA


              TZ400PQRTQ300         PAGE : 1
             
ROWHDR1   ROWHDR2    ROWHDR3   ROWHDR4  ROWHDR5
~~~~~~~   ~~~~~~~    ~~~~~~~   ~~~~~~~  ~~~~~~~
MICTEK     3111        CAR      HONDA    CIVIC
MICTEK     3111        CAR      FORD     MUSTANG


[/code]
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Apr 27, 2009 10:41 pm
Reply with quote

rajinfy123,

You can very easily push the hdr and grp hdr using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

I assumed your input to be FB and LRECL 80 .

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                           
----+----1----+----2----+----3----+----4----+----5----+---
HDR TZ100PQRTK200                                         
GRP YAHOO  1000 CAR     XXXXX                             
SUB MARY  SMITH HONDA   ACCORD                           
SUB JOHN  SMITH TOYOTA  CAMRY                             
SUB ALEX  SMITH NISSAN  MAXIMA                           
GRP INFY   3114 MINIVAN YYYYY                             
SUB ANNY  LEADS TOYOTA  INNOVA                           
TRL00006                                                 
HDR TZ400PQRTQ300                                         
GRP MICTEK 3111 CAR     ZZZZZ                             
SUB RAJ   PATEL HONDA   CIVIC                             
SUB MOHAN JOHN  FORD    MUSTANG                           
TRL 00003                                                 
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),     
  END=(1,3,CH,EQ,C'TRL'),PUSH=(81:5,13)),                 
  IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'GRP'),           
  END=(1,3,CH,EQ,C'TRL'),PUSH=(94:5,20))                 
                                                         
  OUTFIL OMIT=(1,3,SS,EQ,C'HDR,GRP,TRL'),REMOVECC,       
  BUILD=(01:94,7,11:101,4,21:105,9,31:17,7,41:25,7,80:X),
  SECTIONS=(81,13,                                       
  HEADER3=(15:81,13,35:'PAGE : ',&PAGE,/,/,               
           01:'ROWHDR1',11:'ROWHDR2',21:'ROWHDR3',       
           31:'ROWHDR4',41:'ROWHDR5',/,                   
           01:'~~~~~~~',11:'~~~~~~~',21:'~~~~~~~',       
           31:'~~~~~~~',41:'~~~~~~~'),                   
  TRAILER3=(//))                                         
/*


The output from this job is

Code:

              TZ100PQRTK200       PAGE :      1 
                                                 
ROWHDR1   ROWHDR2   ROWHDR3   ROWHDR4   ROWHDR5 
~~~~~~~   ~~~~~~~   ~~~~~~~   ~~~~~~~   ~~~~~~~ 
YAHOO     1000       CAR      HONDA     ACCORD   
YAHOO     1000       CAR      TOYOTA    CAMRY   
YAHOO     1000       CAR      NISSAN    MAXIMA   
INFY      3114       MINIVAN  TOYOTA    INNOVA   
                                                 
                                                 
              TZ400PQRTQ300       PAGE :      1 
                                                 
ROWHDR1   ROWHDR2   ROWHDR3   ROWHDR4   ROWHDR5 
~~~~~~~   ~~~~~~~   ~~~~~~~   ~~~~~~~   ~~~~~~~ 
MICTEK    3111       CAR      HONDA     CIVIC   
MICTEK    3111       CAR      FORD      MUSTANG 
                                                 
                                                 

If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
rajinfy123

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Mon Apr 27, 2009 11:38 pm
Reply with quote

When I tried the above shared code, I am getting below error. Does this imply "July, 2008 PTF" is not installed.

Thanks,
Raj

Code:

 SYSIN :                                                           
   SORT FIELDS=COPY                                                 
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),               
                      *                                             
                            END=(1,3,CH,EQ,C'TRL'),PUSH=(81:5,13)),
         IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'GRP'),               
                            END=(1,3,CH,EQ,C'TRL'),PUSH=(94:5,20)) 
                                                                   
   OUTFIL OMIT=(1,3,SS,EQ,C'HDR,GRP,TRL'),REMOVECC,                 
   BUILD=(01:94,7,11:101,4,21:105,9,31:17,7,41:25,7,80:X),         
   SECTIONS=(81,13,                                                 
   HEADER3=(15:81,13,35:'PAGE : ',&PAGE,/,/,                       
            01:'ROWHDR1',11:'ROWHDR2',21:'ROWHDR3',                 
            31:'ROWHDR4',41:'ROWHDR5',/,                           
            01:'~~~~~~~',11:'~~~~~~~',21:'~~~~~~~',                 
            31:'~~~~~~~',41:'~~~~~~~'),                             
   TRAILER3=(//))                                                   
 WER268A  INREC STATEMENT   : SYNTAX ERROR                         
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                     
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                     
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 Apr 28, 2009 12:12 am
Reply with quote

Hello,

No, it shows you are using Syncsort rather than DFSORT.

You need to have the current version of Syncsort to use WHEN=GROUP.
Back to top
View user's profile Send private message
rajinfy123

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Tue Apr 28, 2009 12:49 am
Reply with quote

Seems like new version of DFSORT is not installed at my end. Is there any other way to get the desired output ?

Thanks for your help,
Raj.
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 Apr 28, 2009 2:47 am
Reply with quote

Hello,

Suggest you re-read and understand what was posted previously. . .

You do not use DFSORT, so the DFSORT version/ptf level is not a concern.

You ARE using Syncsort and to use WHEN=GROUP, you need the current version of Syncsort installed. . .

Suggest you talk with your system support about installing the current release.
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 Apr 28, 2009 2:54 am
Reply with quote

Hello,

Your duplicate topic has been removed.

Review this topic and notice that it was relocated from DFSORT to JCL hours ago. . .

I'll delete these non-technical replies when things are "caught up".

I'll also change the title to include Syncsort.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Apr 28, 2009 2:55 am
Reply with quote

Raj, regardless of the program named in your EXEC statement, ICE... prefixed messages indicate DFSORT, WER... prefixed ones mean Syncsort.
Back to top
View user's profile Send private message
rajinfy123

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Tue Apr 28, 2009 2:55 am
Reply with quote

Thank Q Dick Scherrer, I would have to followup on that with the Systems Support which is time consuming. Can I be suggested any other alternate way of creating the report using SYNCSORT ??

Thanks,
Raj.
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 Apr 28, 2009 3:01 am
Reply with quote

Hello,

Quote:
would have to followup on that with the Systems Support which is time consuming
Suggest time would be better consumed getting the current release of the software installed rather than spending time on some work-around because the software was not current.

You could always do this the way we did before sort products had this functionality - write your "own code" to read the file and create the required output.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 28, 2009 3:06 am
Reply with quote

rajinfy123 wrote:
Thank Q Dick Scherrer, I would have to followup on that with the Systems Support which is time consuming. Can I be suggested any other alternate way of creating the report using SYNCSORT ??
rajinfy123 wrote:
Code:

 SYSIN :                                                           
   SORT FIELDS=COPY                                                 
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),               
                      *                                             
                            END=(1,3,CH,EQ,C'TRL'),PUSH=(81:5,13)),
         IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'GRP'),               
                            END=(1,3,CH,EQ,C'TRL'),PUSH=(94:5,20)) 
                                                                   
   OUTFIL OMIT=(1,3,SS,EQ,C'HDR,GRP,TRL'),REMOVECC,                 
   BUILD=(01:94,7,11:101,4,21:105,9,31:17,7,41:25,7,80:X),         
   SECTIONS=(81,13,                                                 
   HEADER3=(15:81,13,35:'PAGE : ',&PAGE,/,/,                       
            01:'ROWHDR1',11:'ROWHDR2',21:'ROWHDR3',                 
            31:'ROWHDR4',41:'ROWHDR5',/,                           
            01:'~~~~~~~',11:'~~~~~~~',21:'~~~~~~~',                 
            31:'~~~~~~~',41:'~~~~~~~'),                             
   TRAILER3=(//))                                                   
 WER268A  INREC STATEMENT   : SYNTAX ERROR                         
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                     
 WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                     
The top line of the above sysout should include the version of Syncsort, please post it.
Back to top
View user's profile Send private message
rajinfy123

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Tue Apr 28, 2009 3:15 am
Reply with quote

SYNCSORT FOR Z/OS 1.3.0.2N
Back to top
View user's profile Send private message
rajinfy123

New User


Joined: 09 Jul 2004
Posts: 12

PostPosted: Wed Apr 29, 2009 1:44 am
Reply with quote

Quote:

You ARE using Syncsort and to use WHEN=GROUP, you need the current version of Syncsort installed. . .


Can anyone share which latest version of SYNCSORT has the capability of WHEN=GROUP functionality

Thanks,
Raj
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 Apr 29, 2009 1:55 am
Reply with quote

Hello,

Please look at this similar topic:
ibmmainframes.com/viewtopic.php?t=38889

From that topic:
Quote:
This can also be accomplished in a single step using SyncSort for z/OS 1.3.2:


You might also want to open an issue with Syncsort Support or Alissa Margulies.
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 To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
Search our Forums:

Back to Top