Monday, 4 January 2021

Create Purchase Requisition from Inventory Usage using Action Script (Customized Option) | IBM Maximo

Recently we had the requirement to disable the direct MR to PR automation. so instead of

creating direct PR from MR, the users will select a store on material requisition to reserve material

from store. When the MR is approved, the inventory usage is created from MR.

If the material is available in-store, storeroom will issue the material otherwise he clicks the option

to create Purchase Requisition (PR) from inventory usage.

So we developed this new functionality.

Note: This script contains a few custom attributes. I have commented those line, In your case please remove them.

Step 1:

First Add new Status for Inventory Usage Application: PR_CREATED

Step 2: Create Automation Script

Launch Point:        ACTION

Object:                  INVUSE

Variable:                v_mr

Binding Value:      INVUSELINE[MRNUM is null].MRNUM*

Relations:              INVUSE --> INVUSELINE -->MRNUM (child object:MR, mrnum=:mrnum)

Body:

from psdi.security import UserInfo

from psdi.mbo import MboServerInterface

from psdi.server import MXServer

if v_mr is None and mbo.getString("STATUS") !="PR_CREATED":

    mxServer = MXServer.getMXServer()

    userInfo = mbo.getUserInfo()

    prSet= mxServer.getMboSet("PR", userInfo );

    prSet.add()

    if mbo.isNull('INVUSELINE.WONUM'):

        prSet.setValue("description" , "PR Created for" +  mbo.getString("INVUSELINE.MRNUM")  + "             and Inv. Usage: "+                 mbo.getString("INVUSENUM") )

    else:

        prSet.setValue("description" , "PR Created for " + mbo.getString("INVUSELINE.MRNUM")+ ",             Workorder: "+                         mbo.getString("INVUSELINE.WONUM") + ", Inv. Usage: "+                                   mbo.getString("INVUSENUM")  )          

    #prSet.setValue("SERVICEPROVIDER" ,mbo.getString("SP"))

    #prSet.setValue("invusenum" ,mbo.getString("INVUSENUM"))

    #prSet.setValue("CONTRACT" , mbo.getString("SPCONTRACT"))

    #prSet.setValue("SERVICECODE" , mbo.getString("SERVICECODE")) 

    prSet.setValue("REQUESTEDBY" , mbo.getString("INVUSELINE.MRNUM.REQUESTEDBY"))

    #----------------------------------------------------

    InvuselineSet = mbo.getMboSet("INVUSELINE")

    inuseline = InvuselineSet.moveFirst()

    while (inuseline):

        prLines= prSet.getMbo(0).getMboSet("PRLINE");

        prLines.add(2l);

        prLines.setValue("ITEMNUM" , inuseline.getString("ITEMNUM"))

        prLines.setValue("LINETYPE" , inuseline.getString("LINETYPE"))

        prLines.setValue("DESCRIPTION" ,  inuseline.getString("DESCRIPTION"))

        prLines.setValue("ORDERQTY" , inuseline.getDouble("QUANTITY"))

        prLines.setValue("UNITCOST" , inuseline.getDouble("UNITCOST"))

        prLines.setValue("STORELOC" , inuseline.getString("FROMSTORELOC"))

#       prLines.setValue("ORDERUNIT" , inuseline.getString("ORDERUNIT"))

        prLines.setValue("CONVERSION" , 1)

        prLines.setValue("ENTERBY" , "MAXADMIN")

        prLines.setValue("REQUESTEDBY" ,mbo.getString("INVUSELINE.MRNUM.REQUESTEDBY"))

#      prLines.setValue("PROJECT" , inuseline.getString("PROJECT"))

#      prLines.setValue("TASK" , inuseline.getString("TASK"))

        inuseline = InvuselineSet.moveNext()

    prSet.save()

mbo.changeStatus("PR_CREATED", MXServer.getMXServer().getDate(), ''); 

mbo.getThisMboSet().save()


Step 3:

Now Go to Application designer and Add a signature option with the same name as action script and then add the select option with the same name also.

Provide access to maxeveryone group for this signature. The option will be ready now.



No comments:

Post a Comment