Page 1 of 2

issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 2:35 pm
by Raj2006
Hi,

==
01 WS-IN.
05 WS-A PIC S9(9)V99.
05 WS-C PIC X(50)

01 WS-OUT.
05 WS-B PIC S9(11)V99 COMP-3.
05 WS-D PIC X(100).
==
INITIALIZE WS-IN WS-OUT
MOVE WS-A TO WS-B
INSPCET WS-OUT REPLACING ALL LOW-VALUES BY SPACES
==

NOW, could you please anybody tell me that what would WS-B have? Thanks in advance....

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 4:43 pm
by NicC
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.

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 4:50 pm
by Raj2006
Sorry about that..

it's typo. That is INSPECT..

I searched related to these, but I am not getting the answers...

Adding to it....

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?

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 4:52 pm
by Robert Sample
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.

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 5:19 pm
by Raj2006
ROBERT and NICC please accept my apologies...

I searched in GOOGLE and some other forums too, finally I wanted to ask some experts. that's why I came here......

Do you really want me to search again?

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 5:29 pm
by Robert Sample
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.

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 7:47 pm
by NicC
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.

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 8:10 pm
by dick scherrer
Hello and welcome to the forum,

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?

Re: issue with comp-3 variable movement?

PostPosted: Thu Jul 18, 2013 11:17 pm
by BillyBoyo
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.

If you still have questions, you can read and experiment more. If still questions after that, please ask here, and someone will be around to clarify,

Re: issue with comp-3 variable movement?

PostPosted: Fri Jul 26, 2013 4:16 pm
by Raj2006
Thank you so much....

@Robert Sample
x'00' ZERO - usage is comp/comp-3
x'40' SPACE - usage is display
x'F0' ZERO - usage is diaplay

But could you please advice why x'40' and x'F0' also not good for COMP-3?

@dick sherrer,
If it is +44, PIC 9(9) COMP-3 would contain x'000000044F'. high-order bytes mean?


@BillyBoyo
I have commented out the INSPECT statement and the output was x'0000000000000C'.

When we do have comp/comp-3 variables in our copybooks, I should avoid this kind of INSPECT statements. Because it replaces the zeros. Am I correct? Please advice

@NicC
I have referred the below also,
http://ibmmainframes.com/about38115.html

Thank you all