Quark Engine and JT400 - Part 4

In this part of Quark Engine and JT400 integration series we will show how to use JT400 ProgramCall with help of Green Screens JT400 Extension Pack.

Green Screens JT400 Extension Pack - is a module on top of JT400 helping to map IBM i program parameters and response formats.

We were not happy with PCML approach as neither with writing a lot of manual specific code required for calling IBM i program, so we developed our own engine based on Java Dynamic Proxy and InvocationHandler technology.

Main purpose of this post is to show how to expose ProgramCall to the web browser or NodeJS service etc. Demo will show you how to retrieve data from active terminal workstation based on its display name. As IBM i programs can return multiple data formats, here we will also show format selection and exposure to the web service.

Demo is made for QDCRDEVD Api and DEVD0100 format structure.

As in previous examples, we will create Controller exposing method to the web. If you read previous parts, you could see that we created a skeleton first. Here we added whole demo as only 3 lines of code are required to call IBM i program compared to standard approach making code quite clean.

@ExtJSDirect(paths = { "/ws", "/api" })
@ExtJSAction(namespace = "io.greenscreens", action = "QDCRDEVD")
public class QDCRDEVDController {

	AS400 as400;

	public ExtJSObjectResponse<DEVD0100> describe(final String displayName) {

		final ExtJSObjectResponse.Builder<DEVD0100> builder = ExtJSObjectResponse.Builder.create(DEVD0100.class);

		try {
			// QDCRDEVD program params
			final QDCRDEVD params = QDCRDEVD.build(DEVD0100.class, displayName);
			// QDCRDEVD program to be called
			final IQDCRDEVD program = IQDCRDEVD.create(as400);
			// call IBM i program 
			final DEVD0100 result = program.call(params, DEVD0100.class);

		} catch (Exception e) {
			LOG.debug(e.getMessage(), e);
		return builder.build();



Usage on browser side is straightforward

let ws= 'http://localhost:8080/io.greenscreens.quark/service';
await Engine.init({api: ws, service:ws});
await io.greenscreens.AS400.login('YOUR_SYSTEM', 'USER', 'PASSWORD');	

let obj = await io.greenscreens.QDCRDEVD.describe('QPADEV0001');

Full working source is updated on our GitHub repository here, under package demo4.

Library is open sourced under MIT license and freely available. To get complete source code from our GitHub repository, simply follow this link Green Screens JT400 Extension Pack.

Also, to find out more details, check out our blog post about Green Screens JT400 Extension Pack.