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
 

 

Syncsort - Group Records, count of groups, count in trailer

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 17, 2014 2:57 pm    Post subject: Syncsort - Group Records, count of groups, count in trailer
Reply with quote

Hi All,

I have a file with a record identifier in each record @ 10th position.

Record identifiers are
Code:
01-Header
99-Trailer
10-Start of record


Data records are grouped until the availability of "10" or "99" in the next record
Original file needs to be split based on another identifier in Record type-10 -"A" -Addition, "U"-Updates, "D" - Deletes

After the split, each file should have a Trailer record similar to the one in original file along with the count of "10" type records

I am able to split the file into 3 different files but unable to get the count in the trailer record. Can anyone help.

Below is the code that I have written for split the files.

Code:

Input File: DCB=(LRECL=80,RECFM=FB)

//TOOLIN   DD *                             
  COPY  FROM(IN)   TO(TEMP)      USING(CTL1)
  COPY  FROM(TEMP) TO(UPD,DEL)   USING(CTL2)
//CTL1CNTL DD *   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),
                            PUSH=(81:16,1,         
                                  82:ID=8)),       
        IFTHEN=(WHEN=(10,2,CH,EQ,L(C'01',C'99')),   
                            BUILD=(01:1,80,         
                                  81:1C'0',         
                                  82:8C'0'))       
  OUTREC IFTHEN=(WHEN=INIT,BUILD=(1:82,8,X,
                                  10:81,1,X,
                                  12:1,80))
  SORT FIELDS=COPY                             
