Using Java API calls to execute ECRTP

This section describes how to use a Java program to call the Java-callable version of the ECRTP. CALLRTP.DLL was created using jni (Jave Native Interface) and OWRM32C.DLL contains ECRTP C/C++ API calls. Both are compiled as fully reentrant, multi-threaded .dlls using VC++. The Java classes MYAPP and RTP call CALLRTP.DLL. CALLRTP.DLL is a wrapper around OWRM32C.DLL and were compiled using JDK 1.3, as follows:

The Java program calls RTP.java and passes in two parameters:

Based on the first parameter passed in, the program calls one of four Java functions—JINBOUNDRunCmd, JOUTBOUNDRunCmd, JINRun, or JOUTRun.

These Java calls automatically interface with CALLRTP.DLL that in turn calls OWRM32C.DLL. OWRM32C.DLL executes the map and returns a value that indicates the success of the map run. The CALLRTP.DLL contains a JNI (Java Native Interface) which calls an API function in OWRM3C.DLL. OWRM3C.DLL returns an integer from 0 to 5 indicating the degree of success of the map run. The value is returned to CALLRTP.DLL.


Sample program for using a Java API call

public class MYAPP
{
  public static void main(String[] args)
  {
    int ret;
    // Declare and initialize the RTP JAVA Class.
    RTP myrtp;
    myrtp = new RTP();

    // Convert the first argument as the case number.
    Integer num = Integer.valueOf(args[0]);
    switch (num.intValue()) {
      case 1:
        System.out.println("one");
        System.out.println("args[1] = " + args[1]);
        // Run an inbound map, pass the command switches
			 as the parameter.
        ret = myrtp.JINBOUNDRunCmd(args[1]);
        System.out.println("ret = " + ret);
        break;

      case 2:
        System.out.println("two");
        System.out.println("args[1] = " + args[1]);
        // Run an outbound map, pass the command switches as the parameter.
        ret = myrtp.JOUTBOUNDRunCmd(args[1]);
        System.out.println("ret = " + ret);
        break;

      case 3:
        System.out.println("three");
    // Prepare the string array as the JINRun() parameter to run 271in map.
        String[] strarr_inrun =
        {
          // Command line switches for 271in map.
          "d:\\maps\\271in\\271gdtst.txt -dg d:\\maps\\271in -dt d:\\maps\\271in -du d:\\maps\\271in -xl -l -it -o -wx 1 -n -w -b -m 271IN -mx 2",
          // Input file name to be substituted with memory buffer.
          "d:\\maps\\271in\\271gdtst.txt",
          // Input data of 271in map.
          "ISA*00*          *00*          *01*9012345720000  *01*9088877320000  *001030*1030*U*00401*000000001*0*T*:!\n" +
          "GS*HB*901234572000*908887732000*20001030*1615*1*X*004010X092!\n" +
          "ST*271*0001!\n" +
          "BHT*0022*11*3920394930203*20001030*1615!\n" +
          "HL*1**20*1!\n" +
          "NM1*PR*2*BLUE CROSS BLUE SHIELD*****PI*9012345918341!\n" +
          "PER*IC*ARTHUR JONES*TE*6145551212*FX*6145551214!\n" +
          "HL*2*1*21*1!\n" +
          "NM1*1P*1*JOHNSON*BARBARA****SV*223447582752!\n" +
          "REF*1J*500!\n" +
          "HL*3*2*22*1!\n" +
          "TRN*2*12345678900987654321768958473*1311234567*500!\n" +
          "NM1*IL*1*DAVIS*SAM*T***MI*223344!\n" +
          "REF*18*223453424!\n" +
          "N3*PO BOX 123!\n" +
          "N4*CINCINNATI*OH*43017*US!\n" +
          "PER*IC**HP*6147562231*WP*6145221212!\n" +
          "DMG*D8*19720513*F!\n" +
          "INS*Y*18*******F*N!\n" +
          "DTP*102*D8*001030!\n" +
          "EB*1*CHD*1*GP**6*100.00****N*N!\n" +
          "HSD*DY*100*DA*163395*6*100*1*A!\n" +
          "REF*18*4654746868565!\n" +
          "DTP*193*D8*001030!\n" +
          "III*BF*11!\n" +
          "LS*2120!\n" +
          "NM1*13*1*SMITH*MUFFY****24*111222333!\n" +
          "N3*157 WEST 57TH STREET!\n" +
          "N4*COLUMBUS*OH*43017*US!\n" +
          "PER*IC*MAGGIE MCGILLICUTTY*TE*6145551245!\n" +
          "PRV*AT*9K*3920394930203!\n" +
          "LE*2120!\n" +
          "SE*31*0001!\n" +
          "GE*1*1!\n" +
          "IEA*1*000000001!\n",
          // Output file name.
          "d:\\maps\\271in\\dbo_EL_ENVOY",
          // An empty string that indicates the previous 
           // file name is substituted with output memory file.
          ""
        };
        // Run an inbound map with Memory I/O, pass a
			 string array as the parameter.
        ret = myrtp.JINRun(strarr_inrun);
        System.out.println("ret = " + ret);
        System.out.println("strarr_inrun[4] = " +
			 strarr_inrun[4]);
        break;

      case 4:
        System.out.println("four");
        // Prepare the string array as the JOUTRun() parameter to run 270out map.
        String[] strarr_outrun =
        {
          // Command line switches for 270out map.
          "d:\\maps\\270out\\270out.x12 270OUT HS -t 270 -xl -dg d:\\maps\\270out -dt d:\\maps\\270out -du d:\\maps\\270out -xl -l -it -o -wx 1 -mx 2",
          // Input file name to be substituted with memory buffer.
          "D:\\maps\\270out\\dbo_EL_ENVOY",
          // Input data of 270out map.
          "0394930203 										SAM
 DAVIS 										PO BOX 123
 CINCINNATI 										OH     
 43017                         19720513      F223344
 1 			100BLUE CROSS BLUE SHIELD 	9012345918341
                                                                   JOHNSON                            223447582752
 AT SMITH
 \n",
 		// Output file name.
		"d:\\maps\\270out\\270out.x12",
 		// An empty string that indicates the previous
		// file name is substituted with output memory file.
          ""
        };
          // Run an outbound map with Memory I/O, pass
 			// a string array as the parameter.
        ret = myrtp.JOUTRun(strarr_outrun);

        System.out.println("ret = " + ret);

        System.out.println("strarr_outrun[4] = " + strarr_outrun[4]);

        break;

      default:
        System.out.println("Invalid option!");
        break;    }  }}