View Full Version : Play Time = Productive Time?
sfordenbacher
08-15-2007, 05:11 AM
I wrote a system on the iseries that allows our QC operators to measure various physical dimensions for our parts. In fact every part has different dimension measuring requirements and acceptable limits, everything is control file driven. Once the test data is recorded, the data is stored in DB2, and we generate statistical reports such as histograms and control charts. The software that does the charting is a PC based tool that uses ODBC. The way we tell the PC tool what to chart is by generating a complex XML document. So cgidev2 was in fact a life saver that made generating the xml file much easier.
lujate
08-15-2007, 05:35 AM
The two URL's for the source (http://www.mcpressonline.com/ftp/prog/02/MCPRESSXML.zip & http://www.mcpressonline.com/ftp/prog/02/ProdTempl.zip) are not working.
V.Mack
08-15-2007, 06:30 AM
My apologies. The links should work now. Victoria Mack, Executive Editor
Guest.Visitor
08-15-2007, 08:26 AM
Hi Jon, Should you wrap the XML character field data in an Encode2()? After all, I've been thinking about creating a product number in our system that is called '<>&". Thanks for the article. :o) Chris
Guest.Visitor
08-15-2007, 08:55 AM
Greetings, Jon! After attending a few of your sessions at COMMON this Spring in Anaheim, I decided to use CGIDEV2 and Scott Klement's HTTPAPI in our shop's XML project. (Since we're still at V5R2, we're unable to utilize the XML-abilities of RPGIV available in V5R4.) We needed to build an XML file, put it into a SOAP wrapper and send it to the Medical Information Bureau (MIB)--then parse the response from the MIB and print the relevant data for our customer. CGIDEV2 helped tremendously! Our template contained the SOAP wrapper as well as the XML, and writing the file to the IFS was a piece of cake. HTTPAPI then aided the sending of the XML file via an HTTP POST, and the parsing of the response. It's a beautiful thing. Thanks so much for bringing it to our attention!
Guest.Visitor
08-15-2007, 09:03 AM
kgibson, I did something very similar. My problem was that some of the variables in the /COPY books from CGIDEV2 and LIBHTTP are named the same, so I got compiler errors. I had to break that logic up into separate programs. This was only a minor inconvenience, for the end result. Chris
JonFParis
08-15-2007, 09:57 AM
Hi Chris, Yes - if you need to include characters that have specific meaning in XML in the data then it should be encoded. I debated whether to include this information in the article, but it can get complex quickly and I decided it was better to not confuse the issue at this point. I do intend to write a follow up a some point in the future which will cover this topic. If I have time later I'll dig out some references to threads in various forums that discuss this topic. Glad you liked the article.
JonFParis
08-15-2007, 10:00 AM
Wow - that's terrific to hear. It really is a great approach - particularly if the "shape" of the XML document is likely to change in the future. You can often just get away with changing the template. Good to hear that Scott's terrific work came in handy for you as well. Thanks for writing.
JonFParis
08-15-2007, 10:06 AM
Hi Chris, It is one of the limitations of the RPG /COPY that you have no option to change the names in a COPY member as you can in COBOL for example. I'm a bit surprised though since I know Scott uses naming conventions that are designed to avoid such collisions. What variables in particular were involved? If they relate to common structures such as USEC then you could probably avoid the problem by using conditional compilation directives to wrap those portions of the code so that they are not included if the other version is already present.
Guest.Visitor
08-15-2007, 11:24 AM
Jon, CGIDEV2/QRPGLESRC,PrototypeB and LIBHTTP/QRPGLESRC,IFSIO_H have lots of IFS root system type collisions. (O_RDONLY, O_WRONLY, O_RDWR, read, write, etc). I didn't see a way to avoid it using DEFINED. If you can suggest a way, that would be great. Thanks. Chris
JonFParis
08-15-2007, 12:16 PM
OK - I should have guessed that they would both use those names! OK - here's how it works (I haven't got time to check this but you'll get the idea). Source - PrototypeB /DEFINE(PrototypeB) /IF NOT DEFINED(IFSIO_H) stuff that is in both /ENDIF Source - IFSIO_H /DEFINE(IFSIO_H) /IF NOT DEFINED(PrototypeB) stuff that is in both /ENDIF In other words each one sets a flag to say it has been included in the program. The other one uses that flag to determine if the duplicate lines should be included or not.
watsonw@ggc.com
08-15-2007, 12:19 PM
Jon, Another great job! I attended your session on CGIDEV2 last year in Naples and enjoyed it a great deal. Now that we have some breathing room I think we are ready to give it a try in earnest. Can't wait to hear about the enhancements to CGI that will further simplify it's use. Thanks again, Bill
lujate
08-15-2007, 12:25 PM
Any ideas on the best way to set the column width for an Excel worksheet? I can use the <Column ss:Width="x"/> to set the width, but how can I determine what the value of x should be?
Guest.Visitor
08-15-2007, 12:47 PM
Jon, Thanks for the suggestion. I am familiar with those compiler directives. Are you saying I should edit the installed /COPY books? My concern with that method is that I will need to revisit them when I install new versions of CGIDEV2 and LIBHTTP down the road (although CGIDEV2 is not likely to change, right?) because those updated /COPY's may have new variables added to them, some in common, some not. I just feel that putting those /COPY's in separate modules may require less maintenance in the future. Regards, Chris
dandruchuk@csdainc.com
08-15-2007, 01:38 PM
you could use the %len BIF to determine the length such as: ColLgth = %len(%trim(column)) where collgth is the result of the length of the column field
lujate
08-16-2007, 04:55 AM
Unfortunately, the column width is measured in points, not characters.
JonFParis
08-16-2007, 05:59 AM
I don't bother trying to determine the point width. I simply set a test sheet up the way I want it to look with the correct font etc. then use the point width in the resulting XML doc. Remember this is a column value - so using %Trim against a field normally wouldn't help as that field may be short content wise and you have to determine column width for the whole sheet. That's why I normally do it "by hand" after analyzing the file to determining what column width will handle the majority of data without looking "silly" on the short fields.
dandruchuk@csdainc.com
08-16-2007, 07:43 AM
Jon, I wish to thank you for including the Excel example as I have used that many times to communicate with feeds off the System i and have found it the best way to do so using XML & CGIDEV2. Simpler is most often better when it comes to code design and the fact that an RPG developer of very little experience can pick it up quickly w/o knowledge of XML is very beneficial in our shop, not to mention the fact that many are experienced in Excel but may not be in XML so it is a well accepted means of data exchange.
Guest.Visitor
08-19-2007, 07:09 AM
I have been using the same technique to replace various paper reports, especially exception reports and periodic summaries (sales, performance, quotas, commissions ect...) Here is a similar example: http://tinyurl.com/q7v9h
JonFParis
08-19-2007, 02:08 PM
Nice example - thanks for sharing it with us. How did you build the original XML - from scratch or from an example sheet with the look/feel you wanted?
Prairie Dog
11-13-2007, 11:57 AM
So am I to understand that there is not an XML-GENERATE equivalent for RPG V5R4? Thanks.
MCWebsite.Staff
11-13-2007, 11:57 AM
** This thread discusses the Content article: Play Time = Productive Time? (http://www.mcpressonline.com/index.php?option=com_content&view=article&id=648)0
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.