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.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


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