Module ibm.jzos
Package com.ibm.jzos

Class AccessMethodServices


  • public class AccessMethodServices
    extends java.lang.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
    • Constructor Summary

      Constructors 
      Constructor Description
      AccessMethodServices()
      Construct an instance
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addInputLine​(java.lang.String inputLine)
      Add an input line to be treated as a SYSIN input record to IDCAMS.
      int execute()
      Execute IDCAMS.
      java.lang.String getOutputLines()
      Answer a String containing the output lines, separated by newlines.
      void setOutputBufLen​(int length)
      Sets the output buffer length.
      void setOutputDDName​(java.lang.String ddname)
      Sets a pre-allocated DDNAME to be used to write IDCAMS SYSPRINT output.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AccessMethodServices

        public AccessMethodServices()
        Construct an instance
    • Method Detail

      • addInputLine

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

        public java.lang.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​(java.lang.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:
        getOutputLines(), setOutputDDName(String), setOutputBufLen(int)