|
Hi Dan,
Yikes, there are so many things that can go wrong with the approach
you're taking. It's certainly possible to get it work, but I'm
wondering if you wouldn't be better served by taking a different approach?
Here's the approach I would recommend (though, I don't know that much
about the scenario, so I may be off-base)
1) Use CPYTOIMPF or some other tool to convert your PF to an ASCII file
in the IFS. Get it exactly the way the Windows system wants it.
2) Run your MD5 against the IFS file.
3) FTP the file to the Windows box in BINARY mode so nothing can be
changed in the data during transit.
So that's my recommendation. That will ensure that your MD5 is
calculated on the same data that the Windows one will be. That's
crucial, because the main purpose of an MD5 hash is to verify that the
data is identical. Any change to the data will give you a different
hash... which is why your current approach is so difficult.
Your current approach is tricky because you have to try to calculate
exactly what will be done to the file. In other words, you have to try
to guess the future :) Then, change each record in your file to look
like it will be in the future, and calculate the hash on that.
Possible, but tricky.
1) Translating EBCDIC to ASCII. You are already doing this, but I
wonder if you've thought of everything? For example, if your job is
CCSID 65535, RPG won't translate the file as it's read. But, if your
job ever changes, it will translate the data as it's read. So you can't
simply assume the data in your program will be the CCSID of the file,
and you can't assume it'll be the CCSID of the job. It could be either.
Plus, RPG uses the "mixed byte CCSID that corresponds to the jobs
CCSID" so you can't really use the job's CCSID directly anyway, even if
you know it'll never be used on a 65535 system. It's a bit tricky.
Once you get the right EBCDIC CCSID, then you also have to make sure
you're using the right ASCII one.
an MD5 -- because therein lies the road to madness. But in your case
you have to because you're trying to predict what the file will end up
as...
I glanced at your code, and you do not appear to be using iconv().
wouldn't iconv() work better than QTQCVRT?
3) Adding CRLF. FTP in ASCII mode will add CRLF to the end of every
record, however, the FTP client MIGHT change that to just LF (probably
not if the client is Windows -- but in Unix it would... and some clients
allow that option anywhere.)
There is no "end of file" character normally. Some very old PC software
uses Ctrl-Z as end of file, but I don't think FTP does this, so it
wouldn't be an issue for you.
That's my $0.02 for now.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.