Decimal data error for blanks in zoned values

60 pts.
Tags:
AS/400
RPG
I have a Zoned decimal field where blanks are accumulated and hence job is throwing decimal data error. Can you please tell me decimal data error occurs because of the blanks in zoned decimal field?


Software/Hardware used:
AS/400
1

Answer Wiki

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

Yes, a blank in a numeric field will cause a data decimal error. If you look at the hex value of a zero and a blank, you will see that the values are different, consequently the system see that the blank is out of the range of valid numeric values and will throw a data decimal error.

Check where the input is coming from, it may be that there is no validation being done or it’s not inititalized properly and letting the bad data through.

Discuss This Question: 8  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.
  • TheRealRaven
    It's very likely that blanks are the problem, but we can't tell without seeing the details of the error message along with the program instructions pointed to by the error. The data definitions used by the instructions should also be shown.
    35,980 pointsBadges:
    report
  • vishwaraj
    Thank You Todd.
    60 pointsBadges:
    report
  • TheRealRaven
    Blanks might not be the cause, though it's likely. Note that compiler options for RPG (both OPM and ILE) determine whether or not blanks in zoned decimal fields will cause decimal data errors. Neither COBOL nor C have similar options. Other possibilities will cause such errors and there are no options to avoid them.

    The best action is to clean up the data and to fix any programs that are placing blanks in those fields.
    35,980 pointsBadges:
    report
  • 6r

    whatif these values are coming from local data area as a blank and within program these are being used as followings:-

    movel a b

    here a is zoned field (2s 0) and b is packed field(2p 0).

    so at this statement error is coming and value of a is being populated from a data area which is based on another files(externally described file which again is referring to another file for field references) so any idea how to avoid this decimal data error?

    2,920 pointsBadges:
    report
  • mmanley
    Your best option might be to use the Monitor statement, and trap the error internally.  If you're positive that the problem is blanks that should be a zero, you can overlay a character field on the zoned field, and check that for blanks before trying to move the data to the packed field.  If the value is blanks, then you would just move zero to the packed field.
    470 pointsBadges:
    report
  • ToddN2000
    I cases like that I never use the dataarea value directly. When I retrieve it's value, I test it then move it if alpha or z-add it to a workfield to be used by the program. This is especially true if you use an alpha defined dataarea to store numeric values or a string containing a numeric value.
    134,495 pointsBadges:
    report
  • azohawk
    I question using a movel on numeric data. I have encountered it before, but I am always asking myself "why?" The times I did encounter it, it seems like there was like a MOVE *all(0) B preceeding the movel. (Sorry, it has been years since I coded a  MOVE statement and I don't recall the exact syntax, but you get the gist.) Doing the move *all was to ensure that there were no blanks in b.
    4,055 pointsBadges:
    report
  • ToddN2000
    @azohawk: Good memory, very close the code is actually below. I have not coded that way in may years. Back in the day a lot of programmers took shortcuts and may have done some down a dirty coding not taking into account bad data. Today we need to be more diligent and make sure we are not getting bogus data or an SQL injection attack.
    MOVE      *ALL'0'       @QTY
    134,495 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.

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

Following

Share this item with your network: