issue with comp-3 variable movement?
05 WS-B PIC S9(11)V99 COMP-3.
Re: issue with comp-3 variable movement?
Ok - you are new so you probably do not know about the code tags which present your screen data in a fixed font format and in a format that looks like a screen shot. Search for code tags using the search facility of the forum.
Also, cut and paste - the snippet you showed wioll not compile - INSPCET is not a valid COBOL code.
Finally, please explain WHY you are posting. Have you a problem? Have you searched the forum for a similar problem? If not then you MUST also read the forum rules.
it's typo. That is INSPECT..
I expected that it would have X'F0F0F0F0F0F00C', but it has '4040404040400C'.
Due to the INSPECT verb it is getting changed into spaces.. Can anyone advice?
There is a link to IBM Manuals on the top right of this page. You need to click on that link, find the COBOL Language Reference manual, and start reading. We are here to help and answer questions; we are not here to read the manual for you -- and what you are asking is easily answered by reading the manual for a while.
Do you really want me to search again?
No, I do not want you to search. I want you to READ THE MANUAL! Especially the section on the INITIALIZE statement where it tells you explicitly how a group level variable is handled by INITIALIZE. Then read the manual sections on the internal formats of data so you will know how a COMP-3 data item looks in memory.
Finally, read the manual to determine the difference between X'00' and X'40' and X'F0' -- and why none of these are good for a COMP-3 variable.
Also, this same topic came up yesterday, or the day before, on another forum - I think the sister forum to this site which is why I mention it.
I can tell you that the only reason why I know the anwer to the problem is that I picked it up from the forums before I became a 'COBOL programmer' last year. So, keep on reading as many forums as you can - preferably daily - as you can pick up so much info.
While doing the research, consider what a PIC 9(9) COMP-3 field will contain when the actual value is +44 . . .
What might be in the high-order bytes?
The INITIALIZE of WS-IN will set WS-A to X'F0F0F0F0F0F0F0F0F0F0C0' and WS-C to 50 spaces.
For WS-OUT it will set WS-B to X'0000000000000C' and and WS-D to 100 spaces.
Your MOVE WS-A TO WS-B will PACK and MVC, and possibly "sign-fix". But, since WS-A is zero, WS-B will end up with exactly the same value that it had before, an identically arranged "packed zero".
Your INSPECT will then only affect the first six bytes of WS-B (as LOW-VALUES will not be found elsewhere in WS-OUT) and these will be replaced by space giving you exactly the output you have shown through experimentation.
But could you please advice why x'40' and x'F0' also not good for COMP-3?
If it is +44, PIC 9(9) COMP-3 would contain x'000000044F'. high-order bytes mean?
I have commented out the INSPECT statement and the output was x'0000000000000C'.
How to check whether the Comp variable has Spaces or not .