COBOL言語をJavaに変換します。
以下にCOBOL言語からJava言語に変換した例を掲載します。
000100 ID DIVISION.
000200 PROGRAM-ID. SAMPLE1.
000300* FILE INITIAL LORD.
000400* 85-01-02. CALTEC-SCUBE SAMPLE
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. IBM-4300.
000800 OBJECT-COMPUTER. IBM-4300.
000900 INPUT-OUTPUT SECTION.
001000 FILE-CONTROL.
001100 SELECT FILE1 ASSIGN TO FIL
001200 ORGANIZATION IS INDEXED
001300 ACCESS MODE IS DYNAMIC
001400 RECORD KEY IS RECKEY
001500 STATUS IS FS1.
001600 DATA DIVISION.
001700 FILE SECTION.
001800 FD FILE1 LABEL RECORD IS STANDARD.
001900 01 REC1.
001900 02 RECKEY PIC X(50).
001900 02 FILLER PIC X(200).
002000 WORKING-STORAGE SECTION.
002100 01 FS1 PIC X(2).
002200 PROCEDURE DIVISION.
002400 OPEN OUTPUT FILE1.
002500 MOVE LOW-VALUE TO REC1.
002600 WRITE REC1.
002800 DISPLAY 'SAMPLE1 FS = ' FS1.
003000 CLOSE FILE1.
003100 STOP RUN.
/***
* FILE INITIAL LORD.
* 85-01-02. CALTEC-SCUBE SAMPLE
*/
public class SAMPLE1 extends COBOLBase {
//***************************************************************************
//開始処理
//***************************************************************************
public void execute() throws Exception{
try {
initRtn();
mainRtn();
} catch (Exception e) {
errorRtn(e);
throw e;
} finally {
try {
finalRtn();
} finally {
dispose();
}
}
}
//***************************************************************************
//* メイン処理*
//***************************************************************************
private COBOLIndexedFile file1
= new COBOLIndexedFile("FIL",AccessMode.DYNAMIC,250 ,0,50);
private REC1 rec1 =new REC1();
private String fs1;
private void mainRtn() throws Exception {
file1.openOutput();
rec1.setValue(LOW_VALUE);
file1.write(rec1);
DISPLAY("SAMPLE1 FS = " + fs1);
file1.close();
STOPRUN();
}