Focal Point
SOLVED - strip characters from a numeric value

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

February 28, 2013, 11:54 AM
Spence
SOLVED - strip characters from a numeric value
I'm trying to duplicate this sql in focus.

cast((sales * 2.30000) / 1.87000000 as varchar(100)) as charin,
substring(charin from 1 for 3) || substring(charin from POSITION('.' IN charin)+1 for 3) as hashchar

I need the first three positions and the last three position.
The last 3 I can do. The first three get padded with leading zeros in focus.

DEFINE FILE CAR
charin1/D12.3 = ((SALES * 2.30000) / 1.87000000);
charin/A15 = FTOA(charin1, '(D12.3)', charin);
last_three/A3 = EDIT(charin,'$$$$$$$$$$$999');
edit_charin/A15 = STRIP(15, charin, ',' , 'A15');
-* i need the first three characters from edit_charin (not including leading zeros)
first_three/A5=EDIT(edit_charin,'99999');
END
TABLE FILE CAR
PRINT SALES
charin1
charin
last_three
edit_charin
first_three
IF SALES GT 0
END

This message has been edited. Last edited by: Spence,


WF 8 version 8.2.04. Windows.
In focus since 1990.
February 28, 2013, 03:57 PM
Waz
You need to left justify brfore the EDIT.

DEFINE FILE CAR
charin1/D12.3 = ((SALES * 2.30000) / 1.87000000);
charin/A15 = FTOA(charin1, '(D12.3)', charin);
last_three/A3 = EDIT(charin,'$$$$$$$$$$$999');
left_charin/A15 = LJUST(15,STRIP(15, charin, ',' , 'A15'),'A15');
-* i need the first three characters from edit_charin (not including leading zeros)
first_three/A5=EDIT(left_charin,'999');
END
TABLE FILE CAR
PRINT SALES
charin1
charin
last_three
left_charin 
first_three
IF SALES GT 0
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!

March 01, 2013, 07:36 AM
Spence
Thank you Waz.


WF 8 version 8.2.04. Windows.
In focus since 1990.