The CHKFMT function will check the format of a string.
August 07, 2014, 04:38 PM
Tomsweb
TABLE FILE CAR
PRINT
MODEL
SALES
DEALER AS 'DEALER'
RETAIL AS 'RETAIL'
COMPUTE BADCHAR/I6 = CHKFMT(6, SALES, '999999', 'I6') ;
-*
BY COUNTRY
BY CAR
ON TABLE SAVE
END
-RUN
-EXIT
And I get this error...
0 ERROR AT OR NEAR LINE 43 IN PROCEDURE sjustify.fexFOCEXEC * (FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION CHKFMT (FOC009) INCOMPLETE REQUEST STATEMENT BYPASSING TO END OF COMMAND -EXIT
CHKFMT checks each character, in a character string, for incorrect character types.
Here is a model of how it works:
APP PREPENDPATH IBISAMP
SET ONLINE-FMT = STANDARD
-RUN
DEFINE FILE CAR
CHARSTRING/A10 = DECODE COUNTRY ('JAPAN' '1234567890'
'ENGLAND' '123456 123'
ELSE 'ABC');
BADCHAR/I2 = CHKFMT(10, CHARSTRING, '999999999', BADCHAR);
ISANUMBER_YN/A1 = IF BADCHAR EQ 0 THEN 'Y' ELSE 'N';
END
TABLE FILE CAR
PRINT COUNTRY
CHARSTRING
BADCHAR
ISANUMBER_YN
END
Only Japan is flagged as a number:
COUNTRY CHARSTRING BADCHAR ISANUMBER_YN
------- ---------- ------- ------------
ENGLAND 123456 123 7 N
JAPAN 1234567890 0 Y
ITALY ABC 1 N
W GERMANY ABC 1 N
FRANCE ABC 1 N
CAR.SALES, in your example, is defined as an I6 in the MFD. Is this representative of the field you need to check?This message has been edited. Last edited by: David Briars,
August 10, 2014, 02:37 PM
Danny-SRL
Or:
-* File tomsweb9.fex
DEFINE FILE CAR
TOM/A10=DECODE COUNTRY(
'ENGLAND' '1234567890'
'FRANCE' '123 456'
'ITALY' 'ASDFG'
'JAPAN' '0'
ELSE '56');
END
TABLE FILE CAR
PRINT TOM
COMPUTE ISNUM/A1=IF TOM EQ '0' THEN 'Y' ELSE IF ATODBL(TOM,'10','D10') EQ 0 THEN 'N' ELSE 'Y';
BY COUNTRY
END
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
August 11, 2014, 03:20 PM
susannah
if the variable you want to check is an &var, then just &var.TYPE will produce either an A or an N. If an &var is all numbers, you'll get an N for its TYPE, no matter how you grabbed it.
&var.TYPE and &var.LENGTH are two handy characteristics
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
August 12, 2014, 03:25 AM
Danny-SRL
Susannah,
Not quite:
quote:
If an &var is all numbers, you'll get an N for its TYPE, no matter how you grabbed it.
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
August 13, 2014, 03:16 AM
Dave
And this is a nice one too...
-SET &MINUS='-'; -TYPE &MINUS.TYPE
( it's a N )
_____________________ WF: 8.0.0.9 > going 8.2.0.5
January 09, 2015, 09:32 AM
Doug
Revisited with an nice insight:
In the case where the CHKFMT function does not work, as when using the SQL1010 adapter, consider the use of the EDIT command.
The EDIT command returns a 0 (zero) if the field is not a numeric field and the numeric value if it is. then check that EDITed field for a zero (which is the value for an alpha field, GT zero is a numeric field.
I hope this helps someone, someday...
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
January 09, 2015, 09:53 AM
susannah
hey that works great, doug. i never knew that edit returned a 0 on a /A. Beers on me at Rotiers.
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
January 09, 2015, 10:41 AM
Doug
Actually, I just found that out from a newbie... live And Learn...
Rotiers? When? I'll make it there this time...
January 09, 2015, 02:29 PM
Doug
Cross reference to : [url=https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5591039892[/url]
I added that URL just to make it easy for the next time anyone needs this.
January 10, 2015, 10:00 AM
George Patton
What happens if it is a numeric field and the value happens to be zero ....
We don't use Oracle for starters, and I consult the MFD before writing any code, so I haven't had any reason to try this one. Nice to have in one's back pocket though ...