IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Does moving a value of S9(9) COMP-4 to 9(04) works fine?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ideas

New User


Joined: 25 May 2005
Posts: 52
Location: India

PostPosted: Tue Apr 25, 2006 11:55 am
Reply with quote

dear all,

Does moving a value of S9(9) COMP-4 variable to to 9(04) works fine?

thanks!
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Apr 25, 2006 12:32 pm
Reply with quote

Quote:
Does moving a value of S9(9) COMP-4 variable to to 9(04) works fine?

Did you face any problem in that ??
S9(9) occupies 4 Bytes, it would be a normal COBOL MOVE moving a S9(9) COMP-4 variable to 9(04).

Regards,
Priyesh.
Back to top
View user's profile Send private message
muthukumar

New User


Joined: 24 Mar 2004
Posts: 29

PostPosted: Tue Apr 25, 2006 12:58 pm
Reply with quote

All,

I am hearing first time on this comp-4 type. can you please throw some lights on how this will get stored and what is the use of this type of declations.

thanks & regards
Muthu
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Tue Apr 25, 2006 1:13 pm
Reply with quote

Hi,

COMP-4 and Binary or COMP all are same. So you can move the
S9(9) COMP-4 variable to 9(04).


Correct me if I am Wrong.

Thanks
Shri
Back to top
View user's profile Send private message
vijayakumar.yellala

New User


Joined: 19 Apr 2006
Posts: 63
Location: Chennai

PostPosted: Wed Apr 26, 2006 1:59 pm
Reply with quote

Hi Boss....

S9(9) COMP it will take 4 bytes, then 9(4) also will take 4 bytes only..

but here we are moving value of S9(9) Comp, here the length of the field S9(9) Comp is 9 ,

if we move the S9(9) to 9(4), the value will tructe....

Correct me , if i am wrong....

Regards
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 29, 2006 7:35 pm
Reply with quote

To complete the discussion you must code the receiving field as
PIC S9(10) to avoid truncation and preserve the sign.
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Sat Apr 29, 2006 11:24 pm
Reply with quote

Hi all,

It work fine.........but you have to care bat the truncation .......as mmwife told is correct.............



Thanks
Shri
Back to top
View user's profile Send private message
jayanta_nit

New User


Joined: 13 Apr 2006
Posts: 22
Location: hyderabad

PostPosted: Thu May 04, 2006 2:16 pm
Reply with quote

hi,
i think it will not work fine bacause s9(9) comp-4 will take (9+1)=5 bytes,and if we want to move this value to 9(04) then left most value will be truncated..pls correct me if i'm wrong.
Regards
Jayanta kr. mondal
Back to top
View user's profile Send private message
jayanta_nit

New User


Joined: 13 Apr 2006
Posts: 22
Location: hyderabad

PostPosted: Thu May 04, 2006 2:19 pm
Reply with quote

hi muthukumar,
as far i knw hat comp-3 and comp-4 are the same type i,e packed decimal format..
regards
jayanta
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Thu May 04, 2006 2:28 pm
Reply with quote

Its all depend upon the legth of the field.

but you can move

correct me If I am wrong

Thanks
Shri
Back to top
View user's profile Send private message
jayanta_nit

New User


Joined: 13 Apr 2006
Posts: 22
Location: hyderabad

PostPosted: Thu May 04, 2006 2:29 pm
Reply with quote

hi,
i think it will not work fine bacause s9(9) comp-4 will take (9+1)/2=5 bytes,and if we want to move this value to 9(04) then left most value will be truncated..pls correct me if i'm wrong.
Regards
Jayanta kr. mondal
Back to top
View user's profile Send private message
jayanta_nit

New User


Joined: 13 Apr 2006
Posts: 22
Location: hyderabad

PostPosted: Thu May 04, 2006 2:31 pm
Reply with quote

hi,
i think it will not work fine bacause s9(9) comp-4 will take (9+1)/2=5 bytes,and if we want to move this value to 9(04) then left most value will be truncated..pls correct me if i'm wrong.
Regards
Jayanta kr. mondal
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 06, 2006 7:08 am
Reply with quote

Hi Jayanta,

What you described is not how the length of a COMP/COMP-4/BINARY field is determined; that's how a COMP-3 field is determined.

Do a search on COMP and/or COMP-4 for an explanation
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top