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
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.
*********************************************************
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.
Joined: 15 Aug 2015 Posts: 1329 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.
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.
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.
Joined: 15 Aug 2015 Posts: 1329 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
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-
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.
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.
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.
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.
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.
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.
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.