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
 

 

Replacing leading zeroes from signed numeric field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kishpra

New User


Joined: 24 May 2010
Posts: 87
Location: Pune

PostPosted: Thu Oct 03, 2013 4:25 pm    Post subject: Replacing leading zeroes from signed numeric field
Reply with quote

Hi,

I have a variable defined as -

05 A PIC -9(09).99.

it is taking the values from databse as -

000000100.00
-000000015.25
000060000.00

Now I want the output in the field as -

100.00
-15.25
600.00


Please assist.
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1747
Location: Bloomington, IL

PostPosted: Thu Oct 03, 2013 4:34 pm    Post subject:
Reply with quote

Define a variable with a floating sign, and MOVE A to that variable.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7273

PostPosted: Thu Oct 03, 2013 4:41 pm    Post subject: Reply to: Replacing leading zeroes from signed numeric field
Reply with quote

And if you want it left-justified, use UNSTRING ... DELIMITED BY ALL SPACE INTO a-rubbish-field the-field-you-want.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 87
Location: Pune

PostPosted: Thu Oct 03, 2013 5:00 pm    Post subject: Reply to: Replacing leading zeroes from signed numeric field
Reply with quote

Please give an example
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1747
Location: Bloomington, IL

PostPosted: Thu Oct 03, 2013 5:06 pm    Post subject:
Reply with quote

Floating insertion editing.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 87
Location: Pune

PostPosted: Thu Oct 03, 2013 5:12 pm    Post subject: Reply to: Replacing leading zeroes from signed numeric field
Reply with quote

I defined the variable as PIC +++++++9999.99.

and the output i got is -

+0100.00
-0015.25
+60000.00

But i need the output as -

100.00
-15.25
60000.00

Please assist.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7273

PostPosted: Thu Oct 03, 2013 5:20 pm    Post subject: Reply to: Replacing leading zeroes from signed numeric field
Reply with quote

Use - instead of plus.

Decide what you want for zero, for numbers less than one, Define an apporpriate number of -s, like PIC -(9)9.99 - who knows? You do.

Read my previous post.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Fri Oct 11, 2013 10:48 pm    Post subject:
Reply with quote

Try the below code
Code:
05 A PIC -9(09).99.
05 B PIC -(09)9.99.
05 B-X  REDEFINES B PIC X(13).
05 C PIC X(13).
05 D PIC X(13).

MOVE A TO B
UNSTRING B-X
  DELIMITED BY ALL ' '
  INTO C D
END-UNSTRING
DISPLAY D

Variable D has what you want
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 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 37 Tue Dec 06, 2016 8:04 pm


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