PO Receipt Detail

Getting stuck on this script, I've tried a column post val on the qty received and a table post read.  Both are getting stuck at the same point, on the first "retVal=oSOLines.MoveNext()", should it be MoveFirst?

Dim sPurchaseOrderNo
Dim sSalesOrderNo
Dim sItemCode
Dim sItemCodeCur
Dim nPO_QTYREC
Dim nSO_QTYREC
Dim sOrderStatus
Dim oSalesOrder

sPurchaseOrderNo = ""
sSalesOrderNo = ""
sItemCode = ""
sItemCodeCur = ""
nPO_QTYREC = 0
nSO_QTYREC = 0
nSOPREVREC = 0
nNEWSO_QTYREC = 0
sOrderStatus = ""
oSalesOrder = 0

retVal = oBusObj.GetValue("SalesOrderNo$",sSalesOrderNo)
r=oScript.DebugPrint("SalesOrderNo: " & sSalesOrderNo)


if sSalesOrderNo <> "" then

	retVal = oBusObj.GetValue("ItemCode$",sItemCode)
	retVal = oBusObj.GetValue("QuantityReceived",nPO_QTYREC)
	r=oScript.DebugPrint("ItemCode: " & sItemCode)
	r=oScript.DebugPrint("Quantity Rec: " & CStr(nPO_QTYREC))
	
	If nPO_QTYREC <> 0 Then
	
		oSOLines = oSession.GetObject("SO_SalesOrderDetail_bus")
		r=oScript.DebugPrint("After oSession.GetObj ")


		If oSOLines <> 0 Then
			SET oSOLines = oSession.AsObject(oSOLines)
			r=oScript.DebugPrint("After Set oSession.AsObj ")
			sSONo = ""
			

			retVal = oSOLines.SetBrowseFilter(sSalesOrderNo)
			r=oScript.DebugPrint("retVal SO Line SetBrowseFilter = " & CStr(retVal))
			retVal = oSOLines.MoveNext()
			r=oScript.DebugPrint("retVal SO Line MoveNext = " & CStr(retVal))
			retVal = oSOLines.GetValue("SalesOrderNo$", sSONo )
			r=oScript.DebugPrint("SO No: " & sSONo)
			r=oScript.DebugPrint("oSOLines BOF: " & cBool(oSOLines.BOF))
			r=oScript.DebugPrint("oSOLines EOF: " & cBool(oSOLines.EOF))
			
				
			sItem = "" : sComment = "" : sLineKey = "" : sItemType = "" : sItemDesc = ""
			nRevQty = 0 : nLUPrice = 0 : nLExtAmt = 0
			
			
			'Now Loop through the lines looking for any item codes beginning with a /
			lineUpdated = 0 ' initialize new indicator

			Do While Not CBool(oSOLines.EOF) And lineUpdated = 0
				retVal = oSOLines.GetValue("ItemCode$",sItemCodeCur)
																						
				if sItemCode = sItemCodeCur AND (sOrderStatus = "N" Or sOrderStatus ="O") Then

					retVal = oSOLines.GetValue("UDF_QTY_RECEIVED", nSOPREVREC)
					nNEWSO_QTYREC = nSOPREVREC+nSO_QTYREC
					retVal = oSOLines.SetValue("UDF_QTY_RECEIVED",nNEWSO_QTYREC)
					retVal = oSOLines.Write()
					lineUpdated = 1 'trip flag
										
				end if
				retVal = oSOLines.MoveNext()
				r=oScript.DebugPrint("SO Line ItemCode = " & sItemCode)
				
				
				retVal = oSOLines.GetValue("SalesOrderNo$", sSONo )
				r=oScript.DebugPrint("Lines SONo  = " & sSONo)

			Loop
		End If 'Check to see that we can open SO_SalesOrderHistoryHeader

Parents
  • 0

    Don't go straight to the SO Detail object, that won't work.  Open the SO header, then get the Lines object from there.

    As an aside, I see no control over your script running more than once (if the event trigger is ever executed more than once, the SO line values would be updated again...).

    I'd avoid all this, and write a report to do the query of receipt history (vs SO lines) instead of trying to script something.  Much easier.

Reply
  • 0

    Don't go straight to the SO Detail object, that won't work.  Open the SO header, then get the Lines object from there.

    As an aside, I see no control over your script running more than once (if the event trigger is ever executed more than once, the SO line values would be updated again...).

    I'd avoid all this, and write a report to do the query of receipt history (vs SO lines) instead of trying to script something.  Much easier.

Children
No Data