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

Move COMP-3 variable into Alphanumeric


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
siddhartha biswas
Currently Banned

New User


Joined: 04 May 2008
Posts: 15
Location: india

PostPosted: Fri Dec 12, 2008 2:21 pm
Reply with quote

Hi,

Can any one suggest how to convert a COMP-3 variable into alphanumeric variable in cobol ?
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Dec 12, 2008 3:06 pm
Reply with quote

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
View user's profile Send private message
siddhartha biswas
Currently Banned

New User


Joined: 04 May 2008
Posts: 15
Location: india

PostPosted: Fri Dec 12, 2008 3:42 pm
Reply with 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?
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Fri Dec 12, 2008 4:26 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Dec 12, 2008 6:11 pm
Reply with quote

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
View user's profile Send private message
naren_kang

New User


Joined: 27 Feb 2006
Posts: 3
Location: pune

PostPosted: Wed Dec 17, 2008 12:51 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Wed Dec 17, 2008 1:32 pm
Reply with quote

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
View user's profile Send private message
naren_kang

New User


Joined: 27 Feb 2006
Posts: 3
Location: pune

PostPosted: Wed Dec 17, 2008 2:33 pm
Reply with quote

ok umey will try that will move it to masked numeric field.
Back to top
View user's profile Send private message
rahul.banik

New User


Joined: 23 Jan 2007
Posts: 16
Location: Mysore

PostPosted: Sun Dec 21, 2008 12:40 pm
Reply with quote

Please help
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: Sun Dec 21, 2008 12:59 pm
Reply with quote

Hello,

Quote:
Please help
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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top