
How to Move Mainframe Batch Jobs to AWS Step Functions, Step by Step
An open-source converter handled 497 of 511 job instructions automatically. It converts the job flow, not the programs inside the steps. Here is what it did, what it missed, and how to run it.
AWS Community Builder | AWS Road to re:Invent Hackathon Champion
AWS publishes a sample mainframe application called CardDemo . It is a small credit-card system written in COBOL, with accounts, cards and transactions. Like a real mainframe system, it has an online part for users and a set of batch jobs that run on a schedule.
One of those batch jobs is TRANBKP. It runs every day in a group of jobs called DAILY-TransactionBackup. First a job named CLOSEFIL closes the transaction file in the online system. Then TRANBKP does its work in three steps:
- STEP05R copies the transaction file into a new backup.
- STEP05 deletes the transaction file.
- STEP10 creates the transaction file again, empty.
After that, a job named WAITSTEP pauses for a short time, and OPENFIL opens the file again for the online system.
Now suppose STEP05 abends one night. An abend, short for abnormal end, means the program crashed instead of finishing. The job stops at STEP05, and STEP10 never starts. The operator, the person who watches the batch run, reads the log and fixes the cause. Then they submit the job again with
RESTART=STEP05 on its first line.The mainframe starts the job at STEP05. STEP05R does not run again, so no second backup is written for the same day. STEP05 runs, then STEP10, and the day carries on.
I spent 11 years on the mainframe, and this was routine for us. A step abends, we fix the issue, and we restart from the failed step. The mainframe has supported this for about 60 years.
How the mainframe makes restart work
The restart is not magic. It comes from a few plain pieces that every mainframe batch job has.
The job is a script of steps. A batch job is a text file written in JCL, Job Control Language. Think of it as a shell script with a strict format. Each step starts with an EXEC line that names the program to run. The lines under it, called DD statements, name the files that program reads and writes.
Every step ends with a return code. The return code is a number the program hands back to the system. 0 means fine. Higher numbers mean a warning or an error, and each program decides what its numbers mean. An abend is different. The step never returns a code, and the job stops.
COND decides whether a step runs. A step can carry a COND test on the return codes of earlier steps. COND reads backwards for most people. Picture a recipe card with a note in the margin of step 3. The note says "skip this step if the oven ran hotter than 4 earlier." The card never says when to do step 3. It only lists the reason to skip it.
COND works the same way. In TRANBKP, STEP10 has
COND=(4,LT) . It means bypass this step if 4 is less than the return code of any earlier step. A true COND test skips the step. It does not fail the job.RESTART= tells the job which step to resume from. In TRANBKP, the backup that STEP05R wrote was kept when STEP05R ended. So when the operator restarts at STEP05, the backup is already there. Nothing before STEP05 needs to run.
A scheduler runs the jobs in order. CardDemo uses Control-M, a scheduler product from BMC. Think of it as cron with dependencies. Jobs sit in folders. When a job ends well, it raises a flag called an OUTCOND. The next job waits for that flag, its INCOND, before it starts. That is how CLOSEFIL, TRANBKP, WAITSTEP and OPENFIL run one after another.
Why restart gets lost when a job moves
You might ask why this is a problem at all. Cloud engineers restart work every day. You can save a checkpoint after each step. You can make each step idempotent, so running it twice does no harm. You can model the job as a workflow that remembers which steps finished.
All of that works. The catch is that someone has to build it by hand, for every job, from JCL they may never have read. CardDemo alone has 38 jobs.
A quick hand rewrite can turn TRANBKP into one script, or one Lambda function with a retry around it. That runs fine until STEP05 fails. Then the retry starts at the top. STEP05R runs again and writes a second backup for the same day. COND can get lost the same way, as
COND=(4,LT) looks like "run if" to someone new to JCL.
TRANBKP after STEP05 fails, three ways. Only the one-script rewrite runs the backup step a second time.
So the real question is how to rebuild restart for every job without writing it by hand each time.
AWS Step Functions already has the pieces these jobs need. A Step Functions workflow is a state machine, written in the Amazon States Language , a JSON format. A Task state does one unit of work, like a JCL step. A Choice state adds conditional logic, so it can do the COND check. Redrive restarts a failed execution from the step that failed. The steps that already succeeded are not run again.
This guide is for cloud engineers who are handed mainframe batch jobs and have never read JCL. It shows you how to move TRANBKP, and the rest of CardDemo's batch, to Step Functions with an open-source converter called ironbridge. Its
jcl to-asl command reads JCL and writes Amazon States Language. It converts the job flow, not the programs inside the steps. On CardDemo, ironbridge jcl to-asl handled 497 of 511 JCL constructs automatically. That is 97.3%. It flagged the other 14 for a person to finish. The Control-M schedule converted at a lower 72.9%.A JCL construct is one job instruction the converter can count. A step, a DD line, a COND test and a backup generation reference are each one construct. When the converter cannot translate a construct safely, it does not guess. It flags it, and a person decides what to do. The tool's output calls these flags TODO markers.
Read TRANBKP line by line
This is TRANBKP from CardDemo, with comments, the UNIT, DCB and SPACE lines, SYSPRINT and most IDCAMS input trimmed:
//TRANBKP JOB 'REPRO and Delete Transaction Master',CLASS=A,MSGCLASS=0,// NOTIFY=&SYSUID//JOBLIB JCLLIB ORDER=('AWS.M2.CARDDEMO.PROC')//STEP05R EXEC PROC=REPROC,// CNTLLIB=AWS.M2.CARDDEMO.CNTL//PRC001.FILEIN DD DISP=SHR,// DSN=AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS//PRC001.FILEOUT DD DISP=(NEW,CATLG,DELETE),// DSN=AWS.M2.CARDDEMO.TRANSACT.BKUP(+1)//STEP05 EXEC PGM=IDCAMS//SYSIN DD * DELETE AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS - CLUSTER IF MAXCC LE 08 THEN SET MAXCC = 0//STEP10 EXEC PGM=IDCAMS,COND=(4,LT)Here is what each part says in plain words.

