I want to remove header and trailer using sort



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

I want to remove header and trailer using sort

Postby pgkkreddy1 » Wed Jan 24, 2018 12:13 pm

Hi,
Good morning!

I have file with header like this '***HEADER***' and trailer is ***TRAILER***. I want to process the file when we have both header and trailer.
1.if only header record present we should not process the file
2.If only trailer record present we should not process the file

if I use below code, it is handling if file has both header and trailer. if file has only header or trailer it Is not working.

Please help me out.

I used the below code :

//STEP1    EXEC PGM=SORT,PARM='NULLOUT=RC4'      
//SYSOUT   DD SYSOUT=*                            
//SYSPRINT DD SYSOUT=*                            
//SYSUDUMP DD SYSOUT=*                            
//SORTIN   DD DSN=INPUT.FILE.NAME,DISP=SHR        
//SORTOUT  DD SYSOUT=*                            
//SYSIN    DD *                                  
   SORT FIELDS=COPY                              
   INCLUDE COND=(01,12,CH,EQ,C'***HEADER***',OR,  
                 01,13,CH,EQ,C'***TRAILER***')    
   END                


Scenarios like below:

1.it has to process : This working with above code) - return code -RC0

000001 ***HEADER***      
 000002 0000000000007FT9X  
 000003 000000000000Y4ZPM  
 000004 0000000000007GSXB  
 000005 000000000000YPLCL  
 000006 000000000000VM5DT  
 000007 0000000000000000000
 000008 000000000000X34T3  
 000009 ***TRAILER***  


2.Below should not process: (This working with above code) - RC4
0000000000007FT9X  
000000000000Y4ZPM  
0000000000007GSXB  
000000000000YPLCL  
000000000000VM5DT  
0000000000000000000
000000000000X34T3  


3.Below should not process: (This is not working with above code)
***HEADER***        
0000000000007FT9X  
000000000000Y4ZPM  
0000000000007GSXB  
000000000000YPLCL  
000000000000VM5DT  
0000000000000000000
000000000000X34T3  


4.Below should not process: (This is not working with above code)

0000000000007FT9X    
000000000000Y4ZPM    
0000000000007GSXB    
000000000000YPLCL    
000000000000VM5DT    
0000000000000000000  
000000000000X34T3    
***TRAILER***  


Regards,
kk
pgkkreddy1
 
Posts: 21
Joined: Wed May 13, 2015 8:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: I want to remove header and trailer using sort

 

Re: I want to remove header and trailer with diffent scenar

Postby pgkkreddy1 » Thu Jan 25, 2018 12:05 am

Can some one please help on this
pgkkreddy1
 
Posts: 21
Joined: Wed May 13, 2015 8:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: I want to remove header and trailer using sort

Postby Robert Sample » Thu Jan 25, 2018 12:19 am

Can some one please help on this
Prompting for replies like this is the one way that is pretty much guaranteed to NOT get you answers. People who respond on this forum are volunteers -- as in, they answer if they have knowledge of the topic, the time to write a response, and the interest to write a response. If you have a time-sensitive question, a forum is NOT the way to go; convince your management to hire a consultant to provide you help. Answers may take hours ... or days ... or weeks ... or months ... or years to appear; this is normal and expected. If you had waited a week or two without any responses, that would be a pretty good clue that nobody on this forum can help you (for whatever reason). But prompting after just 12 hours indicates the people who would normally respond will not respond since they're not going to want the hassle of dealing with your time demands.

Furthermore, it appears that you do not understand the difference between OR and AND in the INCLUDE statement. I recommend you go back and read the manual until you do understand (no matter how many times you have to read it, nor how long it takes) the difference.
Robert Sample
Global moderator
 
Posts: 3393
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 229 times

Re: I want to remove header and trailer using sort

Postby pgkkreddy1 » Thu Jan 25, 2018 12:46 am

Sorry Robert. I can wait..
pgkkreddy1
 
Posts: 21
Joined: Wed May 13, 2015 8:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: I want to remove header and trailer using sort

Postby Robert Sample » Thu Jan 25, 2018 1:19 am

While you wait, read up on the difference between AND / OR on the INCLUDE statement.
Robert Sample
Global moderator
 
Posts: 3393
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 229 times

Re: I want to remove header and trailer using sort

Postby enrico-sorichetti » Thu Jan 25, 2018 1:38 am

IIRC the or/and condition applies ONLY to comparisons for the record being processed.
the requirement needs two steps.. extract and check the count for 2 records
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2663
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 134 times

Re: I want to remove header and trailer using sort

Postby Aki88 » Sat Feb 10, 2018 12:41 am

Hello,

Unsure if this requirement is still open; if it is not, then this might help.

As Mr. Sorichetti and Mr. Sample have already pointed out, INCLUDE is needed but is to be used a little differently.
The primary challenge here is that, you'll not come to know about the properties of the tail record unless you've read it, which can be done by either:
a. Reading the complete dataset
b. Reading the dataset in reverse, but then you miss the header (unless you read the complete DS)

Here is a solution using *SORT; the code is untested as I no longer have access to a mainframe, but errors if any, should be minor and can be easily resolved:


//STEP001  EXEC PGM=SORT              
//SORTMSG  DD SYSOUT=*                
//SYSOUT   DD SYSOUT=*                
//SORTIN   DD *                        
HEAD                                  
ASDFLASJHDF                            
ASF                                    
ASDF                                  
ASDFGGDFSAGLLJH                        
TAIL                                  
/*                                    
//HEAD     DD DSN=&&HEAD,              
//            DISP=(NEW,PASS,DELETE),  
//            DCB=(RECFM=FB,LRECL=80),
//            SPACE=(TRK,(1,1),RLSE)  
//DATA     DD DSN=&&DATA,              
//            DISP=(NEW,PASS,DELETE),  
//            DCB=(RECFM=FB,LRECL=80),
//            SPACE=(TRK,(1,1),RLSE)  
//TAIL     DD DSN=&&TAIL,              
//            DISP=(NEW,PASS,DELETE),  
//            DCB=(RECFM=FB,LRECL=80),            
//            SPACE=(TRK,(1,1),RLSE)              
//SYSIN    DD *                                  
 SORT FIELDS=COPY                                
 OUTFIL FNAMES=HEAD,NULLOFL=RC4,                  
        INCLUDE=(1,4,CH,EQ,C'HEAD')              
 OUTFIL FNAMES=DATA,                              
        OMIT=((1,4,CH,EQ,C'HEAD'),OR,            
              (1,4,CH,EQ,C'TAIL'))                
 OUTFIL FNAMES=TAIL,NULLOFL=RC4,                  
        INCLUDE=(1,4,CH,EQ,C'TAIL')              
/*                                                
//STEP002  EXEC PGM=SORT,COND=(0,NE)              
//SORTMSG  DD SYSOUT=*                            
//SYSOUT   DD SYSOUT=*                            
//SORTIN   DD DSN=&&HEAD,DISP=(OLD,DELETE,DELETE)
//         DD DSN=&&DATA,DISP=(OLD,DELETE,DELETE)
//         DD DSN=&&TAIL,DISP=(OLD,DELETE,DELETE)
//SORTOUT  DD SYSOUT=*                            
//SYSIN    DD *                                  
 SORT FIELDS=COPY                                
/*

 
Aki88
 
Posts: 377
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post