1

I am trying to get information about created date and time for a set of objects in AS400. I have created an outfile using DSPOBJD in AS400. Below is code snippet for getting information about one object. Now, after this i will have to open connection to AS400 and query the outfile to get creation date and time. I want to know of there is a better way of doing this.

String serverIP="XXX.XX.XXX.XX";
String userName="UserId";
String password="Password";

String commandString="DSPOBJD OBJ(ABCD) OBJTYPE(*PGM) OUTPUT(*OUTFILE)   
 OUTFILE(Library/FileName) OUTMBR(*FIRST *ADD)";
 AS400 as400=null;
 try
 {
    as400=new AS400(serverIP,userName,password);
    CommandCall command = new CommandCall(as400);
    System.out.println("Executing Command "+commandString);
    boolean success = command.run(commandString);
    if(success)
    {
        System.out.println("Executed Successfully");
    }
    else
    {
        System.out.println("Encountered Error");
    }
    AS400Message [] messageList=command.getMessageList();
    for(AS400Message message:messageList)
    {
        System.out.println(message.getText());
    }
    System.out.println("Deleting Object");
    Thread.sleep(10000);
    command.run("DLTOBJ OBJ(Library/FileName) OBJTYPE(*FILE)");
    System.out.println("Deleted...");
}
catch(Exception ex)
{
    ex.printStackTrace();
}
finally
{
    try
    {

        as400.disconnectAllServices();
    }    catch(Exception e)
    {System.out.println("Excpetion in closing connection: "); 
        e.printStackTrace();
    }}

Thanks in advance!!

1 Answers1

1

I did something similar to get an Object's size.

                AS400 as400 = new AS400(iseries, login, password);
                ObjectDescription aFile = new ObjectDescription(as400, library, fileName, "FILE", iasp);
                if (aFile.exists()) {
                    aFile.refresh();
                    aFile.getValue(ObjectDescription.CREATION_DATE);
                    aFile.getValue(ObjectDescription.OBJECT_SIZE);
                }
YLombardi
  • 1,755
  • 5
  • 24
  • 45
  • Can you tell me what is iasp and how do I find it for a non- system object in non-system library . – true_programmer Apr 03 '15 at 13:26
  • IASP (Independent Auxiliary Storage Pools) is the name of the "database" is your AS400 system. I don't how you can find it but if there is only one in your systeme, this parameter isn't mandatory. You can see mor information here : http://javadoc.midrange.com/jtopen/com/ibm/as400/access/ObjectDescription.html#ObjectDescription%28com.ibm.as400.access.AS400,%20java.lang.String,%20java.lang.String,%20java.lang.String%29 – YLombardi Apr 03 '15 at 13:35
  • How do i find it? We have DB2 – true_programmer Apr 03 '15 at 13:36
  • You can try the command "DSPASPBMR" on your system to see the list of ASP. – YLombardi Apr 03 '15 at 13:39
  • Thanks YLombardi.. I used other constructor of ObjectDecription class which doesnot include ASP device name and was successfully able to retrieve Object information. Thanks a lot for your help!!! – true_programmer Apr 03 '15 at 14:23