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

Strange results, Surprise!!


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

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Mar 07, 2013 11:41 am
Reply with quote

Team,

Could you please guess what should be the result of below piece of code when executed?
Code:
01  WS-STRG-dec            PIC  9(2).                 
01  WS-STRG-dec-c          PIC s9(2) comp.             
01  WS-space               PIC x(2).                   
  88 WS-space-tr           value 'a1'.                 
                                                       
*******************************************************
PROCEDURE DIVISION.                                   
                                                       
MAINLINE SECTION.                                     
      set ws-space-tr   to true                       
      move ws-space                to  WS-STRG-dec     
                                       WS-STRG-dec-C   
      display WS-STRG-dec                             
      display WS-STRG-dec-C                           
      stop run.                                       
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Mar 07, 2013 11:48 am
Reply with quote

Below are the compiler options in effect ,

Code:
PP 5655-G53 IBM Enterprise COBOL for z/OS  3.4.1     
Invocation parameters:                               
F(I,W),LIST,MAP,NOSEQ,XREF,LIB,TEST(NONE,SYM,SEPARATE
Options in effect:                                   
    NOADATA                                         
    NOADV                                           
      APOST                                         
      ARITH(COMPAT)                                 
    NOAWO                                           
      BUFSIZE(4096)                                 
    NOCICS                                           
      CODEPAGE(1140)                                 
    NOCOMPILE(S)                                     
    NOCURRENCY                                       
      DATA(31)                                       
    NODATEPROC                                       
    NODBCS                                           
    NODECK                                           
   NODIAGTRUNC     
   NODLL           
   NODUMP         
   NODYNAM         
   NOEXIT         
   NOEXPORTALL     
   NOFASTSRT       
     FLAG(I,W)     
   NOFLAGSTD       
     INTDATE(ANSI)
     LANGUAGE(EN) 
     LIB           
     LINECOUNT(60)
     LIST         
     MAP           
   NOMDECK         
   NONAME         
     NSYMBOL(DBCS)
NONUMBER                 
  NUMPROC(NOPFD)         
  OBJECT                 
NOOFFSET                 
NOOPTIMIZE               
  OUTDD(SYSOUT)         
  PGMNAME(COMPAT)       
  RENT                   
  RMODE(AUTO)           
NOSEQUENCE               
  SIZE(MAX)             
  SOURCE                 
  SPACE(1)               
NOSQL                   
  SQLCCSID               
NOSSRANGE               
NOTERM                   
  TEST(NONE,SYM,SEPARATE)
  NOTHREAD               
    TRUNC(OPT)           
  NOVBREF               
  NOWORD                 
    XREF(FULL)           
    YEARWINDOW(1970)     
    ZWB                 
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Mar 07, 2013 11:52 am
Reply with quote

SYSOUT
Code:
*********
A1       
11       
*********

HEX ON
Code:
--
A1
CF
11
--
11
FF
11--


Quote:
1PP 5655-S71 IBM Enterprise COBOL for z/OS 4.2.0
0Options in effect:
NOADATA
NOADV
APOST
ARITH(COMPAT)
AWO
NOBLOCK0
BUFSIZE(8192)
NOCICS
CODEPAGE(1140)
NOCOMPILE(S)
NOCURRENCY
DATA(31)
NODATEPROC
NODBCS
NODECK
NODIAGTRUNC
NODLL
NODUMP
NODYNAM
NOEXIT
NOEXPORTALL
FASTSRT
FLAG(I,I)
NOFLAGSTD
INTDATE(ANSI)
LANGUAGE(EN)
LIB
LINECOUNT(60)
NOLIST
MAP
NOMDECK
NONAME
NSYMBOL(DBCS)
NONUMBER
NUMPROC(MIG)
OBJECT
OFFSET
OPTIMIZE(STD)
OUTDD(SYSOUT)
PGMNAME(COMPAT)
RENT
RMODE(AUTO)
NOSEQUENCE
SIZE(6144000)
SOURCE
SPACE(1)
NOSQL
SQLCCSID
NOSSRANGE
NOTERM
NOTEST
NOTHREAD
TRUNC(OPT)
NOVBREF
WORD(MER)
XMLPARSE(XMLSS)
XREF(FULL)
1PP 5655-S71 IBM Enterprise COBOL for z/OS 4.2.0
0 YEARWINDOW(1900)
ZWB
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Mar 07, 2013 11:54 am
Reply with quote

Is it now allowed to move alphanumeric value to numeric it means as expected to get S0C7?

May be one of the compiler option did this.
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: Thu Mar 07, 2013 12:46 pm
Reply with quote

You can move an alpha-numeric to a numeric.

Personally I don't consider it remotely good practice. I always test for NUMERIC, REDEFINES as PIC 9(x) (USAGE DISPLAY) and MOVE the PIC 9(x).

I believe that back in the mists of time it was not possible to move PIC X(x) to a "computational" field.

None of what you have done will cause a S0C7, although your results may not be what you expect (as you didn't expect it to work). Try using the PIC 9(2) in a calculation of some type - it will work. However, change the value of your 88 to ".." and try, you'll get the S0C7.

Why do you have NUMPROC(MIG) as a compile option? It is intended as a migration-support option, although nothing stops you using it, but you should be aware of what it does.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Mar 07, 2013 3:27 pm
Reply with quote

Quote:
Could you please guess
Nope. When it comes to the compiler, I either know or find out -- I don't guess.

If you are surprised to find that PIC X variables can be moved to PIC 9 variables, the surprise is only because you don't pay attention to this forum. The issue comes up at least once every other month.

An S0C7 ABEND occurs when dealing with invalid numeric data. Since COBOL usually packs USAGE DISPLAY data before computing with it, that means any character in the collating sequence that has the values 0 through 9 in the rightmost 4 bits of the byte will convert to a numeric since the zone bits (the leftmost 4 bits) will be stripped off during the conversion to packed decimal. The S0C7 indicates that something other than 0 through 9 was found in the rightmost 4 bits of at least one byte.

In other words, your "surprise" results are usual and expected for the data you presented.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Thu Mar 07, 2013 10:14 pm
Reply with quote

Robert,Bill, Perfectly explained, Thank you.

Quote:
Why do you have NUMPROC(MIG) as a compile option? It is intended as a migration-support option, although nothing stops you using it, but you should be aware of what it does.


I don't think I used this any where but by Gnanas N..icon_smile.gif
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 Mar 08, 2013 5:02 am
Reply with quote

Rohit Umarjikar wrote:

I don't think I used this any where but by Gnanas N..icon_smile.gif


Ah... the old "fake quote" trick claims another hapless victim :-)
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Mar 08, 2013 5:18 am
Reply with quote

hahahahha....icon_smile.gif
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 DB2 Statistics - Using EXPLAIN and qu... DB2 1
No new posts Strange MNOTE related to BMS using PI... CICS 0
No new posts COBOL NOADVANCING strange results in ... COBOL Programming 4
No new posts partitioning row-num and aggregation ... DB2 0
No new posts How to extract the difference from Su... TSO/ISPF 3
Search our Forums:

Back to Top