Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol 400 - duplicate variable error

Status
Not open for further replies.

sweetM

Programmer
Nov 24, 2002
2
CA
Hi,

I'm new to Cobol and I'm trying to write an interactive program that allows you to enter a customer number and the resulting customer info is displayed (this is stored in another file).

I've encounted these errors -

1) "Variable is previously defined in program, use cannot be determined. Default item is assumed."

2) "file is not externally described, keyed file. External key specification ignored"
> I've created a DDS for the customer file that declares a key, however my program is not recognizing it. As a result, I have tried to declare the fields in my program.

3) In my screen display, the user enters a customer number. however, the program isn't reading it.

I know I probably don't make sense...thanks in advance to anyone who may have some tips!

cheers!
 
Hi sweetM,

It looks like you have tried to finish coding the program, before testing it. This approach will always give lots of headaches.

Try to always code a little, then test, code a little more, then test... You get the idea. This way, as soon as a problem is introduced, you'll have a pretty good guess how it happened.

Right now, you have a slew of problems to deal with; and, I am not sure it is wise to try to solve them without taking a look at what you're dealing with.

Could you post some of the code here?

Dimandja
 
Hi Dimandja,

*sheepish grin* Thanks, I definitely tried to rush it this time.

Here is my DDS:
UNIQUE
R CUSTPAYR TEXT('CUSTOMER PAYMENT RECORD')
CUSTNUM 5A ALIAS(CP_CUSTNUM)
CUSTNAME 20A ALIAS(CP_CUSTNAME)
STREET 20A ALIAS(CP_STREET)
CITY 10A ALIAS(CP_CITY)
PROVINCE 3A ALIAS(CP_PROVINCE)
POSTALCODE 6A ALIAS(CP_POSTALCODE)
STATEAMT 5S ALIAS(CP_STATEMENT_AMT)
PAYAMT 5S ALIAS(CP_PAYMENT_AMT)
DATEPAYDUE 8S ALIAS(CP_DATE_PAY_DUE)
DATEPAYREC 8S ALIAS(CP_DATE_PAY_RECVD)
K CUSTNUM

Here is a part of the File Control:

SELECT CUST-PAY-FILE
ASSIGN TO DATABASE-CUSTPAYPF
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS EXTERNALLY-DESCRIBED-KEY.

I have declared the fields in my program as:

01 CUSTPAYR.
05 SC-CUSTNUM PIC X(05).
05 SC-CUSTNAME PIC X(20).
05 SC-STREET PIC X(20).
05 SC-CITY PIC X(10).
05 SC-PROVINCE PIC X(03).

The other problem I have is w/ the display file, my program isn't capturing the customer number.

120-PROCESS-SCREEN-RECORD-RTN.
MOVE CP-CUSTNUM TO SC-CUSTNUM.
READ CUST-PAY-FILE
INVALID KEY
SET CUSTNUM-NOT-FOUND TO TRUE
NOT INVALID KEY
PERFORM 240-CHECK-STATUS-RTN
PERFORM 500-WRITE-SCREEN2-DISPLAY-RTN
END-READ.
IF NOT WS-FUNCTION-KEY-03
INITIALIZE DISPLAY-RECORD
WRITE DISPLAY-RECORD
FORMAT IS "SCREEN1"
INDICATORS ARE WS-INDICATOR-LIST
READ DISPLAY-FILE RECORD
END-IF.

This compiles ok, but when I've stepped through it, I get the error #1 from above. The screen shows but when I tried entering a CUSTNUM, it doesn't go to the next screen.

Thanks,
sweetM

 
I am new to this as well, so I may not be a big help, but don't you also need to do the DDS for the display file? And that would have a select statement and FD as well.

SELECT SCREEN-FILE ASSIGN TO WORKSTATION-DSPFILE-SI
ORGANIZATION IS TRANSACTION
ACCESS MODE IS DYNAMIC
RELATIVE KEY IS CURR-SFL-RECNO


FD SCREEN-FILE
DATA RECORD IS SCREEN-REC.
01 SCREEN-REC PIC X(1920)

Also, you didn't list the FD for the file used above. That's one of the benefits of externally dscribed files.

Ex.


FD CUST-PAY-FILE
DATA RECORD IS CUST-PAY-REC.
01 CUST-PAY-REC.
COPY DDSR-CUSTPAYR OF CUSTPAYPF.

This eliminates having to define the cust-pay-rec.
confusedlady
 
I found using display files/interactive programs a little tricky at first. This would also be in WS:

01 SCREEN-MAINREC-IN.
COPY DDSR-CUSTPAYR-I OF CUSTPAYF.
01 SCREEN-MAINREC-OUT.
COPY DDSR-CUSTPAYR-O OF CUSTPAYF.

Anytime you wish to check for user input, you have to WRITE SCREEN-REC FROM SCREEN-MAINREC-OUT and then READ SCREEN-FILE INTO SCREEN-MAINREC-IN to determine what the user did.

confusedlady
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top