Module ibm.jzos
Package com.ibm.jzos

Class AccessMethodServices

java.lang.Object
com.ibm.jzos.AccessMethodServices

public class AccessMethodServices extends Object
A class that provides a Java interface to z/OS Access Method Services (IDCAMS).

Output from IDCAMS (DD SYSPRINT) is redirected by default to a String (getOutputLines()). The method setOutputDDName(String) may be used before execute() to direct IDCAMS output to a pre-allocated DDNAME.

Example: LISTC output directed to outputLines String buffer.


    AccessMethodServices ams = new AccessMethodServices();
    ams.addInputLine("LISTC LEVEL(ACCTING)");
    int rc = ams.execute();
    System.out.println("IDCAMS output:");
    System.out.println(ams.getOutputLines());
   

Example: LISTC output directed to temporary dataset.


    String ddname = ZFile.allocDummyDDName();
    ZFile.bpxwdyn("alloc fi(" + ddname +
                  ") da(&&IDTEMP) new delete reuse msg(2)");
    AccessMethodServices ams = new AccessMethodServices();
    ams.setOutputDDName(ddname);
    ams.addInputLine("LISTC LEVEL(BILLING)");
    int rc = ams.execute();
    ...
    ZFile.bpxwdyn("free fi(" + ddname + ") msg(2)");
   

For detailed information on using Access Method Services (IDCAMS), see: SC26-7394 DFSMS Access Method Services for Catalogs.

Since:
2.3.0
  • Field Details

  • Constructor Details

    • AccessMethodServices

      public AccessMethodServices()
      Construct an instance
  • Method Details

    • addInputLine

      public void addInputLine(String inputLine) throws IllegalArgumentException
      Add an input line to be treated as a SYSIN input record to IDCAMS.
      Parameters:
      inputLine - String
      Throws:
      IllegalArgumentException - if inputLine is null or greater than MAX_INPUT_LINE_LEN
    • getOutputLines

      public String getOutputLines()
      Answer a String containing the output lines, separated by newlines. This value is null until execute() is called, and is limited by the setOutputBufLen(int) setting.
      Returns:
      output lines separated by newlines
    • setOutputDDName

      public void setOutputDDName(String ddname)
      Sets a pre-allocated DDNAME to be used to write IDCAMS SYSPRINT output.

      If this method is not used to set a DDNAME, then the SYSPRINT output will be written to a String which can be obtained using getOutputLines()

      Parameters:
      ddname - String
    • setOutputBufLen

      public void setOutputBufLen(int length)
      Sets the output buffer length. This is the maximum size of outputLines used for IDCAMS SYSPRINT output, if an output DDName has not been set. Any output from IDCAMS longer than this length will be discarded.
      If not set, the default is DEFAULT_OUT_BUF_LEN
      Parameters:
      length - output buffer length
    • execute

      public int execute()
      Execute IDCAMS.

      • SYSIN input to IDCAMS is read from the current inputLines.
      • SYSPRINT output from IDCAMS is captured as "outputLines", unless and output DDNAME was set.
      Returns:
      int the return code from IDCAMS. 99 indicates a storage allocation error.
      See Also: