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

Expecting SOC7 to occur but not


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

New User


Joined: 03 Oct 2008
Posts: 25
Location: chennai

PostPosted: Fri Jan 20, 2012 5:06 pm
Reply with quote

Hi,

I have following variable declaration -
01 WS-S.
03 WS-NUM PIC S9(2) COMP-3 VALUE ZEROES.
03 WS-CHAR PIC X(2) VALUE 'AB'.

i have run the below piece of code -
MOVE WS-CHAR TO WS-NUM
DISPLAY WS-NUM
ADD +1 TO WS-NUM
DISPLAY 'CHAR :' WS-CHAR
DISPLAY 'NUM1:' WS-NUM
STOP RUN
.
I'm expecting SOC7 to occur since i'm doing arithmetic operation with the non-numeric data.
But i got the following output -
12
CHAR :AB
NUM1:13

Please explain.
Thanks,
Suma
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jan 20, 2012 5:21 pm
Reply with quote

Please search the forum before posting

DISCUSSED MANY TIMES

http://ibmmainframes.com/viewtopic.php?t=56322&highlight=s0c7

http://www.ibmmainframes.com/viewtopic.php?t=51115&highlight=s0c7


Moderators Please lock it
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: Fri Jan 20, 2012 6:57 pm
Reply with quote

Review the "POPS" (Principles of Operation) manual and find exactly what an Assembler "PACK" instruction does.

You'll then understand why "AB" becomes 12, add 1 and you end up with 13.

The following link should suffice -

publibfp.boulder.ibm.com/epubs/pdf/dz9zr006.pdf

Mr. Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Jan 20, 2012 7:15 pm
Reply with quote

suma_infy wrote:
I'm expecting SOC7 to occur since i'm doing arithmetic operation with the non-numeric data.


the above is not true.

only if a source has non/numerics.

and as you proved yourself, the numeric fields contain numeric data.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 20, 2012 7:39 pm
Reply with quote

If you use the SEARCH function on this forum, and use airthmetic non-numeric as your search values, and restrict only to the COBOL forum -- you get 227 returned hits. This topic has been discussed many, many, many times before. Your lack of knowledge about COBOL variables and internal formats indicates you need to spend time reading the COBOL Language Reference and Programming Guide manuals (link at the top of this page).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jan 20, 2012 11:57 pm
Reply with quote

suma_infy wrote:
Hi,

I have following variable declaration -
01 WS-S.
03 WS-NUM PIC S9(2) COMP-3 VALUE ZEROES.
03 WS-CHAR PIC X(2) VALUE 'AB'.

i have run the below piece of code -
MOVE WS-CHAR TO WS-NUM
DISPLAY WS-NUM
ADD +1 TO WS-NUM
DISPLAY 'CHAR :' WS-CHAR
DISPLAY 'NUM1:' WS-NUM
STOP RUN
.
I'm expecting SOC7 to occur since i'm doing arithmetic operation with the non-numeric data.
But i got the following output -
12
CHAR :AB
NUM1:13

Please explain.
Thanks,
Suma


Why would you want to move PIC XX to COMP-3 PIC S99? I've never felt the need to do that.

If I had a PIC XX that should contain a numeric which I want to MOVE to a numeric field, I'd redefine it as PIC 99, test it for NUMERIC and do the move with that.

If you don't do something to deal with it properly, using the NUMERIC test, you will potentially give yourself problems which, at best, will give a S0C7, but at worst will just infect your system with rubbish data which, after you've done the MOVE, looks just like any other number and which may become difficult to track back to the original value for problem determination.

I hope nobody coded anything like that thinking "if it isn't numeric, we'll get a S0C7, so it's OK". If they did, you could well have a long search trying to identify the rubbish.

If you have to embark on the search, it is important to know the implications for your data of the compiler options NUMPROC(NOPFD) and NUMPROC(PFD) (or NUMPROC(MIG) in less-likely cases).
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 SOC7 error with DFSORT DFSORT/ICETOOL 9
No new posts SOC7 abend- How to resolve it COBOL Programming 24
No new posts Want a code of SOC7 with out using co... COBOL Programming 1
No new posts Create DDIO file to view the soc7 Compuware & Other Tools 13
No new posts SOC7 Numeric Movement COBOL Programming 7
Search our Forums:

Back to Top