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 - 3715 days ago
Last viewed on: 16 Mar 2023 (5010 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: 11 years 2 months 14 hours 37 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: 11 years 1 months 28 days 22 hours 16 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: 11 years 1 months 28 days 20 hours 44 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: 11 years 1 months 28 days 19 hours 34 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.