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

REDEFINE problem


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

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 09, 2011 12:53 am
Reply with quote

Hi All,

I have a condition in program to check a variable S9(11)V9(2).If that variable is not numeric then it will give an error.

Code:
IF VARIABLE  NUMERIC
       SUBTRACT
ELSE
      MOVE ERROR
END-IF
poster too slack to "Code"

When I am displaying that variable it is having zero value (13 zeros in this case ,when I do a hex on).

Cobol definition is
Code:
05    BIG-AREA                                  X(180).
05    TEMP-1    REDEFINES BIG-AREA.
        10   A                                     X(2).
        10   B                                     X(2).
        10   C                                    S9(03). COMP-3.
        10   D                                    S9(9)V9(2).
05   TEMP-4    REDEFINES BIG-AREA.
        10   A4                                     X(2).
        10   B4                                     S9(11)v9(2) COMP-3.
        10   VARIABLE                          S9(11)v9(2) COMP-3.
ditto
BIG-AREA is redefined several times.How can I determine that from where I am getting that value.Also when I am displaying it is showing as zero only but why it is not going inside the if condition.

Thanks.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Wed Feb 09, 2011 1:11 am
Reply with quote

Which is it???
is it a S9(11)v9(2) as per your first line - or s9(11)v9(2) comp-3 as per your cut and paste ??

10 VARIABLE S9(11)v9(2) COMP-3.
This is a packed decimal field occupying 7 bytes. So should contain:

0000000
000000C

Not as you say"...When I am displaying that variable it is having zero value (13 zeros in this case ,when I do a hex on). ..."

If you are indeed expecting this in packed decimal - are you seeing the sign in the rightmost byte?
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 09, 2011 1:27 am
Reply with quote

Hi david,

It is not having sign in the end.

It is coming as
Code:

0000000000000
FFFFFFFFFFFFF
0000000000000
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Feb 09, 2011 1:37 am
Reply with quote

What about the answer to his first question:
Quote:
Which is it???
is it a S9(11)v9(2) as per your first line - or s9(11)v9(2) comp-3 as per your cut and paste ??



The data you show is not packed (sort of), why are two FF missing?

The definition in your redefines is packed data.

If that is what your progran is using, then the data you display is NOT NUMERIC.

You are showing conflicting and inaccurate information, yet you expect an exact answer. How well does that work?
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: Wed Feb 09, 2011 1:51 am
Reply with quote

Use the compile option MAP to generate a storage map. For each variable, it will tell you the offset and length of the variable (in Assembler format) and which base cell is being used (each file has its own base cell whereas all WORKING-STORAGE variables use a sequence of base cells starting at zero and going up as needed. With the map you can look at other variables that use the same offsets to determine exactly where your data is coming from.

AND BEFORE YOU DO ANYTHING ELSE, you need to click on the Manuals link at the top of the page, find the COBOL Language Reference manual, and read section 5.3.17 on USAGE clause and the internal formats for the various types of data. If you don't know how COBOL stores the data, you cannot write a valid IF NUMERIC test.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 09, 2011 1:57 am
Reply with quote

Hello,

In addition to learning how things are stored (i.e. internal formats) you also need to understand that when data is redefined as this has been posted, there has to be some way to know which format of the data is being worked with. . .
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 09, 2011 2:19 am
Reply with quote

THe variable PIC clause are defined correctly .
I copy-pasted the value from the mainframe only.I don't know how it missed 2 'F'.

I will look into internal storage of those variables now.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Feb 09, 2011 2:25 am
Reply with quote

Quote:
THe variable PIC clause are defined correctly


There you have it then.

Your definition is looking for packed data, but your data is not packed.

Hence it is NOT NUMERIC.

Your program is working correctly as it is coded.
Back to top
View user's profile Send private message
david jackson

New User


Joined: 24 Jan 2011
Posts: 22
Location: California

PostPosted: Wed Feb 09, 2011 2:34 am
Reply with quote

rgupta71 wrote:
Hi david,

It is not having sign in the end.

It is coming as
Code:

0000000000000
FFFFFFFFFFFFF
0000000000000


Then quite clearly this is 13 bytes character format and NOT 7 bytes of packed decimal.

You say your PIC clause as defined is correct. i.e. pic 9(11)v9(2) COMP-3.

Therefore PIC 9(11)v9(2) COMP-3 does NOT match the character format that you are testing for numeric so will fail.
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 09, 2011 2:45 am
Reply with quote

Thanks Everyone.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top