Wednesday, August 15, 2018

Getting data from XML file directly into data structure array

xml straight into file

I have written before about retrieving data from a XML file in the IFS. In that example I took that data from the file into a XML column in a DDL (SQL) table and then processed it from there. Since I published the example I have received two messages, one from Birgitta Hauser and another from Jan Koefoed-Nielsen, giving me examples of how to retrieve the data from the file and format it into columns, not using a DDL table as an interim step.

In this example I will not be directly outputting the information from the IFS XML file directly into an output file or table in IBM i. My experience of receiving XML files makes me want to validate what I am sent, before I start updating production files. A comma in a number, currency symbols, characters in what should be numeric value, and untranslatable characters should all be handled before updating any file. To this end I will be retrieving the data from the XML file and putting it into a data structure array. I can then "read" the array and perform any validations I want.

Monday, August 13, 2018

AS400 to IBM i: And we're just getting started

Video featuring Steve Will, chief architect of IBM i, and Alison Butterill, product offering manager for IBM i, showing ways IBM i clients have innovated over the past 30 years.

Runs just over 1 hour.

Hosted by HelpSystems, recorded July 18, 2018.

Wednesday, August 8, 2018

Using reference fields

using reference fields in dds, rpg, sql

When I first started programming on the AS400 the biggest improvement I encountered, compared to the System/36, was the external database. No longer did I have to have file specifications in my RPG programs, and I now had the ability to define fields by referencing another. Over the years I have used the referencing ability whenever I can had to define fields in files or variables in my RPG programs. By using reference fields makes database changes easier as a field's definition is changed in one place, then by recompiling all of the objects with the referencing, the new objects all have the new definition of the field in them.

In the past fortnight I have been asked several times about using reference fields, and in my experience there are many more who would like to ask the same question but feel intimated to do so. Therefore, I am writing this post to give examples of how I use them and why I do things the way I do.

All well-built databases have a data dictionary that defines the types of all the fields, or columns, within it. On AS400 and IBM i many of us achieved something similar using a reference file. This file contains the definition of every type of field that could be contained in any of the other files in the application.

Tuesday, August 7, 2018

IBM i 7.3 TR5 and 7.2 TR9 announced

ibmi 7.3 tr5 7.2 tr9 announced

The awaited announcement of new Technical Refreshes for IBM i 7.3, TR5, and 7.2, TR9, has been made. So what's new?

On the hardware side is the announcement of the Power9 chip based IBM Power E980 model 9080-M9S server.

I am not going to list all the changes on the software side just those that catch my eye at first glance.

Wednesday, August 1, 2018

Copying any data to and from a file in the IFS

using sql to write to a text ifs file

In previous posts I have shown how to write SQL data to a file in the IFS and then how to retrieve the XML data from an IFS file, but what about just plain old text?

In this post I am going to keep the example as simple as possible so that you can see how easy this is. I am going to write three strings of data, "records", to an IFS file, retrieve the data from the file, then move each the "record" into an array. Some of what I am describing here I have also mentioned in my earlier posts, but I think it is valuable to have it in here too.

My example program is only 32 lines, which goes to show easy this is. All the hard work is performed by Db2 for i.

Wednesday, July 25, 2018

Using SQL UDF with RPG

using values from sql udf in rpg program

This short post comes from a discussion I was having with two other IBM i developers at my place of work. I had shown them a number of SQL User Defined Functions, UDF, I had created to make my SQL statements easier.

"That's fine," started one of the developers, "but how does that help me in RPG. Won't I have to duplicate the procedures so I can call them in RPG?"

"No", I replied, "you can call them using SQL".

At first they were skeptical. Having shown them how easy it was to do they were sold.

Wednesday, July 18, 2018

Getting data from a XML file using SQL

retrieve xml data from file in ifs

A couple of months ago I write a post about creating XML from an IBM i hosted file and write it to a file in the IFS. It was obvious to me that I would have to write this post, describing how to get data from the XML file using SQL.

I could extract the data from the XML file in the IFS using the RPG operation code XML-INTO, but I want to use SQL to do this.

Where to start? I guess with the XML data. The XML file, xmlfile.xml, is in my folder, MyFolder, in the IFS. It contains the same data I used in the post about writing to the XML file. In the file the data is not formatted, it is just one long string of data.

Wednesday, July 11, 2018

Using an output queue to send spool files to another partition

create remote outq to another as400

The germ of the idea for this post came from a conversation I was having with two other programmers I work with. The conversation became finding an easy way to transfer spool files from a development IBM i partition to a production partition.

Where I work there are multiple partitions on one PowerSystems server. These partitions are used by various subsidiary companies in different parts of the USA, and three locations in Europe. If a modification is made to a spool file layout, for example: invoice, how do I show a user in Germany or Illinois what this new layout looks like when I am in California? The development partition does not connect to all the printers used, as we do not want test data printing on a "live" printer when testing. In my experience if I copy the spool file to a PDF the user is not convinced. The only way they will be convinced that the change works is for it to print on their printer.

Wednesday, July 4, 2018

Securing DDM files

making ddm file connections secure

Using DDM files is a very easy way to access data from another IBM i. I frequently use them to pass data from one IBM i partition to another and back.

All I need to do is to create the DDM file with the following command and be able to access the data in the file SOMEFILE in the library SOMEIB in the IBM i partition RMTSYS.

                            Create DDM File (CRTDDMF)

Type choices, press Enter.

DDM file . . . . . . > DDMFILE  
  Library  . . . . . >   QTEMP     
Remote file:
  File . . . . . . . > SOMEFILE  
    Library  . . . . >   SOMELIB   

Remote location:
  Name or address  . > RMTSYS                                  

Type . . . . . . . . . *SNA     *SNA, *IP