EXPORT Statement

Purpose

The EXPORT statement makes JCL variables (system symbols) available to subsequent jobs within the same execution group. This enables job-to-job communication through shared variables, allowing later jobs to access values created in earlier jobs. The EXPORT statement is particularly useful in multi-job workflows where information needs to be passed along in a processing sequence.

Key Benefit:

EXPORT enables data sharing between related jobs, eliminating the need for intermediate datasets to pass simple values between job steps in a processing chain.

Basic Syntax

Simple EXPORT

jcl
1
// EXPORT SYMLIST=*

This form exports all defined system symbols to subsequent jobs.

Export Specific Variables

jcl
1
// EXPORT SYMLIST=(VAR1,VAR2,VAR3)

This form exports only the specified variables to subsequent jobs.

No Export

jcl
1
// EXPORT SYMLIST=NONE

This form explicitly prevents any variables from being exported from this job.

Complete Example

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//JOB1 JOB (ACCT#),'ADMIN',CLASS=A // EXPORT SYMLIST=(TODAY,ENV,STATUS) // SET TODAY=&SYSDATE // SET ENV='PROD' // SET STATUS='NORMAL' //* //STEP1 EXEC PGM=PROGRAM1 //INPUT DD DSN=MY.INPUT.FILE,DISP=SHR //OUTPUT DD DSN=MY.OUTPUT.FILE,DISP=(,CATLG), // SPACE=(CYL,(10,5)),UNIT=SYSDA //* //JOB2 JOB (ACCT#),'ADMIN',CLASS=A //* This job can access TODAY, ENV, and STATUS from JOB1 //STEP1 EXEC PGM=PROGRAM2 //DD1 DD DSN=MY.&ENV..&TODAY..FILE,DISP=SHR

In this example, JOB1 exports three variables that JOB2 can then use. Note that JOB2 must be in the same execution group as JOB1.

Usage Details

Execution Order Requirements

  • Jobs must execute in the same JES execution group
  • Jobs must execute in sequence - the exporting job must complete before the importing job starts
  • Variables are available only to jobs within the same execution group
  • A job cannot pass variables to a previous job (only forward in the execution sequence)

Placement Rules

  • EXPORT must appear before the first EXEC statement in the job
  • Multiple EXPORT statements are allowed, but the last one overrides previous ones
  • EXPORT must follow any SET statements for variables you want to export
  • EXPORT can be used in conjunction with JCL procedures

Use Cases

Job-to-Job Communication

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//JOB1 JOB (ACCT#),'ADMIN',CLASS=A // EXPORT SYMLIST=(RETURNCODE,COUNT) //STEP1 EXEC PGM=PROCESS //* Program sets RETURNCODE and COUNT values // SET RETURNCODE=&STEP1.RC // SET COUNT=100 //* //JOB2 JOB (ACCT#),'ADMIN',CLASS=A //* This job can access RETURNCODE and COUNT from JOB1 // IF &RETURNCODE = 0 THEN //STEP1 EXEC PGM=NORMAL // ELSE //STEP1 EXEC PGM=RECOVERY // ENDIF

This example shows how a second job can make processing decisions based on the outcome of the first job.

Multi-Job Processing Pipeline

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//EXTRACT JOB (ACCT#),'ADMIN',CLASS=A // EXPORT SYMLIST=(ROWCOUNT,FILEDATE) //STEP1 EXEC PGM=EXTRACT //* After extract, SET variables based on execution // SET ROWCOUNT=1000 // SET FILEDATE=&SYSDATE //* //PROCESS JOB (ACCT#),'ADMIN',CLASS=A // EXPORT SYMLIST=(ROWCOUNT,FILEDATE,PROCSTAT) //* Use values from prior job //STEP1 EXEC PGM=PROCESS,PARM='ROWS=&ROWCOUNT' // SET PROCSTAT='COMPLETED' //* //REPORT JOB (ACCT#),'ADMIN',CLASS=A //* Use values from both prior jobs //STEP1 EXEC PGM=REPORT //SYSOUT DD SYSOUT=A //SYSIN DD * REPORT FOR DATA PROCESSED ON &FILEDATE ROWS PROCESSED: &ROWCOUNT PROCESSING STATUS: &PROCSTAT /*

This example demonstrates a three-job pipeline where information flows through the jobs.

Dynamic Dataset Names

jcl
1
2
3
4
5
6
7
8
9
10
11
//CREATE JOB (ACCT#),'ADMIN',CLASS=A // EXPORT SYMLIST=(DSNAME,DSSIZE) //STEP1 EXEC PGM=CREATE // SET DSNAME='MY.NEW.DATASET' // SET DSSIZE=50 //* //BACKUP JOB (ACCT#),'ADMIN',CLASS=A //STEP1 EXEC PGM=BACKUP //INPUT DD DSN=&DSNAME,DISP=SHR //OUTPUT DD DSN=BACKUP.&DSNAME,DISP=(NEW,CATLG), // SPACE=(CYL,(&DSSIZE,10)),UNIT=SYSDA

Here, the BACKUP job uses the dataset name and size determined by the CREATE job.

Security Considerations

  • Variables exported between jobs may contain sensitive information
  • Ensure jobs in an execution group have appropriate security classifications
  • Consider restricting access to JCL that contains EXPORT statements
  • Avoid exporting passwords or other credentials between jobs
  • Installation security settings may restrict EXPORT functionality

Best Practices

  1. Export only necessary variables - Use specific variable lists rather than SYMLIST=*
  2. Document exported variables - Add comments explaining what variables are exported and their purpose
  3. Validate imported variables - Check that variables exist before using them in subsequent jobs
  4. Use meaningful variable names - Makes the JCL more understandable when variables are shared
  5. Consider job dependencies - Ensure jobs execute in correct sequence through JES dependencies
  6. Test variable passing - Verify that variables are correctly passed between jobs in test environment
  7. Include default values - Provide fallbacks in case exported variables aren't available

Troubleshooting

IssuePossible CausesSolutions
Variables not available in subsequent job
  • Jobs not in same execution group
  • First job did not complete successfully
  • Variable not included in SYMLIST
  • Ensure jobs are submitted in same execution group
  • Add job dependencies to guarantee execution order
  • Check SYMLIST includes all needed variables
JCL error on EXPORT statement
  • Syntax error in SYMLIST specification
  • EXPORT statement after first EXEC
  • Invalid variable names in list
  • Check syntax of EXPORT statement
  • Move EXPORT before first EXEC statement
  • Verify all variable names are valid
Inconsistent variable values
  • Variable set after EXPORT statement
  • Variable value changed during job execution
  • Different variable with same name in receiving job
  • Set variables before EXPORT statement
  • Re-EXPORT after significant value changes
  • Use unique variable names across jobs

Debugging Tips

  • Use SYMLIST command to display defined symbols in each job
  • Set MSGLEVEL=(1,1) to see expanded JCL with resolved variables
  • Add debug steps that write variable values to job log
  • Check job scheduling to ensure correct execution sequence
  • Review system log for variable export/import messages

JES2 vs JES3 Considerations

  • Basic EXPORT functionality works similarly in both JES2 and JES3 environments
  • JES3 provides additional job dependency options through //*MAIN HOLD statement
  • JES2 and JES3 may have different rules for job execution groups
  • Check installation-specific settings for EXPORT limitations

Related Concepts