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

Active User


Joined: 31 Oct 2006
Posts: 131
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: 3051
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top