Focal Point
[CLOSED] (FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR

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

April 28, 2010, 10:08 AM
Jeff Moses
[CLOSED] (FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR
Hi,
I am trying to get some code to work and I'm stuck here
When I execute the second SET command the values all appear to be there but when I TYPE it out after the SET I get the ******** is there anyway to fix this?

-*****--V_MASTER_CASH_ADJ
-TYPE 104038080.74
104038080.74
-SET &V_ASSETS_MASTER_CASH=TRUNCATE( 104038080.74);
-SET &V_MASTER_CASH_ADJ=IF 'EXECUTED' EQ 'ORDERED' THEN (( 104038080.74) - 0 - 0) ELSE IF 'EXECUTED' EQ 'EXECUTED' THEN (( 104038080.74) - 0) ELSE ( 104038080.74);
-SET &V_MASTER_CASH_ADJ=TRUNCATE(********);
-TYPE ********
********
-SET &V_HOL_MASTER_ASSET_TYPE1=UPCASE(15,'AS ACCOUNTED','A15');
-SET &V_HOL_MASTER_ASSET_TYPE1=TRUNCATE(AS ACCOUNTED );
-******--V_MASTER_TNA
-SET &V_MASTER_TNA= IF 'AS ACCOUNTED' EQ 'CALCULATED' THEN ( 2757428823.60 + ******** - 0) ELSE IF 'AS ACCOUNTED' EQ 'OTHER' THEN As-Accounted ELSE 2860464543.06;
(FOC281) ALPHA ARGUMENTS IN PLACE WHERE NUMERIC ARE CALLED FOR

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


PROD: WF 7.6.4/Solaris
NON-PROD: WF 7.6.11/Solaris
April 28, 2010, 10:37 AM
njsden
Can you post the actual code being used instead of the execution output?



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
April 28, 2010, 10:39 AM
njsden
We need to see which variables are being used and how, but apparently you're getting a data precision error based on the ******* results being displayed.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
April 28, 2010, 10:49 AM
njsden
This is probably not exactly what you need but give it a try and see if it gives you some ideas:

-SET &V_MASTER_CASH_ADJ= PTOA(104038080.74 - 0 -0, '(P20.2)', 'A20');
-SET &V_MASTER_CASH_ADJ_T= PTOA(&V_MASTER_CASH_ADJ, '(P20)', 'A20');
-TYPE &V_MASTER_CASH_ADJ
-TYPE &V_MASTER_CASH_ADJ_T


I'm basically converting everything to strings since DM does not seem to be able to keep "big" numbers in &variables. It can deal properly with them in internal calculations though.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
April 28, 2010, 10:52 AM
njsden
quote:
-SET &V_MASTER_CASH_ADJ_T= PTOA(&V_MASTER_CASH_ADJ, '(P20)', 'A20');


Keep in mind that this is not technically truncating the number but rounding it instead!



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
April 28, 2010, 11:02 AM
Francis Mariani
I poked around with this as well. By default DM uses integers with a maximum size of 11 digits. Use DMPRECISION to set decimal precision:

SET DMPRECISION = 2


I just can't get DM to work with the 104038080.74 number. I thought we could convert the value to numeric using a format conversion function, but I can't get this to work.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 28, 2010, 11:27 AM
Jeff Moses
Here is the actual code....

-*****--V_MASTER_CASH_ADJ
-TYPE &V_ASSETS_MASTER_CASH
-SET &V_ASSETS_MASTER_CASH=TRUNCATE(&V_ASSETS_MASTER_CASH);
-SET &V_MASTER_CASH_ADJ=IF &P_MSTR_HLDNGS_TYPE1.QUOTEDSTRING EQ 'ORDERED' THEN ((&V_ASSETS_MASTER_CASH) - &V_EXORD_MASTER_ORDERED_MKT_VAL - &V_EXORD_MASTER_EXEC_MKT_VAL) ELSE IF &P_MSTR_HLDNGS_TYPE1.QUOTEDSTRING EQ 'EXECUTED' THEN ((&V_ASSETS_MASTER_CASH) - &V_EXORD_MASTER_EXEC_MKT_VAL) ELSE (&V_ASSETS_MASTER_CASH);
-SET &V_MASTER_CASH_ADJ=TRUNCATE(&V_MASTER_CASH_ADJ);
-*SET &V_MASTER_CASH_ADJ=115542157.55;
-TYPE &V_MASTER_CASH_ADJ
-SET &V_HOL_MASTER_ASSET_TYPE1=UPCASE(15,&V_HOL_MASTER_ASSET_TYPE.QUOTEDSTRING,'A15');
-SET &V_HOL_MASTER_ASSET_TYPE1=TRUNCATE(&V_HOL_MASTER_ASSET_TYPE1);
-******--V_MASTER_TNA
-SET &V_MASTER_TNA= IF &V_HOL_MASTER_ASSET_TYPE1.QUOTEDSTRING EQ 'CALCULATED' THEN (&V_MSTR_MKT_VAL_SUM + &V_MASTER_CASH_ADJ - &V_EXORD_MASTER_FUTURES_EXPOSUR) ELSE IF &V_HOL_MASTER_ASSET_TYPE1.QUOTEDSTRING EQ 'OTHER' THEN &P_D_MSTR_ASSET_TYPE ELSE &V_ASSETS_MASTER_ASSETS_TNA_ADJ;
-TYPE &V_MASTER_TNA


PROD: WF 7.6.4/Solaris
NON-PROD: WF 7.6.11/Solaris
April 28, 2010, 02:16 PM
Francis Mariani
Sometimes it's easier working with WebFOCUS code than with Dialogue Manager, particularly with numbers:

-SET &ECHO=ALL;

SET HOLDLIST=PRINTONLY
-RUN

-DEFAULT &V_ASSETS_MASTER_CASH = 104038080.74;
-DEFAULT &V_EXORD_MASTER_ORDERED_MKT_VAL = 1;
-DEFAULT &V_EXORD_MASTER_EXEC_MKT_VAL = 1;
-DEFAULT &V_MASTER_CASH_ADJ = 3.4;
-DEFAULT &V_EXORD_MASTER_FUTURES_EXPOSUR = 76.7;
-DEFAULT &P_D_MSTR_ASSET_TYPE = 666123.23;
-DEFAULT &V_MSTR_MKT_VAL_SUM = 500.19;
-DEFAULT &V_ASSETS_MASTER_ASSETS_TNA_ADJ = 101.94;
-DEFAULT &P_MSTR_HLDNGS_TYPE = 'Ordered';
-DEFAULT &V_HOL_MASTER_ASSET_TYPE = 'Calculated';

-SET &P_MSTR_HLDNGS_TYPE = UPCASE(15,&P_MSTR_HLDNGS_TYPE,'A15');
-SET &V_HOL_MASTER_ASSET_TYPE = UPCASE(15,&V_HOL_MASTER_ASSET_TYPE,'A15');

DEFINE FILE CAR
V_MASTER_CASH_ADJ/D20.2 =
  IF '&P_MSTR_HLDNGS_TYPE' EQ 'ORDERED'
  THEN ((&V_ASSETS_MASTER_CASH) - &V_EXORD_MASTER_ORDERED_MKT_VAL - &V_EXORD_MASTER_EXEC_MKT_VAL) ELSE
  IF '&P_MSTR_HLDNGS_TYPE' EQ 'EXECUTED'
  THEN ((&V_ASSETS_MASTER_CASH) - &V_EXORD_MASTER_EXEC_MKT_VAL) ELSE (&V_ASSETS_MASTER_CASH);

V_MASTER_TNA/D20.2 =
  IF '&V_HOL_MASTER_ASSET_TYPE' EQ 'CALCULATED'
  THEN (&V_MSTR_MKT_VAL_SUM + &V_MASTER_CASH_ADJ - &V_EXORD_MASTER_FUTURES_EXPOSUR) ELSE
  IF '&V_HOL_MASTER_ASSET_TYPE' EQ 'OTHER'
  THEN &P_D_MSTR_ASSET_TYPE ELSE &V_ASSETS_MASTER_ASSETS_TNA_ADJ;
END

TABLE FILE CAR
PRINT
COUNTRY NOPRINT
V_MASTER_CASH_ADJ
V_MASTER_TNA
ON TABLE SAVE AS S001
WHERE RECORDLIMIT EQ 1
END
-RUN
-READ S001 &V_MASTER_CASH_ADJ.A20. &V_MASTER_TNA.A20

-TYPE &V_MASTER_CASH_ADJ &V_MASTER_TNA



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 28, 2010, 09:20 PM
Dan Satchell
Your number 104038080.74 seems to be one digit too big for DM to handle in calculations. If you don't expect to deal with numbers that large then your code should work as is. Otherwise, you may be able to use function FTOA (similar to PTOA suggested by njsden) to avoid this limitation, or you could probably create a DEFINE FUNCTION to handle to calculations. Here's an excellent example of a DEFINE FUNCTION used in DM, posted by Francis:

DEFINE FUNCTION example


WebFOCUS 7.7.05