Loading...
Loading...
In mainframe environments, Job Control Language (JCL) orchestrates the execution of batch programs. A common pattern involves running a COBOL program that reads from multiple input files and writes to an output file, with utility steps (like IEBGENER) for file preparation or copying.
You are given a simplified representation of JCL job steps as a list of step definitions. Each step has a name, a program it executes, and a list of DD (Data Definition) statements describing its input/output datasets. Your task is to validate and sequence the JCL job steps correctly, ensuring:
Input: A list of job step objects. Each step is represented as a string in the format:
STEPNAME,PROGRAM,DD1:TYPE,DD2:TYPE,...
Where TYPE is INPUT or OUTPUT.
Output: A list of valid step names in correct execution order, or "INVALID" if the job definition violates the rules.
"INVALID"."INVALID".Input:
steps = [
"STEP1,IEBGENER,SYSUT1:INPUT,SYSUT2:OUTPUT",
"STEP2,COBPGM,INFILE1:INPUT,INFILE2:INPUT,OUTFILE:OUTPUT"
]
Output: ["STEP1", "STEP2"]
Explanation: STEP1 runs IEBGENER (1 input, 1 output — valid utility). STEP2 runs the COBOL program with 2 inputs and 1 output. Order is valid.
Input:
steps = [
"STEP1,COBPGM,INFILE1:INPUT,INFILE2:INPUT,OUTFILE:OUTPUT",
"STEP2,IEBGENER,SYSUT1:INPUT,SYSUT2:OUTPUT"
]
Output: "INVALID"
Explanation: The IEBGENER step (STEP2) appears after the COBOL step (STEP1), violating the dependency rule.
Input:
steps = [
"STEP1,IEBGENER,SYSUT1:INPUT,SYSUT2:OUTPUT",
"STEP2,COBPGM,INFILE1:INPUT,OUTFILE:OUTPUT"
]
1 <= number of steps <= 50 Step name length: 1-8 characters (alphanumeric) Program name is either 'IEBGENER' or 'COBPGM' Each step has 1-10 DD statements DD type is exactly 'INPUT' or 'OUTPUT' No leading/trailing spaces in input strings
Output: "INVALID"
Explanation: STEP2 (COBOL program) has only 1 INPUT DD but requires exactly 2.