View previous topic :: View next topic
|
Author |
Message |
kavikesav
New User
Joined: 22 Mar 2007 Posts: 21 Location: chennai
|
|
|
|
i am having a file which is having unpacked numbers and i want to write a cobol program to convert it to packed format so that i can use it in the another program |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Your program will be of only one line then-
COBOL does it by MOVE!!
Code: |
01 DISP-VAR 9(09).
01 COMP-3-VAR 9(09) COMP-3.
PROC DIV.
MOVE DISP-VAR TO COMP-3-VAR |
|
|
Back to top |
|
|
kavikesav
New User
Joined: 22 Mar 2007 Posts: 21 Location: chennai
|
|
|
|
S9(009)V9(2) COMP-3 when this is unpacked can u say me how many digits it will return |
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
for comp-3 fields, each digit takes half a byte and a sign half a byte,whether sign is declared or not.
N is the total number of digits.
formula:
N/2 + 1=5.5+1=5+1=6
Quote: |
S9(009)V9(2) COMP-3 when this is unpacked can u say me how many digits it will return |
Rounded down N/2.i.e., if N=11,11/2=5.5=5 |
|
Back to top |
|
|
kavikesav
New User
Joined: 22 Mar 2007 Posts: 21 Location: chennai
|
|
|
|
can u give me a comp-3 example and the data how it will be after it is unpacked?..i cannot catch you... |
|
Back to top |
|
|
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 196 Location: Bangalore
|
|
|
|
Please type 'comp3' in forum search which is in right side of top of page and click GO command button.
You will find a lot of topics discussed about comp-3 variables.
Hope this will help you. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
No calculation is needed to move from comp-3 (packed) to zoned decimal. The number of digits specified in the comp-3 field definition will be moved into a zoned decimal field as long as the number of digits in the receiving field is big enough.
For example (from above) a field of S9(009)V9(2) COMP-3 will "move" 11 digits - the zoned decimal receiving field should be S9(009)V9(2). The difference in the fields will be that one is in character format (easily readable by the eyes) and the other is "packed" which is not easily readable by the eyes until it is shown/viewed in hex. |
|
Back to top |
|
|
|