tbrault
20th June 2002, 18:16
I have created a vba program to record in a Access table the delivery maintain lines from a project (with the form tdsls4120m000).

The program works correctly for a lot of projects but, if the project has some items that have the status 7, my program doesn't work.

I have seen that the program find record with null pono, don't find records that I can see with baan interface.
Why is my program not working correctly? It's a bug?

Help me please:(

This is my program:

'--------------------------------------------------------------------------------
Function Recherche_Ligne_a_Expedier()
CurrentDb.Execute "DELETE * FROM [Ligne a expedier, table];"
'--> Declaration table
Dim db As Database
Dim rs1 As Recordset
Set db = Application.CurrentDb
Set rs1 = db.OpenRecordset("Ligne a expedier, table", dbOpenTable)

'--> DECLARATION
'--> Declaration variable session et champ--
Dim BaanSess As String
Dim OrdreKeyValue As String
Dim SessFieldKey As String
'------------------------------------------
'--> Declaration valeur--------------------
Dim OrdreValue As String
Dim SauvegardeOrdreValue As String
Dim ErrMessage1 As String
Dim SessFieldValue As String
Dim OptionDefilement As String
Dim PonoenCours As String
'------------------------------------------

'--> Programme
Set baanobj = CreateObject("Baan4.Application")
'--> Champ-----
BaanSess = "tdsls4120m000"

OrdreKeyValue = "tdsls045.orno"
'--> Valeur----
OrdreValue = "141649"
ErrMessage1 = Space(30)
OptionDefilement = "next.set"
'--> recherche
baanobj.ParseExecFunction "ottstpapihand", "stpapi.put.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OrdreKeyValue & Chr(34) & "," & Chr(34) & OrdreValue & Chr(34) & ")"
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.change.view(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
'--> Copie des donnees sur table
OptionDefilement = "last.set"
SessFieldKey = "tdsls045.pono"
SessFieldValue = Space(30)
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.browse.set(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OptionDefilement & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.mark(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
SauvegardeOrdreValue = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
OptionDefilement = "first.set"
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.browse.set(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OptionDefilement & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.mark(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
OptionDefilement = "next.set"

Do
rs1.AddNew
rs1.Fields("T$ORNO").Value = OrdreValue
SessFieldKey = "tdsls045.pono"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
PonoenCours = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
rs1.Fields("T$PONO").Value = PonoenCours
SessFieldKey = "tdsls045.item"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
rs1.Fields("T$ITEM").Value = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
SessFieldKey = "itm.dsca"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
rs1.Fields("T$DSCA").Value = RTrim(GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey))
SessFieldKey = "tdsls045.oqua"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
rs1.Fields("T$OQUA").Value = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
SessFieldKey = "tdsls045.dqua"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
rs1.Fields("Qte livre").Value = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
SessFieldKey = "tdsls045.ddat"
SessFieldValue = Space(30)
baanobj.ParseExecFunction "ottstpapihand", "stpapi.get.field(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & SessFieldKey & Chr(34) & "," & Chr(34) & SessFieldValue & Chr(34) & ")"
DateLivraison1initial = GetValueFromStapiGet(baanobj.FunctionCall, BaanSess, SessFieldKey)
If DateLivraison1initial <> "" And DateLivraison1initial > 0 Then
DateLivraison1 = CDate(DateLivraison1initial - 693594)
rs1.Fields("Date de livraison").Value = DateLivraison1
rs1.Fields("DejaLivre").Value = True
End If
rs1.Update
'--> Deplacement du pointeur
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.browse.set(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & OptionDefilement & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")
ret = baanobj.ParseExecFunction("ottstpapihand", "stpapi.mark(" & Chr(34) & BaanSess & Chr(34) & "," & Chr(34) & ErrMessage1 & Chr(34) & ")")

Loop Until SauvegardeOrdreValue = PonoenCours
rs1.Close
baanobj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & BaanSess & Chr(34) & ")"

End Function
'-----------------------------------------------------------------------------------

günther
21st July 2006, 16:43
I just had a look on tdsls4120m000 and AFS.

Here are some remarks for others:
* The above solution will not work for systems that have the sales parameter tdsls000.orpi.4 = tdsls.orpi.pino.
* I found SOL 152376 dated 2006-02-16 on baan support related to that setting.

Günther