|
View previous topic :: View next topic
|
| Author |
Message |
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
Hi! I have a requirement to perform validation of a file by finding blank spaces in between the file.
The validation will be like -
The file has data and all records need to have
11,2 blank and
15,1 blank and
21,2 blank and
27,3 blank and
38,1 blank
If the validation is successful, I need to send all records on the current file as per the copybook to the requested addresses.
If the validation fails i.e. if the file will contain bad records (in any of the places that should be blank), no report/mail will be send.
Please advise how it can be done.
Thank you |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2281 Location: USA
|
|
|
|
What exactly prevents you from doing your own job??  |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Quote: |
| a file by finding blank spaces in between the file. |
What exactly does this mean? I suspect you mean dataset not 'file' in the first instance and 'fields' for the second 'file'. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Kumar Sandeep wrote: |
Hi! I have a requirement to perform validation of a file by finding blank spaces in between the file.
The validation will be like -
The file has data and all records need to have
11,2 blank and
15,1 blank and
21,2 blank and
27,3 blank and
38,1 blank
If the validation is successful, I need to send all records on the current file as per the copybook to the requested addresses.
If the validation fails i.e. if the file will contain bad records (in any of the places that should be blank), no report/mail will be send.
Please advise how it can be done.
Thank you |
Please use code tags when representing any code or data.
Easy way you can try -
1. Step#1 , Filter the records and find any one suing Include.
| Code: |
| INCLUDE COND=("Your mentioned Conditions") |
2. Step#2, Check if the Dataset is empty form Step2 and set RC=4
| Code: |
| COUNT FROM(IN) EMPTY RC4 |
Use IF THEN in JCL and use the step#2 RC=4 to execute Email step.
Note : Both steps may be combined to one, but I believe you are looking for simple solution based on the requirements and not solving any performance problems. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
To not make this thread too boring..this should do what's requested.
| Code: |
//ISANYBAD EXEC PGM=ICEMAN
//SORTIN DD DISP=OLD,DSN=<input>
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(11,2,CH,EQ,C' ',AND,
15,1,CH,EQ,C' ',AND,
21,2,CH,EQ,C' ',AND,
27,3,CH,EQ,C' ',AND,
38,1,CH,EQ,C' ')
OUTFIL NULLOFL=RC4,ACCEPT=1
END
/*
// IF (ISANYBAD.RC=4) THEN
//SENDMAIL EXEC <whatever_is_needed_here>
// ENDIF |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Joerg.Findeisen wrote: |
To not make this thread too boring..this should do what's requested.
| Code: |
//ISANYBAD EXEC PGM=ICEMAN
//SORTIN DD DISP=OLD,DSN=<input>
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(11,2,CH,EQ,C' ',AND,
15,1,CH,EQ,C' ',AND,
21,2,CH,EQ,C' ',AND,
27,3,CH,EQ,C' ',AND,
38,1,CH,EQ,C' ')
OUTFIL NULLOFL=RC4,ACCEPT=1
END
/*
// IF (ISANYBAD.RC=4) THEN
//SENDMAIL EXEC <whatever_is_needed_here>
// ENDIF |
|
Are you sure this will work ? I don't see RC-4 is being set, if anyone record has is a bad record. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
| Rohit Umarjikar wrote: |
| Are you sure this will work ? I don't see RC-4 is being set, if anyone record has is a bad record. |
I am confident it will work. I usually test before submitting to the Forum.
1) OMIT anything valid
2) OUTFIL first invalid record or RC4 if nothing invalid to be printed
3) IF / THEN on RC4 |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Joerg.Findeisen wrote: |
| Rohit Umarjikar wrote: |
| Are you sure this will work ? I don't see RC-4 is being set, if anyone record has is a bad record. |
I am confident it will work. I usually test before submitting to the Forum.
1) OMIT anything valid
2) OUTFIL first invalid record or RC4 if nothing invalid to be printed
3) IF / THEN on RC4 |
I tried your JCL with simple input but did not work -
| Code: |
//ISANYBAD EXEC PGM=ICEMAN
//SORTIN DD *
123456
123456
123451
23456
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(1,1,CH,EQ,C' ')
OUTFIL NULLOFL=RC4,ACCEPT=1
END |
*********************************************************
This is what I could do in one step and works if anyone record is invalid ( contains blank) TS can now change this to actual offsets and expand include cond to its real values.
IF RC-4 then execute Email step else NO.
| Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
123416
122226
122416
//OUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
//SORTOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
COUNT FROM(OUT) EMPTY RC4
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,EQ,C' ') |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
Do not send if any of the input records is invalid, right?
| Code: |
//ISANYBAD EXEC PGM=ICEMAN
//SORTIN DD *
Valid
this has data on pos 11 to 12 and makes this an invalid input
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(11,2,CH,EQ,C' ',AND,
15,1,CH,EQ,C' ',AND,
21,2,CH,EQ,C' ',AND,
27,3,CH,EQ,C' ',AND,
38,1,CH,EQ,C' ')
OUTFIL NULLOFL=RC4,ACCEPT=1
END
/*
// IF (ISANYBAD.RC=4) THEN
//SENDMAIL EXEC PGM=IEFBR14
// ENDIF |
This will flush the SENDMAIL step because of the second record.
| Code: |
STEPNAME ProcStep Pgm-Name Step-CC
ISANYBAD ICEMAN CC 0000
SENDMAIL IEFBR14 FLUSH |
without the invalid second record
| Code: |
STEPNAME ProcStep Pgm-Name Step-CC
ISANYBAD ICEMAN CC 0004
SENDMAIL IEFBR14 CC 0000 |
|
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Joerg.Findeisen wrote: |
Do not send if any of the input records is invalid, right?
| Code: |
//ISANYBAD EXEC PGM=ICEMAN
//SORTIN DD *
Valid
this has data on pos 11 to 12 and makes this an invalid input
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(11,2,CH,EQ,C' ',AND,
15,1,CH,EQ,C' ',AND,
21,2,CH,EQ,C' ',AND,
27,3,CH,EQ,C' ',AND,
38,1,CH,EQ,C' ')
OUTFIL NULLOFL=RC4,ACCEPT=1
END
/*
// IF (ISANYBAD.RC=4) THEN
//SENDMAIL EXEC PGM=IEFBR14
// ENDIF |
This will flush the SENDMAIL step because of the second record.
| Code: |
STEPNAME ProcStep Pgm-Name Step-CC
ISANYBAD ICEMAN CC 0000
SENDMAIL IEFBR14 FLUSH |
without the invalid second record
| Code: |
STEPNAME ProcStep Pgm-Name Step-CC
ISANYBAD ICEMAN CC 0004
SENDMAIL IEFBR14 CC 0000 |
|
SORTIN has both invalid records in your case. You will need keep many valid and one invalid to test.
Moreover, I have a syncsort product and I have not got RC-4 for any valid or invalid combination. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
Tested with SYNCSORT now, you need to slightly edit the JCL/SYSIN here. Please be so kind and try on your site with both input records first, then delete the second.
| Code: |
//ISANYBAD EXEC PGM=SORT
//SORTIN DD *
Valid
this has data on pos 11 to 12 and makes this an invalid input
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DUMMY
//ANY DD DUMMY
//SYSIN DD *
OPTION COPY
OMIT COND=(11,2,CH,EQ,C' ',AND,
15,1,CH,EQ,C' ',AND,
21,2,CH,EQ,C' ',AND,
27,3,CH,EQ,C' ',AND,
38,1,CH,EQ,C' ')
OUTFIL FNAMES=(ANY),NULLOFL=RC4,ACCEPT=1
END
/*
// IF (ISANYBAD.RC=4) THEN
//SENDMAIL EXEC PGM=IEFBR14
// ENDIF |
WER169I RELEASE 2.1 BATCH 0539 TPF LEVEL 7.0 |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
FNAMES=(ANY) wouldn't make any much of a difference than before. I don't still see it is working.
| Code: |
//SORTIN DD *
Valid
this has data on pos 11 to 12 and makes this an invalid input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
/* |
RC-0
| Code: |
//SORTIN DD *
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
/* |
RC-4 is expected since both records are good but your card will product RC-0.
Your card will only product RC-4 if first one is a bad record.
The requirement is if input data set has anyone bad record , anywhere then the email should not be send out else it do.
IF (ISANYBAD.RC=4) is never set for all good records , on contrary if the the input has only one record and that's bad one then RC-4 is set and email is sent when we don't want to.
**************************************************
This is what I shared earlier-
| Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
123416
122226
122416
//OUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
//SORTOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
COUNT FROM(OUT) EMPTY RC4
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,EQ,C' ') |
If there is any one bad record anywhere then RC-0 is set else RC-4. If RC-4 I set then in the next step email can be sent out else No |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
| Rohit Umarjikar wrote: |
FNAMES=(ANY) wouldn't make any much of a difference than before. I don't still see it is working.
| Code: |
//SORTIN DD *
Valid
this has data on pos 11 to 12 and makes this an invalid input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
/* |
RC-0
| Code: |
//SORTIN DD *
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
/* |
RC-4 is expected since both records are good but your card will product RC-0. |
This is not correct! Your second sample is also expected to RC0 (=there are bad records) because both records are not valid. Look again at what the TS has written:
| Kumar Sandeep wrote: |
The file has data and all records need to have
11,2 blank and
15,1 blank and
21,2 blank and
27,3 blank and
38,1 blank |
The only issue on my side I can see is, that when the input is empty it's considered valid. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
You are right on this , if its blanks on those positions then its a valid else invalid. I just flipped it, my bad. what you posted should also work except for the empty file (which I don't think is a big deal for TS to fix it)
This is what I tried and should work for empty file too.
| Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
BBBBBBBBBB**BB*BBBBB**BBBB***BBBBBBBB*BBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBB BB BBBBB BBBB BBBBBBBB BBBBBBBBBBBBBBBBBBBBBB
//OUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
//SORTOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
COUNT FROM(OUT) EMPTY RC4
COUNT FROM(IN) EMPTY RC8
//CTL1CNTL DD *
INCLUDE COND=(11,2,CH,NE,C' ',AND,
15,1,CH,NE,C' ',AND,
21,2,CH,NE,C' ',AND,
27,3,CH,NE,C' ',AND,
38,1,CH,NE,C' ') |
If the input data set is empty then RC-8
If there is even one bad record then RC-0
If all the records are good then RC-4
IF RC-4 then email can be sent. |
|
| Back to top |
|
 |
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
| Nic Clouston wrote: |
| Quote: |
| a file by finding blank spaces in between the file. |
What exactly does this mean? I suspect you mean dataset not 'file' in the first instance and 'fields' for the second 'file'. |
It's a sequential file (PS). The validation should be, say for example the file is containing records as below.
AAAAA BBBBB CCCCC DDDD
There should not be any other character between 2 records (like below) and that should be blank.
AAAAA 5BBBBB CCCCC DDDD
If there will be any character in between then in that case the validation will fail. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
| You have got working samples for your request. Out of curiosity, is it likely that the input will be empty sometimes? |
|
| Back to top |
|
 |
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
| Rohit Umarjikar wrote: |
You are right on this , if its blanks on those positions then its a valid else invalid. I just flipped it, my bad. what you posted should also work except for the empty file (which I don't think is a big deal for TS to fix it)
This is what I tried and should work for empty file too.
| Code: |
//S1 EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
BBBBBBBBBB**BB*BBBBB**BBBB***BBBBBBBB*BBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBB BB BBBBB BBBB BBBBBBBB BBBBBBBBBBBBBBBBBBBBBB
//OUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
//SORTOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUT) USING(CTL1)
COUNT FROM(OUT) EMPTY RC4
COUNT FROM(IN) EMPTY RC8
//CTL1CNTL DD *
INCLUDE COND=(11,2,CH,NE,C' ',AND,
15,1,CH,NE,C' ',AND,
21,2,CH,NE,C' ',AND,
27,3,CH,NE,C' ',AND,
38,1,CH,NE,C' ') |
If the input data set is empty then RC-8
If there is even one bad record then RC-0
If all the records are good then RC-4
IF RC-4 then email can be sent. |
Thank you Rohit. I hope you understood my requirement correct. I am again reposting my requirement to make it more clear and for you to provide a more accurate solution.
For example, I have a file as below:
AAAA BBBB CCCC DDDD
XXXX BBBB CCCC PPPP
The job should perform the validation that there should be blanks at below positions in this file.
11,2 blank and
15,1 blank and
21,2 blank and
27,3 blank and
38,1 blank
What it means, there should not be any other character in those positions and those should be blank.
The below file is invalid as per this check.
AAAA5BBBB CCCC DDDD
XXXX BBBB CCCC7PPPP
If the validation is successful, I need to send all records on the current file as per the copybook to the requested addresses.
If the validation fails i.e. if the file will contain bad records (in any of the places that should be blank), no report/mail will be send. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1439 Location: Bamberg, Germany
|
|
|
|
| Rohit's solution works well now. Please test yourself with sample input. |
|
| Back to top |
|
 |
Kumar Sandeep
New User
Joined: 24 Apr 2020 Posts: 10 Location: India
|
|
|
|
| Joerg.Findeisen wrote: |
| Rohit's solution works well now. Please test yourself with sample input. |
Thank you. I will check the solution. Empty file checking I will perform in first step and validation of file, which will check for blanks in second step. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Kumar Sandeep wrote: |
| Joerg.Findeisen wrote: |
| Rohit's solution works well now. Please test yourself with sample input. |
Thank you. I will check the solution. Empty file checking I will perform in first step and validation of file, which will check for blanks in second step. |
Please ..echo ..echo
Understand the SORT card provided, it handles empty file too and no need to add any extra steps for that. test before you come to any conclusion as directed. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|