MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

remove a part (with same key) from the Dataset

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
hungerbuehler
Beginner


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Sun Mar 25, 2007 1:00 pm    Post subject: remove a part (with same key) from the Dataset Reply with quote

Hi all,

I m trying to remove the first record-block with the same key. The key changes with every job-run.
The key is in the digits 1-4. But the key changes every job-run. I need only the records from the first key-value.

An example:

I have one input-file:
Code:


1000 header1
1000 text1
1000 text2
1000 text3
2000 header1
2000 text1
2000 text2
2000 text3
2000 text4
3000 header1
3000 text1
3000 text2
4000 header1
4000 text1
4000 text2
4000 text3
4000 text4
4000 text5


Output1 should be:
Code:

1000 header1
1000 text1
1000 text2
1000 text3


Output2 should be:
Code:

2000 header1
2000 text1
2000 text2
2000 text3
2000 text4
3000 header1
3000 text1
3000 text2
4000 header1
4000 text1
4000 text2
4000 text3
4000 text4
4000 text5


Is this possible with dfsort or icetool?


thank you very much in advance

hungerbuehler
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Mar 25, 2007 6:44 pm    Post subject: Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//OUT1 DD DSN=...  output file1 (FB/80)
//OUT2 DD DSN=...  output file2 (FB/80)
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(6,7,CH,EQ,C'header1'),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTFIL FNAMES=OUT1,INCLUDE=(81,8,ZD,EQ,+1),
    BUILD=(1,80)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hungerbuehler
Beginner


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Mon Mar 26, 2007 6:42 am    Post subject: Reply with quote

Many many thanks. It works fantastic.
It was a very good idea with the seqnum.

Today i saw following test-cases:

There are several header-lines for a block.

An example:
Inputfile:
Code:

1000 header1
1000 header1
1000 header1
1000 text1
1000 text2
1000 text3
2000 header1
2000 text1
2000 text2
2000 text3
2000 text4
3000 header1
3000 header1
3000 text1
3000 text2
4000 header1
4000 header1
4000 header1
4000 text1
4000 text2
4000 text3
4000 text4
4000 text5


Output1 should be:

Code:

1000 header1
1000 header1
1000 header1
1000 text1
1000 text2
1000 text3


Output2 should be:

Code:

2000 header1
2000 text1
2000 text2
2000 text3
2000 text4
3000 header1
3000 header1
3000 text1
3000 text2
4000 header1
4000 header1
4000 header1
4000 text1
4000 text2
4000 text3
4000 text4
4000 text5


I tried much, but I do not have a success.

thank you very much in advance

hungerbuehler
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Mon Mar 26, 2007 8:02 am    Post subject: Reply with quote

Here is Frank's jcl modified a bit :
Code:

//STEP0001 EXEC PGM=ICETOOL
//DFSMSG   DD SYSOUT=*
//TOOLMSG  DD SYSOUT=*
//TOOLIN   DD *
  COPY FROM(IN) USING(ICE0)
/*
//IN       DD *
1000 HEADER1
1000 HEADER1
1000 HEADER1
1000 TEXT1
1000 TEXT2
1000 TEXT3
2000 HEADER1
2000 TEXT1
2000 TEXT2
2000 TEXT3
2000 TEXT4
3000 HEADER1
3000 HEADER1
3000 TEXT1
3000 TEXT2
4000 HEADER1
4000 HEADER1
4000 HEADER1
4000 TEXT1
4000 TEXT2
4000 TEXT3
4000 TEXT4
4000 TEXT5
/*
//OUTX     DD SYSOUT=*
//OUTY     DD SYSOUT=*
//ICE0CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
                OVERLAY=(81:SEQNUM,5,ZD,
                         86:SEQNUM,5,ZD,RESTART=(1,4),
                         81:81,5,ZD,SUB,86,5,ZD,M11,LENGTH=5))
  OUTFIL FNAMES=OUTX,
         INCLUDE=(81,8,ZD,EQ,+0),
         BUILD=(1,80)
  OUTFIL FNAMES=OUTY,
         SAVE,
         BUILD=(1,80)


If you are picky about using ICETOOL then use this

Code:

//STEP0001 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
1000 HEADER1
1000 HEADER1
1000 HEADER1
1000 TEXT1
1000 TEXT2
1000 TEXT3
2000 HEADER1
2000 TEXT1
2000 TEXT2
2000 TEXT3
2000 TEXT4
3000 HEADER1
3000 HEADER1
3000 TEXT1
3000 TEXT2
4000 HEADER1
4000 HEADER1
4000 HEADER1
4000 TEXT1
4000 TEXT2
4000 TEXT3
4000 TEXT4
4000 TEXT5
/*
//OUTX     DD SYSOUT=*
//OUTY     DD SYSOUT=*
//SYSIN    DD *
  SORT FIELDS=COPY
  INREC IFTHEN=(WHEN=INIT,
                OVERLAY=(81:SEQNUM,5,ZD,
                         86:SEQNUM,5,ZD,RESTART=(1,4),
                         81:81,5,ZD,SUB,86,5,ZD,M11,LENGTH=5))
  OUTFIL FNAMES=OUTX,
         INCLUDE=(81,8,ZD,EQ,+0),
         BUILD=(1,80)
  OUTFIL FNAMES=OUTY,
         SAVE,
         BUILD=(1,80)
 
/*


Alain
Back to top
View user's profile Send private message
hungerbuehler
Beginner


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Tue Mar 27, 2007 11:21 pm    Post subject: Reply with quote

Many thanks for your help. It works perfect.

DFSORT and this forum are great!

Best regards

hungerbuehler
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Wed Mar 28, 2007 5:24 am    Post subject: Reply with quote

Instead of
Code:

INCLUDE=(81,8,ZD,EQ,+0),


it should be replaced per
Quote:

INCLUDE=(81,5,ZD,EQ,+0),


Alain
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group