View previous topic :: View next topic
|
Author |
Message |
Rena
New User
Joined: 11 Apr 2005 Posts: 4 Location: India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Ah Dick, cut him/her a break.....
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Rena
New User
Joined: 11 Apr 2005 Posts: 4 Location: India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 ... |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Sorry Dick ... didn't see your reply ... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Quote: |
didn't see your reply ... |
Not to worry
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 |
|
|
Rena
New User
Joined: 11 Apr 2005 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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... |
|
Back to top |
|
|
|