Solved

how to display 0.00 on the screen?

Posted on 2002-04-26
9
544 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
Adding Computers to AD groups through an SCCM Task Sequence
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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