Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replace least value for a particular selection

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Replace least value for a particular selection
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: 578
Location: USA

PostPosted: Thu Aug 12, 2010 7:42 pm    Post subject:
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    Post subject:
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: 578
Location: USA

PostPosted: Thu Aug 12, 2010 9:14 pm    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Aug 12, 2010 11:26 pm    Post subject:
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    Post subject: Reply to: Replace least value for a particular selection
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: 578
Location: USA

PostPosted: Fri Aug 13, 2010 12:15 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us