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

Packed deciaml to aplhanumeric conversion


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

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Fri Sep 01, 2006 11:34 am
Reply with quote

Hi All,
I am facing a problem. Please help me out of this. The problem is -
I am having some packed decimal variables holding some value. But in the output file, I want to show their value in alphanumeric format. So for that I have to move the values from the packed decimal fields to aljphanumeric fields.

Can you please send me a shortest and easiest way to do that beacause I have to do this for near about 100 variables.
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Sep 01, 2006 8:01 pm
Reply with quote

You can move the packed decimal variable to an edited field which can be moved to alphanumeric field. I hope this is what you are looking for.

eg. A PIC 9(03)V9(02)
B PIC 999.99
C PIC X(06)

MOVE A TO B
MOVE B TO C
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Sep 02, 2006 12:45 am
Reply with quote

Why the move from 'B' to 'C'? 'B' is already in a display format.

Also, don't forget to include the sign if negative values are possible.

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

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Sep 03, 2006 2:19 am
Reply with quote

Hi Amitava,

You didn't say if the packed fld is signed. And you didn't say what you intend to do with it after the coversion to A/N. I suppose it's signed and you want to display/print it.

If you do, you'll have trouble w/the sign. A pos 123 will display as 12C; a neg 123 as 12L. When you go to display/print it, move to a field defined something like this:

disp-fld pic -999. You'll probably have to also redefine the A/N fld as PIC 999 and move that to the disp-fld.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Sep 03, 2006 1:10 pm
Reply with quote

If you have to MOVE about 100 variables, you could consider using a
MOVE CORRESPONDING command.
Back to top
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Thu Sep 07, 2006 9:44 am
Reply with quote

Thanx a lot for your responses. In response to MMWIFE's query,
i. The packed decimal fields can be positive or negetive(That I don't know before) - i.e The packed decimal fields are signed.
ii. These fields will be written to the output file, not for report genearion but just as an output flat-file(which will be used in down-streams.).
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 09, 2006 9:58 am
Reply with quote

Hi Amitava,

If you don't have a need to print the fields it may be best to define them with the same PIC as their COMP-3 senders, but w/o the COMP-3, e.g.:

S9(5)V99 COMP-3 ===> S9(5)V99.
Back to top
View user's profile Send private message
hey_its_me
Warnings : 1

New User


Joined: 23 Aug 2006
Posts: 14
Location: USA

PostPosted: Tue Sep 19, 2006 5:09 pm
Reply with quote

hi,

I sincerely think this fact that i would like to share with my friend, would clarify his/her doubt on the relevant topic.

In the case packed decimals the no of bytes used(the space used by the variable in memory) can be calculatd by a simple formula.

if the variable is defined as S9(n) comp-3, where n is an integer, then the number of bytes used by the variable is given by

((n/2)+1).

Then if you want to display anything which is packed decimal format, then move the value into a numeric variable of the size as per the formula and then move this value to a alphanumeric variable of same type.

If there is any further details regarding the particular topic please be kind enough to share it with me.


Thanks and regards,

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

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Sep 20, 2006 7:37 am
Reply with quote

Hi Anil,

The number of bytes used to house a comp-3 variable is less than its DISPLAY format equivalent, BUT the PIC contains the same # of 9s.
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 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top