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
 

 

Comparing COMP-3 and Invalid decimal
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 3:37 pm    Post subject: Comparing COMP-3 and Invalid decimal
Reply with quote

Hi,

Please throw some light into this.

I have a two fields with following definition
PAYEE-NO PIC 9(10). This is an array variable.
PAYEE-ID-NO PIC 9(10) COMP-3.

Following are the values contained in two fields.
PAYEE-ID-NO (1) = 0000000000
PAYEE-NO = ??????????? INVALID DECIMAL

In normal case the following statement should not be satisfied correct?
WHEN PAYEE-ID-NO = PAYEE-NO (1)

But in my execution this statement is getting satisfied.

Can an invalid decimal value be equal to COMP-3 zeroes.

Please help.

Thanks and Regards,
Abin.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Aug 06, 2007 3:47 pm    Post subject:
Reply with quote

one place you are talking about
Code:

PAYEE-NO              PIC 9(10).              This is an array variable.
PAYEE-ID-NO         PIC 9(10) COMP-3.

another where you are indexing a non-array element
Code:

PAYEE-ID-NO (1) = 0000000000
PAYEE-NO = ??????????? INVALID DECIMAL

and here you are complaining about a WHEN statement with yet 2 new elements.

Code:

WHEN L3001-CHN-PHAR-PAYEE-ID-NO = CHN-PAYEE-NUMBER (1)


much too confusing. now, if you would provide data descriptions and contents of the the variables in the WHEN statement, maybe we could help.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 4:41 pm    Post subject:
Reply with quote

sorry for the confusion.

The when is in a search table statement.

SEARCH PROCESS-INFO VARYING P-ID
AT END
MOVE 1 TO WS-TBL-FOUND-IND
WHEN PAYEE-ID-NO
= PAYEE-NO (P-ID)


The table definition is as follows.

01 PROCESS-TABLE.
05 PROCESS-INFO
OCCURS 1 TO 500 TIMES
OCCURS 1 TO 1000 TIMES
DEPENDING ON WS-NUMBER-OF-TIMES
INDEXED BY P-ID.
10 PAYEE-NO PIC 9(10).
10 PAYEE-IND PIC X(01).
10 PAYEE-SUB-ID PIC X(11).
10 PAYEE-ID-QUAL PIC X(02).
10 PAYEE-ID PIC X(10).
10 PAYEE-IND-A PIC X(01).
10 PAYEE-PLB-IND PIC X(01).

Definition of PAYEE-ID-NO is as follows.
PAYEE-ID-NO PIC 9(10) COMP-3.

Values of fields at time of execution of code in question:

P-ID=1
PAYEE-NO (P-ID) = ??????????? (Invalid decimal)
PAYEE-ID-NO = 0000000000

Hope this clears the matter.

Regards,
Abin.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Aug 06, 2007 5:08 pm    Post subject:
Reply with quote

OK, I'll bite, who or what decieded that PAYEE-NO (1) equaled a string of question marks? Or is that meaning unknown value? Who said thea it was "invalid decimal"?

One more thing, what platform is this running on?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Aug 06, 2007 5:12 pm    Post subject: Re: Comparing COMP-3 and Invalid decimal
Reply with quote

oh boy, oh boy, oh boy.


Code:

SEARCH PROCESS-INFO VARYING P-ID
AT END
         MOVE 1 TO WS-TBL-FOUND-IND
WHEN PAYEE-ID-NO = PAYEE-NO (P-ID)


When you have a no find, you are setting WS-TBL-FOUND-IND to 1. What does that mean? To what value is it initially SET? meaning what?
what code follows the WHEN clause to the END-SEARCH?
what code follows the END-SEARCH?
are you initializing P-ID to 1 before you start your search?
is WS-NUMBER-OF-TIMES populated correctly?


is have two occurs clauses 'NEW COBOL'?
Code:

01 PROCESS-TABLE.
    05 PROCESS-INFO
                                OCCURS 1 TO 500 TIMES
                                OCCURS 1 TO 1000 TIMES
                                DEPENDING ON WS-NUMBER-OF-TIMES
                                INDEXED BY P-ID.


