Page 1 of 2

Moving no value to Numeric

PostPosted: Mon Nov 11, 2013 2:32 pm
by pulsar22
Hi,

How can we move no value to a numeric field i.e. if we display it....nothing shud be displayed.....not even zero.

Re: Moving no value to Numeric

PostPosted: Mon Nov 11, 2013 3:38 pm
by NicC
What have you tried? Have you referred to the manuals? If not then I suggest you take a look at "Numeric-edited items" amongst other sections.

Re: Moving no value to Numeric

PostPosted: Mon Nov 11, 2013 4:29 pm
by BillyBoyo
Specifically BLANK WHEN ZERO.

Re: Moving no value to Numeric

PostPosted: Mon Nov 11, 2013 5:51 pm
by Robert Sample
Or use a PIC of all Z instead of 9. Either this or BLANK WHEN ZERO will work -- but which method to use depends upon your specific requirements.

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 11:55 am
by pulsar22
Thanks for the replies....but i guess i failed to mentined the requirement properly.

It is an S9(4) Usage Comp variable, used as host variable. The requirement is that it should not have zero. I have tried redefining it to X(4), but it didn't help.

Redefines works with normal 9(4) but can't use 9(4) as a host variable.

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 12:12 pm
by pulsar22
also PIC of Z and Blank when zero can't be used with COMP

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 12:52 pm
by BillyBoyo
Yes, we do know that.

Why don't you show the code you have so far, tell use what the source data can be, what you want for the output, and what you get at the moment?

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 1:28 pm
by pulsar22
It is variable of a SP return cursor. The applications calling this Sp do not reside on Mainframe.

If the calling application gets any value in this field (even zero), they call some other application passing this value, but since zero is not a valid value this call is an overhead on system. They want me to return this field as null.

Things i have tried:
1) redefined S9(4) comp to z(4) and then moved zero to z(4) variable.
2) redefined s9(4) comp to 9(4) blank when zero.
3) redefined s9(4) comp to X(4) and then moved spaces/low-values. S9(4) variable still has zeroes.

So the value of this

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 5:05 pm
by Robert Sample
What value do you want the PIC S9(04) COMP variable to have? You ARE aware, I hope, that a PIC S9(04) COMP variable will ALWAYS have a value? COMP means that every value in the collating sequence represents a valid numeric value -- if you move two spaces to that variable, the X'4040' represents a value of 16448.

So your original post has been answered -- what you wanted to do (have a numeric variable not display anything when no value is assigned) has been answered. You might not like the answer (that what you want to do is not possible), but unfortunately sometimes NOT POSSIBLE is a valid answer.

Re: Moving no value to Numeric

PostPosted: Tue Nov 12, 2013 7:08 pm
by BillyBoyo
Yes, the only way for a field to itself have no value at all is for it not to be a field. We don't have "undef"ined fields in COBOL. If it is defined, it has a value (the value it has can itself be "undefined" as to what the value is, but it will still have a value). If you want to indicate different behaviour to the caller in different circumstances, you have to agree on a value to be set. If all values are already valid for the field in the business case, then you need a new field to use as a "flag".