Converting AS/400 negative numeric to character with leading zeros

5 pts.
Tags:
AS/400
AS/400 numeric fields
iseries v5r4
Numeric conversion
I need to convert numeric values to character keeping the leading zeros and when the value is a negative, I need to prepend the negative sign in rpgle.

Example: Positive Amount : 00005679.05 = 5,769.05

              Negative Amount: 00000-500.25 = -500.25 

 

I've tried the editc with the 'X' edit code but i need the negative sign.

    



Software/Hardware used:
AS400 with os v5r4

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try edit code P
<pre>
Edit code summary

Code Comma Zeros Sign
1 Y Y N
2 Y N N
3 N Y N
4 N N N

5-9 User-defined
A Y Y CR
B Y N CR
C N Y CR
D N N CR
J Y Y – (right)
K Y N –
L N Y –
M N N –
N Y Y – (left)
O Y N –
P N Y –
Q N N -</pre>

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Negative Amount: 00000-500.25 = -500.25 What does that mean? Are you saying that you have "00000-500.25" in a variable and you want to convert it to "-500.25" in another variable? Or do you want to convert "-500.25" to "00000-500.25"? Or was the first value just typed incorrectly? Neither of those two values are "numeric". What exactly are you trying to do? What are the field definitions and what are some actual example values? And maybe we should ask why you're doing it in program code? Usually a minus or plus sign is irrelevant in a numeric program variable. The signs are usually only meaningful to humans when they're actually looking at a display or a printed report. The sign characters are normally generated automatically by the output specifications, not by program code. It's true that there are situations where this should be done in program variables, but I'd sure hate to find out that it all came from a misunderstanding of how to control output! It seems like there are almost too many questions like this. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Please confirm 1. You want these formats? Positive Amount : 00005679.05 Negative Amount: 00000-500.25 <-- this is most unusual!!! 2. Really 11 wide for positive and 12 wide for numeric???? justified left or right? 3. What are you using RPGLE? Phil
    51,355 pointsBadges:
    report
  • philpl1jb
    2. Really 11 wide for positive and 12 wide for negative???? justified left or right? Sorry .. negative!!! What are you using? RPGLE? (RPG IV) or SQL or COBOL or QUERY. Phil
    51,355 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following