DF Sort : Copy file eliminating the spaces and adjust output
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: DF Sort : Copy file eliminating the spaces and adjust output Author: Satish PostPosted: Thu Mar 23, 2006 2:35 pm
    —
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

#2:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Mar 23, 2006 3:30 pm
    —
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/


Last edited by Frank Yaeger on Mon Sep 04, 2006 11:51 am; edited 1 time in total

#3:  Author: Satish PostPosted: Thu Mar 23, 2006 4:49 pm
    —
Thank for your prompt Response Frank

Satish

#4:  Author: Frank YaegerLocation: San Jose PostPosted: Thu Apr 27, 2006 5:11 pm
    —
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/



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group