View previous topic :: View next topic
|
Author |
Message |
Amsar
New User
Joined: 26 Sep 2008 Posts: 84 Location: Chennai
|
|
|
|
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
. i want the value like this -$962.33.
How to achive this in cobol?
Thanks,
Amol |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Amsar
New User
Joined: 26 Sep 2008 Posts: 84 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Look up reference modification in the COBOL Language Reference manual, the link to which is at the top of the page. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Amsar
New User
Joined: 26 Sep 2008 Posts: 84 Location: Chennai
|
|
|
|
Thanks Dick this is a Good Idea!!! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Amsar
New User
Joined: 26 Sep 2008 Posts: 84 Location: Chennai
|
|
|
|
Dick,
I want it like this.
Code: |
1234+678901234+ <<<char position within variable
-$999.99 |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India
|
|
|
|
Hi
Just like Z is used for leading zero suppression , what should eb used for leading space suppression. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
|