Hi,
i am trying to compare two FB datasets with same record length of 80 on 1,34 and override 35,6 only when matched without changing the record order.
I tried the below but the unmatched records are written at bottom.
F1: LRECL=80, FB
Code:
**************************************************
* UPDATE AS REQUIRED FOR EACH RUN.
*
**************************************************
*MNTH START NEXT
*ID VL REGION ARA PRODCT SEQ SEQ
*==== == ====== === ====== ====== ======
MAY 12 400972 770 XXXXXA 000502 000000 SEEDS
MAY 12 400972 781 XXXXXB 000502 000000 SEEDS
MAY 12 400972 789 XXXXXC 000502 000000 SEEDS
MAY 12 400972 791 XXXXXD 000506 000000 SEEDS
MAY 12 400977 416 XAXAXA 001002 000000 SEEDS
MAY 12 400977 416 XAXAXB 701002 000000 SEEDS
MAY 12 400977 421 XAXAXC 201002 000000 SEEDS
MAY 12 400977 421 XAXAXD 501002 000000 SEEDS
MAY 12 400977 425 XAXAXE 201002 000000 SEEDS
MAY 12 400977 425 XAXAXF 501002 000000 SEEDS
MAY 12 400977 425 XAXAXG 001002 000000 SEEDS
MAY 12 400977 425 XAXAXH 701002 000000 SEEDS
MAY 12 400977 426 XAXAXI 201003 000000 SEEDS
MAY 12 400977 426 XAXAXJ 501004 000000 SEEDS
F2:
Code:
MAY 12 400972 770 XXXXXA 000502 001456
MAY 12 400972 781 XXXXXB 000502 004456
MAY 12 400972 789 XXXXXC 000502 001233
MAY 12 400972 791 XXXXXD 000506 000045
MAY 12 400977 416 XAXAXA 001002 000022
MAY 12 400977 416 XAXAXB 701002 000001
MAY 12 400977 421 XAXAXC 201002 034556
MAY 12 400977 421 XAXAXD 501002 003422
MAY 12 400977 425 XAXAXE 201002 000099
MAY 12 400977 425 XAXAXF 501002 007566
MAY 12 400977 425 XAXAXG 001002 196663
MAY 12 400977 425 XAXAXH 701002 000301
MAY 12 400977 426 XAXAXI 201003 000000
MAY 12 400977 426 XAXAXJ 501004 000000
Frankly speaking, this way of resolving such a problem is a sort of workaround: processing all garbage/headers/etc. records along with real data lines, and the re-order resulting lines by initial record numbers. Some accidentally matching garbage/header records may produce unexpected results.
Correct way would be:
1) Omit all non-data records from both input files by using INCLUDE/OMIT parameters of JOINKEYS statements
2) Match/build/overlay required data-only lines as needed
3) In OUTFIL statement, re-generate clear new HEADER/TRAILER/SECTION records as needed.
It looks a bit longer to code, but logically it would be more correct way of processing this case.
Besides of this, after all non-data records are filtered out, it becomes possible to rely on pre-sorted order of input data. When using FIELDS=(1,34,A),SORTED it would become unnecessary neither to include SEQNUM, nor to re-sort the final result on this SEQNUM field.
This is irrelevant for small sample "toy projects", but becomes much more serious when huge datasets are to be joined.