× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: ?Java Function for RCVMSG?
  • From: dawall@xxxxxxxxxx
  • Date: Fri, 11 Aug 2000 08:11:53 -0500

As long as you don't disconnect, when you use the same AS400 object all
command calls and program calls go to the same AS/400 job.  After your
command runs you could use program call to call the get job info API,
extract the job name/user/number out of the returned data, then use JobLog
to read the log.  Here is an example I cut/pasted from a couple of
different places.


   void PrintJobLog()
   {
       try
       {
        AS400 system = new AS400();
        CommandCall cc = new CommandCall(system);
        cc.run("crtlib fred");
        cc.run("crtlib fred");
        cc.run("crtlib fred");

        ProgramCall pc = new ProgramCall(system);

        // Set up the parameter list for the program that we will use to
get the Job information (QWCRTVCA).

        // Format for Retrieve Current Attributes (QWCRTVCA) API:
        // 1 - Receiver variable - Output - Char(*)
        // 2 - Length of receiver variable - Input - Binary(4)
        // 3 - Format name - Input - Char(8)
        // 4 - Number of attributes to return - Input - Binary(4)
        // 5 - Key of attributes to be returned - Input - Array(*) of
Binary(4)
        // 6 - Error code - I/O - Char(*)

        //  Relevant Key Attributes for QWCRTVCA API:
        //  ______ ___________ ______________
        // | Key  | Type      | Description  |
        // |______|___________|______________|
        // | 1009 | CHAR(26)  | Job name     | Values shown in decimal.
        // |______|___________|______________|

        ProgramParameter[] parameterList = new ProgramParameter[6];

        // First parameter: output, the receiver variable.
        byte[] dataReceived = new byte[46]; // RTVC0100's 20-byte header,
plus 26 bytes for "Job name" field.
        parameterList[0] = new ProgramParameter(dataReceived.length);

        // Second parameter: input, length of receiver variable.
        byte[] receiverLength = new byte[4];
        BinaryConverter.intToByteArray(dataReceived.length,
                                       receiverLength,
                                       0);
        parameterList[1] = new ProgramParameter(receiverLength);

        // Third parameter: input, format name.
        AS400Text converter8 = new AS400Text(8, system);
        byte[] formatName = converter8.toBytes("RTVC0100");
        parameterList[2] = new ProgramParameter(formatName);

        // Fourth parameter: input, number of attributes to return.
        byte[] numAttributes = new byte[4];
        BinaryConverter.intToByteArray(1,
                                       numAttributes,
                                       0);
        parameterList[3] = new ProgramParameter(numAttributes);

        // Fifth parameter: input, key(s) of attribute(s) to return.
        byte[] attributeKey = new byte[4];
        BinaryConverter.intToByteArray(1009,             // "Job name"
                                       attributeKey,
                                       0);
        parameterList[4] = new ProgramParameter(attributeKey);

        // Sixth parameter: input/output, error code.

        // In format ERRC0100, the first field in the structure, "bytes
        // provided", is a 4-byte INPUT field; it controls whether an
exception
        // is returned to the application, or the error code structure is
filled
        // in with the exception information.
        // When the "bytes provided" field is zero, all other fields are
        // ignored and an exception is returned (rather than the error code
        // structure getting filled in).
        byte[] errorCode = new byte[17];  // Format ERRC0100
        BinaryConverter.intToByteArray(0, errorCode, 0); // return
exception if error
        parameterList[5] = new ProgramParameter(errorCode, 17);

        // Call Retrieve Current Attributes.  Failure is returned as a
message list.

        if(!pc.run("/QSYS.LIB/QWCRTVCA.PGM", parameterList))
        {
            AS400Message[] messageList_ = pc.getMessageList();
            for (int i = 0; i < messageList_.length; ++i)
            {
                System.out.println(messageList_[i].toString());
            }
            return;
        }

        // Get the data returned from the program.
        dataReceived = parameterList[0].getOutputData();

        // Format of RTVC0100 structure returned from QWCRTVCA API:

        // Offset
        // __________
        //  0        | BINARY(4)  | Number of attributes returned
        // __________|____________|______________
        // These     | BINARY(4)  | Length of attribute information
returned
        // fields    |____________|______________
        // repeat,   | BINARY(4)  | Key
        // in the    |____________|______________
        // order     | CHAR(1)    | Type of data
        // listed,   |____________|______________
        // for each  | CHAR(3)    | Reserved
        // key       |____________|______________
        // requested.| BINARY(4)  | Length of data
        //           |____________|______________
        //           | CHAR(*)    | Data
        //           |____________|______________
        //           | CHAR(*)    | Reserved
        // __________|____________|______________

        // Verify that one attribute was returned. Assume that if exactly
        // one was returned, it's the one we asked for.
        int numAttributesReturned =
BinaryConverter.byteArrayToInt(dataReceived, 0);
        if (numAttributesReturned != 1)
        {
            System.out.println("unexpected data returned: " +
numAttributesReturned);
            return;
        }

        // Examine the "Job name" field.  26 bytes starting at offset 20.
        // Parse out the job name, user name, and job number.
        // Contents of returned "Job name" field:
        // The name of the user job that this thread is associated with.
        // The format of the job name is a 10-character simple job name,
        // a 10-character user name, and a 6-character job number.
        AS400Text converter10 = new AS400Text(10, system);
        AS400Text converter6  = new AS400Text(6, system);
        String name = (String) converter10.toObject(dataReceived, 20);
        String user = (String) converter10.toObject(dataReceived, 30);
        String number = (String) converter6.toObject(dataReceived, 40);

        System.out.println(name + " " + user + " " +number);

        JobLog log = new JobLog(system, name, user, number);
        Enumeration messages = log.getMessages();
        while (messages.hasMoreElements())
        {
           QueuedMessage message = (QueuedMessage) messages.nextElement ();
           System.out.println (message.getText ());
        }

       }
       catch (Exception e)
       {
          e.printStackTrace();
       }
   }


David Wall
AS/400 Toolbox for Java


jjmatthe@us.ibm.com on 08/10/2000 09:07:13 AM

Please respond to JAVA400-L@midrange.com

To:   JAVA400-L@midrange.com
cc:
Subject:  ?Java Function for RCVMSG?




Hello,
     I have recently developed a servlet that does many CL commands based
on data submitted from a user.  During the input stages there is room for a
user to enter data that I can not tell if it is valid at the time of input,
but can later because an error in a CL command.  What I would like to do is
to display the whole job log if an error happens, so they could better
understand why the command did not run.  I currently use the command class
and do a command.getMessage( ) but this only gives me an cut down version
of the error.  In the JobLog class you have to specify the job name and the
job number. I was wondering if anyone knows of a simpler way to do
something like a RCVMSG in java with out specifying the job name and job
number.

Any information would be appreciated,
   Jeff Matthes


+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---



+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.