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

Getting the records with the lastest date


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Alexis Sebastian

New User


Joined: 04 Mar 2010
Posts: 38
Location: DC

PostPosted: Wed Dec 22, 2010 8:39 pm
Reply with quote

There is an input file in the below format,
Code:

H21122010HEADER RECORD
D00000000019122010   
D00000000020122010   
D00000000021122010   
T0000003             


Input file Description:-
1. First Byte shows H - Header D- Detail T-Trailer records
2. In Header record, from position 2 to pos 9 -> header date
3. in Detail Record, from Pos 11 to pos 18 -> date field
4. In Trailer record, from pos 2 to pos 8 is the trailer count.
5. Date format is 'DDMMYYYY'

Output requirements:-
1. Need to copy the header record as it is
2. records with the latest date need to be taken out for detail records.
3. Also latest date in the detail record should match with the header date
4. Correspondingly trailer count needs to be written based on the no of detail records.

Sample Output file is given below.
Code:

H21122010HEADER RECORD
D00000000021122010   
T0000001             
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: Wed Dec 22, 2010 11:27 pm
Reply with quote

Your output requirements are not clear (actually they don't even make sense).

Quote:
2. records with the latest date need to be taken out for detail records.


But your output file example has the latest date. So what do you mean by "taken out". Looks like the other dates were taken out.

Quote:
3. Also latest date in the detail record should match with the header date


Huh? Are you trying to keep the detail record with the same date as the header? What do you want to do if the detail record does not match the header date. Your explanation is quite confusing.

You need to do a better job of explaining what you want to do with better examples of input and expected output.
Back to top
View user's profile Send private message
Alexis Sebastian

New User


Joined: 04 Mar 2010
Posts: 38
Location: DC

PostPosted: Thu Dec 23, 2010 7:51 pm
Reply with quote

Sorry Frank!!! Here it goes...

Need to keep the details records with the same date as the Haeader date.

If there is no match then, only Header and trailer record will be there in the output file. trailer count would be zero.
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 23, 2010 11:19 pm
Reply with quote

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY
  OMIT COND=(1,1,CH,EQ,C'T')
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
    PUSH=(81:2,8))
  OUTFIL REMOVECC,
   INCLUDE=(1,1,CH,EQ,C'H',OR,
    (1,1,CH,EQ,C'D',AND,81,8,CH,EQ,11,8,CH)),
    BUILD=(1,80),
    TRAILER1=(C'T',COUNT-1=(M11,LENGTH=7))
/*
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 Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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 Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top