Page 1 of 1

Syncsort Question

PostPosted: Thu Nov 28, 2013 2:06 am
by rayngerfan
I have a file that contains the following records. The records starts in col 1 - 10 and is FB. I want to extract only the ACCESSORID records that aren't proceeded by a ATTRIBUTRES record. In the below data record ACCESSORID = P000005 wouldn't be extracted because it is proceeded by record ATTRIBUTES = ASUSPEND. These records wouldn't be extracted (ACCESSORID = P000005 , ACCESSORID = PCCCCCC , ACCESSORID = PZZZZZZ). Using SYNCSORT FOR Z/OS 1.4.0.0. Any help is greatly appreciated.


ACCESSORID = P000001
ACCESSORID = P000002
ACCESSORID = P000003
ACCESSORID = P000004
ACCESSORID = P000005
ATTRIBUTES = ASUSPEND
ACCESSORID = PAAAAAA
ACCESSORID = PBBBBBB
ACCESSORID = PCCCCCC
ATTRIBUTES = ASUSPEND
ACCESSORID = PXXXXXX
ACCESSORID = PDDDDDD
ACCESSORID = PRRRRRR
ACCESSORID = PYYYYYY
ACCESSORID = PZZZZZZ
ATTRIBUTES = ASUSPEND


Code'd

Re: Syncsort Question

PostPosted: Thu Nov 28, 2013 3:02 am
by Akatsukami
rayngerfan wrote:I have a file that contains the following records. The records starts in col 1 - 10 and is FB. I want to extract only the ACCESSORID records that aren't succeeded by a ATTRIBUTRES record. In the below data record ACCESSORID = P000005 wouldn't be extracted because it is succeeded by record ATTRIBUTES = ASUSPEND. These records wouldn't be extracted (ACCESSORID = P000005 , ACCESSORID = PCCCCCC , ACCESSORID = PZZZZZZ). Using SYNCSORT FOR Z/OS 1.4.0.0. Any help is greatly appreciated.

Re: Syncsort Question

PostPosted: Thu Nov 28, 2013 4:03 am
by Thampy
Please try the below Syncsort JCL. I asssume the input file record length is 80.

//STEP010   EXEC PGM=SORT                                   
//SYSOUT    DD   SYSOUT=*                                   
//SORTIN     DD *                                           
ACCESSORID = P000001                                       
ACCESSORID = P000002                                       
ACCESSORID = P000003                                       
ACCESSORID = P000004                                       
ACCESSORID = P000005                                       
ATTRIBUTES = ASUSPEND                                       
ACCESSORID = PAAAAAA                                       
ACCESSORID = PBBBBBB                                       
ACCESSORID = PCCCCCC                                       
ATTRIBUTES = ASUSPEND                                       
ACCESSORID = PXXXXXX                                       
ACCESSORID = PDDDDDD                                       
ACCESSORID = PRRRRRR                                       
ACCESSORID = PYYYYYY                                       
ACCESSORID = PZZZZZZ                                       
ATTRIBUTES = ASUSPEND                                       
//SYSIN     DD   *                                         
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,10,CH,EQ,C'ACCESSORID'),
                          PUSH=(81:ID=4,85:SEQ=4))         
 SORT FIELDS=(81,4,ZD,A)                       
 SUM FIELDS=(85,4,ZD)                         
 OUTFIL INCLUDE=(85,4,ZD,EQ,1),BUILD=(1,80)
//SORTOUT   DD SYSOUT=*


Code'd

Re: Syncsort Question

PostPosted: Thu Nov 28, 2013 4:59 am
by BillyBoyo
It is unclear from your description whether you want the ATTRIBUTES records in the output. You don't say you don't, but they would have the same destructive effect next time you run the job, if kept.

If you file is as simple as that, and will remain so, then you can retain the idea of the SUM but avoid the SORT by using MERGE with a single SORTIN01 DD.

If your file, or your processing, is more complicated, you could have a look at http://ibmmainframes.com/about60582.html.

If your SyncSort was just a little more up-to-date you'd have access to JNFnCNTL files, and you could look at a JOINKEYS solution (follow the links for an example). SyncSort do provide a patch to allow JNFnCNTL for 1.4.0, so as a longer term thing, it would be useful to arrange for that.

Without JOINKEYS, the other solution is possible for you.

The idea is to arrange that each record ends up also containing the data from the previous record. The way you pass data from one record to another is WHEN=GROUP with PUSH. If you just PUSH for every record, you'll have the extra data overwritten before you can use it. So, for alternate records, the entire record is PUSHed into different locations.

For your case, you will then be interested in looking at the "record after". If that record is not ATTRIBUTES, output the correct stored record.

If you do not have a trailer on the file, you will need to create a dummy one. This is done in a simple SORT step prior to this, which has the same file for SORTIN but which will only process the first record.

OPTION COPY,STOPAFT=1
INREC OVERLAY=(C'TRAILER DUMMY')

Give that SORTOUT a DSN.

You then have a dummy trailer, which has the same attributes as your input file on SORTIN, which you can simply concatenate to your actual input on SORTIN.

When you identify TRAILER DUMMY in your code (or whatever actual trailer identifier, if you have one) you output a record if it is not ATTRIBUTES.

Re: Syncsort Question

PostPosted: Thu Nov 28, 2013 8:02 pm
by rayngerfan
Hi Thampy & BillyBoyo

I tried the below card which worked.

//SYSIN     DD   *
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,10,CH,EQ,C'ACCESSORID'),
                          PUSH=(81:ID=4,85:SEQ=4))
 SORT FIELDS=(81,4,ZD,A)
 SUM FIELDS=(85,4,ZD)
 OUTFIL INCLUDE=(85,4,ZD,EQ,1),BUILD=(1,80)
//SORTOUT   DD SYSOUT=*


I would like to understand how the parameters work. The ID number for the ACCESSORID record before the ATTRIBUTES record are the same, but the SEQ number is 0002. Not sure how the SUM Fields works?
00010001
00020001
00030001
00040001
00050001
00050002  ( ATTRIBUTES Record)


Thanks for your help