on 09-29-2008 1:59 PM
Hi all,
i am using udo and bind with docnum but when i open that form next doc number of form not showing.
Is necessary to right separate code to retrieve max doc number and show in the form as document number.
if any one have sample code post it.
Thanks in Advance.
Awaiting soon reply
Rajkumar Gupta
Edited by: Rajkumar Gupta on Sep 29, 2008 2:59 PM
hi,
Declare Public FormCount as Integer=0
i m using this code for displaying form
If (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = False) Then
Try
'Closing any lookup windows if open"
For Each oFormTest As SAPbouiCOM.Form In SBO_Application.Forms
If oFormTest.UniqueID = "GLS_PurRequ" Then
oFormTest.Close()
Exit For
End If
Next
DrawForm()
Dim RS As SAPbobsCOM.Recordset = Nothing
RS = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
RS.DoQuery("Select DocNum from [@Table] where DocEntry in (Select Max(DocEntry) from [@Table])")
Dim oEdit As SAPbouiCOM.EditText = SBO_Application.Forms.Item("FormUID").Items.Item("ItemUID").Specific
oEdit.Value = RS.Fields.Item("DocNum").Value + 1
FormCount=SBO_Application.Forms.Item("FormUID").TypeCount
Catch ex As Exception
End Try
repeat same in MenuEvent for Changing to AddMode.
If (pVal.MenuUID = "1282") And (pVal.BeforeAction = False) Then 'AddMode
If FORMCOUNT = 1 Then
Dim RS As SAPbobsCOM.Recordset = Nothing
RS = ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
RS.DoQuery("Select DocNum from [@Table] where DocEntry in (Select Max(DocEntry) from [@Table])")
Dim oEdit As SAPbouiCOM.EditText = SBO_Application.Forms.Item("FormUID").Items.Item("ItemUID").Specific
oEdit.Value = RS.Fields.Item("DocNum").Value + 1
End If
End If
use this in FormClose event
If pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE Then
FORMCOUNT = 0
End If
regards,
varma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Varma is correct. we have set the value after menu event.
Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
If (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = True) Then
Try
'Closing any lookup windows if open"
For Each oFormTest As SAPbouiCOM.Form In SBO_Application.Forms
If oFormTest.UniqueID = "GLS_PurRequ" Then
oFormTest.Close()
Exit For
End If
Next
DrawForm()
Catch ex As Exception
End Try
ElseIf (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = False) Then
'Added by Yatsea, we have set the value after menu event.
oFormAPRequistions = SBO_Application.Forms.GetFormByTypeAndCount("2020000121", 1)
oFormAPRequistions.Visible = True
DisplayUDFsValue = True
'// DocNum is the form's item that will show the next Doc number.
Dim odbs As SAPbouiCOM.DBDataSource = oFormAPRequistions.DataSources.DBDataSources.Item("@GLS_OPOR")
Dim docNum As String = oFormAPRequistions.BusinessObject.GetNextSerialNumber(Trim(odbs.GetValue("Series", odbs.Offset))).ToString
odbs.SetValue("DocNum", odbs.Offset, docNum)
End If
End Sub
Hi,
I use the following SQL query and add the output to the Edit Text. The query is as follows..
SELECT Top 1 DocEntry FROM " & sTableName + " ORDER BY Convert(Int,DocEntry) desc
Hope it helps u..
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Once the form is loaded we can set the edit text value. Actually it depends on the senario, Genarally i do it as follows.... On the form load and also when the user Presses Add Mode...
I execute the query and assign the value to the edit text.
ORec.DoQuery("SELECT TOP....")
Oedit.String = ORec.Fields.Item(0).Value
Use that..
Vasu Natari.
Hello,
You can get the next doc number with oForm.BusinessObject.GetNextSeriesNumber(CLng(str))
Regarding to the event, you'd better handle it with
1.FormLoadEvent: Get the next doc number for the default searis
2.ItemEvent : when the Series is changed, get the next doc number for the selected searis.
You may refer to the SDK Online help:
Content (Tab) => Customization Tools => User-Defined Object =>Creating UDO=>Registering UDOs=>Available Service=>Manage Series
Hope it help. Thanks.
Kind Regards
-Yatsea
i m using 1.FormLoadEvent but
when i set that next number using that code
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.BeforeAction = True Then
oFormAPRequistions = SBO_Application.Forms.ActiveForm
' oFormAPRequistions = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
oFormAPRequistions.Visible = True
' oFormAPRequistions = SBO_Application.Forms.Item(FormUID)
If oFormAPRequistions.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
Dim str As Integer = GetMaxNum()
oEditNum = oFormAPRequistions.Items.Item("txtnum").Specific
oEditNum.Value = str
End If
End If
error i got that no item active
--oFormAPRequistions.Items.Item("txtnum").Specific Run-time exception thrown : System.Runtime.InteropServices.COMException - Item - Invalid item [66000-3]. Form Unique Id: 'F_3', Item Unique Id: 'txtnum'
plz find that solution asap
Regards
Rajkumar Gupta
Edited by: Rajkumar Gupta on Oct 25, 2008 10:12 AM
i m using this code for displaying form
If (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = False) Then
Try
'Closing any lookup windows if open"
For Each oFormTest As SAPbouiCOM.Form In SBO_Application.Forms
If oFormTest.UniqueID = "GLS_PurRequ" Then
oFormTest.Close()
Exit For
End If
Next
DrawForm()
Catch ex As Exception
End Try
but in formload no item in form object.
Hello,
The form should be drawed before action of B1 (pVal.BeforeAction = True). Try this:
If (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = True) Then
Try
'Closing any lookup windows if open"
For Each oFormTest As SAPbouiCOM.Form In SBO_Application.Forms
If oFormTest.UniqueID = "GLS_PurRequ" Then
oFormTest.Close()
Exit For
End If
Next
DrawForm()
Catch ex As Exception
End Try
Kind Regards
-Yatsea
thanks for reply but when i m using this below code
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE And pVal.BeforeAction = True Then
oFormAPRequistions = SBO_Application.Forms.Item(FormUID)
oFormAPRequistions.Visible = True
DisplayUDFsValue = True
'// DocNum is the form's item that will show the next Doc number.
With oFormAPRequistions.DataSources.DBDataSources.Item("@GLS_OPOR")
.SetValue("DocNum", .Offset, oFormAPRequistions.BusinessObject.GetNextSerialNumber(Trim(.GetValue("Series", .Offset))).ToString)
End With
end if
no item in oFormAPRequistions object if no item in this object how i can set docnum value
plz help me.
Regards
Rajkumar Gupta
Edited by: Rajkumar Gupta on Oct 27, 2008 8:36 AM
Hello Rajkumar,
All the magic here is BeforeAction:
In Menu Click Event, the form should be draw before action (pVal.BeforeAction = True)
While in the Formload event, you should set the doc number after action (pVal.BeforeAction=False), B1 has draw the form, all items have been drawed there
Try this:
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE And pVal.BeforeAction = False Then
oFormAPRequistions = SBO_Application.Forms.Item(FormUID)
oFormAPRequistions.Visible = True
DisplayUDFsValue = True
'// DocNum is the form's item that will show the next Doc number.
With oFormAPRequistions.DataSources.DBDataSources.Item("@GLS_OPOR")
.SetValue("DocNum", .Offset, oFormAPRequistions.BusinessObject.GetNextSerialNumber(Trim(.GetValue("Series", .Offset))).ToString)
End With
end if
Kind Regards
-Yatsea
Edited by: Yatsea Li on Oct 27, 2008 4:17 PM
Did you try the code in my last post?
The reason here all item in the form will be displayed in the formload (pVal.BeforeAction=False) after the B1 action (B1 draw all items in the form)
By the way, You can download the tool EventLogger to check the UI.
=>SAP Business One Event Logger
Kind Regards
-Yatsesa
for menu
Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
If (pVal.MenuUID = "mnuPurRequi") And (pVal.BeforeAction = True) Then
Try
'Closing any lookup windows if open"
For Each oFormTest As SAPbouiCOM.Form In SBO_Application.Forms
If oFormTest.UniqueID = "GLS_PurRequ" Then
oFormTest.Close()
Exit For
End If
Next
DrawForm()
Catch ex As Exception
End Try
End If
End Sub
form creation
Private Sub DrawForm()
Dim oForm As SAPbouiCOM.Form ' The new form
Dim oItem As SAPbouiCOM.Item ' An item on the new form
Dim oColumns As SAPbouiCOM.Columns ' The Columns collection on the matrix
Try
LoadFromXML("SysPurchaseRequisition.srf")
Catch ex As Exception
MyErrorMsg(ex.Message)
End Try
Try
oForm = SBO_Application.Forms.Item("GLS_PurRequ")
' BP Code
oItem = oForm.Items.Item("txtVendor")
txtBPCode = oItem.Specific
' BP Name
oItem = oForm.Items.Item("txtName")
txtBPName = oItem.Specific
oItem = oForm.Items.Item("txtNum")
txtNum = oItem.Specific
oItem = oForm.Items.Item("txtowner")
txtowner = oItem.Specific
' Add a matrix
oItem = oForm.Items.Item("38")
oMatrix = oItem.Specific
oMatrix.AutoResizeColumns()
oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single
oColumns = oMatrix.Columns
' Item Code
colItemCode = oColumns.Item("ItemCode")
colItemName = oColumns.Item("ItemDec")
colItemQty = oColumns.Item("Qty")
colDeliveryDate = oColumns.Item("DatDel")
oForm.DataBrowser.BrowseBy = "txtVendor"
Catch ex As Exception
MyErrorMsg(ex.Message)
End Try
calling event in formload for dispalying docnum-
If pVal.FormType = "2020000121" Then
Dim oEditQty As SAPbouiCOM.EditText
Dim oEditItemcode As SAPbouiCOM.EditText
Dim oEditNum As SAPbouiCOM.EditText
Dim SQLStr As String
If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD And pVal.BeforeAction = True Then
oFormAPRequistions = SBO_Application.Forms.Item(FormUID)
oFormAPRequistions.Visible = True
'// DocNum is the form's item that will show the next Doc number.
With oFormAPRequistions.DataSources.DBDataSources.Item("@GLS_OPOR")
.SetValue("DocNum", .Offset, oFormAPRequistions.BusinessObject.GetNextSerialNumber(Trim(.GetValue("Series", .Offset))).ToString)
End With
end if
end if
when i calling this formload event for set docnum
but no item count in form object
like oFormAPRequistions.items.count =0
why this happend plz help me out.
Regards
RAJKUMAR GUPTA
I would write a query to retrieve it.
I would also retrieve it either to a separate field or a label--- as I'm not sure what will happen if you tried to set the field before adding...
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.