I am trying to write a Fileaid jcl where i give an input PS dataset to the JCL in which there are lot of content out of which I need to extract the complete paragraph which has successful keyword in it.
The Content of the PS dataset is like this,
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
The content of my PS dataset repeats in the above format one after the other including those which are not successful.
I was writing a JCL which should search for Successful keyword and should extract the whole paragraph which has successful keyword in it and not those which has failed keyword in it.
Below is the Sample JCL i wrote but not getting any success.
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
Code:
//WHATEVER EXEC PGM=ICEMAN,PARM='MSG=AP'
//F1 DD * <* F1 is exactly the same as F2
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//F2 DD *
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SUCCESS DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(50,8,A),SORTED,NOSEQCK
JOINKEYS F2=F2,FIELDS=(50,8,A)
REFORMAT FIELDS=(F1:1,49,F2:60,2)
OUTFIL FNAMES=(SORTOUT),
OMIT=(50,2,BI,EQ,+0),
REMOVECC,
BUILD=(1,49)
OUTFIL FNAMES=(SUCCESS),
REMOVECC,SAVE,
BUILD=(1,49)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8)),
IFTHEN=(WHEN=(1,49,SS,EQ,C' FAILED '),OVERLAY=(60:+1,BI,LENGTH=2))
SUM FIELDS=(60,2,BI)
END
/*
DD:SORTOUT will have all the failed stuff. DD:SUCCESS is for the successful parts.
//WHATEVER EXEC PGM=ICEMAN,PARM='MSG=AP'
//F1 DD * <* F1 is exactly the same as F2
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//F2 DD *
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SUCCESS DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(50,8,A),SORTED,NOSEQCK
JOINKEYS F2=F2,FIELDS=(50,8,A)
REFORMAT FIELDS=(F1:1,49,F2:60,2)
OUTFIL FNAMES=(SORTOUT),
OMIT=(50,2,BI,EQ,+0),
REMOVECC,
BUILD=(1,49)
OUTFIL FNAMES=(SUCCESS),
REMOVECC,SAVE,
BUILD=(1,49)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8)),
IFTHEN=(WHEN=(1,49,SS,EQ,C' FAILED '),OVERLAY=(60:+1,BI,LENGTH=2))
SUM FIELDS=(60,2,BI)
END
/*
DD:SORTOUT will have all the failed stuff. DD:SUCCESS is for the successful parts.
Thank you Joerg for helping.
But I didn't understand, why have you created F1 and F2 ?
I have a PS file where all this data exists and can be many in existence one after the other. So, instead of writing the data directly into the JCL in F1 and F2, can't it be pulled directly from a PS file where all these data exist.
I do not have access to mainframe till next week. Please try this simplified version.
Your homework is: please detect possible typos while I cannot do it.
I do not have access to mainframe till next week. Please try this simplified version.
Your homework is: please detect possible typos while I cannot do it.
DD:FAILURE will have all the failed stuff. DD:SUCCESS is for the successful parts.
Thanks Sergey.
I did solve the syntax errors in it and the code executed. But somehow the logic is not correct. I didn't get the DD SUCCESS at all. and in the DD FAILURE, it captured everything from the PS provided.
I did solve the syntax errors in it and the code executed. But somehow the logic is not correct. I didn't get the DD SUCCESS at all. and in the DD FAILURE, it captured everything from the PS provided.
Try to extend BUILD=(1,80) to BUILD=(1,80,X,81,8,X,89,2,BI,EDIT=(TTTT))
- in order to verify intermediate data.
//WHATEVER EXEC PGM=ICEMAN,PARM='MSG=AP'
//F1 DD * <* F1 is exactly the same as F2
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//F2 DD *
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SUCCESS DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(50,8,A),SORTED,NOSEQCK
JOINKEYS F2=F2,FIELDS=(50,8,A)
REFORMAT FIELDS=(F1:1,49,F2:60,2)
OUTFIL FNAMES=(SORTOUT),
OMIT=(50,2,BI,EQ,+0),
REMOVECC,
BUILD=(1,49)
OUTFIL FNAMES=(SUCCESS),
REMOVECC,SAVE,
BUILD=(1,49)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(60:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'ALGORITHM'),PUSH=(50:ID=8)),
IFTHEN=(WHEN=(1,49,SS,EQ,C' FAILED '),OVERLAY=(60:+1,BI,LENGTH=2))
SUM FIELDS=(60,2,BI)
END
/*
I added REGION parameter and this code works. And the logic solves much better than the later. I got close to the desired output, really thanks for the effort. But one thing is the problem, and which I have been trying to sort out also is that it builds only 49 records in a single line and moves to the other since the BUILD parameter is also for 49 record length. But some of the lines of the PS file has more than 70 records in a line(record format and length FBA 80). I tried to modify the code but i am not successful in that. But anyways really appreciate to be so close to the desired output atleast. I will see what I can do.
I added REGION parameter and this code works. And the logic solves much better than the later. I got close to the desired output, really thanks for the effort. But one thing is the problem, and which I have been trying to sort out also is that it builds only 49 records in a single line and moves to the other since the BUILD parameter is also for 49 record length. But some of the lines of the PS file has more than 70 records in a line(record format and length FBA 80). I tried to modify the code but i am not successful in that. But anyways really appreciate to be so close to the desired output atleast. I will see what I can do.
Don't know about others, but I'm not able to understand any issue of this long sentence.
What are "records in one line"?????!!!!!
What is REGION parameter? Where it is, and how it is used?
If your input format is really FBA/80, then:
1) the position 1 of each record should contain Print Control Character, and all you other input is shifted 1 position to the right
2) each "line" = "record" is exactly 80 characters in size. THE LINE CANNOT CONTAIN ANY RECORDS INSIDE!!!
3) any your failed attempt described as "i am not successful in that" is absolutely useless without clear explanation.
I repeated my example on real mainframe, and only changed counter format from BI to ZD, for clarity during debugging. Everything is working fine, despite your unknown problems with it.
Code:
//*ICETOOL EXEC PGM=ICETOOL,
//SYNCTOOL EXEC PGM=SYNCTOOL,
// PARM='MSG=AP'
//TOOLMSG DD SYSOUT=*
//DFMSG DD SYSOUT=* FOR ICETOOL
//SSMSG DD SYSOUT=* FOR SYNCTOOL
//*
//*INPUT DD DISP=SHR,DSN=INPUT_DATASET
//INPUT DD *
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
//*
//INPUTSEQ DD SPACE=(TRK,(100,100)) RENUMBERED INPUT
//SELECTOR DD SPACE=(TRK,(5,5)) CALCULATION OF ' FAILED '
//*
//FAILURE DD SYSOUT=* FAILED PARAGRAPHS
//SUCCESS DD SYSOUT=* SUCCESS PARAGRAPHS
//*
//TOOLIN DD *
COPY FROM(INPUT) TO(INPUTSEQ,SELECTOR) USING(GRPS)
COPY JKFROM TO(FAILURE,SUCCESS) USING(SPLT)
//*
//GRPSCNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(89:C'00')),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,9,CH,EQ,C'ALGORITHM'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=(1,80,SS,EQ,C' FAILED '),
OVERLAY=(89:C'01'))
OUTFIL FNAMES=(INPUTSEQ)
OUTFIL FNAMES=(SELECTOR),
REMOVECC,NODETAIL,
SECTIONS=(81,8,
TRAILER3=(81:81,8,
TOT=(89,2,ZD,EDIT=(TT))))
//*
//SPLTCNTL DD *
JOINKEYS F1=INPUTSEQ,
FIELDS=(81,8,A),
SORTED
JOINKEYS F2=SELECTOR,
FIELDS=(81,8,A),
SORTED
REFORMAT FIELDS=(F1:1,80,
F2:81,10)
OUTFIL FNAMES=SUCCESS,
OMIT=(89,2,ZD,GT,+0),
BUILD=(1,80,X,81,8,X,89,2)
OUTFIL FNAMES=FAILURE,
SAVE,
BUILD=(1,80,X,81,8,X,89,2)
//*
Code:
********************************* TOP OF DATA ***************************************************
ALGORITHM 00000002 01
++THIS IS THE OUTPUT FROM LINK EDIT: 00000002 01
UPDATE FROM THE MASTER 00000002 01
THE JOBNAME IS = 'MYJCL' 00000002 01
RESULT OF THE JOB: 00000002 01
JCLCODE = 0000, EXECUTION FAILED 00000002 01
JCLCODE = 00000 SQL RETURN CODE 00000002 01
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION 00000002 01
JCLCODE = 0000 0000 0000 0000 INFORMATION 00000002 01
SUCCESSFUL UPDATE 00000002 01
ALGORITHM 00000003 01
++THIS IS THE OUTPUT FROM LINK EDIT: 00000003 01
UPDATE FROM THE MASTER 00000003 01
THE JOBNAME IS = 'MYJCL' 00000003 01
RESULT OF THE JOB: 00000003 01
JCLCODE = 0000, EXECUTION FAILED 00000003 01
JCLCODE = 00000 SQL RETURN CODE 00000003 01
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION 00000003 01
JCLCODE = 0000 0000 0000 0000 INFORMATION 00000003 01
SUCCESSFUL UPDATE 00000003 01
******************************** BOTTOM OF DATA *************************************************
Code:
********************************* TOP OF DATA *************************************************
ALGORITHM 00000001 00
++THIS IS THE OUTPUT FROM LINK EDIT: 00000001 00
UPDATE FROM THE MASTER 00000001 00
THE JOBNAME IS = 'MYJCL' 00000001 00
RESULT OF THE JOB: 00000001 00
JCLCODE = 0000, EXECUTION SUCCESSFUL 00000001 00
JCLCODE = 00000 SQL RETURN CODE 00000001 00
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION 00000001 00
JCLCODE = 0000 0000 0000 0000 INFORMATION 00000001 00
SUCCESSFUL UPDATE 00000001 00
******************************** BOTTOM OF DATA ***********************************************
I repeated my example on real mainframe, and only changed counter format from BI to ZD, for clarity during debugging. Everything is working fine, despite your unknown problems with it.
Code:
//*ICETOOL EXEC PGM=ICETOOL,
//SYNCTOOL EXEC PGM=SYNCTOOL,
// PARM='MSG=AP'
//TOOLMSG DD SYSOUT=*
//DFMSG DD SYSOUT=* FOR ICETOOL
//SSMSG DD SYSOUT=* FOR SYNCTOOL
//*
//*INPUT DD DISP=SHR,DSN=INPUT_DATASET
//INPUT DD *
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION SUCCESSFUL
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
ALGORITHM
++THIS IS THE OUTPUT FROM LINK EDIT:
UPDATE FROM THE MASTER
THE JOBNAME IS = 'MYJCL'
RESULT OF THE JOB:
JCLCODE = 0000, EXECUTION FAILED
JCLCODE = 00000 SQL RETURN CODE
JCLCODE = 0 14 6 -7 DIAGNOSTIC INFORMATION
JCLCODE = 0000 0000 0000 0000 INFORMATION
SUCCESSFUL UPDATE
//*
//INPUTSEQ DD SPACE=(TRK,(100,100)) RENUMBERED INPUT
//SELECTOR DD SPACE=(TRK,(5,5)) CALCULATION OF ' FAILED '
//*
//FAILURE DD SYSOUT=* FAILED PARAGRAPHS
//SUCCESS DD SYSOUT=* SUCCESS PARAGRAPHS
//*
//TOOLIN DD *
COPY FROM(INPUT) TO(INPUTSEQ,SELECTOR) USING(GRPS)
COPY JKFROM TO(FAILURE,SUCCESS) USING(SPLT)
//*
//GRPSCNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(89:C'00')),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,9,CH,EQ,C'ALGORITHM'),
PUSH=(81:ID=8)),
IFTHEN=(WHEN=(1,80,SS,EQ,C' FAILED '),
OVERLAY=(89:C'01'))
OUTFIL FNAMES=(INPUTSEQ)
OUTFIL FNAMES=(SELECTOR),
REMOVECC,NODETAIL,
SECTIONS=(81,8,
TRAILER3=(81:81,8,
TOT=(89,2,ZD,EDIT=(TT))))
//*
//SPLTCNTL DD *
JOINKEYS F1=INPUTSEQ,
FIELDS=(81,8,A),
SORTED
JOINKEYS F2=SELECTOR,
FIELDS=(81,8,A),
SORTED
REFORMAT FIELDS=(F1:1,80,
F2:81,10)
OUTFIL FNAMES=SUCCESS,
OMIT=(89,2,ZD,GT,+0),
BUILD=(1,80,X,81,8,X,89,2)
OUTFIL FNAMES=FAILURE,
SAVE,
BUILD=(1,80,X,81,8,X,89,2)
//*