Support This Project Get i5/OS Programmer's Toolkit at SourceForge.net. Fast, secure and Free Open Source software downloads

MI Portal Examples

All examples of using MI Portal to issue MI instructions on an IBM i server are arranged by categories as the following:

Space Addressing

Operating MI Objects

19## 0E## 0A## 0401

Machine Interface Support Functions

Retrieving HMC Information

import com.ibm.as400.access.*;

public class hmc {

    public static void main(String[] args) {

        byte[] inst_inx = {  // ubin(2) instruction index, hex 0001 MATMATR
            0x00, 0x01
        };
        byte[] tmpl = new byte[1052]; // bin(4) bytes-in, bin(4) bytes-out, bin(4) entries-returned,
                                      // char(4) reserved, ubin(2) HMC info length, char(1034) HMC info
        tmpl[2] = 0x04; tmpl[3] = 0x1C; // byte-in = 1052
        byte[] opt = {0x02, 0x04};

        AS400 i = new AS400();
        ProgramParameter[] plist_matmatr = new ProgramParameter[] {
            new ProgramParameter(inst_inx),  // input, ubin(2) instruction index
            new ProgramParameter(tmpl, 1052),  // inout, instruction template
            new ProgramParameter(opt) // input, instruction template of RSLVSP
        };
        ProgramCall portal = new ProgramCall(i,
                                             "/qsys.lib/i5toolkit.lib/miportal.pgm",
                                             plist_matmatr);

        try {
            if(!portal.run())
                System.out.println("Issuing _RSLVSP2 failed.");
            else {
                tmpl = plist_matmatr[1].getOutputData();
                int hmc_info_len = 0;
                hmc_info_len |= (int)(tmpl[16]) << 8;
                hmc_info_len |= (int)(tmpl[17]);
                System.out.println("Length of returned HMC info: " + hmc_info_len);
                String hmc_info = new String(tmpl, 18, hmc_info_len);
                System.out.println("HMC info: " + hmc_info); // returned HMC info are in ASCII charset
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

    }

}

Heap Management

Here the term heap refers to a Single Level Store (SLS) heap. Unlike teraspace heap storage, a single allocation on an SLS heap has the 16M - 1Page size limit like all other types of SLS storage: static storage, automatic storage, or MI space objects. So you might come up with questions like this: why should we use such a heap having a size limit? If so, you might find the answer of your question here: Tech-notes: Single Level Store or Teraspace: which storage model to choose? .

So is the ablitiy to utilize heap storage important to client programs? Not always. HLLs in which client programs are written have their own native support for dynamic storage management. It isn't reasonable to turn to a remote server just for a chunk of dynamically allocated storage. But heap storage allocated on an IBM i server sometimes is necessary when MI pointers are to be stored, since MI pointers can only be stored in SLS storage via proper MI instruction (e.g. CPYBWP).


Support This Project
Generated on Tue Sep 27 08:34:40 2011 for i5/OS Programmer's Toolkit: MI Portal by  doxygen 1.5.9