Hi Forum,
I need to write a BOI script to update a PO Line UDF from an external Data Source.
My question is, how can i get the line to update the UDF, i wrote a little script to update the line but i get the message that the o.oLines is in read only mode.
I don't know if i need to set the PO header before looping thru the lines.
I never done this type of script. I have the following ...
' Set the company, module date and module for the Session
r = oss.nsetcompany("ABC")
'r = oSS.nSetDate("P/O",mdate) giving invalid date
r = oSS.nSetDate("P/O",oSS.sSystemDate)
r = oSS.nSetModule("P/O")
strcsinitials = "": strcsinitials = oSS.sUserCode
' Instantiate a Sales Order business object
oSEC = oSS.nSetProgram(oSS.nLookupTask("PO_PurchaseOrder_ui"))
Set o = oScript.NewObject("PO_PurchaseOrder_bus", oSS)
'Setup the instance of the Lookup file
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objFile = objFSO.OpenTextFile("C:\K-Four Customers\AKDO\JASON Scripts\trackinglist.csv", ForReading)
Set objFile = objFSO.OpenTextFile("C:\Apps\trackinglist2.txt", ForReading)
DO WHILE NOT CBool(o.oLines.nEOF)
r = o.oLines.nGetValue("PurchaseOrderNo$",sPONum)
If r = 0 Then
MsgBox(o.sLastErrorMsg & vbCRLF & "PO Number")
End If
'msgbox sPONum
r = o.oLines.nGetValue("LineKey$",sLineKey)
r = o.oLines.nGetValue("UDF_BOL$",sBOL)
'msgbox sBOL
if sBOL <> "" then
'MsgBox "PO Number: " & sPONum & " LineKey: " & sLineKey & " BOL#: " & sBOL
'Read GoComet file
Do While objFile.AtEndOfStream = False
strLine = objFile.ReadLine
'msgbox strLine
arrFields = Split(strLine, vbTab)
strTracking = arrFields(3)
strEvent = arrFields(9)
strETA = arrFields(12)
if strTracking <> "" then
strTracking2 = strTracking
end if
if strTracking2 = sBOL then
if strEvent ="4" then
msgbox "Tracking #: " & strTracking2 & " Event: " & strEvent & " ETA: " & strETA
r = o.nSetKeyValue("PurchaseOrderNo$",sPONum)
r = o.nFind()
msgbox sPONum
If r = 0 Then
MsgBox(o.oLines.sLastErrorMsg & vbCRLF & "...PO Number")
End If
r = o.oLines.nSetKeyValue("PurchaseOrderNo$",sPONum)
r = o.oLines.nSetKeyValue("LineKey$",sLineKey)
r = o.oLines.nSetKey()
'If r = 0 Then
MsgBox(o.oLines.sLastErrorMsg & vbCRLF & "PO Number")
'End If
'if len(strETA) < 10 then
'strETA1 = strETA&Space(10)
'strETA = "" : strETA = strETA1
'end if
'strDate = "" : strDate = strETA(4,2)&"/"&strETA(1,2)&"/"&strETA(7,4)
retVal = o.oLines.nSetValue("UDF_ETA$", strETA)
'if retVal = 0 Then
MsgBox(o.oLines.sLastErrorMsg & vbCRLF & "Setting the Line ETA")
'End If
r = o.oLines.nWrite()
If r = 0 Then
MsgBox(o.oLines.sLastErrorMsg & vbCRLF & "PO Lines")
End If
msgbox "went thru ..."
exit do
End if
End if
'End if
loop
end if
r = o.oLines.nMoveNext()
Loop
any help will be greatly appreciated ...
Regards,
Manuel Roman