Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
dudenithy

New User

Joined: 02 Mar 2012
Posts: 48
Location: India

 Posted: Wed Oct 17, 2012 8:31 pm    Post subject: Shift Half word (Nibble) from Binary data 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,?

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Wed Oct 17, 2012 8:46 pm    Post subject: Reply to: Shift Half word (Nibble) from Binary data 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.
dudenithy

New User

Joined: 02 Mar 2012
Posts: 48
Location: India

 Posted: Thu Oct 18, 2012 2:26 am    Post subject: 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,,
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Thu Oct 18, 2012 3:18 am    Post subject: Reply to: Shift Half word (Nibble) from Binary data 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.
dudenithy

New User

Joined: 02 Mar 2012
Posts: 48
Location: India

 Posted: Thu Oct 18, 2012 12:00 pm    Post subject: Thanks Bill for your well explained suggestion. Will try this out
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us