Operating System - OpenVMS
1753774 Members
7095 Online
108799 Solutions
New Discussion юеВ

Re: vax manipulation of .DAT file

 
SOLVED
Go to solution
Hein van den Heuvel
Honored Contributor

Re: vax manipulation of .DAT file


A lot of words were written already (by me :-), but it may still be simple.

Did you try a straight 'convert' on the file that was 'fixed' on Unix, using the fdl?
That may be all that is needed.

Below you'll find one final contribution, with a vms-only dcl script doing the work pretty much as outlined. It is UNTESTED, so read and study carefully. Use VMS HELP as needed.
Along its path it reports (or intents to, remember untested :-) the first 3 records modified and actually dumps the last one of those to allow you to verify the changes before putting the new file into operation.

Enjoy,
Hein.

$old = "circuit.bak"
$new = "circuit.new"
$fdl = "circuit.fdl"
$tmp = "tmp.tmp"
$mod = 0
$num = 0
$
$close/nolog old
$close/nolog tmp
$creat/fdl=sys$input 'tmp
file; allo 20000; exte 5000; record; size 773; form fixed
$open/appe tmp 'tmp
$open/read old 'old
$
$loop:
$read/end=done old record
$num = num + 1
$if "XG".eqs.F$EXTR(205,2,record)
$then
$ mod = mod + 1
$
$ old_key = F$EXTR(00,38,record)
$ new_key = F$EXTR(86,38,record)
$ mid = F$EXTR(38,48,record)
$ rest = F$EXTR(124,999,record)
$ record = new_key + mid + old_key + rest
$
$ if mod.lt.3
$then
$ write sys$output "Record ''num', Old=''old_key', New=''New_key'"
$ sample = num
$endif
$
$endif
$write/symbol tmp record
$goto loop
$
$done:
$write sys$output "''num' records read, ''mod' modified."
$close old
$close tmp
$dump /record=(count=1,stat='sample') 'tmp
$conv/stat/fast/sort/fdl='fdl' 'tmp 'new
$exit
Ratzie
Super Advisor

Re: vax manipulation of .DAT file

Thank you very much, I have used your script, and get some of the expected results, but with questions.

First it looks like it errors on a variable. That I can not figure out from where.

Unrecognised key word...
Duplicate Key encounter...
It made the swap (all except two) what does this mean?

beta::[SSTRSSYS.DATA] @MOD_CIRCUIT.COM;2
Record 81763, Old=399199 , New=WNPGMB05ONU6

Record 81764, Old=399256 , New=WNPGMB01ONU5

113167 records read, 1426 modified.
%DCL-W-IVKEYW, unrecognized keyword - check validity and spelling
\STAT\
%CONVERT-I-DUP, duplicate key encountered
%CONVERT-I-DUP, duplicate key encountered
%CONVERT-I-DUP, duplicate key encountered
%CONVERT-I-DUP, duplicate key encountered
%CONVERT-I-DUP, duplicate key encountered

CONVERT Statistics
Number of Files Processed: 1
Total Records Processed: 113167 Buffered I/O Count: 215
Total Exception Records: 5 Direct I/O Count: 63498
Total Valid Records: 113162 Page Faults: 12080
Elapsed Time: 0 00:27:06.95 CPU Time: 0 00:08:45.32

I will need to do additional testing with this but I believe I am on to something.
Hein van den Heuvel
Honored Contributor

Re: vax manipulation of .DAT file


>> Record 81763, Old=399199 ,New=WNPGMB05ONU6
>> Record 81764, Old=399256 , New=WNPGMB01ONU5

Those are just two key samples from the first records encountered which needed change.

>> 113167 records read, 1426 modified.

Just a status message.
The numbers suggests that an inline delete+rewrite would have been reasonable.

>> %DCL-W-IVKEYW, unrecognized keyword - check validity and spelling
\STAT\

Ooops, that should have been "START"
The DUMP is just an other sanity check that the script is doign the right thing best we can tell.
You can do the same dump on both files and compare byte by byte if need be.


>> %CONVERT-I-DUP, duplicate key encountered
>> %CONVERT-I-DUP, duplicate key encountered

Now you get into application space.
The file is designed NOT to allow duplicates.
The swap apparently created duplicates.
CONVERT can not decide which is good, which is bad.

Please add /EXCEP=circuit.exception to the final convert command line an try again.
Convert will put those problem records in the exception file and yhe application folks will have to decide what to do next.

They may (should!) have the tools to play with records. Datatrieve perhaps.

If they are at loss, the carefully study the other scripts I provided. They show how to read and delete or write records from an indexed file using DCL. You can use that to play with individual records, by primary or by alternate key (add /IND=1)

Try for example
$OPEN/read/share=write x circuit.old
$READ/KEY=WNPGMB05ONU6/IND=1 x y
$SHOW SYMBOL y

Total Exception Records: 5
Direct I/O Count: 63498
Total Valid Records: 113162

That seems reasonable.

>> I will need to do additional testing with this but I believe I am on to something.

Close, very close...
And a lot learned!

Hein.
Ratzie
Super Advisor

Re: vax manipulation of .DAT file

I want to thank Hein for all his work, I can say that I would not be anywhere close if it was not for him.
I have been testing all week, and I am confident that I can go ahead with these changes.

Appreciate the help.
Thanks
Laura