MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol V6 IS NUMERIC question

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vijay
Beginner


Joined: 09 May 2003
Posts: 131
Topics: 64

PostPosted: Wed Nov 27, 2019 2:39 pm    Post subject: Cobol V6 IS NUMERIC question Reply with quote

Hi,
Need help with COBOL 6

I've the below field definition
Code:

05 INP-AMT          PIC X(14).           
05 INP-AMT-NUM REDEFINES                 
       INP-AMT      PIC ----------9.99.

and in the input file INP-AMT is 14 0's and passed the numeric check using old version of cobol but is failing in cobol 6. Not sure why?
Code:

IF INP-AMT-NUM is numeric
-> pass for old version for cobol
but fails with cobol v6 compiler

Thanks,
Vijay
Back to top
View user's profile Send private message
Spolacek
Beginner


Joined: 17 Dec 2002
Posts: 17
Topics: 2
Location: NJ, USA

PostPosted: Thu Nov 28, 2019 7:56 am    Post subject: Reply with quote

Hello Vijay

I've seen situations like the one you described where an IF NUMERIC test returns different results from one version of COBOL to another. In most cases, the different results can be traced back to the settings of the following compiler options:

NUMPROC
ZONEDATA

(And possibly ZWB)

In version 6, the default for NUMPROC and ZONEDATA is PFD. In prior versions, the default is NOPFD.

What this means is that, for programs compiled under earlier versions of COBOL, the compiler generated object code to ensure that the appropriate sign was present in numeric fields. By default, version 6 compiles assume that the preferred sign is present and doesn't generate object code to ensure that this is the case. Therefore, it is quite possible that a program compiled under an earlier version of COBOL would deem the value to be Numeric (because the compiler generated object code to ensure the appropriate sign is present), whereas a program compiled under version 6 would not. Keep in mind that the IF NUMERIC test includes confirming that the sign in the data corresponds to the sign in the Picture clause.

I suggest you consult a compile listing of your program generated under the prior version of COBOL and note the settings for NUMPROC and ZONEDATA. Then specify those setting for your compile under version 6 and then run a test and see if you get the results you expect.

If your shop has a product such as Endevor which hard-codes the compiler options, you can override them for your program by adding a CBL card to the source code above the IDENTIFICATION DIVISION statement. For example:

CBL NUMPROC(NOPFD) ZONEDATA(NOPFD)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Nov 28, 2019 8:22 am    Post subject: Reply with quote

vijay,

Use meaningful topics (don't use the language/forum name/PGM name for the topic). Use a descriptive Title to explain your problem. I have edited the title of the topic for you. From next time please follow the rules.

Spolacek has provided the right inputs. Apart from checking the obvious compiler options shouldn't your numeric test be done the alphanumeric item instead of the numeric edited item?

Shouldn't the check be

Code:

IF INP-AMT IS NUMERIC                                 
   DISPLAY 'THE VALUE ' INP-AMT ' IS NUMERIC'     
ELSE                                                 
   DISPLAY 'THE VALUE ' INP-AMT ' IS NON-NUMERIC'
END-IF       

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group