     /****************************************************************
      * Copyright (C) 1996 - 2001 Micro Focus International Ltd.     *
      * All Rights Reserved.                                         *
      ****************************************************************/

import com.microfocus.cobol.*;
// OCWIZARD start imports
// OCWIZARD end imports

public class RecordDemo extends com.microfocus.cobol.RuntimeObject
{
	/* static methods - the COBOL RuntimeSystem will register these */
	public native static boolean cobinvokestatic_boolean (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static byte cobinvokestatic_byte (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static char cobinvokestatic_char (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static short cobinvokestatic_short (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static int cobinvokestatic_int (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static long cobinvokestatic_long (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static float cobinvokestatic_float (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static double cobinvokestatic_double (String methodName, Object[] params)
		throws CobolException, Exception;
	public native static void cobinvokestatic_void (String methodName, Object[] params)
		throws CobolException, Exception;	
	public native static Object cobinvokestatic_object (String methodName, Object[] params)
		throws CobolException, Exception;

        static private String javaClassName = "RecordDemo";
	static
	{
		/* Load the class */
		/* cobloadclass (libraryname, cobolname, fulljavaname); */
                cobloadclass ("RecordDemo", "RecordDemo", javaClassName);
	}

	// OCWIZARD - start java methods

        public  void setDetails (RecordData customerDetails) throws Exception, CobolException
	{
		// Parameters are passed to COBOL in an array
		Object[] params = {customerDetails};
		cobinvoke_void ("setDetails", params);
	}
	// OCWIZARD - end java methods

	static public void main(String args[])
	{
       		// Create the OBJECT COBOL class
       		RecordDemo rd = new RecordDemo();
				       
       		// Create the structure to pass
		RecordData customerDetails = new RecordData("Micro Focus", "Newbury", 123456);
       
		// N.B. It is possible to prevent the BY REFERENCE parameters in a
		// COBOL method from modifying the corresponding Java parameters by 
		// removing the comment from the line below. If the comment is removed
		// the showRef method at the end of this class will show the original 
		// details.
       
	// display record before setDetails()...
	System.out.println("before setDetails()\n"+ customerDetails.toString()+"\n\n");

	// mfcobol.runtimeProperties.updateByRefParams = false;

	// pass the details to the COBOL object
       try 
       {
           rd.setDetails(customerDetails);
       }
       catch (Exception e)
       {
	   e.printStackTrace();
	   System.exit(0);
       }
       
       // Show the updated details. 
       customerDetails.showRef();
    }
}

