Focal Point
[SOLVED] Converting on a Packed Decimal to Alpha and attempting a Substring

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

June 19, 2012, 03:38 PM
Ryan Kolatalo
[SOLVED] Converting on a Packed Decimal to Alpha and attempting a Substring
I am attempting to take a packed decimal and convert it into an alphanumeric so that I can perform a SUBSTR on it.

I use PTOA to do the conversion and then attempt the SUBSTR but my results come back blank. Can anyone help?

Example:
DEFINE TEST
PGROSS_TEMP/P15=12345677;
PGROSS/A16 = PTOA(PGROSS_TEMP,'(P15)',PGROSS);
PGROSS_FINAL/A3 = SUBSTR(16,PGROSS,1,3,3,'A3');

This message has been edited. Last edited by: Ryan Kolatalo,


WebFOCUS 7.6
Windows, All Outputs
June 19, 2012, 04:11 PM
rfbowley
It has to do with what is in the first three character positions of PGROSS. Since the number on PGROSS_TEMP is only 8 characters long, PGROSS is 16 characters long, and PTOA right justifys the value when it stores it into PGROSS, the first three characters in PGROSS are indeed blanks.

Try:
 
PGROSS_FINAL/A3 = SUBSTR(16,PGROSS,8,10,3,'A3');
 

and you will see what I mean.


Robert F. Bowley Jr.
Owner
TaRa Solutions, LLC

In WebFOCUS since 2001
June 19, 2012, 04:17 PM
sumant
Try this:

DEFINE FILE CAR
DC/P18.2=1234567890.55;
FMT/A10='(P14.2C)';
DC_ALPHA/A18=PTOA(DC, FMT, DC_ALPHA);
END

TABLE FILE CAR
PRINT
CAR.ORIGIN.COUNTRY
CAR.COMP.CAR
DC_ALPHA
COMPUTE SUBSTR_TEMP/A5 = SUBSTR(18, DC_ALPHA, 1, 5, 5, 'A5');
ON TABLE NOTOTAL
END

As Robert said, the first three characters are blank in your e.g. you dont see any values.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
June 19, 2012, 04:30 PM
susannah
use FPRINT command




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 19, 2012, 05:53 PM
Waz
FYI

PTOA/FTOA outputs a right justified string.


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 20, 2012, 09:49 AM
Ryan Kolatalo
Thanks, it appeared left justified so I didn't even think to look at that. Did a TRIM to remove spaces and it works great now


WebFOCUS 7.6
Windows, All Outputs