Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to display 0.00 on the screen?

Posted on 2002-04-26
9
Medium Priority
?
588 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
[X]
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
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 1000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Read on to get a few ideas on how to promote your next corporate event.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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