I need the full blocks (4 lines blocks) starting with line: "-----------------------------" where substring "AAA" can be found anywhere.
I have used this code
. . . . . . . .
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(35:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'-'),PUSH=(31:ID=4)),
IFTHEN=(WHEN=(1,30,SS,EQ,C'AAA'),OVERLAY=(35:C'XX'))
SUM FIELDS=(35,2,BI)
END
/*
In case there are more than 1 line with 'AAA' in a group, the SUM FIELDS=(35,2,BI) should calculate C'XX' + C'XX', and produce unpredictable value, not detected in the main SORT processing...
It may be better to use OVERLAY=(35:X'0001'), and check for INCLUDE=(31,2,BI,GT,X'0000')
Hello
Thank you for the codes.
Is there any way, if we have more input Datasets?
I mean, I want to do the search in the last 10 or more Generations (in case of GDG Datases).
Many thanks for the answer.
Hello
Thank you for the codes.
Is there any way, if we have more input Datasets?
I mean, I want to do the search in the last 10 or more Generations (in case of GDG Datases).
Many thanks for the answer.
There are 2 options:
1) if record format (and layout) for all input datasets is the same (as it is for GDG datasets), you can concatenate any number of them under //SORTIN DD
2) in all other circumstances you can use PARM=MULTIIN option (maybe, only for SYNCSORT? I don't recall now, lazy to RTFM again). In that case each (different) input dataset is defined under its own //SORTINnn DD, where nn=00-99
As I am a DFSORT beginner, during the code conversation to my real situation, I realized, that my first logic was not correct (sorry for that).
So here I am doing a better description which fit for my real situation:
Record format . . . : FB
Record length . . . : 133
the GROUP should start with DSNAME= and ended with - (group can contain different number of lines)
Dataset I am loking for is: AAA.BBB.CCC
Input (FB/133)
Code:
---
DSNAME=AAA.BBB.CCC OTHER DETAILS
DSNEW=XAG.WOW.LOL.YES OTHER DETAILS
DATE TIME
OTHER DETAILS
---
DSNAME=CCC.BBB.CCC
DSNEW=XAG.AAA.BBB.DDD
DATE TIME
OTHER DETAILS
---
DSNAME=KKK.BBB.CCC OTHER DETAILS
DSNEW=XAG.OOO.TTT.CCC OTHER DETAILS
DATE TIME
OTHER DETAILS
OTHER DETAILS
OTHER DETAILS
---
DSNAME=XAG.YES.EGG.FINE OTHER DETAILS
DSNEW=AAA.BBB.CCC OTHER DETAILS
DATE TIME
OTHER DETAILS
OTHER DETAILS
---
here is my working code where I add the required DS as variable, but maybe some step can be merged as there are some unnecessary ones in my logic:
result is fine (there is the GROUP identifier at the end of every lines what I am not describing here):
Code:
DSNAME=AAA.BBB.CCC OTHER DETAILS
DSNEW=XAG.WOW.LOL.YES OTHER DETAILS
DATE TIME
OTHER DETAILS
---
DSNAME=XAG.YES.EGG.FINE OTHER DETAILS
DSNEW=AAA.BBB.CCC OTHER DETAILS
DATE TIME
OTHER DETAILS
OTHER DETAILS
---
I understand now my code, but my question, there any way to create the same result with less code?
Joined: 15 Aug 2015 Posts: 1308 Location: Bamberg, Germany
The &DSN01 variable should be coded with a starting equal sign in your sample, otherwise you will have false positives. With your recent updates you have ended up with three ICETOOL steps where only one SORT step is actually required, see below:
Code:
//WHATEVER EXEC PGM=ICEMAN
//F1 DD ..
//F2 DD .. same as F1
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(136,8,A)
JOINKEYS F2=F2,FIELDS=(136,8,A)
REFORMAT FIELDS=(F1:1,133,F2:134,10)
OUTFIL FNAMES=(SORTOUT),
OMIT=(134,2,BI,EQ,+0),
BUILD=(1,133)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,END=(1,1,CH,EQ,C'-'),PUSH=(136:ID=8))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(134:2Z)),
IFTHEN=(WHEN=GROUP,END=(1,1,CH,EQ,C'-'),PUSH=(136:ID=8)),
IFTHEN=(WHEN=(1,133,SS,EQ,C'=AAA.BBB.CCC '),
OVERLAY=(134:+1,BI,LENGTH=2))
SUM FIELDS=(134,2,BI)
END
/*
Btw, using SubString with fixed positions, or only one choice, makes no sense. Use other comparison methods instead.
Hello All,
First of all I would like to say sorry if I did something insulting somebody.
The reason why I also working on the proper code on my way that we are working on the rebuild of a lot of Checker Jobs on our systems, and I want to use codes what I understand.
That's why I asked again for help after my code.
I got the JOINKEYS idea from Joerg, and I found a very good documentation then I was able to understand it's working method and the logic here - but for the SUM, FNAMES and the OVERLAY not yet.
As I we want to use DFSORT instead of REXX in many cases (because of the performance), then I need to understand the whole code.
I am still thinking about the suggested code how it work.
Also I would like to tell you that this is my second DFSORT code and still a "bit" hard task to understand the working method.
Many thanks for your help and for your understanding for both of you.
1) Processing of JNF1CNTL and JNF2CNTL
1a) INREC assigns a unique ID to each of your blocks, and adds a counter of all found matches. The counter is initialized with HEXZEROS, but updated on a match.
2) JOINKEYS Processing (basically a SORT/MERGE)
3) SUMming up the counter introduced in 1a)
4) JOIN/REFORMAT based on the unique ID, that is
4a) Original record plus ID and counter of matches per block
5) OUTFIL processing is the report part, FNAMES tells what DD to write the OUTPUT to
5a) OMIT all blocks with no matches and reBUILD the original RECORD (length 133)