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
 

 

How to remove space in edited picture clause

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

New User


Joined: 05 Dec 2007
Posts: 82
Location: chennai

PostPosted: Wed Nov 05, 2008 4:17 pm    Post subject: How to remove space in edited picture clause
Reply with quote

hi,
I have a variable declared as
01 WS-VAR1 PIC -$$$,$$$,$$9.99. (15 characters)

if i move 1.25 to this variable, it is dispayed as
-(9 spaces)$1.25

I want to remove the space between - and $ for all values.
I dont want to have - at the end.
Please comment.
Back to top
View user's profile Send private message

Harsh Saxena

New User


Joined: 10 Jul 2007
Posts: 2
Location: Pune

PostPosted: Wed Nov 05, 2008 6:07 pm    Post subject: Reply to: How to remove space in edited picture clause
Reply with quote

move the variable WS-VAR1 to a temp variable of same size

Eg : WS-VAR2 pic x(15)

Unstring WS-VAR2 delimited by all spaces into WS-TEMP1, WS-TEMP2.

Now WS-TEMP1 carries all the spaces and WS-TEMP2 carries the actual data.

Move WS-TEMP2 TO WS-FINAL(being WS-
FINAL a destination field).
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8124
Location: East Dubuque, Illinois, USA

PostPosted: Wed Nov 05, 2008 6:15 pm    Post subject:
Reply with quote

In COBOL, the $ and the - can be floating insertion characters. However, they both cannot be floating insertion characters in the same PICTURE clause. Use PIC $$$$,$$$,$$9.99 and then use reference modification to insert the minus sign where you want it.
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: Wed Nov 05, 2008 9:05 pm    Post subject:
Reply with quote

Hello,

If you are willing to show the minus (-) on the right, this will do what you want:

Code:
       01  SOME-MONEY        PIC $$,$$$,$$$.99-.

           MOVE -1236.88 TO SOME-MONEY.   
           DISPLAY SOME-MONEY.   

Output:
Code:
   $1,236.88-
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: Thu Nov 06, 2008 11:21 am    Post subject:
Reply with quote

Dick's example is usually the preferred method of displaying a signed currency amount. Is it a business requirement to "not show the - at the end"?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Nov 07, 2008 3:22 pm    Post subject:
Reply with quote

For this you need bit of coding icon_sad.gif
Code:

01 RECVAR2 PIC -$$$,$$$,$$9.99.
01 alnum redefines recvar2.   
   02 sgn pic x.               
   02 numbr pic x(14).         
.
.
.
inspect  numbr tallying cnt for leading spaces.
compute strcnt = cnt + 1.                     
compute strend = 14 - cnt.                     
display sgn numbr(strcnt:strend).             
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Nov 07, 2008 4:14 pm    Post subject:
Reply with quote

Working-Storage
Code:

05  EDIT-MASK               PIC -$$$,$$$,$$9.99.
05  WS-SUB-1                PIC S9(4) COMP.
05  LEN-OF-EDIT-MASK        PIC S9(4) COMP.


Procedure
Code:

MOVE LENGTH OF EDIT-MASK  TO LEN-OF-EDIT-MASK
MOVE -12.34               TO EDIT-MASK

PERFORM VARYING WS-SUB-1
           FROM 2
             BY 1
          UNTIL WS-SUB-1 > LEN-OF-EDIT-MASK
             OR EDIT-MASK(WS-SUB-1:1) > SPACE
END-PERFORM

DISPLAY ':'  EDIT-MASK  ':'

MOVE EDIT-MASK(1:1)  TO EDIT-MASK(WS-SUB-1 - 1:1)

DISPLAY ':'  EDIT-MASK  ':'

MOVE SPACE           TO EDIT-MASK(1:1)

DISPLAY ':'  EDIT-MASK  ':'



OUTPUT:
Code:

:-        $12.34:
:-       -$12.34:
:        -$12.34:
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 VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am
This topic is locked: you cannot edit posts or make replies. Need help in estimating space of unlo... ashek15 IMS DB/DC 12 Fri Apr 07, 2017 5:11 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Need inputs on Space requirement and... ashek15 IMS DB/DC 0 Sat Apr 01, 2017 8:26 am
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm


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