on 10-01-2008 8:07 AM
Hi,
hi want create a goods receipt in a chile - database
(code-fragment)
...
odocument.getbusinessobject(oInventoryGenEntry )
oducument.docentry=2008/10/01
odocument.line.itemcode='9008100021'
odocument.line.price=3.44
odocument.line.quantity=5
odocument.add
...
in all other database is no error. Only in a chile-database (new database, template 'chile')
regards
Martin Heigl
Martin ,
I think you did a typo here, docentry can't be odocument.docentry=2008/10/01. and you need not specify docentry anyway. one more thing. return your odocument.add as some integar. like
dim RetVal as integar
RetVal = odocument.Add
If RetVal <> 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
MsgBox(ErrMsg)
End If
you will get to know the exact error message.
HTH,
Binita
Edited by: Binita Joshi on Oct 1, 2008 9:14 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
this script is ok, no errors!
odocument.getbusinessobject(oInventoryGenEntry )
odocument.line.itemcode='9008100021'
odocument.line.price=3.44
odocument.line.quantity=5
odocument.add
when i set the date, then the di-api-command "add" send a break without errors
odocument.getbusinessobject(oInventoryGenEntry )
oducument.docentry=2008/10/01
odocument.line.itemcode='9008100021'
odocument.line.price=3.44
odocument.line.quantity=5
odocument.add <- break!
getlasterror = empty!
only in chile-database!
when i set a other propertie, then i've the same Error
odocument.getbusinessobject(oInventoryGenEntry )
oducument.comments='hello'
odocument.line.itemcode='9008100021'
odocument.line.price=3.44
odocument.line.quantity=5
odocument.add <- break!
getlasterror = empty!
After the break the api is demage. The application must be restartet.
Hi Martin,
There seem to be a sections in your code that may be causing this issue:
- You are using the DocEntry property which is not used for the document date, therefore it will not accept the date you enter. Use DocDate instead
- You are not treating the date 2008/10/01 as a string which it should be.
- You perform getbusinessobject on the document object when this should be done on the company object
I would advise using Try-Catch statements to catch exceptions to prevent crashes. Please see the following sample, which I tested on a Chile database using Business One 2007 A PL42:
Try
Dim odocument As SAPbobsCOM.Documents
Set odocument = oCompany.GetBusinessObject(oInventoryGenEntry)
odocument.DocDate = "2008/9/29"
odocument.Lines.ItemCode = "test"
odocument.Lines.Price = 3.44
odocument.Lines.Quantity = 5
oReturn = odocument.Add
If oReturn <> 0 Then
oCompany.GetLastError oError, errMsg
MsgBox (errMsg)
Else
MsgBox "Goods Receipt Added"
End If
Catch ex As Exception
msgBox(ex.toString())
End Try
Hope this is useful,
Regards,
Niall
SAP Business One Forums
Hello,
thanks for the answers.
the message of the catch is: Process can't be proceded
* You are using the DocEntry property which is not used for the document date, therefore it will not accept the date you enter. Use DocDate instead ==> is ok
* You are not treating the date 2008/10/01 as a string which it should be. ==> this is not the reason. same error without date (comments, ref2...). i've no errors in other database.
* You perform getbusinessobject on the document object when this should be done on the company object -> i've made a new companyobject for the example.
but the errors are sporadic. i think, is a demage in the database.
Have you a idea how i can test this?
in sap i can create good receipt
without properties on document (comments, date, ref2) i can create good receipt
only with properties on document i can't create a good receipt.
regards
Martin Heigl
Hi Martin,
To test if it is the database which is the issue, the easiest way is the following
- Create a new database or restore a demo database to the same server as the problematic database
- Connect to this database using the same project, same machine and user
- Run the code to add the goods receipt
If you find that your code works on other databases, you will have isolated it to this single company database and should contact support.
If you find the error on all databases, could you please post your full code sample so we can test it on our machines?
Regards,
Niall
SAP Business One Forums
Whats the error that ur getting.. ?
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.