/*
//CTL2CNTL DD *                                 
  OUTFIL FNAMES=UPD,                           
         INCLUDE=(10,1,CH,EQ,L(C'A',C'U',C'0')),
         BUILD=(12,80)
  OUTFIL FNAMES=DEL,                           
         INCLUDE=(10,1,CH,EQ,L(C'D',C'0')),     
         BUILD=(12,80)
  SORT FIELDS=COPY                             
/*                                             
Back to top
View user's profile Send private message

mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Jul 17, 2014 6:26 pm    Post subject:
Reply with quote

What's the starting position of first identifier:
Code:
01-Header
10-Start of record
99-Trailer

What's the starting position of another identifier:
Code:
"A" -Addition, "U"-Updates, "D" - Deletes

Can you post some sample input data and expected output?
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 17, 2014 8:13 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

First identifier is 2bytes starting at 10th position
Second identifier s 1byte starting at 16th position

Sample data
Code:

Header   01
DetailRec10DATAU
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec10dataA
Detailrec20data
Detailrec30data
Detailrec10dataD
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec50data
Detailrec10dataA
Detailrec20data
Detailrec30data
Trailer  99
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 17, 2014 8:46 pm    Post subject:
Reply with quote

I am able to get the output files, but without the trailer record + count of "10" type records

Expected Output Update file
Code:
Header   01
DetailRec10DATAU
Detailrec20data
Detailrec30data
Detailrec40data
Trailer  99 00001


Expected output Add file
Code:
Header   01 
Detailrec10dataA
Detailrec20data
Detailrec30data
Detailrec10dataA
Detailrec20data
Detailrec30data
Trailer  99 00002


Expected output Delete file
Code:
Header   01
Detailrec10dataD
Detailrec20data
Detailrec30data
Detailrec40data
Detailrec50data
Trailer  99 00001
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Fri Jul 18, 2014 3:19 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

Can someone help please with the approach or solution?
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Jul 22, 2014 3:17 pm    Post subject:
Reply with quote

try something on the below lines.

Code:
//STEP01   EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
HEADER   01                                                           
DETAILREC10DATAU                                                     
DETAILREC20DATA                                                       
DETAILREC30DATA                                                       
DETAILREC40DATA                                                       
DETAILREC10DATAA                                                     
DETAILREC20DATA                                                       
DETAILREC30DATA                                                       
DETAILREC10DATAD                                                     
DETAILREC20DATA                                                       
DETAILREC30DATA                                                       
DETAILREC40DATA                                                       
DETAILREC50DATA                                                       
DETAILREC10DATAA                                                     
DETAILREC20DATA                                                       
DETAILREC30DATA                                                       
TRAILER  99                                                           
//F1       DD SYSOUT=*                                               
//F2       DD SYSOUT=*                                               
//F3       DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC  IFTHEN=(WHEN=GROUP,BEGIN=(10,02,CH,EQ,L(C'10',C'01',C'99')),
                            PUSH=(81:16,1))                           
  OUTREC IFTHEN=(WHEN=INIT,                                           
                      OVERLAY=(82:C'00000')),                         
         IFTHEN=(WHEN=(16,1,CH,EQ,L(C'A',C'D',C'U')),                 
                      OVERLAY=(82:C'00001'))                         
  OUTFIL INCLUDE=(81,1,CH,EQ,C'A'),FNAMES=F1,BUILD=(1,80),           
         REMOVECC,HEADER1=(1:'HEADER   01'),                         
                  TRAILER1=(1:'TRAILER  99',                         
                           15:TOT=(82,5,ZD,EDIT=(TTTTT)))             
  OUTFIL INCLUDE=(81,1,CH,EQ,C'U'),FNAMES=F2,BUILD=(1,80),           
         REMOVECC,HEADER1=(1:'HEADER   01'),                         
                  TRAILER1=(1:'TRAILER  99',                         
                           15:TOT=(82,5,ZD,EDIT=(TTTTT)))             
  OUTFIL INCLUDE=(81,1,CH,EQ,C'D'),FNAMES=F3,BUILD=(1,80),           
         REMOVECC,HEADER1=(1:'HEADER   01'),                         
                  TRAILER1=(1:'TRAILER  99',                         
                           15:TOT=(82,5,ZD,EDIT=(TTTTT)))             


Output

F1
Code:
HEADER   01                                                             
DETAILREC10DATAA                                                       
DETAILREC20DATA                                                         
DETAILREC30DATA                                                         
DETAILREC10DATAA                                                       
DETAILREC20DATA                                                         
DETAILREC30DATA                                                         
TRAILER  99   00002                                                     

F2
Code:
HEADER   01                                                             
DETAILREC10DATAU                                                       
DETAILREC20DATA                                                         
DETAILREC30DATA                                                         
DETAILREC40DATA                                                         
TRAILER  99   00001                                                     

F3
Code:
HEADER   01                                                             
DETAILREC10DATAD                                                       
DETAILREC20DATA                                                         
DETAILREC30DATA                                                         
DETAILREC40DATA                                                         
DETAILREC50DATA                                                         
TRAILER  99   00001                                                     
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Tue Jul 22, 2014 6:26 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

Thanks, mistah kurtz

The solution you have posted is working fine. TA.

Is there any way I can preserve the header and use it in all the output files. My header is around 150 in length, which I cannot format using HEADER1.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Jul 22, 2014 6:36 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

Yes, use AND in the INCLUDE=s.

You'll need to make sure it doesn't get included in the count, so set the count value to zero and locate the count at the end of the header or data record, whichever is longer. The count need only be one digit.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Tue Jul 22, 2014 7:22 pm    Post subject:
Reply with quote

There should be some way, but I will have to think about that. Meanwhile you can write your header/trailer in more than one line like this:
Code:
HEADER1=(1:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  50:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
 100:'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Tue Jul 22, 2014 7:34 pm    Post subject:
Reply with quote

Thanks, Bill, mistah kurtz

I have OVERLAYed the header record using IFTHEN in INREC, and then INCLUDed in the 3 OUTFILs. This works fine.
Back to top
View user's profile Send private message
JAYACHANDRAN THAMPY

New User


Joined: 06 Jun 2006
Posts: 8

PostPosted: Wed Jul 23, 2014 4:42 pm    Post subject:
Reply with quote

If you are having Syncsort V1.4.2 , then you can use IFTRAIL parameter in OUTFIL statement to get the desired results. JCL listed below

Code:
//STEP010  EXEC PGM=SORT                                         
//SYSOUT    DD SYSOUT=*                                         
//SORTIN   DD *                                                 
HEADER   01                                                     
DETAILREC10DATAU                                                 
DETAILREC20DATA                                                 
DETAILREC30DATA                                                 
DETAILREC40DATA                                                 
DETAILREC10DATAA                                                 
DETAILREC20DATA                                                 
DETAILREC30DATA                                                 
DETAILREC10DATAD                                                 
DETAILREC20DATA                                                 
DETAILREC30DATA                                                 
DETAILREC40DATA                                                 
DETAILREC50DATA                                                 
DETAILREC10DATAA                                                 
DETAILREC20DATA                                                 
DETAILREC30DATA                                                 
TRAILER  99                                                     
//ADD       DD SYSOUT=*                                         
//UPD       DD SYSOUT=*                                         
//DEL       DD SYSOUT=*                                         
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),           
                              PUSH=(151:16,1)),                 
         IFTHEN=(WHEN=(10,2,CH,EQ,C'10'),OVERLAY=(152:C'0001')),
         IFTHEN=(WHEN=NONE,OVERLAY=(152:C'0000'))               
  OUTFIL FNAMES=ADD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
    TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),                   
    INCLUDE=(151,1,CH,EQ,C'A'),BUILD=(1,150)                     
  OUTFIL FNAMES=UPD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
    TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),                   
    INCLUDE=(151,1,CH,EQ,C'U'),BUILD=(1,150)                     
  OUTFIL FNAMES=DEL,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),
    TRLUPD=(16:TOT=(152,4,ZD,M11,LENGTH=4))),                         
    INCLUDE=(151,1,CH,EQ,C'D'),BUILD=(1,150)                         
//*                                                                   


ADD Output
Code:
HEADER   01             
DETAILREC10DATAA       
DETAILREC20DATA         
DETAILREC30DATA         
DETAILREC10DATAA       
DETAILREC20DATA         
DETAILREC30DATA         
TRAILER  99    0002

UPD Output
Code:
HEADER   01                 
DETAILREC10DATAU             
DETAILREC20DATA             
DETAILREC30DATA             
DETAILREC40DATA             
TRAILER  99    0001         

DEL output
Code:
HEADER   01                 
DETAILREC10DATAD           
DETAILREC20DATA             
DETAILREC30DATA             
DETAILREC40DATA             
DETAILREC50DATA             
TRAILER  99    0001


Code'd
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 24, 2014 2:20 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

Thanks,

I was looking for the same and searched a couple of remaining post. Got IFTRAIL, tried and tested, working fine.

Where can I get the IFTRAIL documentation/manual?

We are using 1.4.2, but the manual available is still for 1.2
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Jul 24, 2014 2:28 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

Someone in your site is responsible for contact with SyncSort. Arrange that they gain access to the current manuals for everyone, or that they allow you to contact SyncSort support to do it yourself.

Sometimes new SyncSort features do not appear in the documentation for a while. Sometimes a long while.
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 24, 2014 4:06 pm    Post subject:
Reply with quote

Hi Again,

Everything till this point was fine. I could get the manual but it has no documentation of IFTRAIL.

I have rearranged the startpos and length based on my requirement.

My I/P file is a VB of 18448. And hence I shifted any Overlays in the beginning by making a 10 byte space at the starting of each record.

Now, with this change, my header and trailer start with '0000' in the final output. Can this be avoided/handled?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Jul 24, 2014 4:17 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

If you BUILD on OUTFIL to only include the data you want, that's the usual way for a variable-length record.

Code:
  BUILD=(1,4,15)


This says "make a new record, with 1,4 from the current record, and then position 15 to the end of the record, from the current record. Then make this new record the current record, replacing the previous current record".

Often when SyncSort play catch-up it is not included in the documentation. Perhaps we should start our own list...
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Thu Jul 24, 2014 4:24 pm    Post subject:
Reply with quote

At our site, we have Syncsort 1.4.1 and I think it does not support IFTRAIL.
Code:
SYNCSORT FOR Z/OS  1.4.1.0R    U.S. PATENTS: 4210961, 5117495   (C) 2010 SYNCSORT INC.
                                                      z/OS   2.1.0     
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 2A807, MODEL 2827 503           
SYSIN :                                                                 
   OPTION COPY                                                         
   OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(10,2,CH,EQ,C'10'),                 
                               PUSH=(81:16,1)),                         
          IFTHEN=(WHEN=(10,2,CH,EQ,C'10'),OVERLAY=(82:C'0001')),       
          IFTHEN=(WHEN=NONE,OVERLAY=(82:C'0000'))                       
   OUTFIL FNAMES=ADD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),     
                     *                                                 
     TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),                           
     INCLUDE=(81,1,CH,EQ,C'A'),BUILD=(1,80)                             
   OUTFIL FNAMES=UPD,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),     
                     *                                                 
     TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),                           
     INCLUDE=(81,1,CH,EQ,C'U'),BUILD=(1,80)                             
   OUTFIL FNAMES=DEL,IFTRAIL=(HD=YES,TRLID=(1,7,CH,EQ,C'TRAILER'),     
                     *                                                 
     TRLUPD=(16:TOT=(82,4,ZD,M11,LENGTH=4))),                           
     INCLUDE=(81,1,CH,EQ,C'D'),BUILD=(1,80)                             
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                               
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                               
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                               
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 24, 2014 4:25 pm    Post subject:
Reply with quote

Completely agree with you, Bill.

I had done the same as you have suggested, but this is only applicable for details records; Header and Trailer are not getting impacted as we have used IFTRAIL, & HD=YES. H/T start with 0 (used in PUSH) followed by 4 more zeros.

I want to OVERLAY the records in the beginning because -
1) Want to maintain the length from the input record,
2) I could have used VLTRIM=X'40' but most of my input records end with x'40', and hence VLTRIM will not be helpful

Code:
000000    HEADER   01                 
DETAILREC10DATAU             
DETAILREC20DATA             
DETAILREC30DATA             
DETAILREC40DATA             
000000    TRAILER  99    0001         
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Thu Jul 24, 2014 5:53 pm    Post subject: Reply to: Syncsort - Group Records, count of groups, count i
Reply with quote

You need to give OUTFIL the formatted trailers that you want to see, and then change the count with the TRLUPD. So do a conditional BUILD, for the trailer only, in INREC (or OUTREC if that is what you are using).
Back to top
View user's profile Send private message
TS70363

New User


Joined: 07 Apr 2010
Posts: 93
Location: Bangalore, India

PostPosted: Thu Jul 24, 2014 6:29 pm    Post subject:
Reply with quote

Thanks, Bill

Worked fine.
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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