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

Query regading the cobol editing charecter.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 12, 2009 5:52 pm
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: 6966
Location: porcelain throne

PostPosted: Fri Jun 12, 2009 6:00 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 12, 2009 6:39 pm
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: 6966
Location: porcelain throne

PostPosted: Fri Jun 12, 2009 6:48 pm
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
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: 6966
Location: porcelain throne

PostPosted: Fri Jun 12, 2009 9:12 pm
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
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: 6966
Location: porcelain throne

PostPosted: Sat Jun 13, 2009 12:50 am
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
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: 6966
Location: porcelain throne

PostPosted: Wed Oct 14, 2009 5:29 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top