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

Convert from binary to character using dfsort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Mon Jun 22, 2009 10:37 pm
Reply with quote

Hi.. I tried digging into this one but could not find a way to do it.

I have a s9(8) comp field that needs to be converted to an x(16) field. I tried using the length function, but that ended up right justifying the values in the field. I want it to be left justified. Is this possible?

Thanks in advance
n
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Jun 22, 2009 11:07 pm
Reply with quote

knarayan,

The following control cards will give you the desired results.

Assumptions:

1. Your input is FB recfm and 80 bytes in length
2. Your integer s9(8) comp field starts in position 1 and has only positive values.
3. You want the 16 byte value in pos 20 with left justified.

Code:

//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(81:1,4,BI,M10,LENGTH=16,20:81,16,JFY=(SHIFT=LEFT)))
/*
Back to top
View user's profile Send private message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Mon Jun 22, 2009 11:36 pm
Reply with quote

Thanks Kolusu.. That is fantastic... Quick question though .. what would you change there if you only had a subset of fields required in the INREC. for e.g if i needed to select fields 1,35. then this field was in position 36,4 and then the last field that i needed was in say 60,20. Can you actually use the INREC FIELDS along with this OVERLAY?

Thanks!!
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 23, 2009 1:09 am
Reply with quote

OVERLAY can be used when you want to replace specific bytes with the same number of bytes without changing the rest of the record.

If you want to reformat the records the way you say, you would need to use BUILD rather than OVERLAY and specify all of the fields you want in the output record. To do what you described, you could use these DFSORT control statements:

Code:

   OPTION COPY                                                     
   INREC IFTHEN=(WHEN=INIT,                                       
    OVERLAY=(81:1,4,BI,M10,LENGTH=16,81:81,16,JFY=(SHIFT=LEFT))), 
   IFTHEN=(WHEN=INIT,BUILD=(1,35,81,16,60,20))                     
Back to top
View user's profile Send private message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Wed Jun 24, 2009 1:29 am
Reply with quote

Thanks Frank.. That was helpful
Back to top
View user's profile Send private message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Wed Jun 24, 2009 1:34 am
Reply with quote

I wasn't really aware that we could actually pass the data from the first IFTHEN into the second IFTHEN.. DFSORT continues to surprise me
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Jun 24, 2009 2:14 am
Reply with quote

Yes, you can reprocess records with multiple IFTHEN clauses. Note that OVERLAY can be used to reprocess fields as well. We aim to please! icon_wink.gif
Back to top
View user's profile Send private message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Tue Jun 30, 2009 2:30 am
Reply with quote

Frank Yaeger wrote:
Yes, you can reprocess records with multiple IFTHEN clauses. Note that OVERLAY can be used to reprocess fields as well. We aim to please! icon_wink.gif


Hi Frank... quick question. If you need to sort on these overlay fields, how do you specify the sort? I am running into issues when I try to sort the new layout

Thanks
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 30, 2009 2:43 am
Reply with quote

You asked to convert BI value to left-justified numeric values. You could use UFF format for the resulting values.

For complete details on DFSORT's UFF format, see:

www.ibm.com/systems/support/storage/software/sort/mvs/pdug/
Back to top
View user's profile Send private message
knarayan

New User


Joined: 25 Nov 2008
Posts: 9
Location: providence, ri

PostPosted: Tue Jun 30, 2009 3:14 am
Reply with quote

Thanks Frank.. Just wanted to let you know that I am really having fun with the nested ifthen...
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 30, 2009 3:41 am
Reply with quote

Quote:
Just wanted to let you know that I am really having fun with the nested ifthen


icon_biggrin.gif
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top