Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
what will happen if invalid subscript entered for an array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: what will happen if invalid subscript entered for an array
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: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Mon Jun 08, 2009 7:00 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Mon Jun 08, 2009 7:40 pm    Post subject:
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: 2504
Location: Atlanta, Georgia, USA

PostPosted: Mon Jun 08, 2009 8:02 pm    Post subject: Reply to: what will happen if invalid subscript entered for
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    Post subject:
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    Post subject:
Reply with quote

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

Site Director


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

PostPosted: Wed Jun 10, 2009 4:47 am    Post subject: Reply to: what will happen if invalid subscript entered for
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts IEF645I INVALID REFERBACK IN THE RC ... abdulrafi JCL & VSAM 2 Mon Aug 29, 2016 10:57 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us