Abend if field from two headers from two files matches!



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

Abend if field from two headers from two files matches!

Postby hsinaz » Tue Aug 27, 2013 11:38 am

I have a GDG. I would like to compare a date field (ccyymmdd) in columns 4-11 lets say from the latest two generations of the file. If the dates (numeric for simplicity) match, then I want to send a RC=12 lets say to the JCL that will be processed by next step to abend. Can this be done in one step? I am thinking on the lines of (although I dont know what/how), read in the first record from the two files, sort on the date column, SUM FIELDS=NONE, then somehow, if the output contains two lines, then I am good. If it contains one line that mean both dates were same, so send RC=12 to JCL. How to do this please?
hsinaz
 
Posts: 4
Joined: Fri Jun 14, 2013 4:43 am
Has thanked: 0 time
Been thanked: 0 time

Re: Abend if field from two headers from two files matches!

 

Re: Abend if field from two headers from two files matches!

Postby BillyBoyo » Tue Aug 27, 2013 12:17 pm

Since you need to set the RC, that is a good place to start. You can only set the RC if SORTOUT or an OUTFIL dataset contains no records, so that is what you have tp get to.

You don't read records yourelf in SORT.

The only time you know the source of a record is with JOINKEYS.

So, use JOINKEYS, with STOPAFT=1 in the JNFnCNTL files.

Use the date for JOINKEYS.

  JOIN F1,F2.ONLY
  REFORMAT FIELDS=(F1:date1start,length,F2:date2start,lenth)
  OPTION COPY,NULLOUT=see what you can have..


Your idea, with the NULLOUT/NULLOFL would generally work with INCLUDE/OMIT to get just the headers, but you'd have to pass all the data. Set a sequence number. Use OUTFIL to OMIT sequence number of 1.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Abend if field from two headers from two files matches!

Postby hsinaz » Tue Aug 27, 2013 11:04 pm

Thanks. This worked :)

JOINKEYS FILES=F1,FIELDS=(37,06,A),STOPAFT=1
JOINKEYS FILES=F2,FIELDS=(37,06,A),STOPAFT=1
JOIN UNPAIRED,F2,ONLY
OPTION COPY,NULLOUT=RC16
REFORMAT FIELDS=(F1:37,06,F2:37,06)
hsinaz
 
Posts: 4
Joined: Fri Jun 14, 2013 4:43 am
Has thanked: 0 time
Been thanked: 0 time

Re: Abend if field from two headers from two files matches!

Postby BillyBoyo » Wed Aug 28, 2013 5:27 am

Well done.

Just a couple of things.

UNPAIRED F2,ONLY will not get you data from F1. You don't strictly "need" it, but it might be nice to see both the dates.

You might want to consider whether to deal with empty input files. Both files empty is already covered, but what if either one is empty?

The STOPAFT will work like that, but I think it better to put them in the JNFnCNTL files. I'd put SORTED,NOSEQCK on the JOINKEYS, because you are actually running two SORTs, even though there is only one record to sort.

To deal with one of the files being empty, think about using UNPAIRED,F1,F2,ONLY and putting a sequence number on the records (INREC OVERLAY in the Main Task). Then use OUTFIL OMIT= to get rid of sequence number one. This will ensure that your output has either zero or one record. You can still get both dates on the output through the use of WHEN=GROUP.

If you get stuck, tell us what you want, show what you have tried, and someone will be here.

Again, well done. Too many people just want the code. You both had a good idea to start with, and got a working solution from suggestions.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post