Sunday 15 February 2015

mainframe - Compare files with DFSORT , insert a string 'ADD' in front of new records -



mainframe - Compare files with DFSORT , insert a string 'ADD' in front of new records -

i have 2 work files old(f1) , new (f2), both of same length. should compare both files record record , new records in new (f2) work file , should insert 'add' in front end of in starting 3 positions , rest of records(matched) should spaces.

as of able re-create records in f2 not in f1 using below code:

//sysin dd * joinkeys file=f1,fields=(1,79,a) joinkeys file=f2,fields=(1,79,a) bring together unpaired,f2,only sort fields=copy /*

but need records f2 'new' string in front end of new records, can done in single step?

this seems want. not convinced want shortly.

all records on each file sorted based on, i'm assuming is, entire length. means first run output in different sequence input.

a "change" same new, if alter possible.

if you're ok both of those, should have said in question.

//sysin dd * joinkeys file=f1,fields=(1,79,a) joinkeys file=f2,fields=(1,79,a) bring together unpaired,f2 reformat fields=(?,f2:1,2,1,79) inrec ifthen=(when=(1,1,ch,eq,c'2'), overlay=(1:c'new')), ifthen=(when=(none, overlay=(1:3x)) sort fields=copy

the unpaired,f2 matches, plus f2 (your new input) don't match.

the reformat statement puts bring together match-marker (the ?) in first position, puts 2 bytes of anything, entire data. reformat record 82 bytes.

in inrec, field sourced match-marker tested new can overlaid @ start of record if required. else, 3 blanks overlaid.

there clearer way express same output:

//sysin dd * joinkeys file=f1,fields=(1,79,a) joinkeys file=f2,fields=(1,79,a) bring together unpaired,f2 reformat fields=(?,f2:1,79) inrec ifthen=(when=(1,1,ch,eq,c'2'), build=(c'new',2,79)), ifthen=(when=(none, build=(3x,2,79)), sort fields=copy

this time build used, not overlay.

with improve (any?) knowledge of data, improve solutions may available.

even info provided on site not here, there not enough.

//sysin dd * joinkeys file=f1,fields=(1,79,a) joinkeys file=f2,fields=(1,79,a) bring together unpaired,f2,only sort fields=copy /*

we can guess file 79, fb, needn't be.

to mismatches , set new @ front end existing code, easy:

//sysin dd * joinkeys file=f1,fields=(1,79,a) joinkeys file=f2,fields=(1,79,a) bring together unpaired,f2,only inrec build=(c'new',1,79) sort fields=copy

you output of course of study 82 bytes per record.

however, presumes have (and can never have) no duplicates on 79-byte key, , entire record 79 bytes.

it assumes not care order of output file.

each joinkeys sorting file, , info presented matching process.

bear in mind change, , method of verifying (sort whole record, compare whole record), find hard not output 2 records record logically same. 1 delete (from f1) , other new (on f2) whereas taken change.

mainframe dfsort

No comments:

Post a Comment