Steps for running Excel sample (Windows only)
- Configure Java security policy
You will need to grant certain permissions for the Z and I Emulator for Web applet in order to run this sample. You can alter the .java.policy file by using policytool or you can create a new policy file and specify this file in the plug-in Java Runtime Parameters(-Djava.security.policy=PolicyFileName).
Your new policy file should contain the following and should be located in your local home directory.grant { permission java.lang.RuntimePermission "accessClassInPackage.sun.jdbc.odbc"; permission java.util.PropertyPermission "file.encoding", "read"; };
If you want to change .java.policy (and not set the parameter above in your plug-in), launch the policytool executable in the bin directory of your Java plug-in install and set the permissions specified in the lines above.
- Set up the Excel spreadsheet as an ODBC data source
- On your Windows machine, go to Settings->Control Panel->Administrative Tools->Data Sources(ODBC).
- Click Add...
- Select Microsoft Excel Driver (*.xls).
- Hit Finish.
- Give a data source name of amnu and give any description you desire (or leave it blank).
- Use the Select Workbook button to find the spreadsheet provided in this example. Hit OK.
- Deselect the Read Only option for this source. You may need to hit an Options>> button to find this option.
- Hit OK. You now have the amnu.xls spread sheet available as the ODBC data source amnu.
- Create a new Deployment Wizard page that gives the Z and I Emulator for Web client
access to the EditDB class.
- Start Deployment Wizard.
- On the Additional Options page, click "Advanced Options..."
- On the Add HTML Parameters panel, add a parameter with Name "AdditionalArchives" and Value "amnu"
- Place amnu.jar in your Z and I Emulator for Web publish directory
- Open your newly created page in a web browser and start your CICS
session.
USING AMNU:
The transaction amnu is a small sample database that is provided with CICS. To start amnu, follow these steps:- Log onto CICS
- At the CICS prompt, type amnu and type enter.
To see if there are any records in the database, follow these steps:- In the ENTER TRANSACTION: field, type abrw
- Leave the NUMBER field blank.
- Type enter.
If the database is empty, you need to add records to it before you run the macro. To add records to the database, follow these steps:- In the ENTER TRANSACTION: field, type aadd
- In the NUMBER FIELD, enter a number for the record that you want to add, such as 40.
- Type enter.
- Follow the instructions on the screen to provide information for the new record.
- Load amnu.mac into your session.
- If it is not already visible, display the Macro Manager toolbar by selecting View->Macro Manager on the session toolbar.
- Click on the Edit current macro properties icon.
- Click on the Import... button on the Macro Editor.
- Browse to the location of amnu.mac and open it.
- Click Save and Exit to save the macro to your current session and close the Macro Editor.
- Navigate to the amnu menu screen and hit the Play macro icon.
You will be prompted to enter a record number. Enter a number of a transaction that you have entered or that you saw when you browsed through the database in step 5. Hit OK. The application screen will display the contents of the record corresponding to the number that you entered. You will be prompted again to ask if you would like to save the record on the screen to your database. The default response is "Y." Hit OK. You will again be prompted to Enter a transaction number. You could continue to enter as many record numbers as you like (and you will be notified if you enter an invalid number), but this time hit Q to quit. Hit OK to close the prompt, and OK again to dismiss the message "Good Bye!" The macro will end, and amnu.xls will open. You should see the contents of the record you just saved inside the spreadsheet.
Hopefully this sample will get you thinking about the powerful ways in which you can put macros to use for your business. Note that this sample can easily be modified, for example to write to a different kind of database (see below for directions on writing to DB2) or to read from the local database and write to the amnu database. Note that this sample was designed to be short and simple, not a lesson in best practices of Java or macro coding. For example, you may have noticed that we are connecting to and disconnecting from the local database every time we write a record out. This could be avoided by writing "connect" and "disconnect" macros that are linked to the amnu macro such that there is only one connect and one disconnect for each macro play.
If you look inside the Excel macro amnu.mac, you'll see that it is using the driver sun.jdbc.odbc.JdbcOdbcDriver to connect to the Excel spreadsheet. If this class is not in your classpath, the sample will not run properly. This class is included in the Sun Java 2 plug-ins but not in IBM plug-ins.