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
 

 

Shift Half word (Nibble) from Binary data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Wed Oct 17, 2012 8:31 pm    Post subject: Shift Half word (Nibble) from Binary data
Reply with quote

Hi, I have a Incoming message with compressed data (binary format), as below,
Hex format: x'005705D121022250'.
If its the Tag 0057 (two bytes) is found, the next byte is the length (here it is 05), then i need to populate next 5 bytes to a common variable (x'D121022250').

The Problem is the half byte 'D' is a junk data that should not be moved to common variable, the data movement should be as x'1210222500' (adding 0 as the last nibble since D was removed).

Could someone can help me out,?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Oct 17, 2012 8:46 pm    Post subject: Reply to: Shift Half word (Nibble) from Binary data
Reply with quote

Multiply by 16 will shift left a half-nybble. Use COMP-5 and no sign. Big COMP-5. Put your value in the low-order five bytes (via REDEFINES) and multiply. Move it back out. Your "D" will evaporate at the left and zero appear as if by magic at the right.
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Thu Oct 18, 2012 2:26 am    Post subject:
Reply with quote

Hi Bill, Thanks for your thoughts, But could you please explain further (pseudo code), Your suggestion is really appreciated but it ll be great if u explain with example,,
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Oct 18, 2012 3:18 am    Post subject: Reply to: Shift Half word (Nibble) from Binary data
Reply with quote

You have five bytes of binary data. In Cobol, you can't define five bytes. as you get given a minimum size (which you could descibe as "twice times the 'boundary' already exceeded, or two bytes, whichever is bigger'.

So, you need eight bytes. So you define a binary item which is eight bytes long - you have to choose the correct number of 9s, or at least enough to make it eight bytes long and best to have at least as many 9s you need to represent the maximum value in your five-byte field.

Don't make the field signed. It won't matter in this case, but if you unthinkingly copy the code for something similar, it might matter.

Make the field COMP-5. Again, it won't matter in this case, but the same advice.

Now redefine that as a FILLER of 3 and a named-field of 5.

Put your five-byte value into the five bytes of the redefinition.

Now multiply the COMP-5 by 16, putting the result in the same COMP-5.

Why 16? If it is base-10, and you have a number 9876, and you multiply by 10, you get 8760, the effect you want. 'Binary' is, for us humans, in base-16. So multiply by 16.

Now you can move the five-byte field to your final destination.

There are other ways, but this is straightforward. Give everything nice clear names, relevant to the task, And document it, both inside and outside the program.

EDIT: In the cold light of day, I noticed I left this out:

Put your five-byte value into the five bytes of the redefinition.

I have added it in the appropriate place.
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Thu Oct 18, 2012 12:00 pm    Post subject:
Reply with quote

Thanks Bill for your well explained suggestion. Will try this out icon_smile.gif
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
No new posts Unable to copy data from spool in a d... srikant314 JCL & VSAM 2 Fri Jul 28, 2017 9:10 pm
No new posts Paasing symbolic parameter to instrea... Robert Sample JCL & VSAM 2 Thu Jul 27, 2017 1:22 pm
No new posts Passing data from REXX to C programme... chong.zhou CLIST & REXX 3 Wed Jul 26, 2017 9:11 pm
No new posts copying data without knowing location Arun Raj DFSORT/ICETOOL 12 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm


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