Hi Sean,

We're using UD 5.2.32.  Our work-a-round is to have the subroutine called by
Uniobjects pass data to/from an executed program using named commons.  Using
unnamed commons in the subroutine called by Uniobjects has never worked for
us.

Tom Cordes

 -----Original Message-----
From:   Sean W Ferguson [mailto:[EMAIL PROTECTED] 
Sent:   December 08, 2004 7:16 PM
To:     [EMAIL PROTECTED]
Subject:        Re: [U2] UniObjects for Java Unnamed Common Corruption

/*
 * Created on Dec 6, 2004
 */
package com.docmagic.rd;

import asjava.uniobjects.*;

/**
 * @author jay
 */
public class TestCommons
{
  UniSession session = null;
  static String host, username, password, accountPath;
 
  public static void main(String[] args)
  {
    if(args.length < 4)
    {
      System.out.println("Usage: host username password accountPath 
iterations");
      return;
    }
  
    try
    {
      host = args[0];
      username = args[1];
      password = args[2];
      accountPath = args[3];
     
      int iterations = 100;
      if(args.length == 5)
      {
        iterations = Integer.parseInt(args[4]);
      }
      TestCommons test = new TestCommons();
      for (int index = 0; index < iterations; index++)
      {
        System.out.println("Iteration : " + index);
        test.run();
      }
      System.out.println("Complete");
    }
    catch (Throwable t)
    {
      t.printStackTrace();
    }

  }

  public TestCommons() throws UniSessionException
  {
    this.session = getSession();
  }

  public UniSession getSession() throws UniSessionException
  {
    UniSession session = new UniSession();
   
    session.setHostName(host);
    session.setUserName(username);
    session.setPassword(password);
    session.setAccountPath(accountPath);

    session.connect();

    return session;
  }

  public void run() throws Throwable
  {
    runCMD();
    runSub();
  }

  private void runSub() throws UniSessionException, UniSubroutineException
  {
    System.out.println("Calling Subroutine");
    UniSubroutine sub = session.subroutine("TEST.COMMON.SUB", 0);
    sub.call();
    System.out.println("Finished Subroutine");
  }

  private void runCMD() throws UniSessionException, UniCommandException
  {
    System.out.println("Calling Command");
    UniCommand command = session.command("TEST.COMMON.CMD");
    command.setBlockSize(1024);

    command.exec();
    int responsecode = command.status();// command.getSystemReturnCode();

    StringBuffer block = new StringBuffer();
    if (responsecode == UniObjectsTokens.UVS_MORE || responsecode == 
UniObjectsTokens.UVS_REPLY)
    {

      String response = null;
      String prev_response = null;
      while (responsecode != UniObjectsTokens.UVS_COMPLETE)
      {
        response = command.response();
        if (prev_response == null || !response.equals(prev_response))
        {
          prev_response = response;
          block.append(response);
          command.nextBlock();
          responsecode = command.status();
        }
        else
        {
          break;
        }
      }
    }
    block.append(command.response());
    System.out.println(block.toString());
    System.out.println("Finished Command");
  }
}


Sean W Ferguson wrote:

>I have recently encountered a very strange UniObjects bug.  I have an 
>application that includes a file containing unnamed commons.  The 
>application calls a subroutine that also includes that same unnamed 
>common.  I also have a command that includes the unnamed comman and 
>calls the same subroutine that includes the unnamed common.  When I run 
>the command and subroutine sequentially in a loop via UniObjects, the 
>UniSession dies.  If I only run the subroutine or the command in a loop, 
>it works like a champ.  Adding more unnamed commons to the include file 
>only causes the problem to happen less often.
>
>Please look at my sample application to see if you have any insight into 
>why this fails consistently.
>
>Attached are the sample applications.
>
>Thanks,
>
>Sean Ferguson
>
>[demime 1.01d removed an attachment of type application/octet-stream which
had a name of asjava.jar]
>
>[demime 1.01d removed an attachment of type application/octet-stream which
had a name of asjava_p.jar]
>COMMON POS
>INCLUDE RMS.BP INPUT.COMMON.POS
>
>CALL TEST.SHARED.SUB
>SUBROUTINE TEST.COMMON.SUB
>  INCLUDE RMS.BP INPUT.COMMON.POS
>  CALL TEST.SHARED.SUB
>RETURN
>SUBROUTINE TEST.SHARED.SUB
>  INCLUDE RMS.BP INPUT.COMMON.POS
>  POS = "1"
>RETURN
>
>[demime 1.01d removed an attachment of type application/octet-stream which
had a name of TestCommons.jar]
>-------
>u2-users mailing list
>[EMAIL PROTECTED]
>To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to