On  Jan 17, 2005 Radoslaw Skorupka wrote:

>I have the following record layout:
>First_name; Last_name; text_data; year.
>
>The fields are variable in length, the record format VB. In fact the
>data are imported from PC world.
>
>I want to sort them by lastname, then by firstname.
>
>Is it possible to use DFSORT here ?

It is now with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006
(April, 2006).  Here's an example.

Let's assume the VB input records look like this:

RDW|Data
29 |Frank; Yaeger; abc; 2006.
37 |Radoslaw; Skorupka; cdefgh; 2006.
32 |Martin; Packer; ijklm; 2005.

We can use the following DFSORT job to extract the delimited fields into
fixed parsed fields, sort on them in the correct order, and remove them.

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN    DD    *
* Extract first from position 5 to before ; into %00 (16 bytes).
* Extract last from after ; to before next ; into %01 (16 bytes).
  INREC PARSE=(%00=(ENDBEFR=C';',FIXLEN=16),
               %01=(ENDBEFR=C';',FIXLEN=16)),
* Build temp. record as:
* |RDW|%01|%00|data|
        BUILD=(1,4,5:%01,21:%00,37:5)
* Sort on %01 and %00.
  SORT FIELDS=(5,32,CH,A)
* Remove %01 and %00.
  OUTREC BUILD=(1,4,37)
/*

SORTOUT will have the following VB records:

RDW|Data
32 |Martin; Packer; ijklm; 2005.
37 |Radoslaw; Skorupka; cdefgh; 2006.
29 |Frank; Yaeger; abc; 2006.

Note that you can also use Symbols for %00 and %01 to show what they
represent.  For example:

//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
* Parsed fields
First,%00
Last,%01
* Original record
RDW,1,4
Data,*
* Temp record
Tmp_RDW,1,4
Tmp_Last,*,16,CH
Tmp_First,*,16,CH
Tmp_Data,*
/*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN    DD    *
* Extract first from position 5 to before ; into First (16 bytes).
* Extract last from after ; to before next ; into Last (16 bytes).
  INREC PARSE=(First=(ENDBEFR=C';',FIXLEN=16),
               Last=(ENDBEFR=C';',FIXLEN=16)),
* Build temp. record as:
* |RDW|Last|First|Data|
        BUILD=(RDW,Last,First,Data)
* Sort on Last and First.
  SORT FIELDS=(Tmp_Last,A,Tmp_First,A)
* Remove Last and First.
  OUTREC BUILD=(RDW,Tmp_Data)
/*

Frank Yaeger - DFSORT Team (IBM)
 Specialties: PARSE, JFY, SQZ, ICETOOL, IFTHEN, OVERLAY, Symbols, Migration

 => DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to