Haroon - I’d be glad to outline some approaches. I’m assuming the data transfer is from Natural to Java rather than the other way around.
On the Natural side, the called subprogram(s) may need to use “DEFINE DATA CONTEXT” to keep track of how much data has been sent already. As each RPC call to a subprogram invokes the subprogram again, you can’t just send all the data from a database access loop.
So, in either case, to use RPC, either the server needs to keep track of where it left off or the data being sent back and forth between the client and server needs to include restart information.
A web based transaction will often include something similar to this. For example, we browse the “employees” file by name, starting with a user-supplied value (“SMITH”). A “page” of names is sent in the first reply, along with some restart values (last name sent and ISN of record). When the web user presses “next”, the subprogram does a new READ LOGICAL that includes the last name and starting ISN.
This “stateless” model is appropriate if there is user interaction between each “page” (as users can abandon a page, it would leave a “conversation” hanging until it timed out, tying up a server). If there is no user interaction, then the subprogram could use the CONTEXT data to track the restart point, but the restart logic would be about the same as for the stateless version. From my point of view, there is not much advantage to the conversational, stateful approach over the stateless approach, besides a modest simplification on the client side.
The one case where a conversation is helpful: if you are doing an series of RPC calls that update the database. When the client commits the conversation, Natural issues an “end transaction” to commit the updates to the database.
I’ve enclosed an example of a Java program calling a Natural program with a conversation. It uses the demo “Employees” file on the Natural side - although written in Natural for Windows, it should work in Natural 3 or above on the mainframe.
The EMPLISTN.txt is the subprogram to be called (EMPLISTP.txt is a driver program to test the subprogram on the mainframe Natural side). Open the emplistn.idl in the EntireX Workbench, adjust the properties for your environment (broker, server address, etc) and generate the Java client. Modify the source for “Emplist.java” to set your RPC properties as appropriate.
Douglas Kelly,
Principal Consultant
Software AG, Inc
Sacramento, California
RPC_Conv.zip (4.84 KB)
#EntireX#webMethods#Mainframe-Integration