MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DF Sort : Copy file eliminating the spaces and adjust output

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Satish
Beginner


Joined: 26 Dec 2002
Posts: 7
Topics: 3

PostPosted: Thu Mar 23, 2006 2:35 pm    Post subject: DF Sort : Copy file eliminating the spaces and adjust output Reply with quote

Hi,

We have DF Sort/ICETOOl in our system and looking for some help for the following scenario using the DF Sort/ICETOOl.


We have many fixed length, comma separated sequential files.
Some of the fields in the fixed length files are spcaes or partially spaces.

We are looking for your expertise help to remove the sapces from the fields and create a new output file which is of different length after eliminating the sapces from fields.

Below are the exmaples of what we have as inputs and what is expected in the outputs.

All Input files are of Fixed length 23 Bytes. The second and third fields are of different size in each of the input and we do not know the length of this field. But each field is comma separated.

The output files should be as shown below and of different length. The length of output file should be decided dynamically after removing the spaces from 3rd field.



Code:
Input File #1
-------------

abc,12346,       02,xyz
pqr,12678,       06,x12
jhg,98798,       09,ui8

Input File #2
-------------

abc,12346567,    02,xyz
pqr,12672345,    06,x12
jhg,98778908,    09,ui8


Input File #3
-------------

abc,123,         02,xyz
pqr,126,         06,x12
jhg,987,         09,ui8


Output file #1
--------------
abc,12346,02,xyz
pqr,12678,06,x12
jhg,98798,09,ui8


Output file #2
--------------

abc,12346567,02,xyz
pqr,12672345,06,x12
jhg,98778908,09,ui8


Output file #3
--------------

abc,123,02,xyz
pqr,126,06,x12
jhg,987,09,ui8


Looking for your expertise
Thank you in advance
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Mar 23, 2006 3:30 pm    Post subject: Reply with quote

DFSORT does not have any built-in functions for doing that kind of thing.

But depending on how many variations you have and what they look like, you may be able to use a variation of the "Find and extract values from different positions" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Mon Sep 04, 2006 11:51 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Satish
Beginner


Joined: 26 Dec 2002
Posts: 7
Topics: 3

PostPosted: Thu Mar 23, 2006 4:49 pm    Post subject: Reply with quote

Thank for your prompt Response Frank

Satish
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Apr 27, 2006 5:11 pm    Post subject: Reply with quote

You can now use the new SQZ function available with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) to do this kind of thing. Squeezing out the blanks is easy with SQZ. The tricky part here is setting the output LRECL to the length of the non-blank characters. Here's the DFSORT/ICETOOL job:

Code:

//STEP1 EXEC  PGM=ICETOOL
//TOOLMSG DD  SYSOUT=*
//DFSMSG DD  SYSOUT=*
//IN DD DSN=...  input file (FB/23)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//TOOLIN  DD    *
COPY FROM(IN) USING(CTL1)
COPY FROM(T2) USING(CTL2)
//CTL1CNTL DD *
* Squeeze out the blanks
  INREC BUILD=(1,23,SQZ=(SHIFT=LEFT))
* Copy compressed records to T1
  OUTFIL FNAMES=T1
* Convert first record to VB to get RDW length.
  OUTFIL FNAMES=T2,FTOV,VLTRIM=C' ',ENDREC=1
//CTL2CNTL DD *
* Create a DFSORT symbol as:
* outrcd,1,n
* where n is rdw length - 4 = output lrecl length
  OUTFIL FNAMES=S1,VTOF,BUILD=(C'outrcd,1,',
    1,2,BI,SUB,+4,TO=ZD,LENGTH=5,80:X)
/*
//STEP2 EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Copy T1 to SORTOUT.  Use the outrcd symbol to set the
* LRECL for SORTOUT.
  OPTION COPY
  OUTREC BUILD=(outrcd)
/*


For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group