I image your problem is the AT END clause.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 5:35 pm    Post subject:
Reply with quote

Hi William,

I used Xpeditor for debugging the code.
What I got is this.
Code:
10 PAYEE-ID-NO      >  0000000000                PACKED
                                      I=1                        OCCURS
10 PAYEE-NO                >  ???????????            INVALID DECIMAL
   P-IDX                           >  1                        INDEX
** END **


When I ran the code using JCL I got the same result. I mean the WHEN satisfies.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Mon Aug 06, 2007 5:43 pm    Post subject:
Reply with quote

You haven't really answered questions asked by dbz, most important about OCCURS clause.
About XPEDITOR,
Try redefining PAYEE-NO with an alphanumeric variable with same number of bytes as PAYEE-NO, may be that will show you the contents.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 5:45 pm    Post subject:
Reply with quote

Hi dbzTHEdinosauer,

I dont think it's the problem with AT END clause, because in my case it does not goes to the AT END clause.

Code that follows from WHEN clause to the END-SEARCH is some MOVE statements, which has no effect on WHEN statement.

Sorry for this, one OCCURS is commented out.

Code:
01 PROCESS-TABLE.
    05 PROCESS-INFO
                                OCCURS 1 TO 1000 TIMES
                                DEPENDING ON WS-NUMBER-OF-TIMES
                                INDEXED BY P-ID.
.

P-ID is initilized to 1 before statrting the search.

WS-NUMBER-OF-TIMES will be populated with the exact number of entries in the table.

Regards,
Abin.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 5:52 pm    Post subject:
Reply with quote

Hi agkshirsagar,

The first entry in the table has some undefined value LOW-VALUE or HIGH-VALUE. Whatever, it is a value that should not be there in a decimal field.

My doubt how is an invalid decimal equals to COMP-3 zeroes. Please clarrify whether this is possible or not.

Regards,
Abin.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Aug 06, 2007 6:24 pm    Post subject: Re: Comparing COMP-3 and Invalid decimal
Reply with quote

Quote:
My doubt how is an invalid decimal equals to COMP-3 zeroes. Please clarrify whether this is possible or not.


No, it is not possible. you are overlooking something. When you are looking at the xpediter data display, is that during the WHEN clause. Do you have a break on a WHEN clause statement (to be executed) and then look at the data.

You might also look at PROCESS-INFO - the group item in hex.
xpediter can be tricky when it comes to indexes. You have to know when to look. Are you going to a display data screen, or are you using the watch data option - displays above the code display. you can have several data areas in the watch area as you step thru your code.

try adding this code to the statements that are executed when the WHEN clause is satisfied
Code:

DISPLAY PAYEE-ID-NO
DISPLAY PAYEE-NO(P-ID)


neither COBOL or Xpediter performs the compare incorrectly. You are not looking at the data at the correct time.

Again, take a look at the group item PROCESS-INFO in hex. ID number is first so you don't even have to find it with page-right.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Aug 06, 2007 6:48 pm    Post subject:
Reply with quote

hi dbzTHEdinosauer,

Please see what I get in the PROCESS-INFO.

I am using watch data option to see the field values.


Code:
                                                ----+----1----+----2----+----3 
 SAME-> K 05 PROCESS-INFO                    >  .........0.................... 
 003318   10 PAYEE-ID-NO                     >  0000000000                PACKED
                                                I=1                       OCCURS
 000487   10 PAYEE-NO                        >  ???????????      INVALID DECIMAL
 COBOL       P-ID                            >  1                          INDEX
          ** END **                                                             
                                                                               
                                                                               
 ------   ------------------------------------- Before L00676E:4392/AMODE 31 <>
 004383    2300-SEARCH-CHAIN-TABLE.                                         
 004384 B       IF PAYEE-ID-NO =  PAYEE-ID       
 004385            CONTINUE                                                 
 004386         ELSE                                                       
 004387            MOVE 0                   TO WS-TBL-FOUND-IND         
 004388            SET P-ID                TO 1                           
 004389            SEARCH PROCESSOR-INFO VARYING P-ID                  0006
 004390                AT END                                               
 004391                   MOVE 1            TO WS-TBL-FOUND-IND         
 =====> B              WHEN PAYEE-ID-NO   
                                 = PAYEE-NO (P-ID)         
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Aug 06, 2007 7:05 pm    Post subject: Re: Comparing COMP-3 and Invalid decimal
Reply with quote

