Maximo Open Forum

 View Only

Need help with an automation script

  • 1.  Need help with an automation script

    Posted 07-19-2023 07:54

    Hello All,

    Need some guidance on the code bolder below as we are trying to convert the poline to a number format but when we try to complete the receiving of a line,system is giving an error related to conversion from string to number,we want to take the substring of the poline from position 2 until 4 characters and convert that to a number format as the Oracle system is havign this field defined as number data type.

    Below is the line that is getting failed

         and a.segment1  = '"""+ponum+"' and c.line_num = to_number(substr('"+poline+"'"+",2,4))")

    from psdi.server import MXServer
    from teu.iface.common import TEUJDBCUtils
    from teu.iface.common import TEUEndPointUtils
    from java.sql import Connection;


    def setError(linenum):
      global errorkey, errorgroup, params
      errorkey="LineClosedInOracle"
      errorgroup="TEURECEIPTS"
      params=[linenum]


    mxserver = MXServer.getMXServer()
    ponum = mbo.getString("PONUM")
    poline = mbo.getString("POLINENUM")
    SUBSTRING = mbo.getString("POLINENUM")
    poline=(SUBSTRING[3:-10])
    linenum=int(poline)
    raise TypeError (linenum)
    conn = None
    myEndPoint = TEUEndPointUtils()
    myjdbcUtil = TEUJDBCUtils()

    #endPoint= myEndPoint.getEndPoint("TEUORARAC")
    endPoint = "TEUORACLEENDPOINT"
    #added below check to avoid the error in WO Application
    if (mbo.getThisMboSet().getParentApp()=='RECEIPTS'):
     if (endPoint is not None or endPoint == ""):
        myEndPoint.getEndPointinfo(endPoint);
     if myEndPoint is not None:
        conn = myjdbcUtil.getConnection(myEndPoint)
     if conn is not None:
      if (mbo.toBeSaved() and mbo.getString("ISSUETYPE") == "RECEIPT" ):
        s= conn.createStatement()
        rs=s.executeQuery("""select a.po_header_id,c.PO_LINE_ID, a.segment1 as PONUM, c.line_num as POLINENUM, a.org_id, a.closed_code as POSTATUS, b.shipment_num as SHIPMENT_NUM, b.closed_code LINE_STATUS
             from po_headers_all a,po_line_locations_all b, PO_LINES_ALL c 
             where a.po_header_id = b.po_header_id
             and a.po_header_id = c.po_header_id
             and b.po_line_id = c.PO_LINE_ID
             and b.closed_code in ('CLOSED','CLOSED FOR RECEIVING')
             and a.segment1  = '"""+ponum+"' and c.line_num = to_number(substr('"+poline+"'"+",2,4))")
        if rs.next():
            setError(poline)
        rs.close()
        s.close()
        conn.close()

    ---------------------------------------------------


    #Administration
    #Customizations
    #EverythingMaximo
    #HSE/OilandGas

    ------------------------------
    Mahadevan Ramakrishnan
    ------------------------------