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
 

 

REDEFINE problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: REDEFINE problem
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    Post subject:
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    Post subject:
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: 645
Location: Pennsylvania

PostPosted: Wed Feb 09, 2011 1:37 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Wed Feb 09, 2011 1:51 am    Post subject:
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

Site Director


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

PostPosted: Wed Feb 09, 2011 1:57 am    Post subject:
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    Post subject:
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: 645
Location: Pennsylvania

PostPosted: Wed Feb 09, 2011 2:25 am    Post subject:
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    Post subject:
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    Post subject:
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    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 Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Problem with GETMAIN command amitc23 CICS 6 Thu Sep 01, 2016 1:01 pm
No new posts TXT2PDF problem - printing @ in PDF vipul65 All Other Mainframe Topics 9 Thu Aug 25, 2016 12:48 am


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