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
 

 

Why TALLYING field increments when there is no matching char

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

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 22, 2009 11:36 pm    Post subject: Why TALLYING field increments when there is no matching char
Reply with quote

Hi,

I am declaring 2 varibles

01 W-TIME-3 PIC X(8).
01 W-TALLY-1 PIC 9.
w-time-3 may contains values 31:40:8 ---> beore 3 there is one space.
or it may conain 10:00:53

iam Inspecting the w-time-3 for leading space.

INSPECT W-TIME-3 TTALLYING W-TALLY-1 FOR LEADING SPACE.

if the W-TIME-3 contains 31:40:8 the W-TALLY-1=1 but
for W-TIME-3 contains 10:00:53 the W-TALLY-1=1

i am not getting why W-TALLY-1 is also 1 for 2nd one even there is no leading space.

Could any one help on this.

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

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jan 22, 2009 11:45 pm    Post subject:
Reply with quote

From the COBOL Language Reference:
Quote:
identifier-2
Is the count field, and must be an elementary integer item defined without the symbol P in its PICTURE character-string.

Identifier-2 cannot be an external floating-point item.

You must initialize identifier-2 before execution of the INSPECT statement begins.
so where do you initialize W-TALLY-1 before each inspect statement?
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Thu Jan 22, 2009 11:56 pm    Post subject: Reply to: Why TALLYING field increments when there is no mat
Reply with quote

Hi,

I have initialized the W-TALLY-1 before the inspect statement as

01 W-TALLY-1 PIC 9 VALUE ZERO.

Regards
suneel
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 Jan 23, 2009 12:08 am    Post subject:
Reply with quote

Are you initializing w-tally-1 before the second inspect?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jan 23, 2009 12:08 am    Post subject:
Reply with quote

Are you doing the two INSPECT statements in two separate program runs, or is there one program run with execution of both INSPECT statements? If the second, you need to move zero back to W-TALLY-1 before the second INSPECT statement.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 23, 2009 12:15 am    Post subject: Reply to: Why TALLYING field increments when there is no mat
Reply with quote

hi,

I am using one Inspect staement in one program by reading each record in the sequential file till end.

if there is any record which has leading space for the w-time-3,i am doing some operation on the particular record

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

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Fri Jan 23, 2009 12:29 am    Post subject:
Reply with quote

You need to move zero to W-TALLY-1 before each time the inspect statement is executed.
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 Jan 23, 2009 12:36 am    Post subject:
Reply with quote

Hello,

Quote:
I have initialized the W-TALLY-1 before the inspect statement as
01 W-TALLY-1 PIC 9 VALUE ZERO.
This provides an initial value at program execution, but not "before the inspect statement". As mentioned above, you need to reset tally every time thru the code.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Jan 23, 2009 12:39 am    Post subject:
Reply with quote

Quote:

i am not getting why W-TALLY-1 is also 1 for 2nd one even there is no leading space.
Because you failed to move zero to W-TALLY-1, and there were no leading spaces in the second field, W-TALLY-1 retained its initialized value. What is the initialized value? The value of 1 you set the variable to the LAST time through the code. Without clearing the value each time, the next INSPECT statement will start with the value from the last INSPECT statement.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Fri Jan 23, 2009 12:48 am    Post subject: Reply to: Why TALLYING field increments when there is no mat
Reply with quote

Hi,

i have initialized the w-tally-1 each time before executing the INSPECT statement.

Its working fine.

Thanks for all your help.

Regards
Suneel
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 Jan 23, 2009 8:46 am    Post subject: Re: Why TALLYING field increments when there is no matching
Reply with quote

Why don't you use the TALLY Special Register and initialize it every time to ZERO. It's implicitly defined as PIC 9(05) COMP.

A one-byte display-numeric Tally field certainly has its limitations, especially if the target-field length exceeds 9-Bytes.

You won't know the true value because overflow may have occurred. icon_redface.gif

Just use the TALLY Special Register and you'll save yourself much grief. icon_wink.gif

Regards,

Bill
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 READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am


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