View previous topic :: View next topic
|
Author |
Message |
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
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 |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
If you have to MOVE about 100 variables, you could consider using a
MOVE CORRESPONDING command. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
hey_its_me Warnings : 1 New User
Joined: 23 Aug 2006 Posts: 14 Location: USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|