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

Redefine Alphanumeric with USAGE COMP


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

New User


Joined: 11 Apr 2005
Posts: 4
Location: India

PostPosted: Sat Mar 06, 2010 4:04 am
Reply with quote

Is it possible to redefine alphanumeric with COMP as illustrated

05 WS-INPUT-X PIC X(9).
05 WS-INPUT REDEFINES WS-INPUT-X
PIC S9(9) USAGE COMP.

My input file gives the value in Alphanumeric and I need to use the value for a comparison with s9(9) COMP variable.

When compiled I got the Warning Message – ‘Redefined a Larger item’.

Since redefine plays with the memory, I would like to be sure the functionality would work as expected.
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: Sat Mar 06, 2010 4:22 am
Reply with quote

Hello,

Not only are the fields different size, but the COMP field is basically useless. The value contained would neither be the original input nor the desired COMP value.

Suggest you change your expectation. . .

At the top of the page is a link to "IBM Manuals". At the top of the list are some COBOL Language Reference manuals. Look in the manual for your version of COBOL for information about numeric fields. If you find something in the manual that is not clear, post what you found and your doubt about it.

Someone here will be able to clarify.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Sat Mar 06, 2010 5:55 am
Reply with quote

Ah Dick, cut him/her a break..... icon_rolleyes.gif
Your redefine is only redefining the first four bytes of the nine byte field, if that is what you want, ignore the compile warning....
Since the length is nine bytes, you have a problem....
As far as I know the max comp field is 9(18) which is eight bytes (more commonly known as a double word).
What do you expect to do with the extra trailing byte?
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: Sat Mar 06, 2010 9:56 am
Reply with quote

Hello,

I suspect the X field is supposed to contain some sort of number (maybe up to 9 digits, maybe space or zero filled on the high-order side, maybe with a decimal point or minus sign?).

4 leading Spaces (x'40's) would = 1077952576 as a comp value in decimal.
4 leading Zeros (x'F0's) would = 4042322160. . .

Possibly Rena can post a few sample "input values" (and explain the rules for the content of the x(9) field) and we can go from there.
Back to top
View user's profile Send private message
Rena

New User


Joined: 11 Apr 2005
Posts: 4
Location: India

PostPosted: Mon Mar 08, 2010 9:25 pm
Reply with quote

Thank you.

The input value would always be a numeric like

200707024

I put some displays in the code and this is what I found ..

Working Storage:-

05 WS-INPUT-STATEMENT-X PIC X(9).
05 WS-INPUT-STATEMENT REDEFINES WS-INPUT-STATEMENT-X
PIC S9(9) USAGE COMP.

Procedure Division

Move INPUT-FIELD TO WS-INPUT-STATEMENT-X.
display 'ws-input-statement :' WS-INPUT-STATEMENT
display 'WS-INPUT-STATEMENT-X :' WS-INPUT-STATEMENT-X

SYSOUT

ws-input-statement :21909069P
AA6899AA6AA8A8989A47FFFFFFFFD44
6209574302313545530A21909069700
--------------------------------
WS-INPUT-STATEMENT-X :200707024
4EE6CDDEE6EECECDCDE6E47FFFFFFFFF
0620957430231354553070A200707024

Looks like this redefine would work as intended.

Thanks - Rena
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: Mon Mar 08, 2010 10:00 pm
Reply with quote

Hello,

Suggest you re-run whatever is this test. The results do not show that your originial "requirement" has been met. . .

Quote:
Looks like this redefine would work as intended.
No, it doesn't. . .

All that i see is that a display of a pic x field, displays the data.

You really need to do some research in the COBOL documentation about the contents of a COMP field.

Maybe there is something i do not yet understand with this.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Mon Mar 08, 2010 10:01 pm
Reply with quote

Hi Rena,

It would be better if you could explain your statement
Quote:
Looks like this redefine would work as intended.


so that all of us can be in the same boat ... icon_cool.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Mar 08, 2010 10:05 pm
Reply with quote

Redfines is not a COBOL verb, it doesn't change the data, it only changes the way the compiler treats your references to it.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Mon Mar 08, 2010 10:06 pm
Reply with quote

Sorry Dick ... didn't see your reply ...
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: Mon Mar 08, 2010 10:30 pm
Reply with quote

Quote:
didn't see your reply ...
Not to worry icon_smile.gif

If several (not dozens, but a few) of us mention that Rena needs a better understanding, maybe more understanding will be sought. . .
Back to top
View user's profile Send private message
Rena

New User


Joined: 11 Apr 2005
Posts: 4
Location: India

PostPosted: Mon Mar 08, 2010 10:41 pm
Reply with quote

Quote:
Looks like this redefine would work as intended. .


It was with the reference to the post of CICS Guy.

I understood my program won't work as coded.

Thanks Craq.. All I wanted to know whether it would change the data internally with the redefine.

Thank you all
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Mar 09, 2010 7:59 am
Reply with quote

Hi Rena,

Yes... As Craq as mentioned... REDEFINES doesn't change the data but just how its referenced...

Going back to initial post... Your "requirement" was ....
Quote:
My input file gives the value in Alphanumeric and I need to use the value for a comparison with s9(9) COMP variable.
Hope you have found your solution... 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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts STEM usage in REXX CLIST & REXX 14
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts z/OS Modules Usage report using SMF 42 DFSORT/ICETOOL 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top