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

Convert unpacked data to packed format


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

New User


Joined: 22 Mar 2007
Posts: 21
Location: chennai

PostPosted: Mon Aug 20, 2007 9:56 am
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Aug 20, 2007 12:14 pm
Reply with quote

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
View user's profile Send private message
kavikesav

New User


Joined: 22 Mar 2007
Posts: 21
Location: chennai

PostPosted: Mon Aug 20, 2007 6:18 pm
Reply with quote

S9(009)V9(2) COMP-3 when this is unpacked can u say me how many digits it will return
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Aug 20, 2007 6:32 pm
Reply with quote

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
View user's profile Send private message
kavikesav

New User


Joined: 22 Mar 2007
Posts: 21
Location: chennai

PostPosted: Mon Aug 20, 2007 6:59 pm
Reply with quote

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
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Aug 20, 2007 7:40 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Aug 20, 2007 7:58 pm
Reply with quote

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
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top