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

Replace least value for a particular selection


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

New User


Joined: 24 May 2006
Posts: 7

PostPosted: Thu Aug 12, 2010 7:32 pm
Reply with quote

Hello experts,

We use product DFSORT at our installation and I'm assuming that its quite possible through it.

I have the following input file

Code:

0000000000111111
1223456789123456
----------------
IDEN  DATE  REST
----------------
ABCD20100810X111
ABCD20100811Y111
ABCD20100710Z111
ZGFG20100810R111
ABCD20100110R111
XXXX20100810R111
YYYY20100810R111
YYYY20100710R111



I would like to put the least value of DATE (Colum 5-13) in all records containing similar IDEN(colum 1 - 4 ).
Further more I would like to make this change only for IDEN=ABCD

The output file should be like this

Code:

ABCD20100110R111
ABCD20100110X111
ABCD20100110Y111
ABCD20100110Z111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111



Many thanks in advance

Saran
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Aug 12, 2010 7:42 pm
Reply with quote

Saran,
What is the LRECL and RECFM of the input file? Is this already sorted by IDEN(colum 1 - 4 )?

Thanks,
Back to top
View user's profile Send private message
saranyan_j

New User


Joined: 24 May 2006
Posts: 7

PostPosted: Thu Aug 12, 2010 8:20 pm
Reply with quote

The file is FB with LREC of 16. It is not sorted by IDEN.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Aug 12, 2010 9:14 pm
Reply with quote

saranyan_j

Because your input is not already sorted and you want final output sorted by 12-16 ASC as well (or atleast that's what you show). I can't think of a solution with single pass.

Code:
//STEP01 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
ABCD20100810X111                                                   
ABCD20100811Y111                                                   
ABCD20100710Z111                                                   
ZGFG20100810R111                                                   
ABCD20100110R111                                                   
XXXX20100810R111                                                   
YYYY20100810R111                                                   
YYYY20100710R111                                                   
/*                                                                 
//SORTOUT  DD DSN=&&TEMP,DISP=(,PASS),SPACE=(CYL,(5,5),RLSE)       
//SYSIN    DD *                                                   
 SORT FIELDS=(1,4,CH,A,5,8,CH,A)                                   
 OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,8,ZD,RESTART=(1,4))),
        IFTHEN=(WHEN=GROUP,BEGIN=(17,8,ZD,EQ,1),PUSH=(25:5,8))     
 OUTFIL IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),                         
                BUILD=(1,4,25,8,13,4)),                           
        IFTHEN=(WHEN=NONE,                                         
                BUILD=(1,16))                                     
/*                                                                 
//STEP02 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&TEMP,DISP=SHR                                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
 SORT FIELDS=(1,16,CH,A)                                           
/*                                                                 


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 Aug 12, 2010 11:26 pm
Reply with quote

Saran,

Here's an easier way to do what you asked for with DFSORT:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/16)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(1,4,CH,EQ,C'ABCD')
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
    TRAILER1=('TARG,''',MIN=(5,8,ZD,TO=ZD,LENGTH=8),'''')
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file1 (FB/16)
//SORTOUT DD DSN=...  output file (FB/16)
//SYSIN DD *
  INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),
    OVERLAY=(5:TARG))
  SORT FIELDS=(1,16,CH,A),EQUALS
/*

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

Senior Member


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

PostPosted: Fri Aug 13, 2010 12:02 am
Reply with quote

Unless I am missing something, can't it be done in just 1 pass?

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
ABCD20100810X111                                                 
ABCD20100811Y111                                                 
ABCD20100710Z111                                                 
ZGFG20100810R111                                                 
ABCD20100110R111                                                 
XXXX20100810R111                                                 
YYYY20100810R111                                                 
YYYY20100710R111                                                 
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=(1,16,CH,A),EQUALS                                 
  OUTREC IFOUTLEN=16,                                           
  IFTHEN=(WHEN=INIT,OVERLAY=(17:SEQNUM,8,ZD,RESTART=(1,4))),     
  IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'ABCD',AND,17,8,ZD,EQ,1),
    END=(1,4,CH,NE,C'ABCD'),PUSH=(26:5,8)),                     
  IFTHEN=(WHEN=(1,4,CH,EQ,C'ABCD'),OVERLAY=(5:26,8))             
//*
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Aug 13, 2010 12:15 am
Reply with quote

Kolusu,
I ran your job and got below output but OP's expected output was sorted on last 4 bytes as well. That's why I thought of another pass to resort the file.

SINGLE PASS OUTPUT
Code:

ABCD20100110R111
ABCD20100110Z111
ABCD20100110X111
ABCD20100110Y111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111


OP's expected output was
Code:
ABCD20100110R111
ABCD20100110X111  --> THIS APPEARS 3RD IN SINGLE PASS SOL.
ABCD20100110Y111  --> THIS APPEARS 4TH IN SINGLE PASS SOL.
ABCD20100110Z111
XXXX20100810R111
YYYY20100710R111
YYYY20100810R111
ZGFG20100810R111



Thanks,
Back to top
View user's profile Send private message
saranyan_j

New User


Joined: 24 May 2006
Posts: 7

PostPosted: Fri Aug 13, 2010 2:39 pm
Reply with quote

Dear Experts,

Thanks again for your reply, all the above worked just fine.

Howevere I opted to use the one with the single pass since the order of records in the O/P were not important.

Thx,
Saran
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts To replace jobname in a file with ano... SYNCSORT 12
No new posts Conditional replace values in output ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top