View previous topic :: View next topic
|
Author |
Message |
rarvins
New User
Joined: 24 Jan 2007 Posts: 59 Location: Texas
|
|
|
|
I have to move a decimal ( comp -3 ) to a character(A) field and write it into a output file...But the value is not retained properly...For example if i move 22.90 to the character or alphanumeric variable , the direct move doesnt work properly...can somebody suggest a soln such that im able to get 22.90 in the character output file properly |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
What is the pic of the input and output fields?
05 a-field pic s9(5)v99 value 22.90.
05 out-field pic x(10) value space.
move a-field to out-field.
doesn't work?
try:
05 temp-field pic -9(5).99.
move a-field to temp-field.
move temp-field to out-field.
is better? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
It would be helpful if you post what you ARE getting rather than just saying that the move doesn't work properly. It would also help if you post what kind of output you'd like beyond just saying 22.90.
Do you want leading zeros? If the value was 2222.90 would you want a comma (2,222.90) inserted?. How do you want negatives to appear?
The more info you provide, the more we can help. |
|
Back to top |
|
|
rarvins
New User
Joined: 24 Jan 2007 Posts: 59 Location: Texas
|
|
|
|
hi, sorry for not providing enuf input.
What I am facing rite now.
If I have 22.90 ( S9(3)V9(2) ) in the input file, I am moving it to a character fields ( A size 8) the value 22.90 comes as some 480 and sumthing.
What I need:
I wud need to supress the leading zeros.No trailing supression is required.
I need the same input value in the output character field.
so I just want 22.90
Even if it is 2222.90 I want it as 2222.90
No more formatting is required.
In case theres is -22.90 I would need the negative sign also
So I need -22.90 in the output
Hope I havent missed out anything this time.
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
rarvins wrote: |
What I am facing rite now.
If I have 22.90 ( S9(3)V9(2) ) in the input file, I am moving it to a character fields ( A size 8) the value 22.90 comes as some 480 and sumthing. |
First, what exactally if the description of the field in the input file, what is its PICture and usage (comp/comp-3)? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Rarvins,
To get what you want, please try:
Code: |
05 a-field pic s9(5)v99 value 22.90.
05 b-field pic x(8).
05 b-field-edited redefines b-field pic '-----.99'.
|
Code: |
move a-field to b-field-edited |
I ran a small test with 22.90 and -22.90 which gave:
Please let us know if you need any additional info. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Dick, I'm more interested in that "22.90 comes as some 480 and sumthing".....Now that's got my curiosity up.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Bill,
Me too, but unless/until we can see the actual result, we'll just have to wonder. . . .
I should have also mentioned that the move statement should be
Code: |
move a-field to b-field-edited |
Ooops |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
dick scherrer wrote: |
I should have also mentioned that the move statement should be
Code: |
move a-field to b-field-edited |
Ooops |
Hi Dick,
I don't know, it looks good to me......
Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Mercy,
'Tis a bad day when your mistake is that you think you made one
Don't know if i should feel better or worse. . . . |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
rarvins wrote: |
hi, sorry for not providing enuf input.
What I am facing rite now.
If I have 22.90 ( S9(3)V9(2) ) in the input file, I am moving it to a character fields ( A size 8) the value 22.90 comes as some 480 and sumthing.
What I need:
I wud need to supress the leading zeros.No trailing supression is required.
I need the same input value in the output character field.
so I just want 22.90
Even if it is 2222.90 I want it as 2222.90
No more formatting is required.
In case theres is -22.90 I would need the negative sign also
So I need -22.90 in the output
Hope I havent missed out anything this time.
|
Hi Ravin
Please let us know whethet the following code solve your query.
01 IN-PUT PIC 9(5)v9(2) COMP-3.
01 OUT-PUT PIC X(8).
01 IP-TEMP PIC 9(5)V9(2).
01 IP-FMAT PIC ZZZZZ.99.
MOVE IN-PUT TO IP-TEMP.
MOVE IP-TEMP TO IP-FMAT.
MOVE IP-FMAT TO X(8).
DISPLAY IN-PUT
DISPLAY IP-FMAT |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Rajesh,
Please modify your solution to include a floating minus sign. What you posted will "work" but the -22.90 will be missing the '-'. Also, if you use redefinition, you will not need to move the data more than once.
If you look at a prior post in this thread, you will see code that does what Rarvins requested. Once you compare the 2 suggestions, try yours and see if you get the correct result for both positive and negative numbers. |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Hi Scherrer
Thanks for your suggestion. Is the following sound ok?
01 IN-PUT PIC 9(5)v9(2) COMP-3.
01 OUT-PUT PIC X(8).
01 IN-PUT-RES.
05 IP-TEMP PIC 9(5)V9(2).
05 IP-FMAT REDEFINE IP-TEMP PIC -ZZZZZ.99.
MOVE IN-PUT TO IP-PUT-RES.
MOVE IP-FMAT TO OUT-PUT.
DISPLAY IN-PUT.
DISPLAY OUT-PUT. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Rajesh,
Why don't you just move in-put to ip-fmat with out the redefined?
Bill |
|
Back to top |
|
|
rajesh_mbt
New User
Joined: 27 Mar 2006 Posts: 97 Location: India
|
|
|
|
Hi Bill
I am not damn sure whether we can directly move comp-3 variable to editing fields like Zero suppressed(IP-FMAT) since, the sending field(IN-PUT) value is stored as packed decimal format. Also I got some errors in my previous exp when I did the same. Hence, I firstly moved it to decimal variable(IP-TEMP) which is moved later to output field.
MOVE IN-PUT TO IP-TEMP.
MOVE IP-FMAT TO OUT-PUT. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Trust me on this, move the comp-3 field directly to the edit field, no redef, just directly, it is now edited, move the edit field anywhere you want (except to a numeric field). I am 'dang sure' that is all you need. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Please review my earlier post and do the redefine that way. You will get the editing needed and will have an x(8) field that is easier to move around or string.
Code: |
05 a-field pic s9(5)v99 value 22.90.
05 b-field pic x(8).
05 b-field-edited redefines b-field pic '-----.99'.
|
The preferred way to get a comp-3 field into edited format is moving it directly. Moving it to some other pic just adds overhead and room for error. The underlying assembler issues an "edit" instruction that must have a comp-3 (packed decimal) field as input. If you don't have the data in a comp-3 field, it will happen internally. If you'd like to see this, put several different formats in some test code and then look at the generated assembler. |
|
Back to top |
|
|
umasankar.eee06
New User
Joined: 04 Sep 2008 Posts: 11 Location: chennai
|
|
|
|
Hi,
I have a filed in my inputfile declared as s9(5)v99 comp-3. I read that file and moved to copy book declared as same at the same time I moved that filed to as variable declared with same notation and displayed that filed but i didt got the exact value.
value is 1143.85 but it displayed as 000 011.
Can any one help me. Thios is urgent I need to solve it by 5pm today.
Thanks |
|
Back to top |
|
|
umasankar.eee06
New User
Joined: 04 Sep 2008 Posts: 11 Location: chennai
|
|
|
|
Sorry to every one rather than answer his question I asked my doubt.
Thanks |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
umasankar.eee06 wrote: |
Sorry to every one rather than answer his question I asked my doubt. |
Not to worry, this is not a bother but you have a seprate thread on the same topic..why?
After going through that thread, would suggest you to post a bit of your code, with WS varaibles and yes please post the scrap from the data which you are referring to as comp-3. Use BBcode when you post your code/data. |
|
Back to top |
|
|
|