

AWS Mainframe Modernization Service (Managed Runtime Environment experience) is no longer open to new customers. For capabilities similar to AWS Mainframe Modernization Service (Managed Runtime Environment experience) explore AWS Mainframe Modernization Service (Self-Managed Experience). Existing customers can continue to use the service as normal. For more information, see [AWS Mainframe Modernization availability change](https://docs.aws.amazon.com/m2/latest/userguide/mainframe-modernization-availability-change.html).

# Available batch utilities in AWS Mainframe Modernization
<a name="utilities-m2"></a>

Mainframe applications often use batch utility programs to perform specific functions such as sorting data, transferring files using FTP, loading data into databases like DB2, unloading data from databases, and so on.

When you migrate your applications to AWS Mainframe Modernization, you need functionally equivalent replacement utilities that can perform the same tasks as the ones you used on the mainframe. Some of these utilities might already be available as part of the AWS Mainframe Modernization runtime engines, but we are providing the following replacement utilities:
+ M2SFTP - enables secure file transfer using SFTP protocol.
+ M2WAIT - waits for a specified amount of time before continuing with the next step in a batch job.
+ TXT2PDF - converts text files to PDF format.
+ M2DFUTIL - provides backup, restore, delete, and copy functions on data sets that is similar to the support provided by the mainframe ADRDSSU utility.
+ M2RUNCMD - lets you run Rocket Software (formerly Micro Focus) commands, scripts, and system calls directly from JCL.

We developed these batch utilities based on customer feedback and designed them to provide the same functionality as the mainframe utilities. The goal is to make your transition from mainframe to AWS Mainframe Modernization as smooth as possible.

**Topics**
+ [Binary Location](#location-utilities)
+ [M2SFTP batch utility](m2sftp.md)
+ [M2WAIT batch utility](m2wait.md)
+ [TXT2PDF batch utility](txt2pdf.md)
+ [M2DFUTIL batch utility](m2dfutil.md)
+ [M2RUNCMD batch utility](m2runcmd.md)

## Binary Location
<a name="location-utilities"></a>

These utilities are preinstalled on the Rocket Enterprise Developer (ED) and Rocket Software (ES) products. You can find them in the following location for all variants of ED and ES:
+ Linux: `/opt/aws/m2/microfocus/utilities/64bit`
+ Windows (32 bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
+ Windows (64 bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

# M2SFTP batch utility
<a name="m2sftp"></a>

M2SFTP is a JCL utility program designed to perform secure file transfers between systems using the Secure File Transfer Protocol (SFTP). The program uses the Putty SFTP client, `psftp`, to perform the actual file transfers. The program works similarly to a mainframe FTP utility program and uses user and password authentication.

**Note**  
Public key authentication is not supported.

To convert your mainframe FTP JCLs to use SFTP, change `PGM=FTP` to `PGM=M2SFTP`.

**Topics**
+ [Supported platforms](#m2sftp-platforms)
+ [Installing dependencies](#m2sftp-dependencies)
+ [Configure M2SFTP for AWS Mainframe Modernization Managed](#m2sftp-configure-managed)
+ [Configure M2SFTP for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)](#m2sftp-configure-customer-infra)
+ [Sample JCLs](#m2sftp-jcl)
+ [Putty SFTP (PSFTP) client command reference](#m2sftp-cmd-ref)
+ [Next steps](#m2sftp-next)

## Supported platforms
<a name="m2sftp-platforms"></a>

You can use M2SFTP on any of the following platforms:
+ AWS Mainframe Modernization Rocket Software (formerly Micro Focus) Managed
+ Rocket Software Runtime (on Amazon EC2)
+ All variants of Rocket Software Enterprise Developer (ED) and Rocket Software Enterprise Server (ES) products.

## Installing dependencies
<a name="m2sftp-dependencies"></a>

**To install the Putty SFTP client on Windows**
+ Download the [PuTTY SFTP](https://www.putty.org/) client and install it.

**To install the Putty SFTP client on Linux:**
+ Run the following command to install the Putty SFTP client:

  ```
    sudo yum -y install putty
  ```

## Configure M2SFTP for AWS Mainframe Modernization Managed
<a name="m2sftp-configure-managed"></a>

If your migrated applications are running on AWS Mainframe Modernization Managed, you will need to configure M2SFTP as follows.
+ Set the appropriate Rocket Enterprise Server environment variables for MFFTP. Here are few examples:
  + `MFFTP_TEMP_DIR`
  + `MFFTP_SENDEOL`
  + `MFFTP_TIME`
  + `MFFTP_ABEND`

  You can set as few or as many of these variables as you want. You can set them in your JCL using the `ENVAR DD` statement. For more information on these variables, see [MFFTP Control Variables](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-3F94BBC8-CB97-4642-A4A7-4235C0C079E2.html) in the Micro Focus documentation.

To test your configuration, see [Sample JCLs](#m2sftp-jcl).

## Configure M2SFTP for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)
<a name="m2sftp-configure-customer-infra"></a>

If your migrated applications are running on AWS Mainframe Modernization runtime on Amazon EC2, configure M2SFTP as follows.

1. Change the [Micro Focus JES Program Path](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-BC8A1796-9EDE-48EB-8363-31C9BDE7F96B.html) to include the binary location for batch utilities. If you need to specify multiple paths, use colons (`:`) to separate paths on Linux and semicolons (`;`) on Windows.
   + Linux: `/opt/aws/m2/microfocus/utilities/64bit`
   + Windows (32bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
   + Windows (64bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

1. Set the appropriate Rocket Enterprise Server environment variables for MFFTP. Here are few examples:
   + `MFFTP_TEMP_DIR`
   + `MFFTP_SENDEOL`
   + `MFFTP_TIME`
   + ``MFFTP\$1ABEND

   You can set as few or as many of these variables as you want. You can set them in your JCL using the `ENVAR DD` statement. For more information on these variables, see [MFFTP Control Variables](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-3F94BBC8-CB97-4642-A4A7-4235C0C079E2.html) in the Micro Focus documentation.

To test your configuration, see [Sample JCLs](#m2sftp-jcl).

## Sample JCLs
<a name="m2sftp-jcl"></a>

To test the installation, you can use either of the following sample JCL files.

**M2SFTP1.jcl**

This JCL shows how to call M2SFTP to send a file to a remote SFTP server. Notice the environment variables that are set in the `ENVVAR DD` statement.

```
//M2SFTP1 JOB 'M2SFTP1',CLASS=A,MSGCLASS=X,TIME=1440
//*
//* Copyright Amazon.com, Inc. or its affiliates.* 
//* All Rights Reserved.* 
//*
//*-------------------------------------------------------------------**
//* Sample SFTP JCL step to send a file to SFTP server* 
//*-------------------------------------------------------------------**
//*
//STEP01 EXEC PGM=M2SFTP,
//            PARM='127.0.0.1 (EXIT=99 TIMEOUT 300'
//*
//SYSFTPD  DD  *
RECFM FB
LRECL 80
SBSENDEOL CRLF
MBSENDEOL CRLF
TRAILINGBLANKS FALSE
/*
//NETRC    DD  *
machine 127.0.0.1 login sftpuser password sftppass
/*
//SYSPRINT DD  SYSOUT=*
//OUTPUT   DD  SYSOUT=*
//STDOUT   DD  SYSOUT=*
//INPUT    DD  *
type a
locsite notrailingblanks
cd files
put 'AWS.M2.TXT2PDF1.PDF' AWS.M2.TXT2PDF1.pdf   
put 'AWS.M2.CARDDEMO.CARDDATA.PS' AWS.M2.CARDDEMO.CARDDATA.PS1.txt
quit
/*
//ENVVAR   DD *
MFFTP_VERBOSE_OUTPUT=ON
MFFTP_KEEP=N
/*
//*
//
```

**M2SFTP2.jcl**

This JCL shows how to call M2SFTP to receive a file from a remote SFTP server. Notice the environment variables set in the `ENVVAR DD` statement.

```
//M2SFTP2 JOB 'M2SFTP2',CLASS=A,MSGCLASS=X,TIME=1440
//*
//* Copyright Amazon.com, Inc. or its affiliates.* 
//* All Rights Reserved.* 
//*
//*-------------------------------------------------------------------**
//* Sample SFTP JCL step to receive a file from SFTP server* 
//*-------------------------------------------------------------------**
//*
//STEP01 EXEC PGM=M2SFTP
//*
//SYSPRINT DD  SYSOUT=*
//OUTPUT   DD  SYSOUT=*
//STDOUT   DD  SYSOUT=*
//INPUT    DD  *
open 127.0.0.1
sftpuser
sftppass
cd files
locsite recfm=fb lrecl=150
get AWS.M2.CARDDEMO.CARDDATA.PS.txt +
'AWS.M2.CARDDEMO.CARDDATA.PS2' (replace
quit
/*
//ENVVAR   DD *
MFFTP_VERBOSE_OUTPUT=ON
MFFTP_KEEP=N
/*
//*
//
```

**Note**  
We strongly recommend storing FTP credentials in a NETRC file and restricting access to only authorized users.

## Putty SFTP (PSFTP) client command reference
<a name="m2sftp-cmd-ref"></a>

The PSFTP client does not support all FTP commands. The following list shows all the commands that PSFTP does support.


| Command | Description | 
| --- | --- | 
|  \$1  |  Run a local command  | 
|  bye  |  Finish your SFTP session  | 
|  cd  |  Change your remote working directory  | 
|  chmod  |  Change file permissions and modes  | 
|  close  |  Finish your SFTP session but do not quit PSFTP  | 
|  del  |  Delete files on the remote server  | 
|  dir  |  List remote files  | 
|  exit  |  Finish your SFTP session  | 
|  get  |  Download a file from the server to your local machine  | 
|  help  |  Give help  | 
|  lcd  |  Change local working directory  | 
|  lpwd  |  Print local working directory  | 
|  ls  |  List remote files  | 
|  mget  |  Download multiple files at once  | 
|  mkdir  |  Create directories on the remote server  | 
|  mput  |  Upload multiple files at once  | 
|  mv  |  Move or rename file(s) on the remote server  | 
|  open  |  Connect to a host  | 
|  put  |  Upload a file from your local machine to the server  | 
|  pwd  |  Print your remote working directory  | 
|  quit  |  Finish your SFTP session  | 
|  reget  |  Continue downloading files  | 
|  ren  |  Move or rename file(s) on the remote server  | 
|  reput  |  Continue uploading files  | 
|  rm  |  Delete files on the remote server  | 
|  rmdir  |  Remove directories on the remote server  | 

## Next steps
<a name="m2sftp-next"></a>

To upload and download files into Amazon Simple Storage Service using SFTP, you could use M2SFTP in conjunction with the AWS Transfer Family, as described in the following blog posts.
+ [Using AWS SFTP logical directories to build a simple data distribution service](https://aws.amazon.com/blogs/storage/using-aws-sftp-logical-directories-to-build-a-simple-data-distribution-service/)
+ [Enable password authentication for AWS Transfer for SFTP using AWS Secrets Manager](https://aws.amazon.com/blogs/storage/enable-password-authentication-for-aws-transfer-for-sftp-using-aws-secrets-manager/)

# M2WAIT batch utility
<a name="m2wait"></a>

M2WAIT is a mainframe utility program that enables you to introduce a wait period in your JCL scripts by specifying a time duration in seconds, minutes, or hours. You can call M2WAIT directly from JCL by passing the time you want to wait as an input parameter. Internally, the M2WAIT program calls the Rocket Software (formerly Micro Focus) supplied module `C$SLEEP` to wait for a specified time.

**Note**  
You can use Micro Focus aliases to replace what you have in your JCL scripts. For more information, see [JES Alias](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-D4206FF9-32C4-43E7-9413-5E7E96AA8092.html) in the Micro Focus documentation.

**Topics**
+ [Supported platforms](#m2wait-platforms)
+ [Configure M2WAIT for AWS Mainframe Modernization Managed](#m2wait-configure-managed)
+ [Configure M2WAIT for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)](#m2wait-configure-customer-infra)
+ [Sample JCL](#m2wait-jcl)

## Supported platforms
<a name="m2wait-platforms"></a>

You can use M2WAIT on any of the following platforms:
+ AWS Mainframe Modernization Rocket Software (formerly Micro Focus) Managed
+ Rocket Software Runtime (on Amazon EC2)
+ All variants of Rocket Software Enterprise Developer (ED) and Rocket Software Enterprise Server (ES) products.

## Configure M2WAIT for AWS Mainframe Modernization Managed
<a name="m2wait-configure-managed"></a>

If your migrated applications are running on AWS Mainframe Modernization Managed, you will need to configure M2WAIT as follows.
+ Use the program M2WAIT in your JCL by passing input parameter as shown in [Sample JCL](#m2wait-jcl).

## Configure M2WAIT for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)
<a name="m2wait-configure-customer-infra"></a>

If your migrated applications are running on AWS Mainframe Modernization runtime on Amazon EC2, configure M2WAIT as follows.

1. Change the [Micro Focus JES Program Path](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-BC8A1796-9EDE-48EB-8363-31C9BDE7F96B.html) to include the binary location for batch utilities. If you need to specify multiple paths, use colons (`:`) to separate paths on Linux and semicolons (`;`) on Windows.
   + Linux: `/opt/aws/m2/microfocus/utilities/64bit`
   + Windows (32bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
   + Windows (64bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

1. Use the program M2WAIT in your JCL by passing the input parameter as shown in [Sample JCL](#m2wait-jcl).

## Sample JCL
<a name="m2wait-jcl"></a>

To test the installation, you can use the `M2WAIT1.jcl` program.

This sample JCL shows how to call M2WAIT and pass it several different durations.

```
//M2WAIT1 JOB 'M2WAIT',CLASS=A,MSGCLASS=X,TIME=1440
//*
//* Copyright Amazon.com, Inc. or its affiliates.* 
//* All Rights Reserved.* 
//*
//*-------------------------------------------------------------------**
//* Wait for 12 Seconds*
//*-------------------------------------------------------------------**
//*
//STEP01 EXEC PGM=M2WAIT,PARM='S012'
//SYSOUT DD SYSOUT=*
//*
//*-------------------------------------------------------------------**
//* Wait for 0 Seconds (defaulted to 10 Seconds)*
//*-------------------------------------------------------------------**
//*
//STEP02 EXEC PGM=M2WAIT,PARM='S000'
//SYSOUT DD SYSOUT=*
//*
//*-------------------------------------------------------------------**
//* Wait for 1 Minute*
//*-------------------------------------------------------------------**
//*
//STEP03 EXEC PGM=M2WAIT,PARM='M001'
//SYSOUT DD SYSOUT=*
//*
//
```

# TXT2PDF batch utility
<a name="txt2pdf"></a>

TXT2PDF is a mainframe utility program commonly used to convert a text file to a PDF file. This utility uses the same source code for TXT2PDF (z/OS freeware). We modified it to run under the AWS Mainframe Modernization Rocket Software (formerly Micro Focus) runtime environment.

**Topics**
+ [Supported platforms](#txt2pdf-platforms)
+ [Configure TXT2PDF for AWS Mainframe Modernization Managed](#txt2pdf-configure-managed)
+ [Configure TXT2PDF for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)](#txt2pdf-configure-customer-infra)
+ [Sample JCL](#txt2pdf-jcl)
+ [Modifications](#txt2pdf-mods)
+ [References](#txt2pdf-ref)

## Supported platforms
<a name="txt2pdf-platforms"></a>

You can use TXT2PDF on any of the following platforms:
+ AWS Mainframe Modernization Rocket Software Managed
+ Rocket Software Runtime (on Amazon EC2)
+ All variants of Rocket Enterprise Developer (ED) and Rocket Enterprise Server (ES) products.

## Configure TXT2PDF for AWS Mainframe Modernization Managed
<a name="txt2pdf-configure-managed"></a>

If your migrated applications are running on AWS Mainframe Modernization Managed, configure TXT2PDF as follows.
+ Create a REXX EXEC library called `AWS.M2.REXX.EXEC`. Download these [REXX modules](https://drm0z31ua8gi7.cloudfront.net/utilities/mf/TXT2PDF/rexx/TXT2PDF_rexx.zip) and copy them into the library. 
  + `TXT2PDF.rex` - TXT2PDF z/OS freeware (modified)
  + `TXT2PDFD.rex` - TXT2PDF z/OS freeware (unmodified)
  + `TXT2PDFX.rex` - TXT2PDF z/OS freeware (modified)
  + `M2GETOS.rex` - To check the OS type (Windows or Linux)

To test your configuration, see [Sample JCL](#txt2pdf-jcl).

## Configure TXT2PDF for AWS Mainframe Modernization runtime on Amazon EC2 (including WorkSpaces Applications)
<a name="txt2pdf-configure-customer-infra"></a>

If your migrated applications are running on AWS Mainframe Modernization runtime on Amazon EC2, configure TXT2PDF as follows.

1. Set the Rocket Software environment variable `MFREXX_CHARSET` to the appropriate value, such as “`A`" for ASCII data.
**Important**  
Entering the wrong value could cause data conversion issues (from EBCDIC to ASCII), making the resulting PDF unreadable or inoperable. We recommend setting `MFREXX_CHARSET` to match `MF_CHARSET`.

1. Change the [Micro Focus JES Program Path](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/GUID-BC8A1796-9EDE-48EB-8363-31C9BDE7F96B.html) to include the binary location for batch utilities. If you need to specify multiple paths, use colons (`:`) to separate paths on Linux and semicolons (`;`) on Windows.
   + Linux: `/opt/aws/m2/microfocus/utilities/64bit`
   + Windows (32bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
   + Windows (64bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

1. Create a REXX EXEC library called `AWS.M2.REXX.EXEC``. Download these [REXX modules](https://drm0z31ua8gi7.cloudfront.net/utilities/mf/TXT2PDF/rexx/TXT2PDF_rexx.zip) and copy them into the library. 
   + `TXT2PDF.rex` - TXT2PDF z/OS freeware (modified)
   + `TXT2PDFD.rex` - TXT2PDF z/OS freeware (unmodified)
   + `TXT2PDFX.rex` - TXT2PDF z/OS freeware (modified)
   + `M2GETOS.rex` - To check the OS type (Windows or Linux)

To test your configuration, see [Sample JCL](#txt2pdf-jcl).

## Sample JCL
<a name="txt2pdf-jcl"></a>

To test the installation, you can use either of the following sample JCL files.

**TXT2PDF1.jcl**

This sample JCL file uses a DD name for the TXT2PDF conversion.

```
//TXT2PDF1 JOB 'TXT2PDF1',CLASS=A,MSGCLASS=X,TIME=1440
//*
//* Copyright Amazon.com, Inc. or its affiliates.* 
//* All Rights Reserved.* 
//*
//*-------------------------------------------------------------------**
//* PRE DELETE*
//*-------------------------------------------------------------------**
//*
//PREDEL  EXEC PGM=IEFBR14
//* 
//DD01     DD DSN=AWS.M2.TXT2PDF1.PDF.VB,                      
//            DISP=(MOD,DELETE,DELETE)
//*
//DD02     DD DSN=AWS.M2.TXT2PDF1.PDF,                       
//            DISP=(MOD,DELETE,DELETE)
//* 
//*-------------------------------------------------------------------**
//* CALL TXT2PDF TO CONVERT FROM TEXT TO PDF (VB)*
//*-------------------------------------------------------------------**
//*
//STEP01 EXEC PGM=IKJEFT1B
//*
//SYSEXEC  DD DISP=SHR,DSN=AWS.M2.REXX.EXEC
//*
//INDD     DD *
1THIS IS THE FIRST LINE ON THE PAGE 1
0THIS IS THE THIRD LINE ON THE PAGE 1
-THIS IS THE   6TH LINE ON THE PAGE 1
THIS IS THE   7TH LINE ON THE PAGE 1
+____________________________________ - OVERSTRIKE 7TH LINE          
1THIS IS THE FIRST LINE ON THE PAGE 2
0THIS IS THE THIRD LINE ON THE PAGE 2
-THIS IS THE   6TH LINE ON THE PAGE 2 
THIS IS THE   7TH LINE ON THE PAGE 2
+____________________________________ - OVERSTRIKE 7TH LINE                 
/*
//*
//OUTDD    DD DSN=AWS.M2.TXT2PDF1.PDF.VB,
//            DISP=(NEW,CATLG,DELETE),
//            DCB=(LRECL=256,DSORG=PS,RECFM=VB,BLKSIZE=0)
//*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD DDNAME=SYSIN
//*
//SYSIN    DD *
%TXT2PDF BROWSE Y IN DD:INDD +
OUT DD:OUTDD +
CC YES
/*
//*
//*-------------------------------------------------------------------**
//* CONVERT PDF (VB) TO PDF (LSEQ - BYTE STREAM)*
//*-------------------------------------------------------------------**
//* 
//STEP02 EXEC PGM=VB2LSEQ
//*
//INFILE   DD DSN=AWS.M2.TXT2PDF1.PDF.VB,DISP=SHR             
//*
//OUTFILE  DD DSN=AWS.M2.TXT2PDF1.PDF,                      
//            DISP=(NEW,CATLG,DELETE),
//            DCB=(LRECL=256,DSORG=PS,RECFM=LSEQ,BLKSIZE=0)
//*
//SYSOUT   DD SYSOUT=*
//*
//
```

**TXT2PDF2.jcl**

This sample JCL uses a DSN name for the TXT2PDF conversion.

```
//TXT2PDF2 JOB 'TXT2PDF2',CLASS=A,MSGCLASS=X,TIME=1440
//*
//* Copyright Amazon.com, Inc. or its affiliates.* 
//* All Rights Reserved.* 
//*
//*-------------------------------------------------------------------**
//* PRE DELETE*
//*-------------------------------------------------------------------**
//*
//PREDEL  EXEC PGM=IEFBR14
//* 
//DD01     DD DSN=AWS.M2.TXT2PDF2.PDF.VB,                      
//            DISP=(MOD,DELETE,DELETE)
//*
//DD02     DD DSN=AWS.M2.TXT2PDF2.PDF,                       
//            DISP=(MOD,DELETE,DELETE)
//* 
//*-------------------------------------------------------------------**
//* CALL TXT2PDF TO CONVERT FROM TEXT TO PDF (VB)*
//*-------------------------------------------------------------------**
//* 
//STEP01 EXEC PGM=IKJEFT1B
//*
//SYSEXEC  DD DISP=SHR,DSN=AWS.M2.REXX.EXEC
//*
//INDD     DD *
1THIS IS THE FIRST LINE ON THE PAGE 1
0THIS IS THE THIRD LINE ON THE PAGE 1
-THIS IS THE   6TH LINE ON THE PAGE 1
THIS IS THE   7TH LINE ON THE PAGE 1
+____________________________________ - OVERSTRIKE 7TH LINE          
1THIS IS THE FIRST LINE ON THE PAGE 2
0THIS IS THE THIRD LINE ON THE PAGE 2
-THIS IS THE   6TH LINE ON THE PAGE 2 
THIS IS THE   7TH LINE ON THE PAGE 2
+____________________________________ - OVERSTRIKE 7TH LINE                 
/*
//*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD DDNAME=SYSIN
//*
//SYSIN    DD *
%TXT2PDF BROWSE Y IN DD:INDD +
OUT 'AWS.M2.TXT2PDF2.PDF.VB' +
CC YES
/*
//*
//*-------------------------------------------------------------------**
//* CONVERT PDF (VB) TO PDF (LSEQ - BYTE STREAM)*
//*-------------------------------------------------------------------**
//*
//STEP02 EXEC PGM=VB2LSEQ
//*
//INFILE   DD DSN=AWS.M2.TXT2PDF2.PDF.VB,DISP=SHR             
//*
//OUTFILE  DD DSN=AWS.M2.TXT2PDF2.PDF,                      
//            DISP=(NEW,CATLG,DELETE),
//            DCB=(LRECL=256,DSORG=PS,RECFM=LSEQ,BLKSIZE=0)
//*
//SYSOUT   DD SYSOUT=*
//*
//
```

## Modifications
<a name="txt2pdf-mods"></a>

To make the TXT2PDF program run on the AWS Mainframe Modernization Rocket Software runtime environment, we made the following changes:
+ Changes to the source code to ensure compatibility with the Rocket Software REXX runtime
+ Changes to ensure that the program can run on both Windows and Linux operating systems
+ Modifications to support both EBCDIC and ASCII runtime

## References
<a name="txt2pdf-ref"></a>

TXT2PDF references and source code:
+ [Text to PDF converter](https://homerow.net/rexx/txt2pdf/)
+ [z/OS Freeware TCP/IP and Mail Tools](http://www.lbdsoftware.com/tcpip.html)
+ [TXT2PDF User Reference Guide](http://www.lbdsoftware.com/TXT2PDF-User-Guide.pdf)

# M2DFUTIL batch utility
<a name="m2dfutil"></a>

M2DFUTIL is a JCL utility program that provides backup, restore, delete, and copy functions on datasets, similar to the support provided by the mainframe ADRDSSU utility. This program retains many of the SYSIN parameters from ADRDSSU, which streamlines the process to migrate to this new utility.

**Topics**
+ [Supported platforms](#m2dfutil-platforms)
+ [Platform requirements](#m2dfutil-platform)
+ [Planned future support](#m2udfutil-future-support)
+ [Asset locations](#mdfutil-assets)
+ [Configure M2DFUTIL or AWS Mainframe Modernization runtime on Amazon EC2 (including AppStream 2.0)](#mdfutil-dependencies)
+ [General syntax](#mdfutil-syntax)
+ [Sample JCLs](#mdfutil-sample-jcls)

## Supported platforms
<a name="m2dfutil-platforms"></a>

You can use M2DFUTIL on any of the following platforms:
+ Rocket Software (formerly Micro Focus) ES on Windows (64 bit and 32 bit)
+ Rocket Software ES on Linux (64 bit)

## Platform requirements
<a name="m2dfutil-platform"></a>

M2DFUTIL depends on calling a script to perform a regular expression test. On Windows, you must install Windows Services for Linux (WSL) for this script to run.

## Planned future support
<a name="m2udfutil-future-support"></a>

Features that are not currently available from the mainframe ADRDSSU utility, but are in the future scope include: 
+ M2 Managed
+ VSAM
+ COPY support for file name renaming
+ RENAME support for RESTORE 
+ Multiple INCLUDE and EXCLUDE
+ BY clause for subselecting by DSORG, CREDT, EXPDT
+ MWAIT clause to retry enqueue failures
+ S3 storage support for DUMP/RESTORE

## Asset locations
<a name="mdfutil-assets"></a>

The load module for this utility is called `M2DFUTIL.so` on Linux and `M2DFUTIL.dll` on Windows. This load module can be found in the following locations:
+ Linux: `/opt/aws/m2/microfocus/utilities/64bit`
+ Windows (32 bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
+ Windows (64 bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

The script used for regular expression testing is called `compare.sh`. This script can be found in the following locations:
+ Linux: `/opt/aws/m2/microfocus/utilities/scripts`
+ Windows (32 bit): `C:\AWS\M2\MicroFocus\Utilities\scripts`

## Configure M2DFUTIL or AWS Mainframe Modernization runtime on Amazon EC2 (including AppStream 2.0)
<a name="mdfutil-dependencies"></a>

Configure your Enterprise Server region with the following:
+ Add the following variables in **[ES-Environment]**
  + `M2DFUTILS_BASE_LOC` - The default location for DUMP output
  + `M2DFUTILS_SCRIPTPATH` - The location of the `compare.sh` script documented in **Asset Locations**
  + `M2DFUTILS_VERBOSE` - [VERBOSE or NORMAL]. This controls the level of detail in the `SYSPRINT `output
+ Verify that the load module path is added to the `JES\Configuration\JES Program Path` setting
+ Verify that the scripts in the utilities directory have run permissions. You can add a run permission using the `chmod + x <script name>` command, in the Linux environment

## General syntax
<a name="mdfutil-syntax"></a>

### DUMP
<a name="mdfutil-dump"></a>

Provides the ability to copy files from the present cataloged location to a backup location. This location must currently be a file system.

#### Process
<a name="mdfutil-dump-process"></a>

DUMP will perform the following:

1. Create the target location directory.

1. Catalog the target location directory as a PDS member.

1. Determine the files to be included by processing the INCLUDE parameter.

1. Deselect included files by processing the EXCLUDE parameter.

1. Determine if the files being dumped are to be DELETED.

1. Enqueue the files to be processed.

1. Copy the files.

1. Export the copied files cataloged DCB information to a side file in the target location to assist with future RESTORE operations.

#### Syntax
<a name="mdfutil-dump-syntax"></a>

```
DUMP
TARGET ( TARGET LOCATION  )    -
INCLUDE ( DSN. )
[ EXCLUDE ( DSN ) ]
[ CANCEL | IGNORE ]
[ DELETE ]
```

#### Required parameters
<a name="mdfutil-dump-requiredparam"></a>

Following are the required parameters for DUMP:
+ `SYSPRINT DD NAME` - To contain additional logging information
+ `TARGET` - Target location. It can be either:
  + Full path of the dump location
  + Subdirectory name created in the location defined in the **M2DFUTILS\$1BASE\$1LOC** variable
+ `INCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string
+ `EXCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string

#### Optional parameters
<a name="mdfutil-dump-optionalparam"></a>
+ CANCEL - Cancel if any error occurs. Files that were processed will be retained
+ (Default) IGNORE - Ignore any error and process until end
+ DELETE - If no ENQ error occurs, then the file is deleted and is uncataloged

### DELETE
<a name="mdfutil-delete"></a>

Provides the ability to mass delete and uncatalog files. Files are not backed up.

#### Process
<a name="mdfutil-delete-process"></a>

DELETE will perform the following:

1. Determine the files to be included by processing the INCLUDE parameter.

1. Deselect included files by processing the EXCLUDE parameter.

1. Enqueue the files to be processed. Setting the disposition to OLD, DELETE, KEEP.

#### Syntax
<a name="mdfutil-delete-syntax"></a>

```
DELETE
INCLUDE ( DSN )
[ EXCLUDE ( DSN ) ]
[ CANCEL | IGNORE ]
[ DELETE ]
```

#### Required parameters
<a name="mdfutil-delete-requiredparam"></a>

Following are the required parameters for DELETE:
+ `SYSPRINT DD NAME` - To contain additional logging information
+ `INCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string 
+ `EXCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string 

#### Optional parameters
<a name="mdfutil-delete-optionalparam"></a>
+ CANCEL - Cancel if any error occurs. Files that are processed will be retained 
+ (Default) IGNORE - Ignore any error and process until end

### RESTORE
<a name="mdfutil-restore"></a>

Provides the ability to restore files previously backed up using DUMP. Files are restored to the original cataloged location unless RENAME is used to alter the restored DSNAME.

#### Process
<a name="mdfutil-restore-process"></a>

RESTORE will perform the following:

1. Validate the source location directory.

1. Determine the files to be included by processing the catalog export file.

1. Deselect included files by processing the EXCLUDE parameter.

1. Enqueue the files to be processed.

1. Catalog files that aren't cataloged based on their export information.

1. If a file is already cataloged and the export catalog information is the same, RESTORE will replace the cataloged dataset if the REPLACE option is set.

#### Syntax
<a name="mdfutil-restore-syntax"></a>

```
RESTORE
SOURCE ( TARGET LOCATION ) 
INCLUDE ( DSN )
[ EXCLUDE ( DSN ) ]
[ CANCEL | IGNORE ]
[ REPLACE]
```

#### Required parameters
<a name="mdfutil-restore-requiredparam"></a>

Following are the required parameters for RESTORE:
+ `SYSPRINT DD NAME` - To contain additional logging information 
+ `SOURCE` - Source location. It can be either:
  + Full path of the dump location
  + Subdirectory name created in the location defined in the **M2DFUTILS\$1BASE\$1LOC** variable
+ `INCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string
+ `EXCLUDE` - Either a single named DSNAME or a valid mainframe DSN search string

#### Optional parameters
<a name="mdfutil-restore-optionalparam"></a>
+ CANCEL - Cancel if any error. Files processed retained
+ (Default) IGNORE - Ignore any error and process until end
+ REPLACE - If the file being restored is already cataloged and the catalog records are the same, then replace the cataloged file

## Sample JCLs
<a name="mdfutil-sample-jcls"></a>

 **DUMP job**

This job will create a subdirectory called `TESTDUMP`. This is the default backup location specified by the **M2DFUTILS\$1BASE\$1LOC** variable. It will create a PDS library for this backup called `M2DFUTILS.TESTDUMP`. The exported catalog data is stored in a line sequential file in the backup directory called `CATDUMP.DAT`. All files selected will be copied to this backup directory.

```
//M2DFDMP JOB 'M2DFDMP',CLASS=A,MSGCLASS=X
//STEP001  EXEC PGM=M2DFUTIL
//SYSPRINT DD DSN=TESTDUMP.SYSPRINT,
//        DISP=(NEW,CATLG,DELETE),
//        DCB=(RECFM=LSEQ,LRECL=256)
//SYSIN    DD *
DUMP TARGET(TESTDUMP)               -
     INCLUDE(TEST.FB.FILE*.ABC)     -
 CANCEL
/*
//
```

 **DELETE job**

This job will delete all files from the catalog that match the INCLUDE parameter.

```
/M2DFDEL JOB 'M2DFDEL',CLASS=A,MSGCLASS=X
//STEP001  EXEC PGM=M2DFUTIL
//SYSPRINT DD DSN=TESTDEL.SYSPRINT,
//        DISP=(NEW,CATLG,DELETE),
//        DCB=(RECFM=LSEQ,LRECL=256)
//SYSPRINT DD SYSOUT=A
//SYSIN    DD *
  DELETE                               -
     INCLUDE(TEST.FB.FILE*.ABC)        -
 CANCEL
/*
 //
```

 **RESTORE job**

This job will restore the files that match the INCLUDE parameter from the `TESTDUMP` backup location. Files that are cataloged will be replaced if the cataloged file is the same as the one in the CATDUMP export and the REPLACE option is specified.

```
//M2DFREST JOB 'M2DFREST',CLASS=A,MSGCLASS=X
//STEP001  EXEC PGM=M2DFUTIL
////SYSPRINT DD DSN=TESTREST.SYSPRINT,
//        DISP=(NEW,CATLG,DELETE),
//        DCB=(RECFM=LSEQ,LRECL=256)
//SYSPRINT DD SYSOUT=A
//SYSIN    DD *
RESTORE SOURCE(TESTDUMP)               -
     INCLUDE(TEST.FB.FILE*.ABC)        -
 IGNORE
 REPLACE
/*
//
```

# M2RUNCMD batch utility
<a name="m2runcmd"></a>

You can use M2RUNCMD, a batch utility program, to run Rocket Software (formerly Micro Focus) commands, scripts, and system calls directly from JCL instead of running them from a terminal or command prompt. The output from the commands is logged to the batch job's spool log.

**Topics**
+ [Supported platforms](#m2runcmd-platforms)
+ [Configure M2RUNCMD for AWS Mainframe Modernization runtime on Amazon EC2 (including AppStream 2.0)](#m2runcmd-configure)
+ [Sample JCLs](#m2runcmd-sample-jcls)

## Supported platforms
<a name="m2runcmd-platforms"></a>

You can use M2RUNCMD on the following platforms:
+ Rocket Software Runtime (on Amazon EC2)
+  All variants of Rocket Software Enterprise Developer (ED) and Rocket Software Enterprise Server (ES) products.

## Configure M2RUNCMD for AWS Mainframe Modernization runtime on Amazon EC2 (including AppStream 2.0)
<a name="m2runcmd-configure"></a>

If your migrated applications are running on AWS Mainframe Modernization runtime on Amazon EC2, configure M2RUNCMD as follows.
+ Change the [Micro Focus JES Program Path](https://www.microfocus.com/documentation/enterprise-developer/ed80/ED-Eclipse/index.html?t=GUID-BC8A1796-9EDE-48EB-8363-31C9BDE7F96B.html) to include the binary location for batch utilities. If you must specify multiple paths, use colons (:) to separate paths on Linux and semicolons (;) on Windows.
  + Linux: `/opt/aws/m2/microfocus/utilities/64bit`
  + Windows (32bit): `C:\AWS\M2\MicroFocus\Utilities\32bit`
  + Windows (64bit): `C:\AWS\M2\MicroFocus\Utilities\64bit`

## Sample JCLs
<a name="m2runcmd-sample-jcls"></a>

To test the installation, you can use either of the following sample JCLs.

 **RUNSCRL1.jcl**

This sample JCL creates a script and runs it. The first step creates a script called `/tmp/TEST_SCRIPT.sh` and with content from `SYSUT1` in-stream data. The second step sets the run permission and runs the script created in the first step. You can also choose to perform only the second step to run already existing Rocket Software and system commands.

```
//RUNSCRL1 JOB 'RUN SCRIPT',CLASS=A,MSGCLASS=X,TIME=1440
//*
//*
//*-------------------------------------------------------------------*
//*  CREATE SCRIPT (LINUX)                                           
//*-------------------------------------------------------------------*
//*
//STEP0010 EXEC PGM=IEBGENER
//*
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DUMMY
//*
//SYSUT1   DD *
#!/bin/bash

set -x

## ECHO PATH ENVIRONMNET VARIABLE
echo $PATH

## CLOSE/DISABLE VSAM FILE
casfile -r$ES_SERVER -oc  -ed -dACCTFIL

## OPEN/ENABLE VSAM FILE
casfile -r$ES_SERVER -ooi -ee -dACCTFIL

exit $?
/*
//SYSUT2   DD DSN=&&TEMP,
//            DISP=(NEW,CATLG,DELETE),
//            DCB=(RECFM=LSEQ,LRECL=300,DSORG=PS,BLKSIZE=0)
//*MFE: %PCDSN='/tmp/TEST_SCRIPT.sh'
//*
//*-------------------------------------------------------------------*
//*   RUN SCRIPT (LINUX)                                              *
//*-------------------------------------------------------------------*
//*
//STEP0020 EXEC PGM=RUNCMD
//*
//SYSOUT  DD  SYSOUT=*
//* 
//SYSIN   DD *
*RUN SCRIPT
 sh /tmp/TEST_SCRIPT.sh
/*
//
```

 **SYSOUT**

The output from the command or script that is run, is written into the `SYSOUT` log. For each carried out command, it displays the command, output, and return code.

```
************ CMD Start ************   
                                                                                    
CMD_STR: sh /tmp/TEST_SCRIPT.sh                                                                                              
CMD_OUT:                                                                                                                                                                                                                             
+ echo /opt/microfocus/EnterpriseServer/bin:/sbin:/bin:/usr/sbin:/usr/bin    
/opt/microfocus/EnterpriseServer/bin:/sbin:/bin:/usr/sbin:/usr/bin           
+ casfile -rMYDEV -oc -ed -dACCTFIL                                                                       
-Return Code:   0                                                                                                         
Highest return code:    0                                                                                                 
+ casfile -rMYDEV -ooi -ee -dACCTFIL                                                                     
-Return Code:   8                                                                                                         
Highest return code:    8                                                                                                 
+ exit 8                                                                                                                  

CMD_RC=8                                                                                                                  

************  CMD End  ************
```

 **RUNCMDL1.jcl**

This sample JCL uses RUNCMD to run multiple commands.

```
//RUNCMDL1 JOB 'RUN CMD',CLASS=A,MSGCLASS=X,TIME=1440
//*
//*
//*-------------------------------------------------------------------*
//*   RUN SYSTEM COMMANDS                                             *
//*-------------------------------------------------------------------*
//*
//STEP0001 EXEC PGM=RUNCMD
//*
//SYSOUT  DD  SYSOUT=*
//* 
//SYSIN   DD *
*LIST DIRECTORY
 ls
*ECHO PATH ENVIRONMNET VARIABLE
 echo $PATH
/*
//
```