Three of those lines carry the behavior from the opening. COND on STEP10 is the step check. The step names give RESTART= something to point at. The
(+1) on FILEOUT writes a new backup on every run, which is why a rerun from the top writes a second one.How each mainframe idea maps to Step Functions
Here is what ironbridge does with each idea, using TRANBKP's own output. You will generate these files yourself in the Try it section.
Return codes become a variable map
This is STEP05 in
build/jobs/TRANBKP.asl.json , with parm, the DD details and the Retry block trimmed:"STEP05": { "Type": "Task", "Comment": "PGM=IDCAMS", "Resource": "arn:aws:states:::lambda:invoke", "Arguments": { "FunctionName": "${StubFunctionArn}", "Payload": { "job": "TRANBKP", "step": "STEP05", "pgm": "IDCAMS", "simulate": "{% $sim %}" } }, "Assign": { "rc": "{% $merge([$rc, {'STEP05': $states.result.Payload.rc}]) %}" }, "Next": "COND STEP10"}The
Assign line is the core idea. Step Functions variables let every state add to a map called $rc . The expressions are JSONata . After STEP05, $rc holds its return code under the key STEP05 . Any later state can read it, the same way JCL lets any later step test it.COND becomes a Choice state
The converter places a Choice state in front of STEP10:
"COND STEP10": { "Type": "Choice", "Comment": "COND on STEP10. True bypasses the step.", "Choices": [ { "Condition": "{% $count([$rc.*][4 < $]) > 0 %}", "Next": "EOJ" } ], "Default": "STEP10"}The condition counts every earlier return code where
4 < rc . If there is at least one, it jumps to EOJ , the end-of-job state, and STEP10 never starts. The converter keeps the JCL order of operands, so (4,LT) reads as 4 < rc and never gets flipped by mistake.
COND=(4,LT) as a Choice state. On the bypass path the Choice goes straight to EOJ , and the job still succeeds.RESTART= becomes redrive
Look at the STEP05 Task again. There is no
Catch , the Step Functions version of try and except. The Task has a Retry block, but it lists Lambda service errors only. So an abend is never retried in place and never caught.Per the Lambda integration docs , an exception in the function fails the Task. With no Catch, that fails the execution. A failed execution can be redriven , and redrive starts again at the failed Task with the same input.

