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

Process records based on header conditional using Syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Nov 29, 2011 7:39 pm
Reply with quote

Hi,

I have an input file having header and Trailer records. Based on the date field condition in header i want to fetch its corresponding records in output.

The condition is if the date field in Header record is less than Current date (Date1) then write them into output file

Assume the file is of Fixed length and LRECL=80.

Input file:-
10 11102012SUB30023 ---> Header with date MMDDYYYY
20 TES1 DATA
30 TES2 DATA
40 TES3 DATA
50 TES4 DATA
99 TRAILER ---> Trailer
10 11102011SUB30024 ---> Header with date MMDDYYYY
20 TES1 DATA
30 TES2 DATA
40 TES3 DATA
50 TES4 DATA
99 TRAILER ---> Trailer

Output :-
10 11102011SUB30024 ---> Header with date MMDDYYYY
20 TES1 DATA
30 TES2 DATA
40 TES3 DATA
50 TES4 DATA
99 TRAILER ---> Trailer

Thanks
-3nadh
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 29, 2011 7:57 pm
Reply with quote

"Current Date" as in system date? Never a good idea. Run it after midnihgt, or have to re-run from several weeks ago, and it will not "work" as you expect.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Nov 29, 2011 9:23 pm
Reply with quote

Hello,

Quote:
I have an input file having header and Trailer records. Based on the date field condition in header i want to fetch its corresponding records in output.

The condition is if the date field in Header record is less than Current date (Date1) then write them into output file


Any chance of multiple header-trailer in the input file
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Tue Nov 29, 2011 11:05 pm
Reply with quote

Each set of record has only 1 Header and one trailer record.
Here the requirement is i want to remove future date records... for example anydate comes after 11302011 ( MMDDYYYY).

Thanks
-3nadh
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Nov 30, 2011 3:46 pm
Reply with quote

Hello,

Try this (Assumed MMDDYYYY starts from 4th position)

Code:
//STEP30 EXEC PGM=ICETOOL                                         
//DFSMSG   DD SYSOUT=*                                             
//TOOLMSG  DD SYSOUT=*                                             
//IN1      DD *                                                   
10 11102012SUB30023 ---> HEADER WITH DATE MMDDYYYY                 
20 TES1 DATA                                                       
30 TES2 DATA                                                       
40 TES3 DATA                                                       
50 TES4 DATA                                                       
99 TRAILER ---> TRAILER                                           
10 11302011SUB30024 ---> HEADER WITH DATE MMDDYYYY                 
20 TES1 DATA                                                       
30 TES2 DATA                                                       
40 TES3 DATA                                                       
50 TES4 DATA                                                       
99 TRAILER                                                         
//OUT1     DD DSN=&TMP1,                                           
//            DISP=(MOD,PASS,DELETE),                             
//            DCB=(RECFM=FB,LRECL=100,BLKSIZE=0),                   
//            SPACE=(CYL,(15,15),RLSE),UNIT=SYSDA                   
//OUT2     DD DSN=&TMP2,                                           
//            DISP=(MOD,PASS,DELETE),                               
//            DCB=(RECFM=FB,LRECL=100,BLKSIZE=0),                   
//            SPACE=(CYL,(15,15),RLSE),UNIT=SYSDA                   
//OUT3     DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  COPY FROM(IN1)  TO(OUT1) USING(CTL1)                             
  COPY FROM(OUT1) TO(OUT2) USING(CTL2)                             
  COPY FROM(OUT2) TO(OUT3) USING(CTL3)                             
/*                                                                 
//CTL1CNTL DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'10'),OVERLAY=(81:8,4,4,2,6,2))   
//CTL2CNTL DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,                                         
        BEGIN=(1,2,CH,EQ,C'10',AND,81,8,CH,EQ,&DATE1),             
        END=(1,2,CH,EQ,C'99'),                                     
        PUSH=(90:ID=1))                                             
//CTL3CNTL DD *                               
  SORT FIELDS=COPY                           
  INCLUDE COND=(90,1,CH,EQ,C'1')             
  OUTREC BUILD=(1,80)

Please use code-tags for better understanding

You need to do,

Please change the OUT3 to your file name, which is pointing to sysout, with the file attributes

Note: Three passes can be reduced
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Nov 30, 2011 6:56 pm
Reply with quote

Thanks Xavier for posting the code :-)

Thanks
-3nadh
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top