[SOLVED] Packed decimal to Numeric or Alphanumeric..
Hi,
I get errors using Focus 7.6.9. I have a file which has fields X and Y X-- usage P13.2 actual P06 Y-- Usage P13.2 actual P06
In a FOCUS module i read these fields as Read value &X.p13.2 and &Y.p13.2
A/p13.2=&X B/p13.2=&Y
Now the error says this "Unrecognised format of amper variable in -read"
Could anyone provide me a solution on this.. Thanks in advance.. This message has been edited. Last edited by: Kerry,
7.6.9 for generating reports Windows All Outputs
December 23, 2009, 08:00 AM
Dan Satchell
Perhaps this sample will help:
DEFINE FILE CAR
P_RETAIL_COST/P13.2 = RETAIL_COST ;
END
TABLEF FILE CAR
PRINT COUNTRY CAR MODEL P_RETAIL_COST
WHERE RECORDLIMIT EQ 1
ON TABLE SAVE AS CARSAVE
END
-RUN
ALPHANUMERIC RECORD NAMED CARSAVE
0 FIELDNAME ALIAS FORMAT LENGTH
COUNTRY COUNTRY A10 10
CAR CARS A16 16
MODEL MODEL A24 24
P_RETAIL_COST P13.2 13
TOTAL 63
1
0 NUMBER OF RECORDS IN TABLE= 1 LINES= 1
0
-READ CARSAVE &COUNTRY.10 &CAR.16 &MODEL.24 &PRCOST.13
-TYPE COUNTRY=&COUNTRY CAR=&CAR MODEL=&MODEL COST=&PRCOST
COUNTRY=ENGLAND CAR=JAGUAR MODEL=V12XKE AUTO COST= 8878.00
WebFOCUS 7.7.05
December 23, 2009, 08:23 AM
khadar78
quote:
13
Can we read Packed decimal and convert it to numeric.. As the packed decimal is amount which shud be numeric.. but the declaration done is in packed decimal i.e p13.2 which is not readable. Hence is there a way where we can read PD and convert it in to numeric or alphanumeric.. I tried an option by changing file format from P13.2 to A14 and read as Read value &X.A14 but it did not work..
7.6.9 for generating reports Windows All Outputs
December 23, 2009, 11:01 AM
Darin Lee
&variables are either numeric or alpha. The format of P13.2 is not a valid format for reading into a variable. Dan's example above should give you what you need. If nothing else, you can read it as an alpha string and use EDIT to convert to a (decimal) number.
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
December 23, 2009, 11:35 AM
Hua
It took me awhile to figure out what went wrong with the packed decimal conversions.
In DB2, when a field defined as P13.2; the equivalent field in wf .mas is P14.2.
PTOA(myfield,'(P14.2)','A14') or EDIT(myfield,'$9999999999999') should work.
It was my mistake to assume wf field length P13.2
Developer Studio 7.6.11 AS400 - V5R4 HTML,PDF,XLS
December 23, 2009, 12:37 PM
susannah
At the risk of overstating the basics: &vars are either alpha or numeric, period end of story. but a numeric can contain decimals. that nifty little improvement came along several releases ago. you can't apply a format to an &var... So, eg, you can read an exchange rate from some source somewhere and have it exist as an &var with decimal postions -SET &EXRATE = 1.6904 ; so that in your fex DEFINE DOLLARS/D12.2= STERLING * &EXRATE ;
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 24, 2009, 04:48 AM
khadar78
Thanks all for valuable replies. I can use PTOA or edit the fields read. but the problem occurs when i try reading it. i.e Read value &X.p13.2 It says not a proper read. Then i changed it to Read value &X.A14 After changing when i move the fields it throws an error. A/A14 = edit(X,'$9999999999999').
Any inputs pls???
7.6.9 for generating reports Windows All Outputs
December 24, 2009, 08:42 AM
Tony A
I'd refer you back to Dan's post above.
Look carefully at how he has coded his -READ statement.
Also check out the documnetation on -READ to see where you are going wrong.
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
December 28, 2009, 06:40 AM
khadar78
Hi All,
Thanks for your replies and suggestions. I got the solution for the above. It wasnt possible without your inputs. I read the fields by Alphanumeric and used the same fields for further condition check, rather copying it to local variables. Thanks again.