issue with comp-3 variable movement?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

issue with comp-3 variable movement?

Postby Raj2006 » Thu Jul 18, 2013 2:35 pm

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....
Raj2006
 
Posts: 17
Joined: Thu Jul 18, 2013 2:13 pm
Has thanked: 16 times
Been thanked: 0 time

Re: issue with comp-3 variable movement?

Postby NicC » Thu Jul 18, 2013 4:43 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
Raj2006 (Fri Jul 26, 2013 7:14 pm)
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: issue with comp-3 variable movement?

Postby Raj2006 » Thu Jul 18, 2013 4:50 pm

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?
Raj2006
 
Posts: 17
Joined: Thu Jul 18, 2013 2:13 pm
Has thanked: 16 times
Been thanked: 0 time

Re: issue with comp-3 variable movement?

Postby Robert Sample » Thu Jul 18, 2013 4:52 pm

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.

These users thanked the author Robert Sample for the post:
Raj2006 (Fri Jul 26, 2013 7:14 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: issue with comp-3 variable movement?

Postby Raj2006 » Thu Jul 18, 2013 5:19 pm

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?
Raj2006
 
Posts: 17
Joined: Thu Jul 18, 2013 2:13 pm
Has thanked: 16 times
Been thanked: 0 time

Re: issue with comp-3 variable movement?

Postby Robert Sample » Thu Jul 18, 2013 5:29 pm

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.

These users thanked the author Robert Sample for the post:
Raj2006 (Fri Jul 26, 2013 7:15 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: issue with comp-3 variable movement?

Postby NicC » Thu Jul 18, 2013 7:47 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

These users thanked the author NicC for the post:
Raj2006 (Fri Jul 26, 2013 7:15 pm)
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: issue with comp-3 variable movement?

Postby dick scherrer » Thu Jul 18, 2013 8:10 pm

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?
Hope this helps,
d.sch.

These users thanked the author dick scherrer for the post:
Raj2006 (Fri Jul 26, 2013 7:15 pm)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: issue with comp-3 variable movement?

Postby BillyBoyo » Thu Jul 18, 2013 11:17 pm

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,

These users thanked the author BillyBoyo for the post:
Raj2006 (Fri Jul 26, 2013 7:14 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: issue with comp-3 variable movement?

Postby Raj2006 » Fri Jul 26, 2013 4:16 pm

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
Raj2006
 
Posts: 17
Joined: Thu Jul 18, 2013 2:13 pm
Has thanked: 16 times
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post