IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting S0C7 when comparing two COMP-3 fields


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Apr 29, 2010 10:25 am
Reply with quote

Hi,

I have two fields which are comp-3 and having initial val as +50 as shown

Code:


01  WS-LINES-PRINTED               PIC S9(03) COMP-3 VALUE +50.
01  WS-PAGE-SIZE                   PIC S9(03) COMP-3 VALUE +50.


When i am comparing them it is giving me 0c7 error. Here is my comparision

Code:

IF WS-LINES-PRINTED = WS-PAGE-SIZE                           
   MOVE WS-PAGE-NO  TO HD01-PAGE-NO                           
   WRITE RPT-REC FROM HEAD-LINE-1 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-2 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-3 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-4 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-5 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-6 AFTER ADVANCING 1 LINE     
   WRITE RPT-REC FROM HEAD-LINE-4 AFTER ADVANCING 1 LINE     
   MOVE +7 TO WS-LINES-PRINTED                               
   DISPLAY 'HELLO IN IF'                                     
   ADD +1 TO WS-PAGE-NO                                       
END-IF.                   
                                   


please help me in this issue.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Thu Apr 29, 2010 12:08 pm
Reply with quote

Are you sure it gives S0C7 while comparing?

If you get S0C7, it means that there is non-numeric data involved.

Please check.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Apr 29, 2010 12:31 pm
Reply with quote

Hi Mathi,

Yes I have declared COMP-3 fileds and I am comparing them. I havn't initialized it anywhere

regards,
rupesh gupta
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Apr 29, 2010 12:45 pm
Reply with quote

This is initializing :

MOVE +7 TO WS-LINES-PRINTED

If you try as assignment like :

WS-LINES-PRINTED = 7

you still get the 0C7?
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Thu Apr 29, 2010 12:54 pm
Reply with quote

Hi Rupesh,

Couple of suggestions ...

Just to be sure that you haven't modified the fields.. you can use a debugging tool to see the value what it is having at the time of comparison... or .. you could redefine the fields as ALPHANUMERIC and display these fields just before comparison.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 29, 2010 1:29 pm
Reply with quote

It could also be an uninitialized WS-PAGE-NO......

Ten minutes of dump reading and the answer would be known, What assembler instruction does the PSW point to?
Back to top
View user's profile Send private message
Bang_1

New User


Joined: 08 May 2009
Posts: 39
Location: Bangalore

PostPosted: Thu Apr 29, 2010 1:45 pm
Reply with quote

This S0C7 is not from comparision. I copied declaration & IF, works for me... Here is the code snippet


WORKING-STORAGE SECTION.
01 WS-LINES-PRINTED PIC S9(03) COMP-3 VALUE +50.
01 WS-PAGE-SIZE PIC S9(03) COMP-3 VALUE +50.
PROCEDURE DIVISION.
MAIN-PARA.
IF WS-LINES-PRINTED = WS-PAGE-SIZE
DISPLAY 'EQUAL'
ELSE
DISPLAY 'NOT EQUAL'
END-IF.
MAIN-EXIT.


Output is --> EQUAL

As CICSGuy said, it might be from WS-PAGE-NO...
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Apr 29, 2010 1:55 pm
Reply with quote

Bang_1,

I wil try to look into the code and let me verify. Thanks for help. Will let you know once I am done with it.

regards,
rupesh gupta
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 29, 2010 6:33 pm
Reply with quote

Bang_1 wrote:
This S0C7 is not from comparision. I copied declaration & IF, works for me...
It can be, but one of the compared values would need to be garbage, somehow stepped on. A Compare Packed will throw a data exception......
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Thu Apr 29, 2010 6:39 pm
Reply with quote

If one or both of the COMP-3 fields is elementary to a group-level, make sure no one is moving ZEROS (which are X'F0's) or anything else for that matter, to the group-level.

That will burn you every time....

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

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Apr 29, 2010 6:55 pm
Reply with quote

Hi,

I am still getting the errors. Here are the display statements:

Code:

WS-LINES-PRINTED 0 
WS-PAGE-SIZE 3     
WS-PAGE-NO0002     


I tried to compare two values which are comp-3 as Bang_1 suggested and its running fine .. i am also not able to get why page no is displaying val 2 as have not increased its value any where.

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

CICS Moderator


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

PostPosted: Thu Apr 29, 2010 7:10 pm
Reply with quote

As CICS Guy said (and I don't want to beat on a dead horse), it could be that all you need to do is to initialize WS-PAGE-NO to a valid packed-decimal value of your choosing.

Have you tried this?

WS-PAGE-SIZE should have displayed as 4-Bytes numeric and it seems to be a static variable, initialized to +50, same with WS-LINES-PRINTED.

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

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Apr 29, 2010 7:56 pm
Reply with quote

CICS Guy wrote:
It could also be an uninitialized WS-PAGE-NO......

I'm with Bill and CICS Guy in this.
Do WS-PAGE-NO have an initial value ?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 29, 2010 8:22 pm
Reply with quote

Not to beat a dead horse, but what assembler instruction does the PSW point to?
Compare Packed?
Zero and Add Packed?
Add Packed?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Thu Apr 29, 2010 8:53 pm
Reply with quote

Anyone care to join? icon_wink.gif

theroosterstrikes.files.wordpress.com/2008/01/beating-a-dead-horse.gif

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top