Page 1 of 1

When=Group - How to exclude a group of records

PostPosted: Thu Mar 12, 2020 1:33 pm
by gyt3
Hi All,

This is my input file and my requirement is to exclude the group that starts with <Request> and ends with </Request> having Event=Payment.
Input is FB file of LRECL : 400

<Report>
<Requests>
<Request RequestID="5803727242796658404053">
<BillTo>
<CustomerID/>
</BillTo>
<PaymentMethod>
<TypeDescription>Checking</TypeDescription>
</PaymentMethod>
<Events>
<Event>Stop Payment</Event>
<EventDate>2020-01-31T16:00:00Z</EventDate>
</Events>
</Request>
<Request RequestID="5803727242796658404053">
<BillTo>
<CustomerID/>
</BillTo>
<PaymentMethod>
<TypeDescription>Checking</TypeDescription>
</PaymentMethod>
<Events>
<Event>Payment</Event>
<EventDate>2020-01-31T16:00:00Z</EventDate>
</Events>
</Request>
</Requests>
</Report>

I tried the following sort card

OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,9,CH,EQ,C'<Request '),
RECORDS=31,PUSH=(401:ID=1)),
IFTHEN=(WHEN=GROUP,BEGIN=(8,7,CH,EQ,C'Payment'),
RECORDS=13,PUSH=(403:SEQ=1)),
IFTHEN=(WHEN=NONE,OVERLAY=(401:C'1'))
OUTFIL INCLUDE=(401,1,CH,NE,C' ',AND,403,1,CH,EQ,C' '),
BUILD(1,400)

This sort card is removing only the group that starts with Payment in the second xml , but I want to remove the entire XML starting from <Request> if that has Payment in Event tag.
I have been breaking my head on this for the past 3 days and I tried several things, but nothing helped . Can someone please look into this and guide me on how to remove the 2nd set of XML start from <Request>to </Request> as it has <Event> = Payment.

Re: When=Group - How to exclude a group of records

PostPosted: Thu Mar 12, 2020 5:28 pm
by sergeyken
gyt3 wrote:This is my input file and my requirement is to exclude the group that starts with <Request> and ends with </Request> having Event=Payment.

Input is FB file of LRECL : 400

1) What's about the group starting with
<Request RequestID="5803727242796658404053">
instead of
<Request>


2) What to do if there are nested <Requests> encountered?

Re: When=Group - How to exclude a group of records

PostPosted: Thu Mar 12, 2020 6:14 pm
by sergeyken
//*=======================================================
//* SELECT DATA ON GROUP SPECIFICS                        
//*=======================================================
//SORTGRP EXEC PGM=ICETOOL                                
//*                                                      
//TOOLMSG  DD  SYSOUT=*                                  
//DFSMSG   DD  SYSOUT=*                                  
//REPORT   DD  SYSOUT=*                                  
//*                                                      
//SORTIN   DD  *                                          
<Report>                                                  
<Requests>                                                
<Request RequestID="5803727242796658404053">              
<BillTo>                                                  
<CustomerID/>                                            
</BillTo>                                                
<PaymentMethod>                                          
<TypeDescription>Checking</TypeDescription>              
</PaymentMethod>                                          
<Events>                                                  
<Event>Stop Payment</Event>                              
<EventDate>2020-01-31T16:00:00Z</EventDate>              
</Events>                                                
</Request>                                                
<Request RequestID="5803727242796658404053">              
<BillTo>                                                  
<CustomerID/>                                            
</BillTo>                                                
<PaymentMethod>                                          
<TypeDescription>Checking</TypeDescription>              
</PaymentMethod>                                          
<Events>                                                  
<Event>Payment</Event>                                    
<EventDate>2020-01-31T16:00:00Z</EventDate>              
</Events>                                                
</Request>                                                
</Requests>                                              
</Report>                                                
//*                                                      
//*-----------------------------------------------------------------
//TOOLIN   DD  *                                                    
  COPY FROM(SORTIN) TO(SELECTOR)    USING(S001)                    
  COPY JKFROM       TO(SORTOUT)     USING(S002)                    
//*                                                                
//*-----------------------------------------------------------------
//S001CNTL DD  *                                                    
 INREC IFTHEN=(WHEN=GROUP,                                          
               BEGIN=(1,80,SS,EQ,L(C'<Request ',C'<Request>')),    
               END=(1,80,SS,EQ,C'<Request/>'),                      
               PUSH=(401:ID=5)),                                    
       IFTHEN=(WHEN=(1,80,SS,EQ,L(C'<Event ',C'<Event>'),          
                 AND,5,80,SS,EQ,C'Payment'),                        
               OVERLAY=(406:401,5))                                
 OUTFIL FNAMES=(SELECT@,SELECTOR),                                  
        REMOVECC,NODETAIL,                                          
        INCLUDE=(401,5,ZD,EQ,406,5,ZD,                              
              OR,401,5,CH,EQ,C' '),                                
        SECTIONS=(401,5,                                            
        TRAILER3=(401,5))                                          
 OUTFIL FNAMES=(NUMBER@,NUMBERED)                                  
//*                                                                
//*-----------------------------------------------------------------
//S002CNTL DD  *                                                    
 JOINKEYS F1=NUMBERED,                                              
          FIELDS=(401,5,A),SORTED                                  
 JOINKEYS F2=SELECTOR,                                              
          FIELDS=(1,5,A),SORTED                                    
 REFORMAT FIELDS=(F1:1,80)                                          
//*                                                                
//*-----------------------------------------------------------------
//SELECT@  DD  SYSOUT=*          debugging trace                                            
//SELECTOR DD  DISP=(NEW,DELETE),                                  
//             UNIT=SYSDA,SPACE=(TRK,(5,5)),                        
//             DSN=&&SELECTOR                                      
//NUMBER@  DD  SYSOUT=*          debugging trace                                            
//NUMBERED DD  DISP=(NEW,DELETE),                                  
//             UNIT=SYSDA,SPACE=(TRK,(500,500)),                    
//             DSN=&&NUMBERED                                      
//*                                                    
//SORTOUT  DD  SYSOUT=*                                
//*                                                    
//*=====================================================
 

********************************* TOP OF DATA *************
<Report>                                                  
<Requests>                                                
<Request RequestID="5803727242796658404053">              
<BillTo>                                                  
<CustomerID/>                                              
</BillTo>                                                  
<PaymentMethod>                                            
<TypeDescription>Checking</TypeDescription>                
</PaymentMethod>                                          
<Events>                                                  
<Event>Stop Payment</Event>                                
<EventDate>2020-01-31T16:00:00Z</EventDate>                
</Events>                                                  
</Request>                                                
<Request RequestID="5803727242796658404053">              
<BillTo>                                                  
<CustomerID/>                                              
</BillTo>                                                  
<PaymentMethod>                                            
<TypeDescription>Checking</TypeDescription>                
</PaymentMethod>                                          
<Events>                                                  
<Event>Payment</Event>                                    
<EventDate>2020-01-31T16:00:00Z</EventDate>                
</Events>                                                  
</Request>                                                
</Requests>                                                
</Report>                                                  
******************************** BOTTOM OF DATA ***********