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
 

 

Strange results, Surprise!!

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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Mar 07, 2013 11:41 am    Post subject: Strange results, Surprise!!
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Mar 07, 2013 11:48 am    Post subject:
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: 785
Location: Chennai, India

PostPosted: Thu Mar 07, 2013 11:52 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Mar 07, 2013 11:54 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Thu Mar 07, 2013 12:46 pm    Post subject: Reply to: Strtange results, Surprise!!
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: 7914
Location: Bellevue, IA

PostPosted: Thu Mar 07, 2013 3:27 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Mar 07, 2013 10:14 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Mar 08, 2013 5:02 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Mar 08, 2013 5:18 am    Post subject:
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    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 Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Strange EXEC function call in z/VM Willy Jensen CLIST & REXX 3 Wed Oct 05, 2016 2:07 pm
No new posts Strange Results with ICETOOL Rohit Umarjikar DFSORT/ICETOOL 4 Tue Dec 22, 2015 4:12 am
No new posts Weird test results when Xpediter is t... Crunch Compuware & Other Tools 6 Tue Oct 06, 2015 7:48 pm
No new posts SORT CAPACITY EXCEEDED Different results abhijit.nayak01 DFSORT/ICETOOL 17 Tue Jun 16, 2015 4:07 pm


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