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 Alphanumeric with USAGE COMP

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Redefine Alphanumeric with USAGE COMP
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

Site Director


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

PostPosted: Sat Mar 06, 2010 4:22 am    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Sat Mar 06, 2010 5:55 am    Post subject:
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

Site Director


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

PostPosted: Sat Mar 06, 2010 9:56 am    Post subject:
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    Post subject: Reply to: Redefine Alphanumeric with USAGE COMP
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

Site Director


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

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

Sorry Dick ... didn't see your reply ...
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: Mon Mar 08, 2010 10:30 pm    Post subject:
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    Post subject:
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm


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