View previous topic :: View next topic
|
Author |
Message |
siddhartha biswas Currently Banned New User
Joined: 04 May 2008 Posts: 15 Location: india
|
|
|
|
Hi,
Can any one suggest how to convert a COMP-3 variable into alphanumeric variable in cobol ? |
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Hi,
There have been few discussions on this topic previously. A straight MOVE of COMP-3 to Alphanumeric doesn't works.
You need to take care of it in the following way :
Code: |
01 WS-A PIC S9(4) COMP-3 VALUE 1234.
01 WS-A-NUM PIC S9(4).
01 WS-B PIC X(4).
MOVE WS-A TO WS-A-NUM.
MOVE WS-A-NUM TO WS-B. |
Try the above piece of code and let me know what response you get.
Thanks,
-Kapil. |
|
Back to top |
|
|
siddhartha biswas Currently Banned New User
Joined: 04 May 2008 Posts: 15 Location: india
|
|
|
|
ya its converting...but after that i need to compare (= , >, < operations) two alphanumeric variables. But it is not working.. Is it possible to compare two alphanumeric element? |
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Hi,
What type of comparision are you looking for. Do you really want to compare character values.
OR
Your alphanumeric variables have numeric data in them. If thats the case, then better you redifine both your alphanumeric variables as numeric ones and then do comparision with their numeric counter parts.
As far as I understand you already have numeric counter part for one of your variables(WS-A-NUM).
Please let me know if you were looking for something else.
Thanks,
-Kapil. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
ya its converting...but after that i need to compare (= , >, < operations) two alphanumeric variables. But it is not working.. Is it possible to compare two alphanumeric element? |
Of course it is possible -- but you need to understand that '12345' will compare less than '87' since alphanumeric comparisons work left to right, character by character, and '1' is less than '8' -- once COBOL determines that, no further comparison is done (as I understand it). |
|
Back to top |
|
|
naren_kang
New User
Joined: 27 Feb 2006 Posts: 3 Location: pune
|
|
|
|
Hi, Just had one question on this.
If I move COMP 3 Field to S9 Field and then S9 field to alphanumeric field
what if i want to retain sign in my alphanumeric field for display purpose.
For eg: If my comp3 field is have -12 I want to retain sign in my alphanumeric field for dispaly purpose.
I hope i am clear. |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi naren_kang !
Perhaps use a separate field with a msk in pic-clause.
01 ZNUM-1008 PIC +++++++++9,99999999.
01 ZNUM-1206 PIC +++++++++++9,999999.
01 ZNUM-1602 PIC +++++++++++++++9,99.
01 ZNUM-1800 PIC ZZZZZZZZZZZZZZZZZ9. |
|
Back to top |
|
|
naren_kang
New User
Joined: 27 Feb 2006 Posts: 3 Location: pune
|
|
|
|
ok umey will try that will move it to masked numeric field. |
|
Back to top |
|
|
rahul.banik
New User
Joined: 23 Jan 2007 Posts: 16 Location: Mysore
|
|
|
|
Please help |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
With what? It is not clear what you are asking.
When you need more info than has been posted, you need to use more words and explain what needs additional detail. |
|
Back to top |
|
|
|