Moving no value to Numeric



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Moving no value to Numeric

Postby pulsar22 » Mon Nov 11, 2013 2:32 pm

Hi,

How can we move no value to a numeric field i.e. if we display it....nothing shud be displayed.....not even zero.
pulsar22
 
Posts: 34
Joined: Mon Sep 09, 2013 12:39 pm
Has thanked: 14 times
Been thanked: 0 time

Re: Moving no value to Numeric

Postby NicC » Mon Nov 11, 2013 3:38 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Moving no value to Numeric

Postby BillyBoyo » Mon Nov 11, 2013 4:29 pm

Specifically BLANK WHEN ZERO.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Moving no value to Numeric

Postby Robert Sample » Mon Nov 11, 2013 5:51 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Moving no value to Numeric

Postby pulsar22 » Tue Nov 12, 2013 11:55 am

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.
pulsar22
 
Posts: 34
Joined: Mon Sep 09, 2013 12:39 pm
Has thanked: 14 times
Been thanked: 0 time

Re: Moving no value to Numeric

Postby pulsar22 » Tue Nov 12, 2013 12:12 pm

also PIC of Z and Blank when zero can't be used with COMP
pulsar22
 
Posts: 34
Joined: Mon Sep 09, 2013 12:39 pm
Has thanked: 14 times
Been thanked: 0 time

Re: Moving no value to Numeric

Postby BillyBoyo » Tue Nov 12, 2013 12:52 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Moving no value to Numeric

Postby pulsar22 » Tue Nov 12, 2013 1:28 pm

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
pulsar22
 
Posts: 34
Joined: Mon Sep 09, 2013 12:39 pm
Has thanked: 14 times
Been thanked: 0 time

Re: Moving no value to Numeric

Postby Robert Sample » Tue Nov 12, 2013 5:05 pm

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.

These users thanked the author Robert Sample for the post:
pulsar22 (Wed Nov 13, 2013 4:23 pm)
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Moving no value to Numeric

Postby BillyBoyo » Tue Nov 12, 2013 7:08 pm

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".

These users thanked the author BillyBoyo for the post:
pulsar22 (Wed Nov 13, 2013 4:23 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post