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

Problem with appending { to a numeric variable.


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

New User


Joined: 11 Mar 2008
Posts: 9
Location: LA,USA

PostPosted: Tue Jan 06, 2009 3:19 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 06, 2009 3:30 pm
Reply with quote

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

New User


Joined: 11 Mar 2008
Posts: 9
Location: LA,USA

PostPosted: Tue Jan 06, 2009 3:56 pm
Reply with quote

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

New User


Joined: 04 Jul 2007
Posts: 91
Location: Hyderabad

PostPosted: Tue Jan 06, 2009 4:34 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jan 06, 2009 4:36 pm
Reply with quote

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

New User


Joined: 11 Mar 2008
Posts: 9
Location: LA,USA

PostPosted: Tue Jan 06, 2009 4:43 pm
Reply with quote

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

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jan 06, 2009 5:11 pm
Reply with quote

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

Moderator Emeritus


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

PostPosted: Tue Jan 06, 2009 10:18 pm
Reply with quote

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

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Jan 07, 2009 11:59 am
Reply with quote

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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top