View previous topic :: View next topic
|
Author |
Message |
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
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.. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Rohit Umarjikar wrote: |
I don't think I used this any where but by Gnanas N.. |
Ah... the old "fake quote" trick claims another hapless victim :-) |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
hahahahha.... |
|
Back to top |
|
|
|