Focal Point
converting alpa w/padded zeroes to Decimal

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

June 20, 2008, 07:57 PM
KenFR
converting alpa w/padded zeroes to Decimal
Hi,
My current method is not always producing data can one of you experts improve on this code?

-IF POS EQ '000000000000' THEN GOTO SKPOS;
POS5/A12=TRIM('L', POS, 12, '0', 1, 'A12');
POS4/A12=IF POS5 EQ ' ' THEN '0' ELSE POS5;
POS2/A11=EDIT(POS4,'999999999$');
POS3/D12C=EDIT(POS4);
-GOTO SKPP2
-SKPOS
POS3/D12C=0;
-SKPP2

Data looks like is in A12 and may be
000000000000 or
000000000120
may contain negatives?

thanks
Ken


8105 Tomcat and AIX reporting server
input: Teradata, SQL, DB2, Essbase, Oracle, text
output:html, excel, PDF,
June 21, 2008, 04:18 PM
Danny-SRL
Ken,

How about using the ATODBL function?
POS3/D12=ATODBL(POS, 12, 'D12');


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

June 22, 2008, 01:17 PM
KenFR
I did try the ATODBL but for some reason it returns zero for values padded with zeros

Basically I just need to convert A12 data to D12C data and the numbers are padded with zeros; it seems simple....but thats the bad ones


8105 Tomcat and AIX reporting server
input: Teradata, SQL, DB2, Essbase, Oracle, text
output:html, excel, PDF,
June 22, 2008, 03:14 PM
Danny-SRL
Ken,

This worked very well for me:
  
-* File Ken1.fex
DEFINE FILE CAR
APOS/A12=DECODE SEATS (2 '000000000000' 4 '000000001234' 5 '-00000000012');
DPOS/D12=ATODBL(APOS, '12', 'D12');
END
TABLE FILE CAR
PRINT APOS DPOS
BY SEATS
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

June 22, 2008, 06:06 PM
Waz
If all else fails, changing the master file description will do it.

e.g.
FILEDEF TESTDATA DISK testdata.ftm
-RUN
-WRITE TESTDATA 000000025
-WRITE TESTDATA 000000020
-WRITE TESTDATA 000000015
-WRITE TESTDATA 000000010
-WRITE TESTDATA 000000005

EX -LINES 4 EDAPUT MASTER,testdata,CV,FILE
FILENAME=TESTDATA , SUFFIX=FIX,$
SEGNAME=TESTDATA ,
FIELD=TESTDATA ,ALIAS=,I10  ,A10  ,$


TABLE FILE TESTDATA
PRINT *
END



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 22, 2008, 06:22 PM
KenFR
Danny,
thanks it does work with the single quotes around the length field; I did not catch that at first
problem solved


8105 Tomcat and AIX reporting server
input: Teradata, SQL, DB2, Essbase, Oracle, text
output:html, excel, PDF,
June 22, 2008, 11:14 PM
susannah
Ken...what about the easy way
just use the EDIT command.
If you're sure that the /A field will only contain integers, then this'll work all day long.
Even if its got negative sign in front

DEFINE FILE CAR
OLD/A12 WITH COUNTRY='000000123456';
NEW/D12=EDIT(OLD);
END
TABLE FILE CAR
PRINT NEW OLD COUNTRY
END




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 22, 2008, 11:22 PM
Waz
quote:
what about the easy way
just use the EDIT command


Susannah, brilliant, sometimes we think complex when there is a simple way.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

June 22, 2008, 11:30 PM
susannah
Big Grin
yep, if you want the lazy man's way to do it...
come ask me!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID