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
 

 

Editing Picture clause in Cobol

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

New User


Joined: 08 Oct 2008
Posts: 6
Location: Pune

PostPosted: Thu Oct 16, 2008 12:11 pm    Post subject: Editing Picture clause in Cobol
Reply with quote

Hi Friends,

I Have one variable in cobol declared as

01 var1 pic S9(15)V99 comp-3

I want to declare this variable as displyable with supressing zeros and with $ symbol.

How many Z's I need to give???
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: Thu Oct 16, 2008 1:23 pm    Post subject:
Reply with quote

Hello,

At the top of the page is a link to "IBM Manuals". Among the manuals is the Enterprise COBOL Language Reference. This is from that manual:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3lr10/5.3.11.9.1?

You will do yourself a very large favor if you become both familiar and comfortable with those manuals. . .
Back to top
View user's profile Send private message
kalyan.v

New User


Joined: 04 Feb 2008
Posts: 65
Location: Hyd

PostPosted: Wed Dec 31, 2008 12:52 pm    Post subject:
Reply with quote

Hi,

I have a doubt similar to this topic.
I have pic clause like below.

05 RPT-PAYMENT PIC -$$$,$$$,$$$.99.
Code:

When i move -123.45 to above variable gives : -       $123.45

I need the output should be like below.

Rpt-payment : -$123.45

What changes i have to do??

Thanks,
Kalyan.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7993
Location: Bellevue, IA

PostPosted: Wed Dec 31, 2008 5:19 pm    Post subject:
Reply with quote

Numeric values are justified to the decimal point, so given the PIC you cannot generate the desired output automatically. You will have to move your number to the variable, then scan the variable using reference modification moving characters to the output field one at a time as required.
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 Dec 31, 2008 9:00 pm    Post subject:
Reply with quote

It would be a lot easier if the acceptable format resulted in $123.45-
Back to top
View user's profile Send private message
kalyan.v

New User


Joined: 04 Feb 2008
Posts: 65
Location: Hyd

PostPosted: Fri Jan 02, 2009 11:27 am    Post subject:
Reply with quote

Hi Terry and Robert.

I need the resulted format should be like -$123.45.
i am using it to generate a report.

Robert, i am not apply this logic one time.So your logic cann't be applicable here,i think.

Please let me know any alternate.

Thanks,
Kalyan
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7993
Location: Bellevue, IA

PostPosted: Fri Jan 02, 2009 4:13 pm    Post subject:
Reply with quote

Numeric editing aligns to the decimal point. If your data field is
Code:
05 RPT-PAYMENT PIC -$$$,$$$,$$$.99.
and you move -123.45 to that field, you're moving 7 characters into a 15-character field. You will have 8 spaces in that field, and they will be somewhere on the left of the number due to alignment. If you cannot use reference modification to change the output field, you must learn to live with the result you posted. There is no way in COBOL to dynamically left-justify a numeric edited field based on the size of the value you moved to it.
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: Fri Jan 02, 2009 8:25 pm    Post subject: Reply to: Editing Picture clause in Cobol
Reply with quote

As Dick suggested: Check the Language Reference Manual.
As Robert has stated: COBOL picture clause will not get you what you want.
If you insist on placing the negative sign to the left of the result, I'd use
Code:
01  RPT-PAYMENT  PIC $(16).99
then use either INSPECT and reference modification or loop through the result planting the sign to the left of the $.
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: Sat Jan 03, 2009 9:35 am    Post subject:
Reply with quote

Hello,

Quote:
I need the resulted format should be like -$123.45.
This is not a standard "solution" for this requirement. Who is to receive this output? Who determined the format? The minus sign is most often presented on the right side of the amount as:

Code:

    $123.45
     $99.00-
     $98.00
    $234.88-


This format provides better overall readability as well as allows the negative amounts to "stand out".

All of the business users i have ever worked with insist on this format (even if some do not want the $ shown).
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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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