10 PAYEE-NO PIC 9(10). is display.

Code:

                                               ----+----1
SAME-> K 05 PROCESS-INFO                    >  .........0


the 10th byte of PAYEE-NO is a 0 (zero). You are working with numbers and using an unsigned display field. COBOL assumes the programmer is an an idiot (don't take it personally icon_rolleyes.gif ). try a compound WHEN -
WHEN PAYEE-NO(P-ID) NUMERIC AND .....
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: Mon Aug 06, 2007 11:39 pm    Post subject:
Reply with quote

Hello,

How is the array loaded?

Before using the values in the array, you might want to execute a bit of code to ensure that all of the values in the array are valid. If any are not, display them in hex and terminate the run.

Before running again, make sure the array will be loaded with valid values.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Tue Aug 07, 2007 9:55 am    Post subject:
Reply with quote

Hi Scherrer,

Actually the array is loaded incorrectly. This is a production code and running ffor years now. still nobody noticed this thing.

The array is loaded from a flat file. The first entry in the array is loaded before the file is readed. So, the first entry will always be an uninitialized entry.

My concern is how can be an invalid decimal be equal to hex zeroes.

Please stop me if I am speaking nonsense.

Regards,
Abin.
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: Tue Aug 07, 2007 6:24 pm    Post subject:
Reply with quote

Hello, Abin,

You're not speaking nonsense - we are trying to make sure we all have the same understanding.

Well, "hex zeros" is an invalid decimal number. . . . Is it possible that the data actually contains hex zeros?

If you can show the hex values in the array and the hex values that are being compared to the entries in the array, it will surely help.

Something else that may help is to isloate the array, loading the array and comparing agains the array in a separate bit of code that exists only for testing this situation. It would probably be a very small program

Even though this has been in operation for a long time, it would be a good idea to correct it. As it is, it may or may not work correctly in all cases.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Aug 08, 2007 6:59 pm    Post subject:
Reply with quote

Hi Scherrer,

I did a display on the fields and following are the HEX of the spool. HEX zero is F0 right? then what is this 00? IS F0 equals to 00.

Code:
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
                                                                               
                                                                               
------------------------------------------------------------------------------
000001  PAYEE-ID-NO 0000000000                                                 
       4DCECC6CC6DD4FFFFFFFFFF4444444444444444444444444444444444444444444444444
       071855094056000000000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------
000002  PAYEE-NO (P-ID)          0                                             
       4DCECC6DD44D6CC54000000000F444444444444444444444444444444444444444444444
       0718550560D7094D00000000000000000000000000000000000000000000000000000000
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Aug 08, 2007 7:18 pm    Post subject:
Reply with quote

did you try adding to the WHEN statement the additional check for IS NUMERIC?
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: Wed Aug 08, 2007 7:56 pm    Post subject:
Reply with quote

Hello,

x'F0' is a display zero.

x'00' is hex zero.

They will not compare equal.
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Wed Aug 08, 2007 7:57 pm    Post subject:
Reply with quote

Hi,

I tried with additional check of NUMERIC. Now WHEN statement is not satisfying. That means what is there in the array is not numeric. But this we found earlier and my concern is how can an invalid numeric be equals to COMP-3 zeroes.

Thanks,
Abin.
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: Wed Aug 08, 2007 8:04 pm    Post subject:
Reply with quote

Hello,

In the data you posted, there is no comp-3 zeros.

You have one field of display zeros and one garbage field of several x'00's and one display zero at the end.

You may have defined something as comp-3 but you do not have a comp-3 value.
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts IEF645I INVALID REFERBACK IN THE RC ... abdulrafi JCL & VSAM 2 Mon Aug 29, 2016 10:57 am
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm


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