Failed arithmetic operations on CICS programs written in C
When I write a CICS program in C language the arithmetic operations are not working in CICS execution. I am receiving two values from CICS and doing addition. The addition statement alone is not working. What is going on?
There are several points where things may go haywire so you're not adding the right things together:
Are you receiving the numbers in EBCDIC? If so, ensure the logic that converts the number string into binary works correctly. Also double-check the input fields' offsets and lengths to make sure the conversion logic doesn't include garbage.
There could be a storage alignment problem if you are working with multiple structures or using something like memcpy() to get the number into a variable.
Remember that native C doesn't support packed decimal numbers. Therefore, if you are trying to add two packed numbers you must use special IBM or custom written routines.
In any case, you will have to find some way to examine your program execution at the time of the addition with a debugging tool. If you don't have a debugging tool you can try forcing an ABEND either right before or after the offending statement.
This was first published in January 2007