Integrating Monarch With the Rest of the World
Using Non-Display File .ASPX Pages

The ASNA Monarch® 3.1 Framework now provides for application integration between Monarch and “non-Monarch” application classes. Using Monarch’s Command class, stateless C#, VB.NET and AVR for .NET ASPX pages can employ CALL/Parm with both stateful interactive and non-interactive Monarch program classes. And, using the Monarch Job’s ShowPage method, stateful programs can initiate stateless web page requests and wait for the web application to return to the program.
Overview of the Monarch Job
Monarch based programs execute within the context of a job, which is not dissimilar in function for an iSeries job. For example, the Monarch Job provides a program with a connection to the database, with a set of global variables shared among all the programs in the Job (the LDA and LDC ), and with a mechanism to support instantiations based on activation groups. A Job also provides an interactive program with the infrastructure supporting display files.
A job can be in one of four general states:
1) Just created
2) Executing a Program
3) Waiting for input from the user
4) Accepting Commands
The first three states would be familiar to most iSeries developers: After a Job has been created it is in state 1), it transitions to state 2) when the Job’s ExecuteStartupProgram method is executed. Then, when a program executes a READ or EXFMT on a workstation format, the job goes into state 3).
In order to invoke a program from within the code-behind a Non-Display File (NDF) ASPX page, it is necessary to have a Job to supply the context where the program can run. This Job needs to be in a state where it is able to accept requests to execute arbitrary programs outside of the normal calling graph created by program calls. The cooperation of the Job in this NDF environment is essential: a program within the Job must make the Job enter state 4) which allows it to accept commands from non-Monarch ASPX pages.
ShowPage Method
Imagine an iSeries 5250 order entry application being able to request a web-based credit card payment and to wait for the processing service to return the result of the request. This is the inter-application execution that is supported by the Monarch job’s ShowPage function. Below is a simple illustration of how the ShowPage is used in the stateful Visual RPG code.

The processing flow might be similar to the diagram below. ProcessCC.aspx is the web page in the application’s web site that makes the formal request to the card processing service (note that is a C# aspx page). The service returns by requesting ProcessCC.aspx or whatever the assigned web page in the Monarch application’s web site. Then the web page employs the Monarch Command class to return to the suspended program, CUSTPAY, at the next instruction following ShowPage.

ShowPage Diagram
The Command class provides a Return method as the mechanism to return to the requesting program call stack (step 4). ASNA.Monarch.Command will be covered in greater detail in a moment.
AcceptCommands
This function is another provided by the Monarch job that places the job at the ready to accept stateful interactive and non-interactive program CALL requests originating from stateless ASPX pages. The typical usage is in the Monarch job’s ExecuteStartupProgram method. When the user makes the initial request to the Web Site, the startup page might be a menu ASPX web page (VB, C#, AVR, etc.) that would use the Monarch Command class to CALL both interactive and non-interactive Monarch program classes.

MyJob.vr
ASNA.Monarch.Command
The Command class is instanced and used by the ASPX web pages to invoke either interactive or process programs. Programs receive parameters by reference; i.e., the ASPX code can send and receive data to/from the called program; the parameters are stored in an array of strings. The called program can define its parameters list using fields of type character and decimal (zoned, packed, binary and decimal).
With the Command class, the non-display file ASPX web pages have the same access to Monarch Program and CLProgram classes that any other migrated program.

CALL/Parm From Stateless ASPX
More Than CALL/Parm
The ASNA.Monarch.Command comes equipped with more job related methods besides CALL. The following methods are implemented with accompanying explanation:

Summary
There is plenty of growing room in a migrated iSeries application. Not only may the application can be extended by adding functionality to the Display File Pages, but Non-Display File pages can CALL and be CALLed by the application.
Availability
Monarch 3.1 is generally available. Ask your ASNA Sales Representative for more information or a Webex presentation.