Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Finding spaces in numeric elementary item in a group variabl

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Thu Oct 15, 2009 9:28 pm    Post subject: Finding spaces in numeric elementary item in a group variabl
Reply with quote

Hi
In a group varibale, how I can find that any elementary numeric data type is having spaces without checking individually all the elementary numeric data types for IS NUMERIC etc.

say in a DCLGEN I have moved a record from a file. After move Numeric data item got spaces in it. How I can replace those spaces to zeros.

for e.g
Code:
EXEC SQL DECLARE TJAEUNDERREFSTRUCT TABLE                 
( INSTRUMENTID                   CHAR(24) NOT NULL,       
  UNDERBASKETNO                  DECIMAL(12, 0) NOT NULL,
  UNDERREFSTRUCTNO               DECIMAL(12, 0) NOT NULL,
  UNDERCOMPONENTNO               DECIMAL(12, 0) NOT NULL,
  PROVIDER1ID                    CHAR(30) NOT NULL,       
  PROVIDER2ID                    CHAR(30) NOT NULL,       
  PROVIDER3ID                    CHAR(30) NOT NULL,       
  CREATETIMESTAMP                TIMESTAMP NOT NULL,     
  UPDATETIMESTAMP                TIMESTAMP NOT NULL,     
  UPDATETIMESTAMPFI              TIMESTAMP NOT NULL,     
  MANDATOR_ID                    CHAR(3) NOT NULL,       
  PART_CRIT                      CHAR(4) NOT NULL         
) END-EXEC.                                               


is table defination.

I make a move from file to dclgen
Code:
MOVE C0499-DCL-RECORD  TO DCLTJAEUNDERREFSTRUCT 

but decimal field got spaces in it.
How I can make these spaces as zeros without checking each elemenatry item.

I hope I am able to state the issue clearly.

Regards
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Oct 15, 2009 9:41 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

A space (X'40') could very well be a valid byte (except for the last byte) in a packed-decimal field. But it would be invalid in a display-numeric field.

Bill
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Thu Oct 15, 2009 9:50 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

thanks for the prompt reply , Bill,

Quote:
A space (X'40') could very well be a valid byte (except for the last byte) in a packed-decimal field.


Do you mean to say DB2 can store space in decimal field ?
My requirement is that i do not want space in decimal field, but a zero.

regards
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Oct 15, 2009 10:06 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

OK, let's say you have a 2-Byte packed-decimal field and it contains PL2'400' (X'400C'). So, you have a X'40' in the first-byte, which is legitimate, but it would be in error if it was in the second-byte.

Are you defining "decimal" as packed-decimal or display-numeric (a/k/a zoned-decimal) or both?

If you have a display-numeric field, such as PIC 9(02), with a value of X'40F1', then this would be invalid, because a X'40' in this type of definition (regardless of the byte-location) is invalid.

However, as strange as this may sound, if this value were to be packed, the result would be PL2'001' (either X'001C' or X'001F'), because a PACK instruction discards the zone-portion of each byte, except for the last-byte.

This is also true if the display-numeric field contains x'4040' as it would pack as PL2'000', but will most likely be resolved (by the compiler) to an 'F' sign-nibble.

Bill
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 16, 2009 1:27 am    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

Hi Bill
I am having the decimal field as packed decimal.

regards
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 16, 2009 2:30 am    Post subject:
Reply with quote

tomehta,

if your input is garbage you need to validate each field.
if you send garbage to DB2, DB2 will return an error.

and a db2 decimal field is BINARY.
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 16, 2009 2:38 am    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

Hi DBZ
Input is not garbage, but is always spaces for comp-3.

Is there a way I can change these spaces to 0000 without validating each elementary field ?

Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 16, 2009 2:46 am    Post subject:
Reply with quote

Quote:
Input is not garbage, but is always spaces for comp-3.


that is a very good example of clausal oxymoron.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Oct 16, 2009 3:32 am    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

If you're referring to packed-decimal, then finding a X'40' in any byte of the field, except the last-byte (that would be an error), is certainly possible and legitimate.

Example -

Code:

03  WS-PACKED PIC S9(07) PACKED-DECIMAL.

MOVE 4040400 TO WS-PACKED.

Internally, in WS-PACKED, you'll find X'4040400C', with bytes 1-3 equal to X'404040' (SPACES), but are treated as just another number.

If you divide WS-PACKED by 10, your internal result will be X'0404040C', with the previous X'40' byte-values now equal to X'04'.

Bill
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Oct 16, 2009 5:51 am    Post subject:
Reply with quote

Quote:
I make a move from file to dclgen
Code:
MOVE C0499-DCL-RECORD TO DCLTJAEUNDERREFSTRUCT

but decimal field got spaces in it.
How I can make these spaces as zeros without checking each elemenatry item.



Ignore all the exotic BS so far. Are to fields in C0499-DCL-RECORD defined the the same as the fields in DCLTJAEUNDERREFSTRUCT with the same usage in both definitions in both layouts. A group move is a character move in cobol and will not convert data from display to packed format. This an elementary beginners error in COBOL.

DECIMAL items in DB2 are stored in binary only to the extent that all data on a mainframe is stored in binary, decimal items are stored as packed decimal.

Yes you should always check NUMERIC fields to ensure that they are NUMERIC before using them or adding them to you own system. Anyone that accepts data from an outside souce without editting it is just asking for trouble.
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 16, 2009 8:07 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

For packed I can check for NUMERIC class test, but what I can test for the BINARY data type, SMALLINT of DB2 maps to BINARY in cobol, what data type class test I can run for binary ?
Thanks all for your help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Oct 16, 2009 8:09 pm    Post subject:
Reply with quote

A binary field in COBOL is numeric -- always. You cannot do a NUMERIC test on a COMP (binary) field for this reason.
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 16, 2009 8:55 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

but say by mistake the input file had spaces for the comp field , which is a invalid value, but system will take it as valid value. ( binary equivalent of space).
How to handle this condition that the input value for comp field is valid numeric field ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 16, 2009 8:58 pm    Post subject:
Reply with quote

Hello,

Validate the input field. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Oct 16, 2009 9:14 pm    Post subject:
Reply with quote

Quote:
but say by mistake the input file had spaces for the comp field , which is a invalid value, but system will take it as valid value. ( binary equivalent of space).
How to handle this condition that the input value for comp field is valid numeric field ?
You do not understand. There is no such thing as an invalid value in a COMP (binary) field. If you think the variable cannot have spaces in it, you will have to compare the variable to x'40404040' and do something if the values are equal -- because x'40404040' is a perfectly valid numeric value of 1,077,952,576 -- and the COMP field will show up as having that value.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 16, 2009 9:23 pm    Post subject:
Reply with quote

Hello,

Redefine this field as pic x(4) and compare to spaces (or x'40404040'). . .

It is not difficult, but it is not automatic - you have to do a bit of work.
Back to top
View user's profile Send private message
tomehta

New User


Joined: 18 Aug 2008
Posts: 98
Location: India

PostPosted: Fri Oct 16, 2009 9:49 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

thanks Robert , Dick , Bill ....i got the point, bit late but point well taken... icon_smile.gif icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 16, 2009 10:05 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

You're welcome - good luck icon_smile.gif

Someone will be here if there are other questions later.

d
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Sun Oct 18, 2009 9:33 pm    Post subject: Reply to: Finding spaces in numeric elementary item in a gro
Reply with quote

Here is another way to look at the problem:

Your DCL contains both CHAR and DECIMAL fields.
If you consider your fields as a group, you won't be able to tell if the space you find belongs to a CHAR field (legal space) or a DECIMAL field (maybe illegal).
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us