baan2tm0
8th August 2005, 10:54
good day to all,

i am having problems when i am updating the price in a sales order to zero. but when i updated it to some other value, it works. :( I don't get an error when i do the update record for both cases. :confused: below is my code:


Dim BaaNObj As Object
Dim sSalesOrder As String = "tdsls4101m000"
Dim sSalesOrderLines As String = "tdsls4102s000"
Dim tSalesOrder As String = "tdsls040"
Dim tSalesOrderLines As String = "tdsls041"
Dim FindRecord As String
Dim FindSubRecord as String
Dim sFunctionCall As String = Space(50)

BaaNObj = CreateObject("Baan4.Application")
BaaNObj.Timeout = 10

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrder & Chr(34) & "," _
& Chr(34) & tSalesOrder & ".orno" & & Chr(34) & "," & Chr(34) & FieldValue & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.handle.subproc( " & Chr(34) & sSalesOrder & _
Chr(34) & "," & Chr(34) & sSalesOrderLines & Chr(34) & "," & Chr(34) & "add" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & sSalesOrder & Chr(34) & "," _
& Chr(34) & sFunctionCall & Chr(34) & ")")
FindRecord= BaaNObj.ReturnValue

If FindRecord="1" Then
BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & tSalesOrderLines & ".orno" & & Chr(34) & "," & Chr(34) & "100344" _
& Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines _
& Chr(34) & "," & Chr(34) & tSalesOrderLines & ".pono" & & Chr(34) & "," & Chr(34) _
& "10" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")

FindSubRecord=BaaNObj.ReturnValue

If FindSubRecord="1" Then
BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines _
& Chr(34) & "," & Chr(34) & tSalesOrderLines & ".price" & & Chr(34) & "," & Chr(34) _
& "0" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.update(" & Chr(34) & sSalesOrderLines & _
Chr(34) & ",1," & Chr(34) & sFunctionCall & Chr(34) & ")")
End If
End If

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & sSalesOrder & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")


hope you can help me, God bless peeps! peace yo! :)

baan2tm0
8th August 2005, 17:06
yup.. :confused:

mark_h
8th August 2005, 17:54
Okay - you can change the price to 0 manually.But when changing the price manually to 0 - do you get asked any questions? Are there any warnings? Something that needs to be accounted for in the function server code.

baan2tm0
9th August 2005, 08:35
you're right! :rolleyes:

i get a tdsls5106s000 (maintains sales order change codes) ..

now i have a question.. in this session there is an Ok button.. how dow i click the Ok button whenever this session starts up. Do i use stpapi.enum.answer or continue.subprocess?

Thanks in advance to all you afs masters.. may the force be with you. :D

baan2tm0
9th August 2005, 09:17
It seems wierd because any change in the price will invoke this session. when i change the price value to something not zero, it updates it.. but when it is updated to zero it fails without giving any error. Probably this session (tdsls5106s000) is not the cause of the problem.. :confused:

mark_h
9th August 2005, 14:34
Use the continue you button. You should be able to look at the form at see what this is - sometime you have to run these sessions to get the calling session to work. When I first developed my maintain production order line session it popped up a session like this and I had to do a continue to get it to work.

baan2tm0
9th August 2005, 15:19
do you have a code sample.. i mean i don't know where to put the stpapi.continue.. whether i put it before or after my stpapi.update.

and also do i also have to do a stpapi.handle.subproc for that session?

thanks again... God bless!

mark_h
9th August 2005, 15:35
Before the update put the stpapi.handle.subproc. Then after the update (which activates the sub-session) put the stpapi.continue and stpapi.end. Below is some real old code on handling one of these reason code sessions.


f5121s00b.handle.sub.process( "tcmcs9551s00b", "add")
| Find the peg.
do.occ(i,find_grp_peg)
ret.code = f5121s00b.find()
if(ret.code<>1) then
message("No peg records")
end_pgc()
endif
| Delete the record.
f5121s00b.delete(1,fserr)
put_reason_code()
f5121s00b.end()

baan2tm0
1st April 2006, 09:49
wow it's been a long time since i have read this post..

anyway in case some people are still figuring out what to do with this... i have noticed that the amount(amta) and price(pric) are computed. when price is zero and amount is not zero, this will automatically compute the price. and vice versa. therefore what i did was set both values of price and amount to zero and voila it worked.

thanks all for your suggestions..
God bless!!

baan2tm0
1st April 2006, 15:09
Dim BaaNObj As Object
Dim sSalesOrder As String = "tdsls4101m000"
Dim sSalesOrderLines As String = "tdsls4102s000"
Dim tSalesOrder As String = "tdsls040"
Dim tSalesOrderLines As String = "tdsls041"
Dim FindRecord As String
Dim FindSubRecord as String
Dim sFunctionCall As String = Space(50)

BaaNObj = CreateObject("Baan4.Application")
BaaNObj.Timeout = 10

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrder & Chr(34) & "," _
& Chr(34) & tSalesOrder & ".orno" & & Chr(34) & "," & Chr(34) & FieldValue & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.handle.subproc( " & Chr(34) & sSalesOrder & _
Chr(34) & "," & Chr(34) & sSalesOrderLines & Chr(34) & "," & Chr(34) & "add" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & sSalesOrder & Chr(34) & "," _
& Chr(34) & sFunctionCall & Chr(34) & ")")
FindRecord= BaaNObj.ReturnValue

If FindRecord="1" Then
BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & tSalesOrderLines & ".orno" & & Chr(34) & "," & Chr(34) & "100344" _
& Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines _
& Chr(34) & "," & Chr(34) & tSalesOrderLines & ".pono" & & Chr(34) & "," & Chr(34) _
& "10" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.find(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")

FindSubRecord=BaaNObj.ReturnValue

If FindSubRecord="1" Then
BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines _
& Chr(34) & "," & Chr(34) & tSalesOrderLines & ".pric" & & Chr(34) & "," & Chr(34) _
& "0" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.put.field(" & Chr(34) & sSalesOrderLines _
& Chr(34) & "," & Chr(34) & tSalesOrderLines & ".amta" & & Chr(34) & "," & Chr(34) _
& "0" & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.update(" & Chr(34) & sSalesOrderLines & _
Chr(34) & ",1," & Chr(34) & sFunctionCall & Chr(34) & ")")
End If
End If

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & sSalesOrderLines & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")

BaaNObj.ParseExecFunction("ottstpapihand", "stpapi.end.session(" & Chr(34) & sSalesOrder & _
Chr(34) & "," & Chr(34) & sFunctionCall & Chr(34) & ")")