sandeep prajapati
New User
Joined: 23 Mar 2020 Posts: 19 Location: India
|
|
|
|
JCL to run.
Code: |
//COBRUN EXEC IGYWCLG
//COBOL.SYSIN DD DSN=Z56117.COBOL(BANKACCT),DISP=SHR
//GO.BALANCE DD *
01234567.01
//GO.DEPOSIT DD *
00000567.01
//GO.WITHDRW DD *
00000067.01 |
cobol program.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. MyBank.
AUTHOR. Otto B Wealthy.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT BALANCE-AMT ASSIGN TO BALANCE.
SELECT DEPOSIT-AMT ASSIGN TO DEPOSIT.
SELECT WITHDRW-AMT ASSIGN TO WITHDRW.
DATA DIVISION.
FILE SECTION.
FD BALANCE-AMT
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F.
01 BALANCE-IO.
02 BAL-AMT PIC 9999999.99.
02 FILLER PIC X(70).
FD DEPOSIT-AMT
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F.
01 DEPOSIT-I.
02 DEP-AMT PIC 9999999.99.
02 FILLER PIC X(70).
FD WITHDRW-AMT
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F.
01 WITHDRW-I.
02 DRAW-AMT PIC 9999999.99.
02 FILLER PIC X(70).
WORKING-STORAGE SECTION.
01 NEWBAL PIC 9999999.99.
PROCEDURE DIVISION.
BEGIN.
OPEN I-O BALANCE-AMT.
OPEN INPUT DEPOSIT-AMT.
OPEN INPUT WITHDRW-AMT.
CLOSE BALANCE-AMT.
CLOSE DEPOSIT-AMT.
CLOSE WITHDRW-AMT.
STOP RUN. |
sysout:
There was an unsuccessful OPEN or CLOSE of file BALANCE in program MYBANK at relative location X'18C'.
Neither FILE STATUS nor an ERROR declarative were specified. The status code was 37.
From compile unit MYBANK at entry point MYBANK at compile unit offset +0000018C at entry offset +0000018C at address 1AD0018C. [/code]
please advise, fixing the error I want generate a simple logic to accept withdraw and deposit amount and aggregate the bank balance. |
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Well, it is saying that you have not declared a file status variable - you should have one for each DDNAME. You then check the file status after each open/close/read/write/rewrite and if it is not 0 then you display the status and abend the job.
Now, the run-time has, very considerately, told you what the status is. You now have to look up the documentation to see what that status means and attempt to fix the problem. If you have problem fixing the problem, and you cannot resolve it by reading the documentation or talking with your colleagues, then you can come back here for more help. |
|