by Keith Dic » Thu, 18 Mar 2010 21:18:59
You really must learn to give us a reasonable amount of information when you start your questions. It isn't so bad to play a game of 20 questions when you are asking questions in person, but it is very annoying when doing it via email. Gather all the information relevant to the question and put it into your first post.
In this case, show us the data in FIELD-B, preferably via some INSPECT command that displays the data without trying to interpret it, such as
DISPLAY FIELD-B WHOLE IN HEX
or whatever the syntax is that displays the field value in hex. That's the syntax for the old INSPECT, if I remember it correctly. If you are using Visual Inspect or Native Inspect, find the equivalent command. I'm not familiar with Native Inspect, but from looking at the manual, the command
x /8xb ADDRESS OF FIELD-B or maybe x /8bx ADDRESS OF FIELD-B
might be the way to display the raw value in hex (the manual is ambiguous about the order of the format and size). I don't know what it is in Visual Inspect and there is no manual on the web to look at.
Do the same for FIELD-A's value after the MOVE.
And if it isn't obvious what went wrong, tell us what you see as the incorrect result.
Then we'll have half a chance to help you figure out what the problem is.
The COBOL manual says that one may MOVE a numeric edited field to a numeric field, which is the situation you have for a statement such as MOVE FIELD-B TO FIELD-A with the above declarations, so it ought to work properly IF the data in FIELD-A matches the declaration. Show us the raw contents of the two fields and we should be able to make some progress.
Your statement that you can't ADD to FIELD-B as it is not numeric seems to match what the manual says about ADD. It says that ADD works only with numeric data items. That generally does NOT include numeric edited. So you must MOVE the data from the numeric edited field into a numeric field before using it in ADD or other arithmetic statements. After you do the calculation, you can MOVE the restult back to the numeric edited field. I can't tell you why the compiler won't do the conversion from numeric edited to numeric automatically when you use a numeric edited item in an ADD statement, but the manual says it doesn't, so I guess you will have to do the conversion to numeric before using it in ADD.
Perhaps that is the point of your first question. Perhaps your original problem was the inability to ADD with a numeric edited field and you are trying to MOVE to the numeric field so you can do some arithmetic. If that is the case, good -- you are on the right track. You recognized that is what you need to do. Now show us the contents of FIELD-B when it doesn't work, and we'll be able to help you figure out what is wrong.