Focal Point
[SOLVED] Plus/Minus Sign Preceeding Number

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

August 03, 2011, 08:00 AM
Carroll
[SOLVED] Plus/Minus Sign Preceeding Number
Hi,

We currently have FOCUS 7.6.11 on the mainframe, and I was wanting to show numeric values with either the + or - sign preceeding the value. The minus sign is no problem is the number is negative, but I haven't found a way to show the plus sign in front of positive values. I need the +/- for the following code:

AND COMPUTE ABOVE_BELOW/I4C = (ALL3 - (.05 * SCOREDRCP));
AS ' CASES, ABOVE,/BELOW, 5.0%'

Thanks,

Carroll

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


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF
August 03, 2011, 09:01 AM
ABT
Seems like you might have to do this in 2 steps.
1 - Calculate the value as a numeric.
2 - DEFINE a variable with the value and append the plus/minus to produce an alpha value for reporting.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
August 03, 2011, 09:50 AM
Carroll
I was trying to produce output that looked like this:

CASES
ABOVE
DAY OF SCORED /BELOW
DATE WEEK CASES PCT 5.0%
----------- ------ ------ ------ ------
07/31/2011 Sun 34 8.82% -1
08/01/2011 Mon 11,613 5.70% +81
08/02/2011 Tue 13,615 5.71% +96
------------------------------------------------

TOTAL 25,262 5.71% +176

Thanks,
Carroll


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF
August 03, 2011, 09:51 AM
Carroll
I didn't realize the numbers would all run together. Sorry the mini-report is hard to read!

Carroll


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF
August 03, 2011, 10:04 AM
GamP
Would this example be of help? (the define is just to generate a negative number)
JOIN COUNTRY IN COUNTRIES TO ALL COUNTRY IN CAR AS J1
DEFINE FILE CAR
 CHAIRS/I5 = IF COUNTRY EQ 'ENGLAND' THEN -SEATS ELSE SEATS;
END

TABLE FILE CAR
 SUM SALES CHAIRS
 COMPUTE PM/A6 = IF CHAIRS LT 0 THEN '-' || LJUST(5,PTOA(ABS(CHAIRS), '(P5)', 'A5'),'A5') ELSE
                 IF CHAIRS EQ 0 THEN '0' ELSE '+' || LJUST(5,PTOA(CHAIRS, '(P5)', 'A5'),'A5');
 BY COUNTRY
END



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
August 03, 2011, 10:09 AM
ABT
I'm sure there is a faster/easier/better way to do this, but here is what I'm talking about:

DEFINE FILE CAR
	MY_VARIANCE/I8 = SALES - 1000;
	DISP_VAR2/A20   = EDIT(MY_VARIANCE);
	DISP_VAR1/A20   = TRIM('L', DISP_VAR2, 20, '0', 1, 'A20');
	DISP_VAR/A21    = IF MY_VARIANCE GT 0 THEN '+' | DISP_VAR1 ELSE IF  MY_VARIANCE LT 0 THEN '-' | DISP_VAR1 ELSE DISP_VAR1;
END

TABLE FILE CAR
PRINT
	COUNTRY 
	CAR 
	MODEL 
	SALES
	MY_VARIANCE
	DISP_VAR2
	DISP_VAR1
	DISP_VAR
END


-ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
August 03, 2011, 10:15 AM
Carroll
Thanks GamP and ABT

Carroll


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF
August 03, 2011, 10:22 AM
j.gross
Let's think NFR. (It's about time IBI provided this)

Suggestions for how to specify this type of decoration on numeric formats:

+ suffix: P10C+ D12.2+
+ infix: D+12.2
P suffix: D12.2P

Use of "+" does not create any problem in DEFINE, COMPUTE, MFD, or final argument of a function. Even in reformatting a column in TABLE, /format never occurs within a numeric expression (else / could not be used in the first place!).

Any other suggestions?
August 03, 2011, 10:26 AM
ABT
why not just expand the Packed format to work with signed values (as it already should)?

I realize that's basically what you said, I just wanted to slip in the 'As it already should' part... Wink

-ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
August 04, 2011, 03:10 AM
Dave
Yes please.

Same 'problem' here. I'd like to explicitly add a + before positive numbers.

AND I would like to choose my own suffix. E.g. pct

( not being the PCT as used in FOCUS syntax )


_____________________
WF: 8.0.0.9 > going 8.2.0.5
August 04, 2011, 08:58 AM
j.gross
If (distant) memory serves, COBOL provides Display options for leading or trailing minus or sign (plus/minus). Obviously the business need existed, so why not fill the void?

Since using + and - in a FOCUS format does not create syntactic ambiguity, I suggest...
leading minus      :  xn or x-n (the latter just for consistency with the 3 forms below)   
leading sign (+/-) :        x+n                
trailing minus     :        xn-
trailing sign      :        xn+
  (where x=numeric format letter[I or P or D or F], and n=their numeric format spec)

August 05, 2011, 07:46 AM
Carroll
I agree that this should be a numeric display option. I realize that even with the excellent coding examples, there are still other issues, such as, the complexity of adding a comma for numbers over 999, and coming up with an alpha replacement for a recompute.

Thanks for the discussion. I appreciate the input.

Carroll


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF
August 07, 2011, 05:12 AM
Dan Satchell
You might be able to use this trick from previous Forum posts. Set the currency symbol to '+' and then dynamically set the output format to display/hide the currency symbol based on whether the value is positive or negative.

TABLE FILE CAR
 PRINT
  COMPUTE AMOUNTX/D8 = IF (COUNTRY LIKE 'IT%' OR 'JA%') THEN RETAIL_COST ELSE (-1 * RETAIL_COST); NOPRINT
  COMPUTE FORMATX/A8 = IF (AMOUNTX LT 0) THEN 'D8' ELSE 'D8M'; NOPRINT
  AMOUNTX/FORMATX
 BY CAR
 ON TABLE SET CURRSYMB '+'
END



WebFOCUS 7.7.05
August 08, 2011, 07:21 AM
Carroll
Thanks Dan.

Carroll


FOCUS 7.6.11 for Mainframe
z/OS - DB2 & Flat Files
Developer Studio 7.6.4
Windows XP Professional SP 2
Output: Excel, PDF