Backup generations and the Control-M folder
A GDG, or generation data group, is a family of versioned files. ironbridge turns each
(+1) or (0) reference into a key prefix shaped for Amazon S3 keys . Each Control-M folder becomes a parent state machine that runs its jobs as nested executions . The XML has no start time or time zone, so each schedule fires at 00:00 UTC and is deployed DISABLED.Shift handover: what the mainframe did for you, and what you own on AWS
On the mainframe these behaviors came with the platform. On AWS each one is a part of the build, and someone has to own it.

What converts automatically and what needs a person
ironbridge converts the job flow, not the programs inside the steps. A construct counts as handled when it lands in the generated state machine without a flag. Program bodies are not converted. Every step calls a Lambda stub, a placeholder, that returns a simulated return code. So you can test the job flow on AWS without any COBOL.

DD statements are 328 of the 511. EXEC steps are 89 of 101, or 88.1%. COND, GDG relative references and PROC calls are 29 of 29.
38 of the 511 are NOTIFY=&SYSUID job card lines. ironbridge maps &SYSUID to the execution role ARN. It does not send a job-end notice. Take those lines out and the rate is 460 of 473, still 97.3%.
The Control-M schedule converted at a lower rate, 62 of 85 constructs, or 72.9%. All 15 TIMETO windows are flagged because EventBridge Scheduler has no end-of-window setting. Two jobs, MNTTRDB2 and TRANEXTR, have no JCL member in CardDemo and fail visibly. TIMETO is the end of the time window in which Control-M may start a job. On AWS, a job that becomes ready after that time still starts.
Most of the 14 flagged constructs are mainframe utilities with no direct AWS equivalent. One is a typo in CardDemo itself. The deep dive lists each one and why.
Every flag lands in
build/coverage.json with its job, file, line and reason. That includes the 15 TIMETO windows and the two jobs with no JCL member. Read that list before you read the percentage. It is the work a person still has to do. Add these to it:- The program bodies, since every step is still a placeholder.
- The schedule start times, since each schedule is set to 00:00 UTC.
Try it yourself
This is a personal project, not official AWS content. The runs and the five failures I saw come from my own AWS account.

Every Check with terminal output below shows the real output from my run on 2026-11-11, with the account id taken out. Long output is trimmed to the lines that matter.

The whole build on one page. You build offline, deploy one stack to us-east-1, and drive the jobs from the AWS CLI.
cdk deploy creates the stack with the AWS CDK . Each job step calls the return-code stub, a Lambda function on arm64 . The job and the stub both write to CloudWatch Logs .Step 1. Clone and build offline
git clone --branch v0.1.1 https://github.com/hsiddhu2/ironbridge.gitcd ironbridge/demos/01-jcl-to-aslmake installmake buildmake build runs the converter on the CardDemo fixtures pinned at commit 59cc6c2. It writes build/ with four things. Job state machines go in jobs/ , folder parents in folders/ , Scheduler definitions in schedules/ , and the inventory in coverage.json .
JCL coverage 97.3% (497/511)Hard subset COND, GDG, PROC 100.0% (29/29)Control-M coverage 72.9% (62/85)TODO markers 37. Wrote build/
make build runs offline and prints the coverage table. No AWS account needed.Open
build/jobs/TRANBKP.asl.json and find the STEP05 Task and the COND STEP10 Choice from the mapping section.
Step 2. Validate and deploy
Before you deploy anything, ask Step Functions to check every generated definition. The harness calls ValidateStateMachineDefinition at WARNING severity on every job and every parent.
export AWS_PROFILE=sandboxexport AWS_REGION=us-east-1uv run python scripts/measure.py validatemake deploymake deploy runs the build again, then cdk deploy , and writes the stack outputs to outputs.json . The stack deploys TRANBKP, DEFGDGD, TRANREPT and the DAILY-TransactionBackup parent. The parent calls CLOSEFIL, WAITSTEP and OPENFIL, so those are deployed too.

