Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A signed numeric - Legal values question (Ascii)

Status
Not open for further replies.

ekimr

Technical User
Jun 28, 2002
124
GB
Apologies to you guys but I have done a search of Tektips and have searched hard and low to see if this question has been asked but cannot find it - so please do forgive me.

I am only dealing with a fixed Ascii text record.

I want to declare a field Signed numeric.

What are the valid values in the first offset?

If I have a negative value for a S9(6) then -12345 is ok or
012345 0r +12345

BUT if the number is positive - can i also have for example 712345 (ie Can I use the first digit for any number greater than 0 in a signed numeric) ?

Thank you for your advice (and patience!)
 
Hi ekimr,

PIC S9(6) allows for a 6-digit number AND a sign, in other words numbers in the range -999999 to +999999. Depending on the usage (Binary, Packed, Display, etc.) and your compiler options it may actually be possible to hold larger numbers. I don't know the ASCII codes but the sign is hidden within the internal representation of the number. Any literals you use will be converted to the proper internal format by the compiler.

I can't tell you the details of the internal format without knowing the USAGE, but unless you are going to redefine the field and use it in some non-numeric processing, you don't really need to know.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
"Are you reading or writing the fixed ascii file?"

Definitley READING ... and its ASCII

but because the first digit has a 1 in, the software is failing - reporting that the only valid value for offset 1 in a signed numeric field is a 0 or sign.

Its whether this is fact or 'a programmers whim' that limits this first digit.

Mike
 
Sorry, misread the question - ignore my post [wink]

Sounds like validation within the program, rather than Cobol itself, to me But without knowing a bit more it's hard to tell.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
I think that from what you said it would be advisable if you placed the file definition you are using (or Working Storage definition if reading with a "read into variable".
(DO NOT TYPE IT, do a cut and paste please..)




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
This is a common problem when reading ascii files. You will probably need to use a redefines such as this:
02 in-field.
03 in-sign pic x.
03 filler pic x(5).
02 in-signed redefines in-field pic s9(5) leading separate.
02 in-integer redefines in-field pic 9(6).

if in-sign = "-" or "+"
move in-signed to my-field
else move in-integer to my-field.
 
Hi Ekmir,

Before you devise a solution you must be sure of what the field can contain. I'd read and display a few records to verify how a +/- or no-sign field will look coming in.

For example, does +123 print as +123; -123 print as -123 and 123 print as b123 (b being a space) or 0123?

Regards, Jack.
 
Ekimr - I am not flaming you, but, why don't you do some experiments which will test out what will (and will not) work? (and post your results for others, who may be interested in understanding what exactly your original problem was, and the discoveries you made.)
 
Thanks to all who have responded.

Just to clarify my initial mail - we are not in charge of the program - but the ascii file side of things.

Our Ascii file has a field that is defined in the spec. as signed numeric.

I believe that if the number is positive we do not need a + in the first offset, and in the first offset the value can be anything between 0 and 9.

Its our programmer (contractor) who says its not a legal use of the field - even though as many of you have implied it can be worked around.

So I guess I am looking for some sort of 'definitive' statement if there indeed is one on valid presentation of Signed numeric fields.

If indeed the programmer is wrong then he needs to apply a fix free of charge otherwise it costs us!!!

Thanks for the help once again.

 
IF you are supplying the file then the following would be expected of you.

Case 1.
Variable size fields
Delimited file (comma or other separator (; used here))
Edited values file
Possible values
;-123;
;+123;
;123;
;123-;
;123+;
Non edited fields (e.g. a letter replaces the sign according to the standard rules. Following example is using EBCDIC)
;J23;
;A23;
;123;
;12L;
;12C;

Fixed size fields

Delimited file (comma or other separator (; used here))
(fixed size fields files are not normally delimited but can be)
Edited values file
Possible values
;-123;
;+123;
; 123;
;123-;
;123+;
;123 ;
Non edited fields (e.g. a letter replaces the sign according to the standard rules. Following example is using EBCDIC)
;J23;
;A23;
;123;
;12L;
;12C;


If I was the contractor doing the COBOL program and if I was supplied with anything ather then the above I would complain, and ask you to fix the data.

Also note that it is NOT normal to have non-edited fields on a delimited file.

So see what was specified on your technical analysis, and see who is wrong. It is even possible that both of you are wrong.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top