Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message

New User

Joined: 02 Aug 2005
Posts: 3
Location: chennai

 Posted: Wed Aug 10, 2005 7:57 pm    Post subject: to check divide by zero codition? is there any statement in cobol to check divide by zero condition as in PLI? eg compute ans = m/n where m is 20 and n is 0 what error it will give? pls reply me?

mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Thu Aug 11, 2005 3:51 am    Post subject: Hi Madhan, Why not: if n not = 0 compute ans = m/n else display 'cant divide by zero' end-if

New User

Joined: 05 Jun 2005
Posts: 41

 Posted: Thu Aug 11, 2005 9:22 am    Post subject: Hi madhan1582, Use ON SIZE ERROR condition. For example Divide A by B giving C On Size error display 'Division by zero'. If B is Zero the message will be displayed. Regards Madhu

New User

Joined: 05 Jul 2005
Posts: 7

 Posted: Fri Aug 19, 2005 7:00 pm    Post subject: hi friend ifu divide numeric by zero u will get a soc c abend so while coding follow on size error imperative satement in the coding regards madhu
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Sat Aug 20, 2005 11:30 pm    Post subject: Hi Madhu, The only problem w/your solution is that a "legitimate" size error (i.e. a result that exceeds the size of the receiving data) area will produce the same msg. That can cause confusion and delays in the prob res process.
sendil

New User

Joined: 30 Jun 2005
Posts: 27

 Posted: Thu Aug 25, 2005 12:01 pm    Post subject: if (n > zero) divide m/n else display ' can't divide by zero' end-if
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics GDG gen check using REXX raghuraman123 CLIST & REXX 6 Wed Apr 18, 2018 9:18 pm How syntax check at Bind time is diff... Poha Eater DB2 5 Wed Mar 21, 2018 9:16 pm ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us