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

Copy a selected number of records from a part record value


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

New User


Joined: 07 Nov 2007
Posts: 27
Location: Mumbai

PostPosted: Thu Dec 13, 2007 9:06 pm
Reply with quote

Hi,

Can any one tell how can i copy selected number of records from particular record value(not the row number of record value) .. for example.

My input:

---
---
---
---
---
----
000004 ( i dont know the exact line number of this record)
000002
342354
856578
563456
567456
968567
546566


My out put should be

856578
563456
567456


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

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Dec 13, 2007 10:14 pm
Reply with quote

Code:
//*******************************************************
//STEP1    EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
000004                                                   
000002                                                   
342354                                                   
856578                                                   
563456                                                   
567456                                                   
968567                                                   
546566                                                   
/*                                                       
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  INCLUDE COND=(1,6,ZD,EQ,856578,|,                     
                1,6,ZD,EQ,567456,|,                     
                1,6,ZD,EQ,563456)                       
  SORT FIELDS=COPY                                       
/*                                                       


SORTOUT:
Code:
856578
563456
567456
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Dec 13, 2007 10:16 pm
Reply with quote

also this SORT card could be used
Code:
//SYSIN    DD *                                   
  INCLUDE COND=(1,6,SS,EQ,C'856578,567456,563456')
  SORT FIELDS=COPY                                 
/*                                                 
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 Dec 13, 2007 11:40 pm
Reply with quote

Quote:
Can any one tell how can i copy selected number of records from particular record value(not the row number of record value) .. for example.


I don't understand what you mean by this or how it relates to your example. Krisprems assumed you just wanted to select records with particular values, but that doesn't seem to match this description.

If Krisprems hasn't guessed right, then you need to explain more clearly the rules for getting from input to output and how they apply to the example you showed.
Back to top
View user's profile Send private message
Uday Kumar R

New User


Joined: 07 Nov 2007
Posts: 27
Location: Mumbai

PostPosted: Fri Dec 14, 2007 2:43 pm
Reply with quote

Hi,

I thankful for you all to give your precious time.

Hi Frank,

May be my examples leads Krisprems to a wrong direction. May be I have to describe the problem in more clear manner. Here it is...


Say suppose a file consist of 1 million entries with no duplicates. I want to put 20000 sequential entries from this file to a new file, starting from the entry whose value matches with <XXXXXX>. So from this point of entry i want to copy the next 19999 entries into a output file. For example....


...........
...........
...........
...........
...........
...........
xxxxxxx ( Do not know the exact line number of xxxxxx entry)
300000 The next 19999 entries starting from the entry value (xxxxxxx) to be in my output file...
452345
674567
467567
454546
...........
...........
...........
...........
...........
...........



Output;

xxxxxxx
300000
452345
674567
467567
454546 plus the remaing entries until the count is 20000 ....


Since i donot know the row value of xxxxxxx, i am unable to use STARTREC in the sort input paramets.

I hope this will give more insight into my problem.

Regards,
Uday
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Dec 14, 2007 4:17 pm
Reply with quote

Try this ICETOOL solution
Code:
//*******************************************************             
//STEP001  EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN1      DD *                                                       
......                                                                 
......                                                                 
......                                                                 
......                                                                 
XXXXXX                                                                 
300000                                                                 
452345                                                                 
674567                                                                 
467567                                                                 
454546                                                                 
/*                                                                     
//TMP1     DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
 COPY FROM(IN1)  TO(OUT) USING(CP01)                                   
/*                                                                     
//CP01CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(93:SEQNUM,8,ZD)),         
        IFTHEN=(WHEN=(1,1,CH,EQ,C'XXXXXX'),                   
                OVERLAY=(93:SEQNUM,8,ZD)),                   
        IFTHEN=(WHEN=NONE,                                   
                OVERLAY=(101:SEQNUM,8,ZD,                     
                         93:93,8,ZD,SUB,101,8,ZD,M11,LENGTH=8,
                         101:SEQNUM,8,ZD,RESTART=(93,8)))     
 OUTFIL REMOVECC,INCLUDE=(93,8,ZD,EQ,1,&,101,8,ZD,LE,20000), 
 BUILD=(1,80)                                                 
/*                                                           


OUT
Code:
XXXXXX
300000
452345
674567
467567
454546
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: Fri Dec 14, 2007 10:36 pm
Reply with quote

Krisprems is on the right track, but his solution gives one too many records and is a bit "off" in other ways. Here's a correct DFSORT/ICETOOL job. I assumed the input file has RECFM=FB and LRECL=80, but the job can be changed for other attributes.

Code:

//STEP001  EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN1      DD DSN=...  input file (FB/80)
//OUT      DD DSN=...  output file (FB/80)
//TOOLIN   DD *
COPY FROM(IN1) USING(CP01)
//CP01CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,6,CH,EQ,C'XXXXXX'),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8,
                         89:SEQNUM,8,ZD,RESTART=(81,8)))
  OUTFIL FNAMES=OUT,
   INCLUDE=(81,8,ZD,EQ,1,AND,(89,8,CH,EQ,C' ',OR,89,8,ZD,LE,+19999)),
   BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Uday Kumar R

New User


Joined: 07 Nov 2007
Posts: 27
Location: Mumbai

PostPosted: Mon Dec 17, 2007 5:22 pm
Reply with quote

Hi,

Thankyou kRISPREM & Frank for your detail explanation.

Regards
Uday
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 Sep 04, 2008 11:42 pm
Reply with quote

You can now do this more easily using the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1   EXEC  PGM=ICEMAN
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD DSN=...  input file (FB/80)
//SORTOUT  DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'XXXXXX'),
    RECORDS=20000,PUSH=(81:ID=1))
  OUTFIL INCLUDE=(81,1,CH,EQ,C'1'),BUILD=(1,80)
/*


For complete details on the new WHEN=GROUP function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top