Building the COBOL program
Using isCOBOL IDE
1. Click on the File menu
2. Choose New
3. Choose isCOBOL Project
4. Give it the name "simple_COBOL_HTML"
5. Click on the Next button until you reach the page where you can set Compiler/Runtime options
6. The class you’re going to obtain may not be compatible with the destination Android device. In order to be compatible with more Android devices, including the oldest ones, it’s good practice to generate classes that are backward compatible with older Java versions. For example, if you’re using Java 8 or greater but you wish to obtain a class that is compatible also with Java 7 and Java 6, switch to the "J" page and fill the "-jo=" field as follows
"-source 1.6 -target 1.6" |
7. It’s also good practice to compile with the -whttp option in order to be advised if our program contains statements that are not supported in the Mobile environment. Switch to the “W” page and check the option "-whttp".
8. Click on the Finish button to confirm settings and complete the project creation.
9. Right click on the source folder and choose New
10. Choose Source File
11. Give it the name "hello.cbl" and click on the Finish button.
12. Put the
COBOL code into the program and compile it
Without isCOBOL IDE
1. Create an empty text file and give it the name “hello.cbl”
3. Open a command prompt and change to the directory where the file is
4. It’s good practice to compile with the -whttp option in order to be advised if our program contains statements that are not supported in the Mobile environment.
Compile the program with the command:
Note - The class you obtain may not be compatible with the destination Android device. In order to be compatible with more Android devices, including the oldest ones, it’s good practice to generate classes that are backward compatible with older Java versions. For example, if you’re using Java 8 or greater but you wish to obtain a class that is compatible also with Java 7 and Java 6, use this command:
iscc -whttp -jo="-source 1.6 -target 1.6" hello.cbl |
5. HELLO.class will be created created; you need to include it in a jar to use it in the future steps. Use the following command:
jar -cvf cobol.jar HELLO.class |
COBOL code
PROGRAM-ID. hello. CONFIGURATION SECTION. REPOSITORY. class web-area as "com.iscobol.rts.HTTPHandler" . WORKING-STORAGE SECTION. 01 hello-buffer identified by "_comm_buffer". 03 filler identified by "_status". 05 response-status pic x(2). 03 filler identified by "_message". 05 response-message pic x any length. 03 filler identified by "hellotext". 05 xml-hellotext pic x any length. LINKAGE SECTION. 01 lnk-area object reference web-area. PROCEDURE DIVISION using lnk-area. main-logic. move "Operation successful" to response-message. move "OK" to response-status. move "Hello World from isCOBOL!" to xml-hellotext. lnk-area:>displayXML (hello-buffer). goback. |