Page 1 of 1

Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 1:13 pm
by Papya013
Hi Team,

I have the input as mentioned below with LRECL as 430.

3111 252700 HEAD
3112 X1
3112 X2
3112 X3
3111 252800 HEAD
3112 Y1
3112 Y2
3112 Y3


I am looking for an output as mentioned below.

3111 252800 HEAD
3112 Y1
3112 Y2
3112 Y3



I have tried below mentioned SYSIN but seems to be deleting only occurrence of 3112.

//SYSIN    DD  *                                                      
  OPTION COPY                                                        
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=((1,3,PD,EQ,03111),                
                                        AND,(30,6,PD,EQ,00000252700)),
     END=(1,3,PD,EQ,03112),PUSH=(431:ID=1),HIT=NEXT)                  
     OUTFIL OMIT=(431,1,CH,NE,C' '),BUILD=(1,430)                    
/*    


Output that I have got is as mentioned below.

3112 X2
3112 X3
3111 252800 HEAD
3112 Y1
3112 Y2
3112 Y3


Please correct me. Thanks in advance.

Re: Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 1:50 pm
by NicC
What is wrong with posting in the correct part of the forum? Topic moved.

Re: Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 3:15 pm
by BillyBoyo
Your END is true for the first 3112, so that is what happens.

You need a limit for the group. If this is for a once-off, then make the END more specific or use RECORDS= to specify the exact number in the group.

For multiple runs, I'd code then END as like the BEGIN except the second condition reversed. Not that this will include the second header in the first group, so you'll need to cater for that.

Re: Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 3:24 pm
by Papya013
Hi, Thanks for your input.

But the records in the group may vary so RECORDS = nnn can't be used.

can you please show the syntax of putting this in place.
"I'd code then END as like the BEGIN except the second condition reversed. Not that this will include the second header in the first group, so you'll need to cater for that."

Re: Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 4:24 pm
by BillyBoyo
//SYSIN    DD  *                                                      
  OPTION COPY                                                        
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=((1,3,PD,EQ,03111),                
                                        AND,(30,6,PD,EQ,00000252700)),
     END=((1,3,PD,EQ,03111),AND,(30,6,PD,NE,00000252700)),PUSH=(431:ID=1)),
       IFTHEN=(WHEN=((1,3,PD,EQ,03111),AND,(30,6,PD,NE,00000252700)),
              OVERLAY=(431:C' '))                  
     OUTFIL OMIT=(431,1,CH,NE,C' '),BUILD=(1,430)                    
/*    


Something like that, untested and thought about only superficially.

Re: Removing Block of records using SORT

PostPosted: Fri Mar 11, 2016 4:52 pm
by Papya013
Excellent and Thanks a lot. Its working as expected.