Run time Error in CL Program

770 pts.
Tags:
AS/400
CL Program
Hi Team, I am getting a run time error (While Calling the program) in the following code.
PGM        PARM(&A &B)
DCL        VAR(&A) TYPE(*DEC) LEN(2 0)
DCL        VAR(&B) TYPE(*DEC) LEN(2 0)
DCL        VAR(&TOTAL) TYPE(*DEC) LEN(4 0)
DCL        VAR(&ADD) TYPE(*CHAR) LEN(4)
CHGVAR     VAR(&TOTAL) VALUE(&A+&B)
CHGVAR     VAR(&ADD) VALUE(&TOTAL)
SNDMSG     MSG(&ADD) TOUSR(ATANEJA)
ENDPGM
------------------------------------------------------------------------------------------------------------------ Message ID . . . . . . :   CEE9901       Severity . . . . . . . :   30 Message type . . . . . :   Information Date sent  . . . . . . :   11/25/13      Time sent  . . . . . . :   22:09:05 Message . . . . :   Application error.  MCH1202 unmonitored by ADDITION at statement 0000000105, instruction X'0000'. Cause . . . . . :   The application ended abnormally because an exception occurred and was not handled.  The name of the program to which the unhandled exception is sent is ADDITION ADDITION ADDITION. The program was stopped at the high-level language statement number(s) 0000000105 at the time the message was sent.  If more than one statement number is shown, the program is an optimized ILE program.  Optimization does not allow a single statement number to be determined.  If *N is shown as a value, it means the real value was not available. Recovery  . . . :   See the low level messages previously listed to locate the cause of the exception.  Correct any errors, and then try the request again.

Software/Hardware used:
AS400

Answer Wiki

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

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.

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

    When showing messages about an error, the actual error message itself should be shown. The message that you posted is simply telling you that an error happened. It's not the error itself.

    The actual error message would be the MCH1202 message. That's a decimal data error.

    The message that you posted also tells us that the MCH1202 happened at statement 0000000105, and you didn't show any statement numbers with your code. We can't tell which command is at statement 0000000105.

    However, there's really only one command that is likely to give a MCH1202 error:

      CHGVAR     VAR(&TOTAL) VALUE(&A+&B) 

    I would guess that (1) your definitions of both &A and &B should be *DEC (15 5) or (2) you need to change how you're calling your program. It seems almost certain that your program is not seeing valid decimal values so it fails when it tries to add them together.

    Since you also don't show how the program is called, that's mostly educated guesswork.

    Tom

    125,585 pointsBadges:
    report
  • ankit2002

    Hi Tom,

                Please find below how I am calling the program.

     

    CALL PGM(ATANEJA/ADDITION) PARM(1.1 2.1)

    770 pointsBadges:
    report
  • TomLiotta

    CALL PGM(ATANEJA/ADDITION) PARM(1.1 2.1)

    That shows why the error is happening. You aren't passing in values that are *DEC (2 0); those values are *DEC (15 5). As I said, either change how you call the program or change the definitions of &A and &B.

    If you need to understand why either of those might work, study the CALL statement. Without looking at anything else, ask yourself how the command line can possibly know what format it should store the two character values "1.1" and "2.1" in in memory while your program is starting. How can it know that those two values should be stored as *DEC (2 0)?

    Tom

    125,585 pointsBadges:
    report
  • philpl1jb

    I thought that the data had to be written something like this

     PARM(X'000000000110000F' X'000000000210000F' )

    49,790 pointsBadges:
    report
  • CharlieBrowne

    Put you program in DEBUG with a break point at the first CHGVAR instruction.

    Now you can learn how to pass in numeric data by seeing exactly &A and &B look like when you try different was of passing the data.

    41,370 pointsBadges:
    report
  • philpl1jb
    I always make a small program to call the target program and pass it the required data.
    49,790 pointsBadges:
    report
  • TomLiotta

    I thought that the data had to be written something like...

    That would work if &A and &B were defined as *DEC (15 5), which is the default anyway. In order to make those parm values give a *DEC (2 0) result when the program accesses them, the OP will need to think through what happens to characters typed on a command line. We'll see how the dialog continues, I suppose.

    Tom

    125,585 pointsBadges:
    report
  • MDratwa
    the parms for that source code should be:

     PARM(X'000F' X'000F' )

    this is passing pack decimal 0 and 0 (up to X'099F' and X'099F' (99 99) or X'099D' and X'099D' for 99- and 99-)

    785 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