Learning To Provide Modern Solutions: Providing Solutions To Meet Today's Industry Standards
Learning To Provide Modern Solutions: Providing Solutions To Meet Today's Industry Standards
Learning To Provide Modern Solutions: Providing Solutions To Meet Today's Industry Standards
11
of this way of programming and dene the reasons why modernization of the code is necessary. The rst thing that comes to mind when discussing modernization is aesthetics. When you have a system that provides indisputable data that is necessary for business processes, you may consider the ability to create modern reports in Microsoft Excel or Adobe PDF form as being an unnecessary enhancement. After all, the data is being generated, the information is being audited, reporting is being performed, and the company is generating revenue. How important is it to make the reports look better? Well, there are other factors beyond appearance that you need to consider when evaluating the need for spreadsheets and PDF les.
Portability
Portability is a big one. To address this issue, your initial thought might be to generate ASCII text les. If youve been working with RPG for a few years, theres a good chance youve already tried this approach. However, if you delimit the ASCII data using a special character, you must make the user aware of which delimiter youre using, and the user must process the data properly. This means you need specications that identify the elds and how they should be separated. In the end, the data is likely to be imported into an Excel spreadsheet anyway. When you provide an ASCII text le, you may have different formats for multiple records in the le. For example, you may have a header that displays a title and possibly user information that does not match the layout of the data, requiring you to identify when record formats change. There is also the issue of delivering the le to the users. Will you use a data transfer that must be dened for each user to download the correct physical le member? Will you use File Transfer Protocol (FTP) and require a user name and password?
12
If you e-mail the text le, its carriage returns and line feeds might be altered during conversion through MIME format. Will you zip the le to avoid this issue, or will your e-mail application embed the text into the e-mail message and force the user to copy and paste the data from there? You could make the data available using a Web server, but if youre going to go that far, you might as well use HTML. The bottom line is that unless youre dealing with another programmer or a power user, you will likely encounter users who resist using ASCII text les, especially given the other options available today. PDF les are built specically to overcome these issues. With PDF les, all that users need is a reader, and they can view any PDF le without any of the preceding concerns. PDF readers are typically free and work on most operating systems. In fact, one is probably already installed with your OS. Even though PDFs are portable, they can be difcult to modify, which can be a good thing or a bad thing depending on your intentions. Microsoft Excel les offer the same portability as PDF les. A free viewer available from Microsoft lets users view these les in read-only mode. And with the availability of several open-source options, you can easily create and change such les using software that is supported on most operating systems.
13
14
15
understand about Java to get it to work properly. It would be nice if you could just plug in a Java method, as you can an application programming interface (API). But there are other things you need to think about when dealing with the Java Virtual Machine, such as starting and stopping it. And because two totally different environments are communicating with each other, you need to take some extra measures to handle some of the ugliness of reclaiming memory resources. Some of these topics may sound unappealing to you, and I agree. But fortunately, both IBM and Sun Microsystems have provided some useful code segments for dealing with these types of matters. So, what well do is create some handy procedures that will take care of most of these details for us, and well have to do minimal coding to support these issues. It took me quite a while to get through all these issues when I rst started. There were little pieces of information all over the place, and I had to discover the solutions as I stumbled through one frustrating setback after another. I hope to provide you with a much smoother transition into the world of Java than I had. I dont mean to sound discouraging. If anything, I intend just the opposite. My goal is to help you to easily overcome those obstacles and get you into production mode relatively quickly. As with the introduction of any new programming language, you will have to go through the growing pains of the initial learning curve. But a practical programming guide dramatically accelerates your ability to provide results quickly. And here we are! This book introduces you to the Java components necessary to provide the results youre looking for. It is not intended to teach you Java, but it does introduce you to Java and how to use specic parts of open-source technology to provide the product of your hard work, which in this case will be Excel spreadsheets and PDF les that you can distribute using e-mail from RPG.
16
17
got out of control from there. Users were starting to archive their reports on the network drive and calling the IT support line about les they were seeking. As the number of les grew, the amount of time required to perform backups grew as well, requiring more administration than I had bargained for. So, I soon decided to accommodate these requirements using an automated e-mail system. This approach allowed the distribution lists to be changed to send only to particular users, gave users the option to save or delete the les, and did not require users to have a network drive mapped. It also made it possible to easily send the reports to customers who didnt have access to the network. When evaluating the options to provide my IBM i system with e-mail capability, I found JavaMail to be the most self-contained and exible solution. Using JavaMail, we will build an e-mail client that simply creates the e-mail and relays it through your current e-mail server no additional servers or conguration required. Well start with a simple text e-mail, specifying the to, from, and subject, and then advance to formatted e-mails containing HTML and attachments. You can even embed the images right into the e-mail, if desired. Using JavaMail for your e-mail client frees you from being tied to the operating system. Once you understand the JavaMail API and you start using Java, youll be able to easily rewrite your RPG program into pure Java and use the exact same API to provide the same capability to any other server on the network. This freedom and knowledge will also help you as a programmer to begin to integrate with other areas of technology in your company and will give you greater exibility, not only in your programming options but as a valued member of the programming team. And thats just the beginning! In addition to giving you the isolated capabilities of the service programs well discuss, Ill walk you through the process of identifying and implementing the classes and methods. So, once you get your RPG programs to start generating electronic documents and sending e-mails, you can further explore other options that are available and expand your service programs to implement more and more features. I hope this will be the beginning of a whole new level of programming using Java for you. Lets get started.
18