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

Map a data element to SPACES if it is 0


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

New User


Joined: 31 Oct 2006
Posts: 91
Location: brisbane

PostPosted: Tue Sep 08, 2020 9:40 am
Reply with quote

I have a requirment to map a data element to SPACES if it is 0, else show two decimal places of precision.

eg,
0 => SPACES
1.5 => 1.50
.15 => 0.15

so with WS-temp as PIC Z(6)9.99, WS-out as PIC X(10) I could do something like:

init ws-out to SPACES
if ws-myVar > 0
move ws-myVar to ws-temp
move ws-temp to ws-out
end-if

is there a better / more elegant way of doing this ?
Back to top
View user's profile Send private message
John Del

New User


Joined: 27 Apr 2012
Posts: 42
Location: NY

PostPosted: Tue Sep 08, 2020 12:01 pm
Reply with quote

Editing clause BLANK WHEN ZERO
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2789
Location: NYC,USA

PostPosted: Tue Sep 08, 2020 8:21 pm
Reply with quote

I don't see anything bad with what you are doing. You could do redefine instead of move if you think better icon_smile.gif
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 Adding a header when change data DFSORT/ICETOOL 6
No new posts Selective extract of multi-record-typ... SYNCSORT 4
No new posts Expected data is not coming up on Fir... CICS 2
No new posts Data for newly added fields not displ... IMS DB/DC 6
No new posts COBOL Table data to a flat file with ... COBOL Programming 9
Search our Forums:

Back to Top