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
 

 

Query regading the cobol editing charecter.

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

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Fri Jun 12, 2009 5:13 pm    Post subject: Query regading the cobol editing charecter.
Reply with quote

Hi,

I want the leading sign for the vaiable A along with $ sign.

i have declared vaiable as below .
A PIC -$Z,ZZZ,ZZZ,ZZZ,ZZ9.99.

But value for this vaiable i am getting after excecution is
Code:
-$              962.33
. i want the value like this -$962.33.

How to achive this in cobol?

Thanks,
Amol
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Fri Jun 12, 2009 5:52 pm    Post subject:
Reply with quote

What did you read in the manual?

Hint: there are three floating insertion symbols for COBOL PICTURE clauses -- currency symbol, +, and -. You can use only one of them as a floating symbol. So how could you get the other floating symbol in the right place?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 12, 2009 6:00 pm    Post subject:
Reply with quote

Amol,
why can't you use a trailing sign?
that could be implemented by changing the edit-mask.

otherwise, you are forced to find the position prior to the '$' and refmod to it.

and, in todays ecomomy, 13 to the left of the decimal isn't very big.
Back to top
View user's profile Send private message
Amsar

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Fri Jun 12, 2009 6:24 pm    Post subject:
Reply with quote

Hi Dick,

This variable i am writing in Excel in HTML format but because of trailing sign value of variable is written as left justified to the column.

Quote:
otherwise, you are forced to find the position prior to the '$' and refmod to it.


I have not undustood your 2 point. Could you be more clear?

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

Global Moderator


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

PostPosted: Fri Jun 12, 2009 6:39 pm    Post subject:
Reply with quote

Look up reference modification in the COBOL Language Reference manual, the link to which is at the top of the page.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 12, 2009 6:48 pm    Post subject:
Reply with quote

After determining the character position of the '$' within your edit-mask (pos-of-dollar-sign)
(you will have to redefine your edit-mask as PIC x(22))
and then use reference modification to move the sign (1st char of edit mask) to position before the '$')
MOVE EDIT-MASK-REDEFINED(1:1) TO EDIT-MASK-REDEFINED(POS-OF-DOLLAR-SIGN - 1:1)
and then MOVE SPACE TO EDIT-MASK-REDEFINED(1:1)
Reference Modification examples
Back to top
View user's profile Send private message
Amsar

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Fri Jun 12, 2009 7:19 pm    Post subject:
Reply with quote

Thanks Dick this is a Good Idea!!! icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jun 12, 2009 9:12 pm    Post subject:
Reply with quote

Amsar,

you realize your contents will be right justified:
Code:

1234+678901234+       <<<char position within variable
       -$999.99

or do you want it

1234+678901234+       <<<char position within variable
-$999.99

Back to top
View user's profile Send private message
Amsar

New User


Joined: 26 Sep 2008
Posts: 84
Location: Chennai

PostPosted: Fri Jun 12, 2009 10:16 pm    Post subject:
Reply with quote

Dick,

I want it like this.

Code:
1234+678901234+       <<<char position within variable
-$999.99
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Jun 13, 2009 12:50 am    Post subject:
Reply with quote

one way to do it:
Code:

you will need to populate the following variables:

ws-len-of-edit-mask pic s9(4) binary <<< with length of edit mask
ws-len-of-move   pic s9(4) binary    <<< calculated, see below
ws-pos-of-dol-sign pic s9(4) binary  <<< calculated, a little chore for you Amsar
ws-sub-1   pic s9(4) binary.
ws-sub-2   pic s9(4) binary.

AFTER MOVE OF AMOUNT FIELD TO EDIT MASK:

compute ws-pos-of-dol-sign = Amsar super code end-compute
compute ws-len-of-move = ws-len-of-edit-mask - ws-pos-of-dol-sign + 1 end-compute
compute ws-sub-1 = 2 end-compute
compute ws-sub-2 = ws-len-of-move end-compute
move edit-mask-redef(ws-pos-of-dol-sign:ws-sub-2) to edit-mask-redef(ws-sub-1:ws-sub-2)

compute ws-sub-1 = ws-len-of-move + 2 end-compute
compute ws-sub-2 = ws-len-of-edit-mask - ws-sub-1 + 1 end-compute
move spaces to edit-mask-redef(ws-sub-1:ws-sub-2)



you could of course use literals where ws-sub-1 or ws-sub-2 has been previously set to a literal,
or where ws-sub-1 or ws-sub-2 has been set to one of the calculated variables.

AND OF COURSE: This has not been tested..........
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Oct 14, 2009 4:01 pm    Post subject: Leading spaces suppression
Reply with quote

Hi

Just like Z is used for leading zero suppression , what should eb used for leading space suppression.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Oct 14, 2009 5:29 pm    Post subject:
Reply with quote

Ambili S,

tagging a new question to an old topic is not very wise, especially since the old was apples and yours is oranges.
you should start your own topic.

and when you do create a new topic, add to your question a fuller explanation of what you mean.

Space suppression?
numeric edit masks replace leading zeroes with spaces.

what would you have replace the spaces?

do you mean left-justified?
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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