Focal Point
Problem converting Alphanumeric to number

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9211009862

January 30, 2008, 10:32 AM
L_G
Problem converting Alphanumeric to number
Hi,

I have looked at the Function documentation and I saw that I can convert from alphanumeric to numeric with EDIT command.

Here is my Code:
  

-SET &&SDTIN/I8 = EDIT(&DATAINIZ,'$$$$$$99999999');

 


where &DATAINIZ is 0000082007102.

The exception is:
(FOC318) A FIELD FORMAT IS NOT ALLOWED IN -SET: &&SDTIN/I8 = ED

Why the conversion does not works?


WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
January 30, 2008, 10:38 AM
jimster06
Note the disparate legths between 0000082007102 and $$$$$$99999999.

You might be trying to convert a blank to an integer.


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
January 30, 2008, 10:40 AM
L_G
Sorry the &DATAINIZ value is 00000082007102


WebFOCUS 7.6
Windows 2000
Output: HTML, PDF
January 30, 2008, 10:51 AM
Leah
quote:
FOC318) A FIELD FORMAT IS NOT ALLOWED IN -SET: &&SDTIN/I8 = ED


I think the error message is telling you, you can't use EDIT with -SET.

I'm sure the dialog manager experts, of which I am not, will have examples for you.


Leah
January 30, 2008, 11:03 AM
jimster06
Good catch Leah.

One can not specify a format with a -SET in DM.

Regards


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
January 30, 2008, 11:05 AM
Glenda
Change

SET &&SDTIN/I8 = EDIT(&DATAINIZ,'$$$$$$99999999');



to

SET &&SDTIN = EDIT(&DATAINIZ,'$$$$$$99999999'); 



Glenda

In FOCUS Since 1990
Production 8.2 Windows
January 30, 2008, 11:31 AM
GinnyJakes
Remember that EDIT has 2 abilities. One is to do simple substring and the other is to convert an alpha string to integer. The latter makes no sense in DM as variables are numbers by default.

You can use EDIT in DM to do substringing as L_G is actually trying to do. Do what Glenda has suggested by removing the format only put a dash (-) in front of the SET.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
January 30, 2008, 11:36 AM
Tony A
If you just wanted the alpha equivalent without the leading zeroes (I know you are cutting off the '8' as well) then you could use PTOA -
-SET &SDTIN = PTOA(0000082007102, '(P13)', 'A13');
-TYPE &SDTIN

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 30, 2008, 11:37 AM
Darin Lee
Jimster has the answer (and Glenda the solution.) Here's the explanation: &vars referenced in the -SET statements don't really know that they are alpha or numeric. I know there are lots of different syntax used to make it appear that way (like the .A8.) and i'm sure there are exceptions (like dates) but for the most part, you can use them interchangeably in numeric or string functions AS LONG AS THE VALUE MATCHES THE FUNCTION'S SYNTAX.

If you tell WF to use an &var as a string (like in your example with an EDIT mask) it will. If you tell it to add one (-SET &SDTIN=&SDTIN + 1; ) it will (if the value contains no alpha characters.) No need to specify the format, and as you saw, it throws an error if you try that.

For example, if &VAR1 is equal to 12345, in a WHERE (or DEFINE or -SET) you could use
WHERE FIELDNAME EQ &VAR1 or
WHERE FIELDNAME EQ '&VAR1'
but if the value were 'Some Value' you would get an error with the first example.

Long answer to a short question, but I hope that helps.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat