Sign In

Big Iron Basics Where entry level users can ask questions and get answers
z & A > Big Iron Basics > need help with legacy COBOL View modes: 
User avatar
Member
Member
mike - 7/23/2012 10:21:30 AM
   
need help with legacy COBOL
Hello,

For a client, I'm developing Java classes that generate a data file to be read by a mainframe COBOL program. Due to HIPPA restrictions, I cannot have access to the client's machine.

What I need is to run the attached COBOL program. All it does it generate a four-record (EBCDIC) output file. I would then like to see a hex dump of the output file (and I'll compare with the Java output).

Thank you very much!

IDENTIFICATION DIVISION.
PROGRAM-ID. TEST-PROG.
AUTHOR. Mike.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT TEST-FILE ASSIGN TO "testfile"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS FS1.
DATA DIVISION.
FILE SECTION.
FD TEST-FILE.

01 FILE-HDR.
05 RCRD-ID PIC X(04) VALUE 'HDRF'.
05 FILLER-1 PIC X(01) VALUE SPACE.
05 CNTRCTR PIC X(05) VALUE SPACE.
05 DATE-1 PIC S9(07) VALUE ZERO COMP-3.
05 FILLER-2 PIC X(04) VALUE SPACE.

01 BOD1.
05 CLAIM-HDR PIC X(2500).
05 RCRD-TYPE PIC X(01).
88 DENY-HDR VALUE 'H'.
88 DENY-DETAIL VALUE 'D'.
05 HDR-INFO.
10 H-NUMBER PIC X(02).
10 H-REASON-CD PIC X(03).
10 H-REMARK-CD PIC X(05).
10 H-CDS.
15 H-CD-1 PIC X(05).
15 H-CD-2 PIC X(05).
10 H-FILLER PIC X(22).
05 ITEM-COUNT-1 PIC S9(04) COMP.
05 ITEM-TABLE.
10 ITEM OCCURS 0 TO 450 TIMES DEPENDING ITEM-COUNT-1.
15 ITEM-NUM-1 PIC S9(04) COMP.
15 REV-CD-1 PIC X(04).
15 HC-CD-1 PIC X(05).
15 FIN-DT PIC S9(07) COMP-3.
15 MD-NUM-1 PIC X(02).
15 REASON-CD-1 PIC X(03).
15 REMARK-CD-1 PIC X(05).
15 CD-1-1 PIC X(10).
15 FILLER-1 PIC X(20).

01 BOD2.
05 CLAIM-HDR PIC X(600).
05 RCRD-TYPE PIC X(01).
88 DENY-HDR VALUE 'H'.
88 DENY-DETAIL VALUE 'D'.
05 HDR-INFO.
10 H-NUMBER PIC X(02).
10 H-REASON-CD PIC X(03).
10 H-REMARK-CD PIC X(05).
10 H-CDS.
15 H-CD-1 PIC X(05).
15 H-CD-2 PIC X(05).
10 H-FILLER PIC X(22).
05 ITEM-COUNT-2 PIC S9(04) COMP.
05 ITEM-TABLE.
10 ITEM OCCURS 0 TO 13 TIMES DEPENDING ITEM-COUNT-2.
15 ITEM-NUM-2 PIC S9(04) COMP.
15 HC-CD-2 PIC X(05).
15 FROM-DT-2 PIC S9(07) COMP-3.
15 THRU-DT-2 PIC S9(07) COMP-3.
15 MD-NUM-2 PIC X(02).
15 REASON-CD-2 PIC X(03).
15 REMARK-CD-2 PIC X(05).
15 CD-1-2 PIC X(10).
15 FILLER-2 PIC X(19).

01 FILE-TRAILER.
05 RECORD-ID PIC X(04) VALUE 'TLRF'.
05 FILLER-1 PIC X(01) VALUE SPACE.
05 CNTRCTR PIC X(05) VALUE SPACE.
05 NUM-PROCESSED PIC S9(07) VALUE ZERO COMP-3.
05 NUM-DENIED PIC S9(07) VALUE ZERO COMP-3.
05 FILLER-2 PIC X(13) VALUE SPACE.

WORKING-STORAGE SECTION.
01 FS1 PIC 99.
PROCEDURE DIVISION.
DISPLAY "BEGIN".
OPEN OUTPUT TEST-FILE.
PERFORM WRITE-HEADER.
PERFORM WRITE-BOD1.
PERFORM WRITE-BOD2.
PERFORM WRITE-TRAILER.
CLOSE TEST-FILE.
DISPLAY "END".
STOP RUN.
WRITE-BOD1.
MOVE SPACES TO BOD1.
MOVE "Claim Header 1" TO CLAIM-HDR OF BOD1.
MOVE "D" TO RCRD-TYPE OF BOD1.
MOVE "AB" TO H-NUMBER OF BOD1.
MOVE "CDE" TO H-REASON-CD OF BOD1.
MOVE "FGHIJ" TO H-REMARK-CD OF BOD1.
MOVE "KLMNO" TO H-CD-1 OF BOD1.
MOVE "PQRST" TO H-CD-2 OF BOD1.
MOVE 2 TO ITEM-COUNT-1.
MOVE 1 TO ITEM-NUM-1 (1).
MOVE "abcd" TO REV-CD-1 (1).
MOVE "efghi" TO HC-CD-1 (1).
MOVE 2012202 TO FIN-DT (1).
MOVE "jk" TO MD-NUM-1 (1).
MOVE "lmn" TO REASON-CD-1 (1).
MOVE "opqrs" TO REMARK-CD-1 (1).
MOVE "tuvwxyz012" TO CD-1-1 (1).
MOVE 2 TO ITEM-NUM-1 (2).
MOVE "ABCD" TO REV-CD-1 (2).
MOVE "EFGHI" TO HC-CD-1 (2).
MOVE 2012202 TO FIN-DT (2).
MOVE "JK" TO MD-NUM-1 (2).
MOVE "LMN" TO REASON-CD-1 (2).
MOVE "OPQRS" TO REMARK-CD-1 (2).
MOVE "TUVWXYZ012" TO CD-1-1 (2).
WRITE BOD1.
WRITE-BOD2.
MOVE SPACES TO BOD2.
MOVE "Claim Header 2" TO CLAIM-HDR OF BOD2.
MOVE "D" TO RCRD-TYPE OF BOD2.
MOVE "ab" TO H-NUMBER OF BOD2.
MOVE "cde" TO H-REASON-CD OF BOD2.
MOVE "fghij" TO H-REMARK-CD OF BOD2.
MOVE "klmno" TO H-CD-1 OF BOD2.
MOVE "pqrst" TO H-CD-2 OF BOD2.
MOVE 2 TO ITEM-COUNT-2 OF BOD2.
MOVE 1 TO ITEM-NUM-2 (1).
MOVE "abcde" TO HC-CD-2 (1).
MOVE 2012202 TO FROM-DT-2 (1).
MOVE 2012202 TO THRU-DT-2 (1).
MOVE "fg" TO MD-NUM-2 (1).
MOVE "hij" TO REASON-CD-2 (1).
MOVE "klmno" TO REMARK-CD-2 (1).
MOVE "pqrstuvwxy" TO CD-1-2 (1).
MOVE 2 TO ITEM-NUM-2 (2).
MOVE "ABCDE" TO HC-CD-2 (2).
MOVE 2012202 TO FROM-DT-2 (2).
MOVE 2012202 TO THRU-DT-2 (2).
MOVE "FG" TO MD-NUM-2 (2).
MOVE "HIJ" TO REASON-CD-2 (2).
MOVE "KLMNO" TO REMARK-CD-2 (2).
MOVE "PQRSTUVWXY" TO CD-1-2 (2).
WRITE BOD2.
WRITE-HEADER.
MOVE "HDRF" TO RCRD-ID.
MOVE SPACES TO FILLER-1 OF FILE-HDR.
MOVE SPACES TO CNTRCTR OF FILE-HDR.
MOVE SPACES TO FILLER-2 OF FILE-HDR.
MOVE 2012202 TO DATE-1.
WRITE FILE-HDR.
WRITE-TRAILER.
MOVE "TLRF" TO RECORD-ID.
MOVE SPACES TO FILLER-1 OF FILE-TRAILER.
MOVE SPACES TO CNTRCTR OF FILE-TRAILER.
MOVE 12 TO NUM-PROCESSED.
MOVE 34 TO NUM-DENIED.
MOVE SPACES TO FILLER-2 OF FILE-TRAILER.
WRITE FILE-TRAILER.

User avatar
Advanced member
Advanced member
mwestholder - 7/25/2012 12:23:20 PM
   
RE:need help with legacy COBOL
mike

I shared your question with an IBM COBOL expert who suggests handing over your program to someone who has access to the machine in question. But first, he says you need to decide what access method you want to use. For COBOL on z/OS, there's QSAM, Line Sequential, and 3 types of VSAM. For more on those, check out the COBOL Language Reference and COBOL Programming Guide.

1