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

Need help in sorting the file correctly


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

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Wed Apr 29, 2009 8:53 am
Reply with quote

Here is my input with VB
Code:
FDXDB01 INIT0019NNYYNNNNNNNNNNNNNNN
FDXDB01 XYZ10012.00050.QSAM.
FDXDB01 XYZ10017.101913.ICICI.
FDXDB01 XYZ10016.104.PRUDENTIAL.
FDXDB01 XYZ10014.107661.UFXYZFGIS.
FDXDB01 XYZ10014.108225.FOTYTRYIL.
FDXDB01 XYZ10021.153.BANK OF BARODA.
FDXDB01 XYZ10019.161.MXXXXX LYYYYY.
FDXDB01 XYZ10020.164.CKJIFT SCHWAB.
FDXDB01 XYZ10020.19.JEXXTRES & CO..
FDXDB01 XYZ10014.109947.AMCO.
FDXDB01 XYZ10020.8.SOCIETE CAPT.


I am using the following control card to format it

Code:
OPTION COPY
INCLUDE COND=(13,4,CH,NE,C'INIT')
INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=X'05',FIXLEN=16),
       %02=(ENDBEFR=X'05',FIXLEN=09),
       %03=(ENDBEFR=X'05',FIXLEN=27)),
    BUILD=(1,4,
        5:%02,
       14:%03,
       84:X)
 OUTFIL VTOF,BUILD=(5,80)


In the next step, sorting using the below control card

Code:
SORT FIELDS=(1,09,CH,A)
SUM FIELDS=NONE


Below is the output i am getting which is incorrect . The first 9 bytes are not in ascending.
Code:

00050    QSAM
101913   ICICI
104      PRUDENTIAL
107661   UFXYZFGIS
108225   FOYIL
109947   REFCO
153      BANK OF BARODA
161      MXXXXX LYYYYY
164      CKJIFT SCHWAB
19       JEXXTRES & CO.
8        SOCIETE CAPT
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 29, 2009 9:24 am
Reply with quote

Hello,

Quote:
The first 9 bytes are not in ascending.
Yes, actually, they are. When CH fields are sorted it is an alphanumeric sort, not a numeric sort. Alphanumerics are sorted from the left.

Can the number ever be negative?
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 Apr 29, 2009 8:54 pm
Reply with quote

suyerasi,

You can use DFSORT's UFF format to get what you want.

Code:

  SORT FIELDS=(1,09,UFF,A)
  SUM FIELDS=NONE         


The output for your input example is:

Code:

8        SOCIETE CAPT         
19       JEXXTRES & CO.       
00050    QSAM                 
104      PRUDENTIAL           
153      BANK OF BARODA       
161      MXXXXX LYYYYY         
164      CKJIFT SCHWAB         
101913   ICICI                 
107661   UFXYZFGIS             
108225   FOYIL                 
109947   REFCO                 
Back to top
View user's profile Send private message
suyerasi

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Wed Apr 29, 2009 9:32 pm
Reply with quote

Dear Frank,

Thanks for your reply . Instead of having 2 sort steps (first step for formatting & the next step to sort on key field & remove duplicates ) , i would like to have one sort control card

First step control cards

Code:

  OPTION COPY
  INCLUDE COND=(13,4,CH,NE,C'INIT')
  INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=X'05',FIXLEN=16),
       %02=(ENDBEFR=X'05',FIXLEN=09),
       %03=(ENDBEFR=X'05',FIXLEN=27)),
    BUILD=(1,4,
        5:%02,
       14:%03,
       84:X)
  OUTFIL VTOF,BUILD=(5,80)


Second step cntrol cards
Code:

  SORT FIELDS=(1,09,CH,A) 
  SUM FIELDS=NONE


Please help me to include them in a single control card
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Apr 29, 2009 9:48 pm
Reply with quote

suyerasi,

Use the following control cards

Code:

//SYSIN    DD *                                       
  INCLUDE COND=(13,4,CH,NE,C'INIT')                   
  INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=X'05',FIXLEN=16),
               %02=(ENDBEFR=X'05',FIXLEN=09),         
               %03=(ENDBEFR=X'05',FIXLEN=27)),       
        BUILD=(01,4,                                 
               05:%02,                               
               14:%03)                               
  SORT FIELDS=(5,9,UFF,A)                             
  SUM FIELDS=NONE                                     
  OUTFIL VTOF,BUILD=(5,36,80:X)                       
