java.lang.Object
com.ibm.jzos.AccessMethodServices
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInputLine
(String inputLine) Add an input line to be treated as a SYSIN input record to IDCAMS.int
execute()
Execute IDCAMS.Answer a String containing the output lines, separated by newlines.void
setOutputBufLen
(int length) Sets the output buffer length.void
setOutputDDName
(String ddname) Sets a pre-allocated DDNAME to be used to write IDCAMS SYSPRINT output.
-
Field Details
-
MAX_INPUT_LINE_LEN
public static final int MAX_INPUT_LINE_LEN- See Also:
-
DEFAULT_OUT_BUF_LEN
public static final int DEFAULT_OUT_BUF_LEN- See Also:
-
-
Constructor Details
-
AccessMethodServices
public AccessMethodServices()Construct an instance
-
-
Method Details
-
addInputLine
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
Answer a String containing the output lines, separated by newlines. This value is null untilexecute()
is called, and is limited by thesetOutputBufLen(int)
setting.- Returns:
- output lines separated by newlines
-
setOutputDDName
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 isDEFAULT_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:
-