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

How to Move Binary value to a particular variable in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 2:38 pm
Reply with quote

Hi,

I have got to move the Binary Value to a COBOL variable. Supposedly, when we want to move hexadecimal value directly, we have an option like MOVE X "FA1FA2FA3FA4" to WS-ALPHA. Likewise, is anything available to move BINARY values.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 04, 2009 2:57 pm
Reply with quote

if you move x to x, there will be no conversion.

what 'exactly' do you want to do? speaking in generalities will not produce an answer.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 3:19 pm
Reply with quote

Hi,

We have a numeric field which is used in the packed decimal format in one set of applications (COMP-3 definition). We are now looking at converting the numeric field to alpha numeric, but trying to keep the packed decimal format intact .

So for the above reason, i was trying to convert the value into hexadecimal or binary value and then move it.

Kindly suggest a viable option.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 04, 2009 4:17 pm
Reply with quote

Quote:
We are now looking at converting the numeric field to alpha numeric, but trying to keep the packed decimal format intact .


why? you'all should rethink what you are trying to do.
This kind of rookie crap will get you into trouble.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 4:34 pm
Reply with quote

Sir,

Atleast to proove them wrong i need to have something substantial in hand. I am thinking of letting them know that it is not possible, but some said that try moving Binary values and get me a screenshot of that. SO i am working on it. It would really be helpful if someone can get me out of this mess.

In any case i want to know if I can move binary values to the cobol variables. If yes, then how and if NO, its OK.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 04, 2009 4:40 pm
Reply with quote

Abhishek Palo,
never did answer my question - why do you want to change the datatype?

what is wrong with packed-decimal?

there are all kinds of things you can do.
there are plenty of idiot sites out there that store numeric data in alphanumeric fields.

what are you trying to accomplish? why?????

give us the answers to those questions and i am sure many solutions will follow.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 4:59 pm
Reply with quote

Fine,

Sir, let me then find out this from my client and let you know at the earliest. But Kudos to your patience for ensuring that I should know why I am doing this. Hatss off.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 5:09 pm
Reply with quote

Sir,
Below are some more pointers.

Currently the client is using a X byte numeric field as a unique identifier. But soon they will run out of options. They have 2 options – one, expand the field from X to Y bytes. 2nd option – convert numeric field to alpha numeric, so that more unique identifiers are available without having to expand the field.
We are currently exploring the 2nd option.

Let me know if you need further details.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 5:34 pm
Reply with quote

Sir,

In my program, i have to 9(4) COMP-3 as my primary key, but soon i will run out of options. So i need to either change it to 9(5) or make it X(4) so that i increase my number of unique identifiers.

Cuurently, i am trying to explore the second option. So kindly pool in your suggestions.
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: Tue Aug 04, 2009 6:43 pm
Reply with quote

If the data is stored in a file or database somewhere, you need to create a conversion process to be run one time to convert the data from COMP-3 to binary. Using a PIC S9(09) COMP (or COMP-5) field uses 4 bytes and greatly increases the number of unique values that can be stored. However, the bit patterns are different hence the conversion process is needed.
Back to top
View user's profile Send private message
Abhishek Palo

New User


Joined: 04 Aug 2009
Posts: 7
Location: Mysore

PostPosted: Tue Aug 04, 2009 7:25 pm
Reply with quote

Hi,

Is there any specific conversion process. I guess i need to do an impact analysis and then go ahead and do the conversions manually. But ya , please let me know if there is any other way out as i want to avoid the converison of number of bytes.

Robert, could you please elaborate a bit more about the conversion to S9(09) COMP. It may prove very helpfull to me.
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: Tue Aug 04, 2009 7:47 pm
Reply with quote

I think your time would be better spent in the COBOL Language Reference manual (link at the top of the page) finding out the specifics of how bits are used in COMP-3 and COMP fields, rather than having me doing the same.
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: Tue Aug 04, 2009 8:50 pm
Reply with quote

Hello,

Quote:
In my program, i have to 9(4) COMP-3 as my primary key
Primary key to what? 9(4) comp-3 doesn't really accomplish anything except limit the value to 9999. A 9(5) comp-3 picture should occupy the same space/storage and allow a value up to 99999. They both require 3 bytes.

How long has the 9(4) size been sufficient? 9(5) may be all that is needed.

All of the screens and reports would need to be modified to handle the expansion, but that would be far less effort than changing the format of the data everywhere it resides. . .

Suggest it is at least worth an experiment. . .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 04, 2009 9:14 pm
Reply with quote

Quote:
Suggest it is at least worth an experiment. . .


unless of course, someone already has a solution and only wants to implement it....
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top