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

Can DFSORT be used to Unpack fields on a file?


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

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Wed Nov 01, 2006 11:25 pm
Reply with quote

Hi,
I am wondering if DFSORT can be used to Unpack fields on a file?
For example, the file is 80 bytes with 10 fields of Pic s9(12)V99 comp-3
and the desired output is to be 150 bytes with 10 fields of Pic 9(15).

Thank-you!
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Nov 01, 2006 11:29 pm
Reply with quote

See here... it discussed.
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Wed Nov 01, 2006 11:32 pm
Reply with quote

Thank-you!
I will read what you have provided.
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: Thu Nov 02, 2006 12:19 am
Reply with quote

Gayle,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/150)
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(1,8,PD,TO=ZD,LENGTH=15,
               9,8,PD,TO=ZD,LENGTH=15,
              17,8,PD,TO=ZD,LENGTH=15,
              25,8,PD,TO=ZD,LENGTH=15,
              33,8,PD,TO=ZD,LENGTH=15,
              41,8,PD,TO=ZD,LENGTH=15,
              49,8,PD,TO=ZD,LENGTH=15,
              57,8,PD,TO=ZD,LENGTH=15,
              65,8,PD,TO=ZD,LENGTH=15,
              73,8,PD,TO=ZD,LENGTH=15)
/*
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Thu Nov 02, 2006 3:22 am
Reply with quote

Thank you, Frank!
This is very helpful.
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Thu Nov 02, 2006 4:27 am
Reply with quote

If the file that I want to unpack also has a field that is character (CH) would I just add a statement to the INREC such as
41,32,CH,TO=CH,length=32?
I get error ICE007A E SYNTAX ERROR on the CH.
Assume the fields prior 1-40 are composed of packed data and the desired output contains the unpacked data plus the 32 characters.

What is the link for the manual on this feature?
Thank-you,
Gayle
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: Thu Nov 02, 2006 6:50 am
Reply with quote

For character fields, you just specify their input position and length (p,m) -> you're not doing any conversion so you shouldn't specify a format, TO or LENGTH. So you'd just have 41,32 for the CH field.

Quote:
What is the link for the manual on this feature?


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links

The complete reference is "z/OS DFSORT Application Programming Guide" which you can find at the same link.
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Thu Nov 02, 2006 9:34 pm
Reply with quote

Thank-you!
I have only used DFSORT to sort files, or to include or omit.
I had just become aware of some of its other features.
I will read the reference you provided.
Thank-you again!
Gayle
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Thu Nov 02, 2006 10:35 pm
Reply with quote

Frank,

I knew how to unpack CH fields, but I now I wonder how to pack them and if it's something needed as well ?

Alain
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Thu Nov 02, 2006 10:48 pm
Reply with quote

Hi,
I don't need to pack CH fields. Thank-you for asking.

But, I may need to unpack COMP-3 fields to numeric-edited fields.
Can this be done with the DFSORT? I know I can do this with COBOL.

Thank-you,
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: Thu Nov 02, 2006 11:28 pm
Reply with quote

Quote:
I knew how to unpack CH fields, but I now I wonder how to pack them and if it's something needed as well ?


Alain,

Maybe I'm misunderstanding your question, but you can pack "CH" fields by treating them as ZD fields, e.g.

...,5,8,ZD,TO=PD,LENGTH=5,...

Quote:
But, I may need to unpack COMP-3 fields to numeric-edited fields.
Can this be done with the DFSORT? I know I can do this with COBOL.


Gayle,

Yes, you can do that using either DFSORT's 27 predefined editing masks (M0-M26) or your own pattern (EDIT=(pattern)). For more details, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.8?DT=20060615173822

If you need more specific help, tell me the starting position, length and format of the input field and exactly what you want the output field to look like.
Back to top
View user's profile Send private message
Alain Benveniste

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Nov 03, 2006 12:10 am
Reply with quote

Frank,

Well by CH, I pretended alphabetic and a mix with numeric and why not special characters like ?/?...

Code:

//STEP0001 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//OUT      DD SYSOUT=*
//TOOLIN   DD *
  COPY FROM(IN) TO(OUT) USING(ICE0)
/*
//IN       DD *
ABCDEFGHIJ
A0B1C2D3E4
/*
//ICE0CNTL DD *
  INREC FIELDS=(1,10,?,TO=?,LENGTH=6)
  OUTREC FIELDS=(1,6,?,TO=?)
/*

Argh, I caught off my guard with my own question, it's not serious !!! icon_smile.gif

alain
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: Fri Nov 03, 2006 12:19 am
Reply with quote

Alain,

I'm glad it's "not serious" since it doesn't make a whole lot of sense to "pack" that kind of data. icon_lol.gif
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Fri Nov 03, 2006 2:12 am
Reply with quote

Thank you Frank!
I will read up on the Edit patterns.
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Fri Nov 03, 2006 2:35 am
Reply with quote

Frank,
How would you code the dfsort parameter if I gave you the following...
A specific record that I have to unpack to numeric edit fields looks like:


F012000013500000450002568
008C000024C000089C009990D

field 1= pic 9
field 2= pic s9(5) comp-3
field 3= pic s9(11)v99 comp-3
field 4= pic s9(11)v99 comp-3
field 5 = pic s9(11)v99 comp-3

and I would like the output to be lrecl=51
field 1 = 9
field 2 = 9(5)
field 3 = -(10)9.99
field 4 = -(10)9.99
field 5 = -(10)9.99

0 182 123.45 48.59 -295969.08


Thank-you!
Gayle
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: Fri Nov 03, 2006 3:46 am
Reply with quote

Gayle,

It's a little hard to tell what positions you want the output fields in and the output example you show has some of the numbers wrong vs the input, but hopefully the following DFSORT control statements will give you something close enough to play around with:

Code:

  OPTION COPY                                   
  INREC FIELDS=(1,1,2,3,PD,EDIT=(IIIIT),     
    5,7,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-),   
   12,7,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-),   
   19,7,PD,EDIT=(SIIIIIIIIIIT.TT),SIGNS=(,-))   


The output record would have:

Code:

0  182         123.45          84.95     -929596.08
Back to top
View user's profile Send private message
Gayle

New User


Joined: 04 Oct 2006
Posts: 11

PostPosted: Fri Nov 03, 2006 4:15 am
Reply with quote

Frank,
This helps alot!
Sorry about the confusion of the input and output fields.
I can follow your example and will play with my file.
Thank-you again! icon_smile.gif
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: Fri Nov 03, 2006 4:57 am
Reply with quote

Glad to help.
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 FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top