Example 10: Read the entire contents of an MVS data set member

In the following example, File Manager Service Provider REST API calls are issued to start a non-persistent session to read all records in an MVS member, using a template to map fields in each record.

This example assumes that a service archive has been created and deployed that maps an MVS data set member with a matching template or copybook. For example, the service archive could be created using the following properties file:

name=fmExample6
description=ADMIN.JCL(TERSE) MAPPED BY MY.TEMPLATE(JCL)
version=1.0
provider=filemanager
host=10.1.1.2
port=9043
userid=admin
passwd=s3cr3t
file=ADMIN.JCL(TERSE)
template=MY.TEMPLATE(JCL)
timeout=300
connid=default

This example maps an MVS data set member called ADMIN.JCL(TERSE) with a template found in MY.TEMPLATE(JCL). This example assumes that the generated SAR file and APIs built in association have been deployed to your z/OS® Connect WLP server.

Initial request

An initial API call to read data from a data resource requires an HTTP Basic Authorization header so that the caller can be authenticated for subsequent access to z/OS® data resources. For example:

Authorization : Basic dXNlcmlkOnBhc3N3b3Jk

where the string after the Basic keyword represents a Base64 encoding of userid:password.

All requests with a JSON payload also require a Content-Type header with a value of application/json.

The API caller only needs to pass "numRecords" : 10000. The session parameter defaults to false:
{
    "operation" :
    {
        "numRecords" : 10000
    }
}

This request will attempt to read and return the entire contents of the ADMIN.JCL(TERSE) member, mapped by MY.TEMPLATE(JCL).

10,000 is the maximum number of records that can be read by a single request. If the file contains more than 10,000 records, a session would be required to read the records in blocks.

{
    "records" : 
    [
        {
            "layouts" : 
            [
                {
                    "FILE" :
                    {
                        "RECORD" : "//ADMIN1   JOB(HCL),CLASS=A,NOTIFY=ADMIN"
                    }
                }
            ]
        },
        {
            "layouts" : 
            [
                {
                    "FILE" :
                    {
                        "RECORD" : "//STEP1    EXEC PGM=AMATERSE,PARM=PACK"
                    }
                }
            ]
        },
        {
            "layouts" : 
            [
                {
                    "FILE" :
                    {
                        "RECORD" : "//SYSUT1   DD DISP=SHR,DSN=ADMIN.BIN"
                    }
                }
            ]
        },
        {
            "last" : true,
            "layouts" : 
            [
                {
                    "FILE" :
                    {
                        "RECORD" : "//SYSUT2   DD DISP=SHR,DSN=ADMIN.BIN.TERSED"
                    }
                }
            ]
        }
    ]
}

The caller does not need to issue a fourth request to terminate the File Manager session because no session was maintained by the service provider. Because the second record returned is the last in the file, last is set to true.