Different Structure Based on Status Code

Sometimes MF buffers’ structures change by the program scenario. With OpenLegacy, you can define the desired structure with a status code and handle the different structures.

What is the status code?

A status code is an integer that describes a buffer structure with hash, for example, F0 will be presented as 15 and F0F0 as 449.

Example hashes:
F0 - 15
F0F0 - 449
F0F1 - 450
F1F0 - 480
F1F1 - 481
F1 - 16
00 - 31

There are no success or error status codes - the customer can select the expected status code.


Status code indicator:

You can indicate the specific success structure by the following application.yml configurations.

ol.cics.project.[orchestrated-key].status-code

Key

Type

Default Value

Description

Key

Type

Default Value

Description

default-success-value

Int

15

The default value indicates success. Default value represents F0

indicators[]

List<StatusCodeIndicator>

Empty list

List of status code indicators

indicators[].offset

Int

0

Offset in the buffer to start read the status code

indicators[].length

Int

1

Number of bytes to read from the offset

 

Application.yml for example:

ol: cics: project: bla: base-url: http://localhost port: 9090 uri-map: /api/echo code-page: CP037 user: password: status-code: default-success-value: 15 indicators: - length: 2 offset: 0


How to handle a different structure?

Currently, we have two cases:

  1. The returned status code matched the default-success-value - no exception is thrown.

  2. The return status code doesn't match the default-success-value - an OperationNotMappedException will be thrown.

The OperationNotMappedException contains the full buffer, the status code bytes, and a message with the status code.

We can handle the OperationNotMappedException with try and catch, in case of more than one known status code we can use a switch case block.


An example use case:

In the following example, we will use a simple echo program that returns the same value as it sent in the response.

For this example I’ll decide that my excepted result is:

{ "echo" : "0" }

It means that the byte value is F0 and the status code is 15. This value placed at the first byte on the response buffer and its length is 1 byte.

My status code configuration should be:

status-code: default-success-value: 15 indicators: - length: 1 offset: 0

If I’ll send “0” in the request I’ll get my excepted response, for every other request I’ll get the following exception:

We can catch this exception and handle the different status codes, for example:

E.g: when echo set to 1, we will get