Pages

Wednesday, August 27, 2014

FTP i-to-i part 2

ftp physical file from one IBM i to another

Having gone through a lot of the basics of using FTP, File Transfer Protocol, on an IBM i in the post FTP i-to-i part 1, in this post I will describe how I can transfer physical files, using FTP, to another instance of IBM i, whether it be another partition or another server.

In this scenario I have a job on QSRV1 that generates physical files that need to be transferred to QSRV2 to be processed. If this was a real job I would automate the FTP transfer, I will explain how to do it in Part 3. But in this post I am going describe how I would do it manually, one FTP subcommand at a time.

Wednesday, August 20, 2014

FTP i-to-i part 1

ftp get put quote rcmd

FTP, File Transfer Protocol, is probably the most widely used way to transfer objects between computers. It should come as no surprise to you that FTP has been available since the AS400 era.

I work in an environment with 11 IBM i partitions and servers, and I can spend a lot of time moving objects between. To move objects between partitions on the same server I use the SAVRSTOBJ and SAVRSTLIB commands. To move objects from one server to another, especially if they are in different geographical locations, I use FTP.

Why FTP rather than SNDNETF or SAVRSTOBJ? In my experience when moving very large amounts of data between servers it can be several hours quicker to FTP the file rather than use the other methods.

This post is going to first of several posts explaining how to FTP a file or files from one IBM i server to another. This method is not secure and I only do this within my company's network or while part of a VPN. I do not recommend doing this in an unsecure environment, i.e. over the internet while not being part of a VPN, as it can be "sniffed" and the data compromised. If you do want to send data via an unsecure environment then use SFTP, Secure FTP.

Wednesday, August 13, 2014

Retrieve file's Column Headings using API

quslfld

In May I posted two examples of how to retrieve the Column Headings for fields in files to be used as the column headings in a CSV file in the IFS. The first example, Adding Column Headings to a file in the IFS, I used DSPFFD. I was sent an alternative method that I gave in a later post, Adding Column Headings to a file in the IFS, continued, which used SQL to extract the information from the SYSCOLUMNS table.

Shortly after the second post I received a message from David Gomes. In it he explained a third method:

Whenever there is an API available to get the data, you should be using that and not running a CL command to produce a output file to read. In this situation I would recommend using the List Fields API (QUSLFLD). This will allow you to retrieve the Field name, Column or Text descriptions for the field. Using the X-Ref tables like SYSCOLUMNS is useless if the file is in QTEMP.

As I have explained how to use a List API, like QUSLFLD, that outputs to a User Space in the post User Space introduction in this post I am just going to explain how to use QUSLFLD.

Thursday, August 7, 2014

User Spaces introduction continued

user space, quscusat

After publishing yesterday's post User Spaces introduction Sam posted a comment:

It seems you forgot one important thing: Change User Space Attribute API
Automatic extendibility. Whether or not the user space is automatically extended by the system when the end of the space is encountered.
0 The user space is not automatically extendible.
1 The user space is automatically extendible.

While I write each post I test the code I give as examples. I did not encounter an error while testing that the User Space was full. But that could be that I did not fill the 128k size I made the User Space in my example.

Perhaps I needed to use a file with more fields? Or what would happen if I created the User Space with a size of 1 byte?

Wednesday, August 6, 2014

User Spaces introduction

user space quscrtus qusdltus qusptrus

User Space is used by many IBM APIs to hold the generated results. It is similar to a data area, but can be a lot larger and will expand in size as more data is added to it. What I consider to be a drawback for using them is that they can only be accessed by API. As I want to talk about some APIs in future posts I thought it would be a good idea to give this introduction to using User Spaces first.

In this example I will be using the following User Space APIs to:

  • QUSCRTUS – Create user space
  • QUSDLTUS – Delete user space
  • QUSPTRUS – Get pointer to user space

In this example I am going to use the List Fields API, QUSLFLD, to generate a list of the fields in a file. I just chose this API at almost random to show how to use the APIs in a very simple manner to demonstrate how they work. You will probably want to add more complicated code to your use of these APIs to cope with errors, etc.

Monday, August 4, 2014

User Group: NiSUG becomes i-UG

nisug i ug user group uk

The United Kingdom based user group the National iSystems User Group, NiSUG, changed their name to match the IBM i operating system and become the i-UG.

They have also created a new web site at i-ug.co.uk, which I have replaced their old NiSUG web site with on the IBM i user group page. There is a link to the user group page at the top of every page of this web site.

Feel free to check out the user groups listed, if you know of one that is not on the list please use the Contact form to send me its details. If you find one near you I encourage you to make contact with them and attend their meetings.