Problem solve Get help with specific problems with your technologies, process and projects.

Failed arithmetic operations on CICS programs written in C

CICS expert Robert Crawford helps a user who's arithmetic operations are failing when programs are written in C language

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.

  • Dig Deeper on IBM system z and mainframe systems

    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.

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.