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: 7314

 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: 7314

 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 3270 Data stream error Benchwarmer CICS 4 Tue Apr 17, 2018 12:06 am How to list data set names with diffe... murali.andaluri CLIST & REXX 8 Thu Apr 12, 2018 11:33 pm converting a mainframe file with ASA ... Lynne Schuler All Other Mainframe Topics 5 Wed Apr 04, 2018 9:44 am Invalid XML character while producing... nikhil.bhole IBM Tools 4 Tue Mar 20, 2018 1:24 am Get the list of data sets on DASD and... rakaitn JCL & VSAM 3 Thu Mar 08, 2018 12:38 pm

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