Midrange News for the IBM i Community


Posted by: renojim
Credit balance in parens
has no ratings.
Published: 26 Jan 2012
Revised: 23 Jan 2013 - 1526 days ago
Last viewed on: 29 Mar 2017 (3082 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Credit balance in parens Published by: renojim on 26 Jan 2012 view comments(4)

How the heck do you get a credit balance to show in parentheses? I got this to work -

'0(        . 0)'

But then I lost zero suppression, and I can't get it back. Now a credit balance of $500.00 shows as (00500.00).

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Credit balance in parens
Posted: 5 years 2 months 4 days 4 hours 20 minutes ago

I'm tending more towards using character fields for output (both display and printer), then use %editc in program to perform the dec->char conversion.  This makes it easy to add fancy stuff like parentheses to negative displays.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Credit balance in parens
Posted: 5 years 2 months 3 days 11 hours 59 minutes ago

Like Neil hinted, you edit codes and edit words don't support what you're trying to do. Use an appropriate edit code or edit word on your numeric, then if it was negative, add the parentheses afterwards.

Posted by: renojim
Premium member *
Comment on: Credit balance in parens
Posted: 5 years 2 months 3 days 10 hours 27 minutes ago

Thanks - there's so many ways to skin a cat in this language I can't keep track of 'em all.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Credit balance in parens
Posted: 5 years 2 months 3 days 9 hours 17 minutes ago

I write a lot of numeric edit functions.  My most recent was a procedure to take DimensionX (9p4), DimensionY (9p4, optional) and UnitOfMeasure (2a).  The character output is totally stripped numerics and something like: 30 X 36 IN, or 42.5 IN.  %editc is a rocking little built in function.