ironbridge-m4.JobTRANBKPArn = arn:aws:states:us-east-1:<account-id>:stateMachine:ironbridge-m4-TRANBKPironbridge-m4.StubFunctionName = ironbridge-m4-rc-stubStep 3. Run TRANBKP clean
Stay in the same shell for steps 3 to 6. Read the two names you need from
outputs.json , then start TRANBKP with an empty simulate map, so every step returns 0.JOB=$(jq -r '."ironbridge-m4".JobTRANBKPArn' outputs.json)FN=$(jq -r '."ironbridge-m4".StubFunctionName' outputs.json)EX=$(aws stepfunctions start-execution --state-machine-arn "$JOB" \ --input '{"simulate":{}}' --query executionArn --output text)sleep 6aws stepfunctions describe-execution --execution-arn "$EX" \ --query '{status:status}' --output tableaws stepfunctions get-execution-history --execution-arn "$EX" \ --query "events[?type=='TaskStateEntered'||type=='ChoiceStateEntered'].[stateEnteredEventDetails.name]" \ --output text
STEP05R.PRC001STEP05COND STEP10STEP10Step 4. Trip COND
Now tell the stub that STEP05 returns 8. The stub stands in for IDCAMS and does not apply the IF MAXCC line, so the 8 reaches COND. Start a new execution with this input, then run the same
sleep , describe-execution and get-execution-history commands from step 3:EX=$(aws stepfunctions start-execution --state-machine-arn "$JOB" \ --input '{"simulate":{"STEP05":8}}' --query executionArn --output text)

//STEP10 EXEC PGM=IDCAMS,COND=(4,LT)STEP05R.PRC001STEP05COND STEP10
The COND trip in the console. The Choice took the bypass path, and STEP10 stays white because it never ran.
Step 5. Make STEP05 abend
The stub is where an abend comes from. It reads the step name and either returns a code or raises an error. Here the error says "S0C7 simulated in TRANBKP.STEP05". S0C7 is the mainframe abend code for bad numeric data. Set
ABEND_STEPS on the stub, wait for the update to finish, then start the job.aws lambda update-function-configuration --function-name "$FN" \ --environment 'Variables={ABEND_STEPS=TRANBKP.STEP05,LOG_LEVEL=INFO}' \ --query LastUpdateStatus --output textaws lambda wait function-updated-v2 --function-name "$FN"EX=$(aws stepfunctions start-execution --state-machine-arn "$JOB" \ --input '{"simulate":{}}' --query executionArn --output text)sleep 6aws stepfunctions describe-execution --execution-arn "$EX" \ --query '{status:status,error:error}' --output table update-function-configuration returns before the change is live. The function-updated-v2 waiter waits for
LastUpdateStatus to be Successful .

//STEP05 EXEC PGM=IDCAMS| error | status |+--------+----------+| Abend | FAILED |Step 6. Fix it and redrive, the way RESTART= works
Clear the abend, wait, and redrive the same execution. Do not redeploy and do not start a new execution. This is the operator fixing the cause and adding
RESTART=STEP05 .aws lambda update-function-configuration --function-name "$FN" \ --environment 'Variables={ABEND_STEPS=,LOG_LEVEL=INFO}' \ --query LastUpdateStatus --output textaws lambda wait function-updated-v2 --function-name "$FN"aws stepfunctions redrive-execution --execution-arn "$EX" \ --query redriveDate --output text >/dev/null && echo redrive startedsleep 6aws stepfunctions describe-execution --execution-arn "$EX" \ --query '{status:status,redriveCount:redriveCount}' --output tableaws stepfunctions get-execution-history --execution-arn "$EX" \ --query "events[?type=='TaskStateEntered'||type=='TaskFailed'||type=='ExecutionFailed'||type=='ExecutionRedriven'||type=='TaskSucceeded'].[type, stateEnteredEventDetails.name]" \ --output text


//PRC001.FILEOUT DD DISP=(NEW,CATLG,DELETE),// UNIT=SYSDA,// DCB=(LRECL=350,RECFM=FB,BLKSIZE=0),// SPACE=(CYL,(1,1),RLSE),// DSN=AWS.M2.CARDDEMO.TRANSACT.BKUP(+1)TaskStateEntered STEP05R.PRC001TaskSucceeded NoneTaskStateEntered STEP05TaskFailed NoneExecutionFailed NoneExecutionRedriven NoneTaskSucceeded NoneTaskStateEntered STEP10TaskSucceeded NoneAfter the redrive there is one
TaskSucceeded with no new TaskStateEntered in front of it. That is STEP05. Redrive put the Task back on the schedule inside the state it had already entered, so no new enter event appears. Then STEP10 entered and succeeded. STEP05R.PRC001 does not appear again.That is the opening story on AWS. The redrive docs say successful steps "are not rerun", and a failed Task is rescheduled and run again. AWS announced redrive on What's New in 2023.

