Tuesday, 18 February 2020

Check Budget with Oracle ERP Through Publish channel and set flag 1 or 0 on PR and PO.

Check Budget with Oracle ERP Through Publish channel and set flag 1 or 0 on PR and PO.

Create End point for publish channel that needs to be used for Publish channel with ERP.

Publish Channel Endpoinnt = MEP

Define external system and publish channel for outbound transactions and Enterprise Service for inboaund transactions

Publish channel  = BDGT_CHECKINTERFACE
Enterprise Service = BDGTCHK_POINTERFACE

once everything is done for integeration side
Send request to ERP through automataion below.


create script with action launch point.
object = 'PO' , object = 'PR' in launch points.


import sys
from psdi.util.logging import MXLoggerFactory
from psdi.mbo import MboConstants
from psdi.util.logging import MXLogger
from psdi.iface.mic import MicService
from psdi.server import MXServer
from psdi.mbo import *
from psdi.webclient.system.session import WebClientSession
from time import sleep
from psdi.security import UserInfo
from psdi.server import MXServer



try:
   
    log = MXLoggerFactory.getLogger("maximo.application.AUTOSCRIPT")
    scriptname="ERP_BUDGET"
    log.info("******Entering Autoscript : " +scriptname +"******")

    myMXServer = MXServer.getMXServer()
    userInfo = mbo.getThisMboSet().getUserInfo()
   
    if mbo.toBeSaved() :
        errorgroup="POPR"
        errorkey="POPR"
    elif mbo.getString("SENDERSYSID") == "MX" :
        errorgroup="POPR"
        errorkey="POPR"
    elif mboname == "PR" and mbo.getString("SENDERSYSID") != "MX" :
        cPRNUM = mbo.getString("PRNUM")
        cSiteid = mbo.getString("SITEID")
        micSrv = MXServer.getMXServer().lookup("MIC")
        micSrv.exportData("BDGT_CHECKINTERFACE", "MEP", "siteid='"+cSiteid+"' and prnum='"+cPRNUM+"'", micSrv.getNewUserInfo() , 1) 
                resp="MX"
                i=0
                while resp == "MX" and i < 10 :
                   pr = myMXServer.getMboSet("PR", userInfo)
                   prWhere = "siteid='"+cSiteid+"' and prnum='"+cPRNUM+"'"
                   pr.setWhere(prWhere)
                   resp= pr.getMbo(0).getString("SENDERSYSID")
           pr.close()     
                   sleep(5)
                   i=i+1
                if resp == "MX" :
                   errorgroup="POPR"
                   errorkey="GenMsgTimeOut"
                else :
                   errorgroup="POPR"
                   errorkey="GenMsgBdgUpdated"
    elif mboname == "PO" and mbo.getString("SENDERSYSID") != "MX" :       
        cPONum = mbo.getString("PONUM")
        cSiteid = mbo.getString("SITEID")
        cREVNUM = mbo.getString("REVISIONNUM")
        micSrv = MXServer.getMXServer().lookup("MIC")
        micSrv.exportData("BDGT_CHECKINTERFACE", "MEP", "siteid='"+cSiteid+"' and ponum='"+cPONum+"' and revisionnum="+cREVNUM , micSrv.getNewUserInfo() , 1)
        resp="MX"
                i=0
                while resp == "MX" and i < 10 :
                   po = myMXServer.getMboSet("PO", userInfo)
                   poWhere = "siteid='"+cSiteid+"' and ponum='"+cPONum+"' and revisionnum="+cREVNUM
                   po.setWhere(poWhere)
                   resp= po.getMbo(0).getString("SENDERSYSID")
               po.close()      
                   sleep(5)
                   i=i+1
                if resp == "MX" :
                   errorgroup="POPR"
                   errorkey="GenMsgTimeOut"
                else :
                   errorgroup="POPR"
                   errorkey="GenMsgBdgUpdated"

                  
    mbo.getThisMboSet().reset()
    app.getAppBean().fireDataChangeEvent()

    log.info("******Existing Autoscript : " +scriptname +"******")   
#################################################################
#Handle all Exceptions
#################################################################
except Exception, e:
        print >> sys.stderr, "[ERROR] script "+scriptname+" failed: ",e.message
        print >> sys.stdout, "[ERROR] script "+scriptname+" failed: ",e.message
        log.error("[ERROR] script "+scriptname+" failed: " +e.message)
       
       
       

Once request has been sent to ERP, From ERP side send data to Maximo through enterprise service   
BUDGETED is a variable in my case we are using in ERP for Budget.
we will define a variable in Maximo PO and PR Object to check budget Yes or NO as per request coming from ERP.

Below aoutomataion script will check budget Yes if BUDGETED = 1 in BDGTCHK_POINTERFACE Sync request.

Create script with Script with Integration.

SYNC.BDGTCHK_POINTERFACE.EXTEXIT.IN


erData.breakData()

bdgted = 0
lines = erData.getChildrenData("POLINE")
i = 0
if lines is not None:
    while(i < len(lines)):
        erData.setAsCurrent(lines,i);
        if erData.getCurrentData("BUDGETED") == "1" :
            bdgted = bdgted + 1
        i = i + 1

        erData.setParentAsCurrent()

if i == bdgted :
   erData.setCurrentData("BUDGETED", 1)
else :
   erData.setCurrentData("BUDGETED", 0)
  
  
  
  
Thanks
  

No comments:

Post a Comment