Example 5: Read from a position within an IMS database

In the following example, Z Data Tools Service Provider REST API calls are issued to position within an IMS™ database and then read a segment at that position.

Initial request

An initial API call to read data from an IMS data resource requires an HTTP Basic Authorization header so that the caller can be authenticated for subsequent access to IMS 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 initial request also requires the name of the IMS subsystem, the IMS database name, a PSB member name, an IMS region type, and a ZDT/IMS view to map the data. Dynamic PSBs are supported and can be specified by using the psbName parameter and the value DYNAMIC.

The position parameters allow the specification of a series of segmentKeys, which match the hierarchy of the database and keyed segments. In this case, we are positioning on a root segment with a key value equal to "02922399-001":

{
    "resource" :
    {
        "ssid" : "IFB2",
        "database" : "HDOU#1",
        "psbMember" : "PHDOU#1",
        "pcbName" : "DBPCB1",
        "regionType" : "BMP"
    },
    "view" :
    {
        "viewName" : "IMS.VIEW(HDOU#1)"
    },
    "operation" : 
    {
        "numSegments" : 1,
        "session" : false
    } ,
    "position" : 
    {
        "segmentKeys" :
        [
            {
                "segmentName" : "PARTROOT",
                "keyValue" : "02922399-001",
                "operator" : "EQ"
            }
        ]
    }  
}

This request reads one segment from the nominated position within the IMS database HDOU#1 in IMS subsystem IFB2. The request will use PSB member PHDOU#1 and the PCB with label DBPCB1 in the PSB member. The region type is BMP. The request will use the view IMS.VIEW(HDOU#1) to map out the segment fields in the response.

The service provider will not persist a ZDT/IMS session because session is set to false.

Successful response

A successful response (HTTP Status Code 200) will be similar to the following:

{
    "segments": 
    [
        {
            "segment": 
            {
                "layout": "PARTROOT",
                "segname": "PARTROOT",
                "fields":
                [
                    {
                        "field": "ROOT-TYPE",
                        "type": "AN",
                        "value": "02"
                    },
                    {
                        "field": "ROOT-KEY",
                        "type": "AN",
                        "value": "922399-001"
                    },
                    {
                        "field": "ROOT-SPACES",
                        "type": "AN",
                        "value": " "
                    },
                    {
                        "field": "ROOT-WOSNAME",
                        "type": "AN",
                        "value": "CONNECTOR"
                    }
                ]
            }
        }
    ]
}

The caller does not need to issue a second request to terminate the ZDT/IMS session because no session was maintained by the service provider.