Update existing PO lines

SOLVED

I am new to this so please bear with me. I have the following script ( i can only post a portion of the code. The SPAM blocker flagged it as malicious) that is used to update two UDF fields from a .csv file. It is called via a custom application. I am passing several parameters to the script. It works great with one exception. If the .csv has a record (PO#, LineKey) that is not already on the PO in SAGE the script is creating a new PO line. I only want it to update existing lines not create a new one. What did I do wrong? Thanks in advance.

Relevant part of the code. I posted the entire code as a PDF to get around this posting issues

poKey = sPoNum + sLkey
retChk oPOObj.oLines.nEditLine(poKey),oPOObj.oLines
retChk oPOObj.oLines.nsetValue("ItemCode$",Cstr(arrValues(2))),oPOObj.oLines
retChk oPOObj.oLines.nsetValue("UDF_STAGING$",Cstr(arrValues(5))),oPOObj.oLines
retChk oPOObj.oLines.nsetValue("UDF_PICKEDUP$",Cstr(arrValues(4))),oPOObj.oLines
retChk oPOObj.oLines.nWrite(),oPOObj.oLines

Code.pdf

Parents
  • +1
    verified answer

    You need to add a check if the line exists.  retChk will be one if the line exist, you only want to write if the line exists.

    ...

    retChk oPOObj.oLines.nEditLine(poKey),oPOObj.oLines

    If retChk =1 Then

    retChk oPOObj.oLines.nsetValue("ItemCode$",Cstr(arrValues(2))),oPOObj.oLinesretChk oPOObj.oLines.nsetValue("UDF_STAGING$",Cstr(arrValues(5))),oPOObj.oLinesretChk oPOObj.oLines.nsetValue("UDF_PICKEDUP$",Cstr(arrValues(4))),oPOObj.oLines

    retChk oPOObj.oLines.nWrite(),oPOObj.oLines

    End If

Reply
  • +1
    verified answer

    You need to add a check if the line exists.  retChk will be one if the line exist, you only want to write if the line exists.

    ...

    retChk oPOObj.oLines.nEditLine(poKey),oPOObj.oLines

    If retChk =1 Then

    retChk oPOObj.oLines.nsetValue("ItemCode$",Cstr(arrValues(2))),oPOObj.oLinesretChk oPOObj.oLines.nsetValue("UDF_STAGING$",Cstr(arrValues(5))),oPOObj.oLinesretChk oPOObj.oLines.nsetValue("UDF_PICKEDUP$",Cstr(arrValues(4))),oPOObj.oLines

    retChk oPOObj.oLines.nWrite(),oPOObj.oLines

    End If

Children
No Data