MCH1202 error in COBOL/400

Decimal Data Error
There are n number of ways a DDE occurs. I saw a new problem recently. Request a help from this group. Q) I have 3 Variables declared in COBOl program A(PIC 9(4)) ,B(PIC 9(4)) and C ( PIC 9(8) ) I am perfoming an arithimatic operation as follows Subtract A from B giving C. i tried with following examples 1) A = 12 ,B = 23 ,resulted in MCH1202 2) A = 1234 ,B = 2332 ,result C = 00001098. I am not able to crack why a 2 length input is throwing DDE.

Answer Wiki

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

MCH1202 is telling you that by subtracting a longer variable size from the shorter variable size the result might be truncated.

I imagine the reason it works in your second example is that you are maxing out to the absolute length of the B value and also A is the same length which sort of “Fakes” the AS/400 into letting it know there’s no loss of data. however if you use a smaller value, less then the full length the AS/400 is trying to let you know you may incure some loss of data during a computation.

In any case, while not always necessary, you might consider using the same field sizes whenever performing mathematical operations. use a temporary work field defined as the same size as your longest field and move the B value into it to avoid this conflict.

Discuss This Question: 6  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.
  • TomLiotta
    Without seeing your code, there's no way we can know. I tried both COBOL/400 and ILE COBOL, but neither of those showed the problem that you described. A and B were PIC 9(4) and C was PIC 9(8). A was VALUE 12 and B was VALUE 23. SUBTRACT A FROM B GIVING C ran fine on a V5R4 system I tried. Tom
    125,585 pointsBadges:
  • philpl1jb
    As Tom said there cannot be anything wrong with the statement SUBTRACT A FROM B GIVING C. So it must be somthing wrong with the values in A and B. I cannot tell how you are populating A and B but that must be your problem If this works A = 1234, B = 2332 then try setting A = 0012, B = 0023 If that doesn't work show us how you are loading those values. Phil
    54,090 pointsBadges:
  • Rlsantucijr
    Yes, please supply us with some of the WS code before & after the PICs and the same with the PROCEDURE statements. And have you dumped the program when you get the MCH1202?
    445 pointsBadges:
  • Gsplmgc
    You msut set the WS fields to a numeric value (usually zero) before you reference them in your program.
    70 pointsBadges:
  • TomLiotta
    If these are display file variables, then the problem changes significantly. The problem becomes one of defining the display file field attributes correctly so that your display sends the values back to your program correctly. In that case, it's not a COBOL problem at all. It doesn't matter if it's COBOL, RPG, CL, C or any other language and it doesn't matter if it's COBOL/400 or ILE COBOL. If the display file is sending the digits "12" left-justified and padded on the right with blanks back to your program, then your program has no way of knowing that the display file isn't behaving properly. We need to know a little more about the circumstances. Tom
    125,585 pointsBadges:
  • MDratwa
    If you run this program under the debugger, you can see what the fields contains before it executes. The program may have move blanks into one of the fields (or maybe both). In your example, "C" should have been a pic S9(8) because is result is negative, the sign will be dropped.
    785 pointsBadges:

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.


Share this item with your network: