Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem with appending { to a numeric variable.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Problem with appending { to a numeric variable.
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: 6968
Location: porcelain throne

PostPosted: Tue Jan 06, 2009 3:30 pm    Post subject:
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    Post subject:
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: 92
Location: Hyderabad

PostPosted: Tue Jan 06, 2009 4:34 pm    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Tue Jan 06, 2009 4:36 pm    Post subject:
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    Post subject:
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: 8121
Location: East Dubuque, Illinois, USA

PostPosted: Tue Jan 06, 2009 5:11 pm    Post subject:
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

Site Director


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

PostPosted: Tue Jan 06, 2009 10:18 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us