Q

Decimal data error

I am passing an 11 digit number (no decimals) around in a CL program, when calling it from an RPG. Interactively

this works fine, but when I try to submit the CL, the submitted job goes to message wait, saying that there is decimal data error, and it is the 11 digit number that has the problem. Is there a way to overcome this? Would CL ILE help?

The number is probably defined in the CL as:

DCL VAR(&NUM) TYPE(*DEC) LEN(11 0)

When you call the CL from your RPG program, it is declared in the RPG as 11,0 packed decimal. This works.

But when you call the CL from SBMJOB or a command line, you can't pass the number as just a naked number:

CALL PGM(MYPGM) PARM(123)

or even in quotes:

CALL PGM(MYPGM) PARM('00000000123')

That's how you get decimal data errors. You have to pass the number as a packed numeric string:

CALL PGM(MYPGM) PARM(X'00000000123F')

This is obviously inconvenient, if the value is subject to frequent change. But if it's going to remain fairly constant on the SBMJOB command, you can live with it.

The only other way is to declare the parameter as a *CHAR of 11 bytes (in your RPG too) and convert the incoming value into a numeric field for the CL to use correctly. CHGVAR can handle that, if the character variable contains valid numbers. The call will then be:

CALL PGM(MYPGM) PARM('00000000123')

More on this topic

The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

 

This was first published in April 2005

Dig deeper on Data backup, storage and retrieval on iSeries

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

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

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close