COBOL -JAVA File Definition

Java Vedios Mainframe programmers can learn Java:

In Mainframe:

SELECT CUSTOMER -FILE ASSIGN TO CUSTOMER
     ORGANIZATION IS RELATIVE
     ACCESS MODE IS RANDOM
     RELATIVE KEY IS WW-CUSTOMER-NUMBER.

FD  CUSTOMER -FILE.
01    CUSTOMER -RECORD.
         05  CUSTOMER-NAME               PIC X(25).
         05  CUSTOMER-ADDRESS            PIC X(30) OCCURS 5 TIMES.

01   WW-CUSTOMER- NUMBER                 PIC 9(10) VALUE ZEROES.

         OPEN INPUT CUSTOMER -FILE.
         MOVE 300 TO WW-CUSTOMER-NUMBER.
         READ CUSTOMER -FILE.
.         CLOSE CUSTOMER -FILE.

In Java:

// Set the record length and number field.
int recLen = 175;
int recNum = 300;
// Open the file.
RandomAccessFile file = new RandomAccessFile(“test.fil”, “r”);
// Seek to the 300th record.
file.seek((recNum – 1) + recLen);

// Allocate the bytes for the record and read it,
byte [] record = new byte[recLen];
file.read(record);
// Close the file.
file.close();

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.