ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Causes of DECIMAL DATA ERROR

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Causes of DECIMAL DATA ERROR

    The following is the issue, i have faced.

    I read a file and moved the value of one of its NUMERIC [Eg.FLD1] field to a working variable [Eg. WFLD1] in COBOL.

    i.e MOVE FLD1 to WFLD1
    [both fields are of numeric & length is same]

    But, my program has received MCH1202 during the processing of the file.

    Now, i need to find out the various possibles scenarios which can cause the DECIMAL DATA ERROR i.e MCH1202 in a COBOL program. so that i can avoid those scenarios.

    Kindly help me in this regard.

  • #2
    Re: Causes of DECIMAL DATA ERROR

    Check to ensure the field has a valid numeric value *before* you move it:

    Code:
    if FLD1 numeric
        move FLD1 to WFLD1
    else
        (Do Error Logic)
    end-if

    Comment


    • #3
      Re: Causes of DECIMAL DATA ERROR

      and make sure the field receiving the numeric value has been properly set to a numeric value as in initilaization
      John M. Mauro
      Software Engineer
      nThrive

      Comment


      • #4
        Re: Causes of DECIMAL DATA ERROR

        Hi Terry and John,

        thanks for the solution. I have also implemented the same like solution.

        But, i just found that the following are the scenarios which will cause the DECIMAL DATA ERROR:
        1. Assigning non-numeric values to NUMERIC field. [NUMERIC validation will prevent this]
        2. Trying to refer a varible, which is not stored/assigned with any values. [Initialization will prevent this]

        If there are anyother possible scenarios which would cause the error, kindly share the same.
        Last edited by kpandian; August 10, 2011, 09:51 PM. Reason: corrected the Typo error.

        Comment

        Working...
        X