TRANBKP after the abend was cleared and redriven. Status Succeeded, Redrive count 1. Account details are blacked out.
Step 7. Look at the schedule
Open EventBridge Scheduler in the console to see the schedule deployed in step 2. The deep dive shows the parent run, the schedule files and how to point the converter at your own JCL.

The schedule from the Control-M folder lands Disabled, in UTC. Nothing runs until you turn it on.
How I checked the path
A green execution only proves that nothing crashed. I wanted proof that the path was the right one.
I ran each of the three sample jobs six times in three scenarios, 54 executions in all. The scenarios were a clean run, a COND trip, and an abend followed by a redrive. All 54 succeeded on the expected path. COND bypassed the right steps in 12 of 12 runs (TRANBKP and DEFGDGD).
In 18 of 18 abend tests, redrive reran only the step that failed, with no redeploy. That is how RESTART= behaves.


make measure : validation, a diff against ASL I wrote by hand, then each deployed run with its path check. I wrote both, so the diff is not an independent check.What broke
Five things went wrong for me while building or testing this. Three are in the ABEND notes above. The other two were a redrive of a run that had already succeeded and a region mismatch.
One more surprised me. I stopped the parent mid-run and redrove the aborted execution. Step Functions accepted it and it succeeded. The docs list aborted runs as redrivable, so this is the service's behavior, not something ironbridge adds.
All five, three more cases from the docs and the design, permissions and the audit trail are in the deep dive .
Open items on the run book
- Program bodies are stubbed. Every step returns a simulated return code. Real IDCAMS, SORT and COBOL steps can fail in ways the stub never will.
- One corpus at one pinned commit. Every number here comes from CardDemo at commit 59cc6c2. Your JCL may use constructs CardDemo never does.
- Three sample jobs measured. I measured TRANBKP, DEFGDGD and TRANREPT. The DAILY parent also ran CLOSEFIL, TRANBKP, WAITSTEP and OPENFIL. The other jobs passed validation, but I did not run them on AWS.
- The Catch case is from the docs only. I never added a Catch and watched redrive fail. I also did not test throttling or a missing permission on one role.
- No alarm and no owner. This release has no alarm on a FAILED execution, and it does not say who owns a job after handoff. Plan for both before any real batch night runs on it.
Clean up
make destroymake leftoversmake leftovers looks for any stack, state machine, function, schedule, log group, role or policy still named after the stack.

make leftovers confirms nothing named ironbridge-m4 is left in the region.A full deploy, measure and destroy cycle costs under $1. Mine was a few hundred state transitions and under 300 Lambda calls. make destroy left nothing billable behind. The CDK bootstrap bucket stays after destroy.
Handover notes
- Keep return codes in one variable map, so any later step can test them.
- Put each skip rule in its own Choice state.
- Leave step errors uncaught when you want redrive to act as your restart.
- Prove a restart from the execution history. A green status only says nothing crashed.
- Read the flagged list before the percentage.
Go back to TRANBKP. STEP05 abends, the operator fixes the cause and redrives the same execution. STEP05R does not run again, so it cannot write a second backup. Next, try the converter on a few of your own jobs and read the flagged list first. A full deploy, measure and destroy cycle costs under $1. I'd like to hear what breaks.
References
The AWS Compute Blog post Migrating mainframe JCL jobs to serverless using AWS Step Functions converts one job by hand and explains COND well. ironbridge does that for every job in the corpus, and adds GDG and the RESTART= to redrive mapping.
DAGify converts Control-M XML to Airflow and reports a conversion rate. ironbridge targets Step Functions and reports its rate per construct.
Thanks to the AWS team behind CardDemo, the authors of that Compute Blog post and the DAGify maintainers. Their work showed me where to start.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article