View previous topic :: View next topic
|
Author |
Message |
dates
New User
Joined: 11 Mar 2008 Posts: 9 Location: LA,USA
|
|
|
|
Hi i have a problem in manipulating data.
My input is
01 ws-price-ip 9(10)v99
01 ws-char x(01) value '{'
Out put is
01 ws-price 9(11)v99
I want to append '{' to ws-price-ip and move the resultant to ws-price.
can anyone provide the solution? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the '{' is an overprint sign configuration for a zero in a numeric display pic clause. if you had a sign in you numeric pic clause.
since the { is alphanumeric, you can not make it part of a value defined with a numeric pic clause.
there is no solution to your request.
what are you trying to do and why? |
|
Back to top |
|
|
dates
New User
Joined: 11 Mar 2008 Posts: 9 Location: LA,USA
|
|
|
|
actually i have a File conataining Price in the format
03 LSP-PRICE PIC 9(11)V99.
and in the input file, the price format is
03 IP-PRICE PIC 9(10)V99.
now i need to append '{' to ip-price and write to the file.
what can be the solution to this? |
|
Back to top |
|
|
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
Hi Date,
Why you need to append '{' to the o/p. Is there any specific reason for this or you just want to append because the mismatch in PIC clause of i/p and o/p. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you have only repeated the same useless crap you mentioned earlier.
I can only assume you are attempting to put a sign on the value.
you are only using unsigned picture clauses, so nothing will work.
explain why you need the {, and come up with a signed field definition.
you do not need to append the { anywhere.
Then all you have to do is move from the unsigned numeric to a signed numeric and the sign will be automatically 'created'.
besides you are not appending, you are changing the bit configuration of the right hand side of the last byte. |
|
Back to top |
|
|
dates
New User
Joined: 11 Mar 2008 Posts: 9 Location: LA,USA
|
|
|
|
Hi Dick Brenholtz ,
That is a business requirement to add { at the end. I am new to COBOL.s o can u let me know what happens with { appended to a value. Will it change the sign of the value? or do nothing? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Appending a character to a numeric value will not change its value -- but I don't think you're going to achieve the results you want with what you're trying to do. For example, if your ws-price-ip is 001234567890 and you append the '{' to the rear of the field, AND the combined value is then read as a single signed numeric value, the input value of 12345678.90 has become +123456789.00. In other words, if you do what you're saying you want to do, every input numeric value will be multiplied by 10.
You are much better off redefining your output field as S9(11)V99 and just moving the input value to the output value. If you start appending characters or otherwise violating the usual rules of COBOL, you can have all sorts of side effects. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
That is a business requirement to add { at the end. |
Maybe it is or maybe it is a misunderstanding. . .
If you post the requirement (not how you have chosen to meet the perceived requirement) we may be better able to offer suggestions. What does a { have to do with "business"? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
If what you're trying to accomplish is to force a sign on WS-PRICE, do as has been suggested and use PIC S9(11)V99. { will display as the last byte of your output if the number is positive and the last digit of cents is zero. If not, you'll see a different character. Also, I used WS-PRICE as the field name since you've changed the names in succeeding posts. |
|
Back to top |
|
|
|