on 04-08-2009 6:48 AM
Dear All,
I have created a screen in this screen,i want to generate a auto generate number
for that i have write a code but when am executing the program in VS2005,the form was loaded in SAPB1 2005,But am not getting the auto generate number in the particular coloumn.
It shows an error like pbject reference not set to an instance of an object
the code is,
Private Sub DCNumber()
Try
oForm = SBO_Application.Forms.Item("FormEditor")
Dim oRs As SAPbobsCOM.Recordset
oRs = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRs.DoQuery("Select DocNum IS NULL THEN '1' ELSE DocNum+1 from @SCDC")
Dim Auto As String = oRs.Fields.Item(0).Value
oForm.Freeze(True)
oForm.Items.Item("25").Specific.Value = Auto
oForm.Freeze(False)
Catch ex As Exception
SBO_Application.StatusBar.SetText(ex.Message)
End Try
End Sub
I call this function in,
Public Sub New()
MyBase.New()
SetApplication()
' Load the Tab Order form
LoadFromXML("SCDC.srf")
oForm = SBO_Application.Forms.Item("FormEditor")
oForm.Visible = True
DCNumber()
End Sub
Hi,
oRs.DoQuery("select MAX( DocNum)+1 from @SCDC")
Dim Auto As String = oRs.Fields.Item(0).Value
if Auto ="0"or Auto ="" then
Auto =1
end if
let me know the result.
Regards,
Aslam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use Aslam's answer but then in one row and use it in a formatted search..
select ISNULL(MAX(DocNum),0) +1 from @SCDC
I think the error is in this line:
Dim oRs As SAPbobsCOM.Recordset
oRs = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Should be:
Dim oRs As SAPbobsCOM.Recordset
oRs = (SAPbobsCOM.Recordset) ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Or in:
Dim Auto As String = oRs.Fields.Item(0).Value
Dim Auto As String = oRs.Fields.Item(0).Value.ToString()
But you can set a breakpoint and debug your code, then it's possible to see where is trown the error..
HTH
Regards Teun
Edited by: Teun Aben on Apr 15, 2009 10:42 PM
Hi Guru,
In which line does the VS threw the error "Object Refference not set to an instance of an object ?
looking at your code maybe you should change to
dim oEdit as sapbouicom.edittext
oedit = oForm.Items.Item("25").Specific
oedit.string = Auto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the sql query isnt correct, try it as
Select case when DocNum IS NULL THEN '1' ELSE DocNum+1 end from dbo.[@SCDC]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
8 | |
7 | |
4 | |
4 | |
3 | |
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.