Maximo Open Forum

 View Only

 Validation on Selecting the same item in prline and poline

  • Assets
  • Everything Maximo
  • Inventory
  • Procurement
pavan Kumar's profile image
pavan Kumar posted 04-13-2025 02:17

Hi,

I wrote the java class which doesn't allow to select the same item number which has been already selected, it working.

But I need to do the same validation using automation script and i tried but no luck.

Please someone can assist me.

Example:

In poline line 1 : I selected item as bearing

In poline line 2: when I selected item as bearing then it should throw error 

Below is the java code I used.

package com.ibm.custom.app.ScrapDisposal;

import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.mbo.MboValueAdapter;
import psdi.util.MXApplicationException;
import psdi.util.MXException;
import psdi.util.logging.MXLogger;
import psdi.util.logging.MXLoggerFactory;

public class Fldscrapitem extends MboValueAdapter {
   private static final MXLogger mylogger = MXLoggerFactory.getLogger("maximo.scrap");

   public Fldscrapitem(MboValue mv) {
      super(mv);
   }

   public void validate() throws MXException, RemoteException {
      super.validate();
      mylogger.debug("Scrap Item  validate()");
      Mbo item = this.getMboValue().getMbo();
      MboSetRemote itemset = item.getThisMboSet();

      for(MboRemote itemmbo = itemset.moveFirst(); itemmbo != null; itemmbo = itemset.moveNext()) {
         if (!item.equals(itemmbo) && item.getString("ITEMNUM").equals(itemmbo.getString("ITEMNUM"))) {
            String[] params = new String[]{item.getString("ITEMNUM")};
            throw new MXApplicationException("Scrap", "Same Item Entered", params);
         }
      }

   }
}