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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Protection Exception in Cobol-CICS

Status
Not open for further replies.

thanuja77

Programmer
Dec 10, 2007
3
US
Hi guys,

I am getting protection execption (ASRA) in a Cobol-CICS program.See the piece of code given below

SET STATE-INDEX TO +1.
SEARCH STATE-CODE-ENTRIES
AT END
MOVE ZERO TO STATE-CODE
ASSIGN-STATE-CODE
WHEN ASSIGN-STATE-CODE = STATE-CODE-ENTRIES
(STATE-INDEX)
SET STATE-CODE-NUM TO STATE-INDEX
MOVE STATE-CODE-NUM TO ASSIGN-STATE-CODE,
STATE-CODE.

The fields STATE-CODE and ASSIGN-STATE-CODE are both
alpha numerals.
when i move ZERO to ASSIGN-STATE-CODE only then its working fine.But fir STATE-CODE its not working.I mean the problem is with the field STATE-CODE.
Can anyone help me in this?

 
For what ASRA is, it indicates a problem with some of the data in the variables. What are the data-types of the variables you showed and where do they come from (CICS screen, copy book, etc)?
 
When i XPED, ASRA is showed at the line
MOVE ZERO TO STATE-CODE
ASSIGN-STATE-CODE
The variables STATE-CODE and ASSIGN-STATE-CODE are defined as ALPHA NUMERICALS.
The variable STATE-CODE is in the copybook and ASSIGN-STATE-CODE comes from the CICS Screen.

I am sure that the exception is coming when ZERO is moved to STATE-CODE.But i couldnt find the reason and solution for this after a long analysis.

 
Okay, we need to think a little more broadly than just one line, etc. As a rule, usually problems like ASRA surface more when the code depends on the data-type being right, etc. For example, a space won't be a problem in numeric data until you try to do something with it (compare, compute, etc)

How is STATE-CODE-ENTRIES defined? Alpha-numeric as well?
Have you tried displaying the contents of ASSIGN-STATE-CODE (to do that, SEND TEXT and then RETURN) before the search happens to make sure you're getting from the map what you think you are? For that matter, how is the variable defined in the map?
 
Okay, I think I have an idea of a problem area.

Code:
SET STATE-CODE-NUM    TO  STATE-INDEX

if STATE-CODE-NUM is alphanumeric as you say (this means PIC X something), then its typically an incompatible variable for a SET statement. In fact, now that I thought about it, your compiler should be producing a warning over it, like mine did when I tried it.

C:\BACKUP\TEST.CBL 12: JMN3343I-S RECEIVING ITEM 'AVALUE' OF SET STATEMENT MUST BE INDEX-NAME,INDEX DATA ITEM,INTEGER ITEM,POINTER DATA ITEM OR ADDRESS OF SPECIAL REGISTER.

Try making STATE-CODE-NUM a numeric.
 
Actually SPACES are passed to ASSIGN-STATE-CODE from the map and so while SEARCH it do not perform the WHEN statements and perform AT END statement.

Also the variable STATE-CODE-NUM is defined as numeric only.So there is no problem with SET statement.And that too here as WHEN condition fails it wont perform the statements
SET STATE-CODE-NUM TO STATE-INDEX
MOVE STATE-CODE-NUM TO ASSIGN-STATE-CODE,
STATE-CODE.

 
thanuja77,
Please give the cobol PIC description of your fields. I believe they are as follows:
STATE-INDEX
STATE-CODE-ENTRIES
STATE-CODE
ASSIGN-STATE-CODE
STATE-CODE-NUM

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top