/*                                                   
Back to top
View user's profile Send private message
suyerasi

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Thu Apr 30, 2009 9:50 am
Reply with quote

Dear Kolusu,

Thanks for your reply . But it does not remove the duplicates..


Regards
Back to top
View user's profile Send private message
suyerasi

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Thu Apr 30, 2009 8:07 pm
Reply with quote

Dear Frank/Kolusu,

Please let me know while formatting the file , Is it possible to sort the file on key fields as mentioned by Kolusu in the above example.?

When i add sort control card for sorting & eliminating the duplicates to the existing control statements, the output is not being shown in sorted order .

Please correct me

Regards
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Apr 30, 2009 8:41 pm
Reply with quote

suyerasi,

*Sigh* The above code shown by me DOES remove the duplicates. Did you code it as is? The sort fields is at pos 5 instead of pos 1. Did you notice that? or are you still using the old sort card?

just for my sanity check I did add a duplicate

Quote:

FDXDB01 INIT0019NNYYNNNNNNNNNNNNNNN
FDXDB01 XYZ10012 00050 QSAM
FDXDB01 XYZ10017 101913 ICICI
FDXDB01 XYZ10016 104 PRUDENTIAL
FDXDB01 XYZ10016 104 PRUDENTIAL
FDXDB01 XYZ10014 107661 UFXYZFGIS
FDXDB01 XYZ10014 108225 FOTYTRYIL
FDXDB01 XYZ10021 153 BANK OF BARODA
FDXDB01 XYZ10019 161 MXXXXX LYYYYY
FDXDB01 XYZ10020 164 CKJIFT SCHWAB
FDXDB01 XYZ10020 19 JEXXTRES & CO
FDXDB01 XYZ10014 109947 AMCO
FDXDB01 XYZ10020 8 SOCIETE CAPT


and it is indeed eliminated when I use the exact same control cards I posted.

If you say it is not working I need to see the complete sysout from the job.
Back to top
View user's profile Send private message
suyerasi

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Thu Apr 30, 2009 10:33 pm
Reply with quote

Dear Kolusu,

I added the below records to the input

Code:
FDXDB01 BROK0023,BLOAN,BXXX LOANS/DEBT
FDXDB01 BROK0021,GNPA,GAPA GENERATOR,


Since the key of the above records is alphabetic, the sorted output should show these records in the beginning of the output . But in my output they are being shown at the end .

8 SOCIETE CAPT
BLOAN BANK LOANS/DEBT
GNMA GAPA GENERATOR
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Apr 30, 2009 10:54 pm
Reply with quote

suyerasi,

You are one talking about a completely different issue. Your first question was about removing duplicates. Was that resolved?

You never mentioned that you have Alpha-numeric data till now. The first posts show that you have all numeric data and we showed a sort card using UFF format to get what you want.

You need to explain all your rules clearly and show sample input and desired output.
Back to top
View user's profile Send private message
suyerasi

New User


Joined: 05 Apr 2007
Posts: 38
Location: india

PostPosted: Thu Apr 30, 2009 11:12 pm
Reply with quote

Dear Kolusu,
Sorry about that . In fact duplicates were eliminated ..

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: Thu Apr 30, 2009 11:33 pm
Reply with quote

suyerasi,

UFF treats an all alphabetic field as 0 so the alphabetic fields would sort before the numeric fields.

You can't use UFF to sort both numeric and alphabetic fields. Instead we can identify the numeric fields, insert leading zeros in them, and then sort them along with the alphabetics using CH. It's a bit tricky but you can use these DFSORT control statements to do what you asked for:

Code:

  INCLUDE COND=(13,4,CH,NE,C'INIT')                           
  INREC IFTHEN=(WHEN=INIT,                                     
     PARSE=(%=(ABSPOS=5,ENDBEFR=X'05',FIXLEN=16),             
               %02=(ENDBEFR=X'05',FIXLEN=09),                 
               %03=(ENDBEFR=X'05',FIXLEN=27)),                 
        BUILD=(1,4,                                           
               5:%02,                                         
               14:%03,                                         
               41:%02,                                         
               50:%02)),                                       
   IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=50,ENDPOS=59,           
    IN=C' ',OUT=C'0')),                                       
   IFTHEN=(WHEN=(50,9,FS,EQ,NUM),                             
     OVERLAY=(41:41,9,UFF,TO=ZD,LENGTH=9))                     
  SORT FIELDS=(41,9,CH,A)                                     
  SUM FIELDS=NONE                                             
  OUTFIL VTOF,BUILD=(5,36,80:X)                               
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 8
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