Sie sind auf Seite 1von 3

What is a decimal data error?

Decimal data error should be a rare thing for an RPG programmer who writes a single stand alone program or does not make any program call with numeric parameters. Decimal data error is actually the error trapped by AS/400 machine at run time when it identifies a difference in the "decimal format" of a parameter in the calling and called programs. This difference is identified only when we try to assign the value of a numeric field to a different numeric type field. It may remain hidden and go un-noticed during testing if that specific variable is never used in the called program.

When does decimal data error occur? Decimal data error occurs mostly during program calls or procedure calls. i.e When PGM1 calls PGM2 and passes a numeric parameter there will a decimal data error if the passed-from variable's decimal format is different than that of the passed-to variable. Now decimal data error will occur when the variable is used in the called program.

When will we say that the decimal formats are different? Decimal formats are understood to be different when Type differs in two programs/procedures The variable being passed is of numeric and the receiver is non numeric (Character) Size differs in two programs/ procedures 13P 6 in one program 12P 7 in the other Packed and zoned parameters Here, From what I've learnt, packed and zoned data type numbers can be used interchangeably within a program. However, You are rewarded with a decimal data error if you try to receive a zoned value in a packed variable(or vice-versa) passed from a different program. Un-Initialized Numeric Variables (Major reason)- RPG program intialization is different than other programming languages like java. In RPG a variable is not assigned a value until we do so ourselves. Be it by using an Eval statement or intialization, and this way it does not know decimal format of the variable while passing it as a parameter to other program. I have seen that chances of decimal data error reduces dramatically if we simply intialize the numeric variables which we are going to pass to some other program as parameters. Junk data in any file field (Mostly the date type field, but sometimes numeric fields also).

They correctly say that Prevention is always better than cure - The Checklist for no decimal data error So, based on the above four reason of decimal data error we can do the followings to avoid decimal data error. Initialize all variables (Particularly the numeric ones) to a default value. You may use the keyword INZ to initialize them with system default value Initalize all data structures by simply putting the keyword INZ in the data structure declaration line. Whenever passing a numeric variable from an RPG program to a CL program, define the parameters as 15P 5 even if it's not required (Do you know why?). Practice using only packed type of numbers. Ensure the order of parameters of the program call and the entry parameter list are the same. Define the prototypes in a copybook and include it in both the modules from where you call the procedure and where the procedure is actually defined. This will ensure that any data type mismatch and order mismatch is caught at the compilation time itself.

Ok, I did everything correct, Even then I get decimal error. What to do now? Firstly check the prevention or the checklist. If you did everything correct, I believe there is little chance of this error. If it still occurs this is how you can identify the culprrit variable. 1. Display source using the command STRDBG PGMNAME UPDPROD(*YES/*NO) as per your logic. 2. Press F12 and call the program. 3. Perform the sequences which lead you to the decimal data error. See the line at which the error occurred. See the values of all variables using F11. The variable with a junk value (identified by 04040404 or some unknown weird characters) is the culprit. Now check whether this variable is initialized? Did it come from a different program? Is the data structure which this variable is the part of (if it is), has been initialized?

If above steps do not resolve the issue it means you are either missing something or I

have not faced your situation yet or I am missing it right now. In any case I would be very eager to know your situation. Do post your problem in the forum under appropriate category. And, lastly your comments and feedbacks (positive/negative whatever) are very helpful to me. Do give your important feedback below. Happy Taming The Wild Error!

Das könnte Ihnen auch gefallen