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
 

 

Convert a COMP-3 variable into Alphanumeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Convert a COMP-3 variable into Alphanumeric
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    Post subject: Reply to: CONVERTING COMP-3 VARIABLE TO ALPHANUMERIC VARIABL
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    Post subject: Reply to: CONVERTING COMP-3 VARIABLE TO ALPHANUMERIC VARIABL
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    Post subject: Reply to: CONVERTING COMP-3 VARIABLE TO ALPHANUMERIC VARIABL
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: 7932
Location: Bellevue, IA

PostPosted: Fri Dec 12, 2008 6:11 pm    Post subject:
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    Post subject: Reply to: How to convert a COMP-3 variable into anphanumeri
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: 743
Location: Germany

PostPosted: Wed Dec 17, 2008 1:32 pm    Post subject:
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    Post subject:
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    Post subject: how to convert alphanumeric to comp-3
Reply with quote

Please help
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: Sun Dec 21, 2008 12:59 pm    Post subject:
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    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 How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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