Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     How to check field contents to see whether numeric or not
Go
New
Search
Notify
Tools
Reply
  
How to check field contents to see whether numeric or not
 Login/Join
 
<sandyhart>
posted
Does anyone know if there is some way to check the contents of a field in MVS Focus to see whether the contents are numeric or not?
In COBOL, it would be IF FIELD IS NUMERIC, but I know of no way to accomplish this in Focus.
Can anyone help?
Thanks.
Sandy
 
Reply With QuoteReport This Post
Guru
posted Hide Post
I don't run MVS Focus but here is some code I use to check amper variables in DM.
-SET &TST1 = 'HI';
-SET &TST2 = 1;
-SET &VAL1 = IF &TST1.TYPE EQ 'A' THEN 'TEXT' ELSE 'NUM';
-SET &VAL2 = IF &TST2.TYPE EQ 'A' THEN 'TEXT' ELSE 'NUM';

The .TYPE is what knows if the value is text or numerical.

I hope this helps.
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Reply With QuoteReport This Post
<sandyhart>
posted
Curtis, thank you so much for your tip.
Please forgive my dumb questions, but I am beginner Focus programmer.

Will your code example work for a field that is more than one digit? For example, if a field were supposed to have a valid numeric date in it, could your example check to see if it was numeric or not?
Thank you again.
 
Reply With QuoteReport This Post
Guru
posted Hide Post
The size of the number does not matter as long as its all numerical. In this example &TST1 is a number and &TST2 is text.

What is the format of the date you are comparing?

-SET &TST1 = 20040721;
-SET &TST2 = '2004-07-21';
-SET &VAL1 = IF &TST1.TYPE EQ 'A' THEN 'TEXT' ELSE 'NUM';
-SET &VAL2 = IF &TST2.TYPE EQ 'A' THEN 'TEXT' ELSE 'NUM';
-TYPE &TST1 &VAL1
-TYPE &TST2 &VAL2
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Reply With QuoteReport This Post
Expert
posted Hide Post
For a 'beginner', as you describe yourself, you ask really good questions.
If your incoming field is a date as you suggest, or is supposed to be a date,
if you convert it to a SmartDate (a focus term here), focus will brilliantly NOT transform anything that isn't a date.
For example, in my legacy databases I have a date field in alpha '20040231';
When i translate that to a SmartDate, it will translate as 0, because of course there IS NO 31st of February. This is a very handy thing, i can produce an exception report, for example, from my legacy db, to tell the data entry folks what they have to fix;
So if your question really is about dates, read the chapters in the manual about SmartDates and you'll be a happy camper. Otherwise check out Chapter 11 in the manual "using functions" ;
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi,
Could you please tell me how can find the Usage type of a field in the table.
Because in my reports all the parameters will be passed as string.
Like as follows
-set &parm1 = 'where country_id eq ''12''';
Actually in my table the country id is a numeric field.so it is throwing error if I include the above parameter in the WHERE section.
Following is the error i am getting
"COMPARISON BETWEEN COMPUTATIONAL AND ALPHA VALUES IS NOT ALLOWED"
My table request looks as follows.

TABLE FILE COUNTRY
PRINT *
&PARM1
END

And the &Parm will be dynamic and it can be of any data type sometime i may use country_name as parm1.
Can anyone of you help me how to figure out columns usage type before comparing it.
 
Posts: 71 | Registered: November 20, 2003Reply With QuoteReport This Post
Master
posted Hide Post
Check out the User-Written Subroutine Manual it has a subroutine called CHKFMT. I think that my be what you want.
 
Posts: 862 | Registered: May 24, 2004Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     How to check field contents to see whether numeric or not

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.