Using OSA for auto emailing

craig_welton

craig_welton

Legendary Poster
Hello all and happy holidays,

I did a little research into using OSA as a mechanism for emailing UBE output upon completion of a batch job. The basic idea is to create an operating system library function (DLL, shared lib or service program) that is called by the UBE runtime engine when the PDF is complete. This was very easy to get built and worked like a charm when hooked up using the OSA app P986168.

So that leaves us with an O/S level function with all the info about the file. From here you could implement any O/S specific calls to a mail API but we don't know anything about who to email the output to. You could build an external repository to map UBE/versions to emails etc. and have the function lookup the info, but that seemed like a big project.

I ended up extending the OSA function and making it JDE "aware" by including jde.h and the libs. Then a simple call to JDB_InitEnv in the Finalize Document OSA event and you're connected to JDE as the user who ran the UBE. With a few BSFN calls you get the user's email and can send the output using JDE_SendEMailSMTPExt.

Initial development was done on a fat client and then tested on a Windows enterprise server (with a different compile of the function for byte alignment). That worked perfectly and so did a custom service program on the iSeries. I don't have access to a Unix enterprise server but I'm sure it will work as well.

Of course, this is just a simple extension. I know some companies store email distribution lists by UBE/version in custom tables so this function could do all the lookups required. There are a lot of possibilities here and not just emailing.

I hope this proves useful.

Craig
 
I was happy to simply learn about OSA. I didn't know this cool little E1 interop feature even existed before today. Your technique to hook back in to JDE would seem to make it even more powerful.
 
Yes, this is cool! I've used other approaches some of which have been discussed here on the list in the past to achieve this, but this approach is certainly looking good too ;-)

So, is the Finalize function the one called after the PDF is all finished, or did you use some other?

PS: It looks like this interface would really allow replacing the default PDF processor with any custom implementation. Which is not something you would normally expect being exposed from JDE. I wonder if there are any 3rd party packages around using this functionality? I.e.: even Create!Print and JetForms and such were all using a different approach (a Printer Conversion DLL, which I once used to write a piece of code to send the completed PDF back to the user's browser, to imitate the usual "To Screen" option in the Fat Client).
 
Hi Alex,

Yes, the Finalize function is the event to work with the complete PDF or CSV. And you're right, the overall idea behind OSA is to be able to replace the standard PDF output with whatever you need at an object by object level. I believe formscape does use this in some way as I remember an article referencing an FSOSA library. This post processing solution is just a by product of there being a Finalize Document event.

There is so much more that can be done through this. For example, we have an implementation where the UBE PDFs are not emailed if the literal "No Data Selected" is included in the PDF. We had to write a fairly complicated PDF parser to extract the text and find that literal. With OSA you can consume the Text Out event and look for this object easily. Again, just scratching the surface ;)

Craig
 
Awesome!!!

This is indeed useful mate.

I was asking about this sometime last year http://www.jdelist.com/vb4/showthread.php/48418-OSA-in-E1?highlight=email.
You replied then too :)

(as I knew BI could tap into the same process) I was under the impression I'd have to write a unix script to do the 'good stuff' so I gave up and wrote my own UBE and BSFN to do the same thing.

If you have any documentation on this, that would be great, especially the jde.h stuff as yes, the OSA could be immensely powerful in the right hands.

Finding documentation on this is like hens teeth :)
 
Back
Top