Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Remove duplicate record with condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rajiv rengasamy

New User


Joined: 24 Sep 2008
Posts: 18
Location: Chennai

PostPosted: Wed Jul 11, 2018 3:55 pm    Post subject: Remove duplicate record with condition
Reply with quote

Hello All,
I have an input file of fixed length 300 characters, my activity is focused on two fields Order number and status code.

Code:
Order number                                    status code
(Position 25, length 7 characters)       (Position 102, length 3 characters)
Order1                                              020
Order1                                              025
Order2                                              020
Order3                                              025
Order4                                              020
Order4                                              025


If there are two records with same order number then I want to remove the record having status code “025”.So the output file should look like the below

Code:
Order number                                    status code
(Position 25, length 7 characters)        (Position 102, length 3 characters)
Order1                                              020
Order2                                              020
Order3                                              025
Order4                                              020


Note the input file is pre-sorted on order number and status code.
I tried few Sort options, but it was removing the first record which is associated with status code “020”.Any help is appreciated.

Regards,
Rajiv R

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

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8714
Location: Welsh Wales

PostPosted: Wed Jul 11, 2018 3:59 pm    Post subject:
Reply with quote

Please show the code that you have used and did not give the required results.

Will there only ever be two records for each order, or more
Back to top
View user's profile Send private message
rajiv rengasamy

New User


Joined: 24 Sep 2008
Posts: 18
Location: Chennai

PostPosted: Wed Jul 11, 2018 4:38 pm    Post subject:
Reply with quote

Yes your correct there can be only maximum two records with same order number, one with status code 020 and other with status code 025,of which the record with status code 025 needs to be removed.


Sorry i was testing with the presorted file,that's the reason it was deleting the record with status code 020.
I tried using sorted file and gives desired result.

The below are options i used

1) Option 1
Code:

//S2      EXEC PGM=ICEMAN
//SYSOUT  DD   SYSOUT=*
//SORTIN  DD   DSN=racfid.TEST.FCAST.UNSOLVD,DISP=SHR
//SORTOUT DD   DSN=racfid.TEST.FCAST.UNSOLVD.SORTED.ICEMAN,
//             DISP=(,CATLG),
//             SPACE=(CYL,(500,500),RLSE),
//             RECFM=FB,
//             LRECL=300
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(301:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(102,3,CH,EQ,C'025'),OVERLAY=(301:8C'0'))
  SORT FIELDS=(25,7,CH,A)
  SUM FIELDS=NONE
  OUTREC FIELDS=(1,300)
/*

2)Option 2:
Code:

//S3      EXEC PGM=SORT
//SYSOUT  DD   SYSOUT=*
//SORTIN  DD   DSN=racfid.TEST.FCAST.UNSOLVD.SORTED,DISP=SHR
//SORTOUT DD   DSN=racfid.TEST.FCAST.UNSOLVD.SORTED.SORT,
//             DISP=(,CATLG),
//             SPACE=(CYL,(500,500),RLSE),
//             RECFM=FB,
//             LRECL=300
//SYSIN    DD    *
  SORT FIELDS=(25,7,CH,A)
  SUM FIELDS=NONE
/*


3) Option 3:
Code:

//S4    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN      DD DSN=racfid.TEST.FCAST.UNSOLVD.SORTED,DISP=SHR
//FIRST   DD DSN=racfid.TEST.FCAST.UNSOLVD.SORTED.NODUP,
//         DISP=(,CATLG),
//         SPACE=(CYL,(500,500),RLSE),
//         RECFM=FB,
//         LRECL=300
//REST    DD DSN=racfid.TEST.FCAST.UNSOLVD.SORTED.DUP,
//         DISP=(,CATLG),
//         SPACE=(CYL,(500,500),RLSE),
//         RECFM=FB,
//         LRECL=300
//TOOLIN DD *
SELECT FROM(IN) TO(FIRST) ON(25,7,CH) FIRST DISCARD(REST)
/*

In all three options it worked fine,only i was using the presorted input file.
Thank you so much for intention to help.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8714
Location: Welsh Wales

PostPosted: Wed Jul 11, 2018 5:12 pm    Post subject:
Reply with quote

Here's a quick snippet of code that may help you, NOT tailored to your needs because I'm busy right now, but may help you out

Use EXCLUDE instead of INCLUDE, also might work in conjunction with your writing 8 x 0 at pos 301
Code:

  OPTION  VLSHRT VLSCMP
  SORT    FIELDS=(29,44,A),FORMAT=CH
  OUTFIL  INCLUDE=(9,2,CH,EQ,C'M ',AND,
                29,44,SS,EQ,C'AB.L00T304A.LABEL'),
          OUTREC=(1,4,29,44,1X,233,6)


Good luck
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2407
Location: @my desk

PostPosted: Wed Jul 11, 2018 10:10 pm    Post subject:
Reply with quote

If the file is already sorted on the 2 fields, you may not need to sort it again.

You could use a COPY override in your Option3. Or something like this in your Options1/2. [UNTESTED]
Code:
//SYSIN    DD *
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(25,7),
        PUSH=(301:SEQ=1))
  SORT FIELDS=COPY
  OUTFIL INCLUDE=(301,1,ZD,EQ,1),BUILD=(1,301)
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 SYNCSORT keep MIN/MAX record Cloink SYNCSORT 16 Mon Sep 17, 2018 3:00 pm
No new posts Remove selected duplicate rows from t... hnharish DFSORT/ICETOOL 3 Wed Sep 05, 2018 3:11 am
No new posts Sort card to find duplicates, without... anand1204 DFSORT/ICETOOL 15 Fri Aug 31, 2018 12:13 am
No new posts Splitting one record in a file to 10 ... mf_123 DFSORT/ICETOOL 9 Tue Aug 21, 2018 8:51 pm
This topic is locked: you cannot edit posts or make replies. remove the gap b/w 2 fields shymala COBOL Programming 5 Thu Aug 02, 2018 12:05 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us