Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
I agree with ofer71's comment. JCL does not read and process records. You would need a program to handle that. I would also add that this process would make more sense to do with a program rather than a batch job.
That being said, yes, theoretically you could do this as a batch process:
1. read one record in FILEA.
You would need to, as mentioned before, use a program to accomplish this. You would obviously need to provide a value to the program, each time it is called, of which record number to start the read on. This program will also need to set a Return-Code value when the End-Of-File condition is found, to meet your requirement for Step 5. The one record should be copied to a temporary dataset for use by the subsequent steps.
2. run PROGRAMA(COBOL) with the record as input.
Yes, using the temporary dataset from Step1 as the input.
3. run PROGRAMB(COBOL) with the record as input.
Yes, same as above.
4. read next record in FILEA.
At this point, you would need to make a decision of how to continue. You could code more job steps to repeat the process of steps1-3 as needed, changing the value for the starting record each time, if there are not a substantial amount of records to process. Otherwise, you might want to submit a new job for each record to be processed, again, providing an input value to each for the record number to process.
5. if at end, run PROGRAMC(COBOL).
This would use the Return-Code value from Step1 to run only on the End-Of-File condition.
Thanks for your help.But I am not sure how to write looping statement to repeat step1 to step3 in JCL .
And how to change the value of record number to start read. I just know the SYSIN DD that used a constant for the parameter, but the record number should be a variable.