IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

what will happen if invalid subscript entered for an array


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 6:56 pm
Reply with quote

hi

i have declared an array as:

Quote:

05 ws-count pic 99 value zeroes
05 tab-contents occurs 10 times
10 tab-no pic 9(2) value zeroes.
10 tab-desc pic x(10) value spaces.


this is part of input file.
i do processing of this array with a subscript varing 1 by 1 until sub > ws-count
i have included a checking in pgm as to check for ws-count is less than equal to 10 , then do processing.
but when i give 11 in input file, and submit jcl, it shows the error msg in sysout but abends.
how can i avoid the abend and it will not allow to key in 11 for ws-count
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 08, 2009 7:00 pm
Reply with quote

Compile option SSRANGE will help. Be aware that it imposes a performance penalty at run-time, though.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon Jun 08, 2009 7:31 pm
Reply with quote

if i declare the variable as

05 ws-count-a.
10 count-pr pic 99.
88 count-t value 1 thru 10.


it giving error as "count-t" was defined as a type that was invalid in this context. The statement was discarded.

whts the reason???
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 08, 2009 7:40 pm
Reply with quote

sm,
Quote:
...was invalid in this context...

refers to the procedure division statement that contains the reference COUNT-T.

so, what procedure division statement contained the reference?

also, cut&paste the entire error message from your compiler listing
and we will show you how to find your errors.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jun 08, 2009 8:02 pm
Reply with quote

Change your WS definition -

Code:

05 WS-COUNT PIC 9(04) COMP.
05 WS-COUNT-MAX PIC 9(04) COMP.
05 TAB-CONTENTS-REC.
   10 TAB-CONTENTS OCCURS 10 TIMES.
      15 TAB-NO PIC 9(02) VALUE ZERO.
      15 TAB-DESC PIC X(10) VALUE SPACES.

MOVE 1 TO WS-COUNT.
DIVIDE LENGTH OF TAB-CONTENTS-REC BY LENGTH OF TAB-CONTENTS (1) GIVING WS-COUNT-MAX.

After the calculation, WS-COUNT-MAX will equal 10 and can be used against WS-COUNT to measure the maximum. If the OCCURS changes in the future, then the calculation will always be correct. Try to always use binary-variables for subscripts, either halfwords (as illustrated) or fullwords (PIC 9(08) COMP). Indices are the better way to go. Display-Numeric subscripts should be avoided....
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Tue Jun 09, 2009 9:48 am
Reply with quote

hi all thanks

just one more query
i have used a check for ws-count in program as

if ws-count > 10
display 'wrong data entered'
perform error-para
else
continue
end-if

i have keyed in '11' in input file for ws-count.

whn i submit jcl, its displaying error message but the job is abending with U0963. what may be the reason.


[/quote]
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Tue Jun 09, 2009 1:19 pm
Reply with quote

issue resolved, no abend
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 10, 2009 4:47 am
Reply with quote

Good to hear it is working - thanks for letting us know icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts To find an array of words (sys-symbol... JCL & VSAM 9
No new posts Invalid URL in Sticky topic TSO/ISPF 1
No new posts How to move values from single dimens... COBOL Programming 1
Search our Forums:

Back to Top