Solved

how to display 0.00 on the screen?

Posted on 2002-04-26
9
533 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 2

Expert Comment

by:macbone2
Comment Utility
Ignore the comments about edit words. I can't make any combination work.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Ellen Chen
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
It works! Thanks.
I did not try and put a SPACE before the decimal point.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now