Page 1 of 1

Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 2:09 pm
by harishcv
Hello,

I have a countdown field in my cobol program which counts the number of days left to reach a particular date(always fixed - say X date) from today. Currently, the counter counts till that X date is reached, that is counter = 000 when today = X date; and will remain as 000 eventhough X date is passed.

My requirement is to add negative numbers to counter processing, that is if the X date is passed, then counter shoud display -1, -2 etc. Please advice how cobol stores and process negative numbers. In reading a cobol book, found an option "PIC S9(03) SIGN IS LEADING SEPARATE" to process negative numbers - but not sure how to use this. or if there is a more simple work around.

If anyone came across such scenarios, please help me out.

Thanks,
Harish

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 3:59 pm
by Robert Sample
The requirement is not difficult to meet: add an S to the PICTURE clause of the count variable. COBOL does not require SIGN LEADING SEPARATE for handling signed numbers -- it can deal with them in any USAGE clause.

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 4:49 pm
by harishcv
Thanks Robert.

The file(where counter field is) which I am trying to update using cobol code is used by many REXX routines as well. I couldnt figure out how REXX codes can read negative counter values if we use "S" in the PICTURE clause.

So I was trying to understand if we can populate the counter field as -1, -2 etc or any other format which the REXX routines can also read.

Please let know your thoughts.

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 5:36 pm
by Robert Sample
You posted in the COBOL forum. Your original post did not mention REXX. If you do not bother to completely AND CLEARLY specify the exact problem you are trying to solve, why do you think we can help you? We are not mind readers and cannot guess that you are using something other than COBOL when you post in the COBOL forum.

What is the current definition for the variable being used to pass the count back to REXX?

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 5:44 pm
by harishcv
I guess, I posted the original output I wish to achieve using COBOL program - "that is if the X date is passed, then counter shoud display -1, -2 etc"

And using S in PIC clause we cannot achieve this output. I am sorry if i confused anyone by mentioning REXX. Using cobol can we make the counter output to display like -1, -2 etc....

Note: The rexx routine used is not having any variable definition. I am just parsing the counter value to a variable.

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 6:16 pm
by Robert Sample
Here is a link to the IBM COBOL library (which you should have had bookmarked a LONG, LONG time ago): http://www-01.ibm.com/software/awdtools/cobol/zos/library/

Find the COBOL Language Reference guide and read up on numeric edited variables (hint: the flashlight is the search function). You will be able to generate whatever format of display data you care to with a numeric edited variable.

It is not clear from your posts whether or not you have any idea about what you want to achieve. If you have a question about how REXX can handle a particular format, I recommend a post in the REXX forum.

Re: Count down field to count negative numbers

PostPosted: Wed Dec 29, 2010 6:30 pm
by harishcv
Thank you very much!

Re: Count down field to count negative numbers

PostPosted: Thu Dec 30, 2010 3:45 pm
by harishcv
Finally, achieved my result using " SIGN IS LEADING SEPARATE " logic. Had to define counter variables and all work counter variables as " SIGN IS LEADING SEPARATE ".

Got the counter output in desired format, that is with +/- sign before them.

-068 -054 -034 -006
+001 +015 +029 +050
+028 +042 +050 +063

Thanks a lot for support guyz.