Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to display 0.00 on the screen?

Posted on 2002-04-26
9
546 Views
Last Modified: 2008-02-01
I have this field defined as 7,2 and it needed to show on the sceen as 99,999.99. But if the field is *ZERO, then it needed to be showed as 0.00. Have tried all possible edit code and edit word but no luck.
0
Comment
Question by:Ellen Chen
9 Comments
 
LVL 2

Expert Comment

by:macbone2
ID: 6979019
Hi chinghwachen
Is it an output only field or both? If it's output only you could make it an alphanumeric field instead of numeric then convert the 7.2 number from the file into a 10 character field on screen,(to allow for commas, dec. point and sign)then format the 0.00 yourself, also put in - signs if required. You'd need to move the numeric field into a numeric array which has 7 elements 1 digit long, then check each element and move to an alpha array 10 x 1 long
i.e say the numeric array is AN and the alpha array is AA
First check to see if the value is ZERO, then Z-ADD the number to AN  Then move AN,7 to AA,10, AN,6 to AA,9 then move '.' to AA,8, and AN,5 TO AA,7. after that, if the number is zero you can stop. If positive or negative, you will also need to range check so that if the number is in the range say > 0 < 10 you stop after filling 4 rightmost elements eg range from 0.01 to 9.99, then next range >= 10 up to < 100 (e.g. from 10.00 to 99.99) and so on. You also need to decide in advance whether the sign is leading or trailing. If it's a trailing sign, you'd need to adjust the array positions above, because the sign would go in AA,10.
macbone2
0
 
LVL 2

Expert Comment

by:macbone2
ID: 6982211
I didn't ask the question in the earlier comment, but I presume your using SDA for screen creation and RPG for the programming. (I also tried a number of edit codes & edit words, but couldn't make it happen. In theory it should be possible. I've just realised, whilst typing,one edit word I didn't try, but will in the morning try this yourself
               123456789
edit word     '  ,  0.00'     OR
edit word     '  ,  0.00-'  

Actually, if this doesn't work, there's no reason why even if the field was to be used for input and output, you could still make it an alphanumeric field. There'd be a lot of validation to do, for example, you would need to check that each character was numeric or dec. point or minus sign; but you could do much of the validation using SCAN or LOKUP on array of valid chars. after excluding blanks, then you'd only need to check position of dec. point and sign e.g 3.45- would be valid but .345- or 3-4.5 wouldn't be.
Hope this helps, and I'll try that edit word tomorrow.

Regards
Geoff McKeown (macbone2)
0
 
LVL 2

Expert Comment

by:macbone2
ID: 6982216
The edit word doesn't show correctly because it's been shifted by the formatting on this page. The '#' below represent spaces in the edit word

  edit word   '##,##0.00'   or '##,##0.00-'

Good Luck

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 2

Expert Comment

by:macbone2
ID: 6986593
Ignore the comments about edit words. I can't make any combination work.
0
 

Author Comment

by:Ellen Chen
ID: 6986668
Geoff,

I know. We have tried every possible edit words and edit code. Please let me know if you have better solution other than the first one.

Thanks.
0
 
LVL 1

Expert Comment

by:MN_Dave
ID: 6987028
It may be possible to create a user defined edit code that will handle this.  IBM allows up to 5 user defined edit codes (5,6,7,8, & 9).  IBM ships with their own definitions for these, but they can be deleted and recreated using the CRTEDTD command.  This command allows you to define both an integer mask and a decimal mask to handle editing on both sides of the decimal point.  I think you could use the integer mask portion of this to accomplish what you are trying to do.  Unfortunately I cannot try this first because our systems people will not grant us authority to change objects in the qsys library.  Give it a shot and see if you can make it work!
0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 6996593
Hi chinghwachen,

I ws sure about the use of editcodes, but I just checked it again (and tested it)

Use Editcode '1' for fields with no-sign,
    editcode 'J' for signed fields.

If it does not work, be sure of the folowing:
RPG: put a 'D' on position 21 of your Control-Specification (H-form)

or

ILERPG: put the DECEDIT('0.') in the Control-Specification

Goodluck
0
 
LVL 3

Accepted Solution

by:
P_S_Price earned 250 total points
ID: 7143192
I may not be understanding the question correctly, but
Have you tried an edit word of '##,#0#.##'  Where '#' is
used here to represent a Space this will definitely output zeros as 0.00 (Copy and paste this - EDTWRD('  , 0 .  ').

But it will however output the number .01 as 0.01.

Is your question that you require the field Zero filled if the value is not zero, and zero suppressed as shown when the value is 0.

0
 

Author Comment

by:Ellen Chen
ID: 7143927
It works! Thanks.
I did not try and put a SPACE before the decimal point.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Some of the SEO trends we might expect in 2017.
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question