Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

New TIBCO Community Coming Soon
In early summer, TIBCO plans to launch a new community—with a new user experience, enhanced search, and expanded capabilities for member engagement with answers and discussions! In advance of that, the current myibi community will be retired on April 30. We will continue to provide updates here on both the retirement of myibi and the new community launch.

What You Need to Know about Our New Community
We value the wealth of knowledge and engagement shared by community members and hope the new community will continue cultivating networking, knowledge sharing, and discussion.

During the transition period, from April 20th until the new community is launched this summer, myibi users should access the TIBCO WebFOCUS page to engage.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Dialog Manager Variable Test for Numerics Using .TYPE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Dialog Manager Variable Test for Numerics Using .TYPE
 Login/Join
 
Platinum Member
posted
I pass an amount (dial. mgr. variable &SAMNT) into a fex via HTML (format on the final database is D15.2). I want to control the data entry so there must be no more than 2 dec. places and the number range is between
-99,999,999,999.99 and 999,999,999,999.99

On the HTML page I have restricted characters entered to just
0 1 2 3 4 5 6 7 8 9 - .
using Javascript.

Sadly the .TYPE test on Dial. Mgr. variable &SAMNT only allow numbers up to 10 to the power 9 - 1 ie. 999999999
This means that if they enter 123456789012.99 it fails the numeric test – if you see my code below you’ll get an idea of what I am trying to do.

Any suggestions ?

-SET &ECHO=ALL;
-SET &SAMNT=9999999999.99;
-SET &POS_DECPT = POSIT(&SAMNT, &SAMNT.LENGTH, '.', '1', 'I4');
-TYPE &SAMNT &SAMNT.TYPE &SAMNT.LENGTH &POS_DECPT
-*EXIT

-IF &SAMNT.TYPE NE 'N' THEN GOTO CONT3;
-IF &SAMNT OMITS '.' THEN GOTO CONT4;
-SET &POS_DECPT = POSIT(&SAMNT, &SAMNT.LENGTH, '.', '1', 'I8');
-SET &NOPLACES = &SAMNT.LENGTH - &POS_DECPT;
-IF &NOPLACES GT 2 THEN GOTO CONT3 ELSE GOTO CONT4;
-RUN
-CONT3
-TYPE You must enter a valid Amount with a maximum of 2 dec. places
-EXIT

-CONT4
-TYPE No. OK
-EXIT

This message has been edited. Last edited by: Ian Dalton,


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
Master
posted Hide Post
For clarification purposes, why not check for a valid number range on the client (with JavaScript)?

This message has been edited. Last edited by: David Briars,
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
&SAMNT will never be numeric with a decimal point in the data.
  
-SET &ECHO=ALL;
-SET &SAMNT= '9999999999.99';
-SET &POS_DECPT = POSIT(&SAMNT.EVAL, &SAMNT.LENGTH, '.', '1', 'I4');
-TYPE &SAMNT &SAMNT.TYPE &SAMNT.LENGTH &POS_DECPT
-*-EXIT

-*-IF &SAMNT.TYPE NE 'N' THEN GOTO CONT3;
-IF &SAMNT OMITS '.'   THEN GOTO CONT4;
-SET &POS_DECPT = POSIT(&SAMNT, &SAMNT.LENGTH, '.', '1', 'I8');
-SET &NOPLACES = &SAMNT.LENGTH - &POS_DECPT;
-TYPE &POS_DECPT
-TYPE &NOPLACES
-IF &NOPLACES GT 2 THEN GOTO CONT3 ELSE GOTO CONT4;
-RUN
-CONT3
-TYPE You must enter a valid Amount with a maximum of 2 dec. places
-EXIT

-CONT4
-TYPE No. OK
-EXIT


works fine when omitting .TYPE statement


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Platinum Member
posted Hide Post
Yes we could do David but this would mean changing loads of .html programs to keep our code etc. consistent across all applications which we don't want to do. We use WebFOCUS to do this.


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
Platinum Member
posted Hide Post
Tom, I beg to differ.
If I code the following below, ie. a no. with a dec. point, it works for 999.99 but not for 9999999999.99
-SET &ECHO=ALL;
-SET &SAMNT=9999999.99;
-TYPE &SAMNT &SAMNT.TYPE &SAMNT.LENGTH

The reason we do the check is that the string coming across may be 999....99 or ---99.99
I can tighten up the input via Javascript as David mentioned, by using the IsNan function for example, but it would be good to be able to do this validation within WebFOCUS.


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
Master
posted Hide Post
Thanks for sharing the reason for the requirement to validate on the server side.

Here is something you might want to 'kick the tires' on...

-* Returns 'Y'.  
-*-SET &SAMNT='999999999999.99';
-*-SET &SAMNT='0';
-*-SET &SAMNT = '-99999999999.99';
-* Returns 'N'  
-SET &SAMNT='IAN';
-*
DEFINE FUNCTION ISANUM (INPUT/A15)
CHECK1/D15.2  = ATODBL(INPUT, '15', 'D15.2');
ISANUM/A1      = IF (INPUT EQ '0') THEN 'Y' ELSE   
                  IF ((CHECK1 GE -99999999999.99) AND 
                      (CHECK1 LE 999999999999.99) AND 
		    (CHECK1 NE 0)) THEN 'Y' ELSE 'N';
END
-RUN
-*
-SET &ISANUMBER_YN = ISANUM(&SAMNT);
-TYPE ISANUMBER_YN => &ISANUMBER_YN  


It has been a long time since I've had to validate numeric input on the server side, but this might be something to consider.

The idea to call a DEFINE FUNCTION from DM, came from a recent post from Alan B. :-)

This message has been edited. Last edited by: David Briars,
 
Posts: 822 | Registered: April 23, 2003Report This Post
Platinum Member
posted Hide Post
Many thanks David - works well and funnily enough Alan B did reply to me privately with the follwing which does what I need also.....
-* Alan B's solution......
DEFINE FUNCTION TEST(NUMBER/A20)
FUNC1/A32 = IF NUMBER CONTAINS '.' THEN
GETTOK(NUMBER, 20, -1, '.', 20, 'A20') ELSE ' ';
FUNC2/A32 = IF NUMBER CONTAINS '.' THEN
GETTOK(NUMBER, 20, 1, '.', 32, 'A20') ELSE NUMBER;
TEST/A1 = IF ARGLEN(20, FUNC1, 'I9') GT 2 THEN 'N' ELSE
IF (ATODBL(NUMBER, '20', 'D20.2') LT -99999999999.99 OR
ATODBL(NUMBER, '20', 'D20.2') GT 999999999999.99) THEN 'N' ELSE 'Y';

END
-RUN
-SET &ECHO=ALL;
-SET &SAMNT=9999999999999.99;
-SET &CERTO = TEST(&SAMNT);
-TYPE &SAMNT &SAMNT.TYPE &SAMNT.LENGTH &CERTO
-*EXIT

-IF &CERTO EQ 'N' THEN GOTO CONT3 ELSE GOTO CONT4;
-RUN
-CONT3
-TYPE You must enter a valid Settlement Amount with a maximum of 2 dec. places
-EXIT

-CONT4
-TYPE No. OK
-EXIT


_______________________
*** WebFOCUS 8.1.05M ***
 
Posts: 196 | Location: London, UK | Registered: December 06, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Dialog Manager Variable Test for Numerics Using .TYPE

Copyright © 1996-2020 Information Builders