on 12-23-2014 11:14 AM
Hi,
I have a grid with 1 column of link buttons.
My first attempt uses only one SAP B1 table (OPDN) as datatable, and I created the linked button using the following code:
''==============================================
''// LINKED BUTTON
''==============================================
Dim oCol As SAPbouiCOM.EditTextColumn
oCol = oGrid.Columns.Item("DocNum")
oCol.LinkedObjectType = "20"
With this model, the linked button works fine. Clicking on it opens the appropriate GRPO document.
----------
My next attempt is to use 2 SAP B1 table (OPDN and ORPD i.e Goods Receipt PO and Goods Return)
I used UNION ALL in the query to group the 2 tables.
If "TYPE" = 'GReturn', then the linked button should refer to ORPD ( oCol.LinkedObjectType = "21")
If "TYPE" = 'GRPO', then the linked button should refer to OPDN ( oCol.LinkedObjectType = "20")
Can this be done? How to modify the basic code?
I can achieve my objective with 2 columns of linked buttons, one for oCol.LinkedObjectType = "21", and the other for oCol.LinkedObjectType = "20".
But I would like to put both types of linked buttons in a single column, and use a 'Type' column to distinguish the LinkedObjectType.
Thanks
Leon Lai
Hi,
This can be achieved.
we can achive by coding i.e. when u click on the link button u need to open the GRPO/GRREturn document based on the type
When u need to open the document in find mode and sent the document no.
Regards,
Prasad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pvsb
Thanks for your reply
My idea is to write code something like this:
Dim oCol As SAPbouiCOM.EditTextColumn
oCol = oGrid.Columns.Item("DocNum")
If "TYPE'" = "GRPO" THEN
oCol.LinkedObjectType = "20"
else
If "TYPE'" = "GReturn" THEN
oCol.LinkedObjectType = "21"
Of course, this is not the correct way to write the code.
Can you suggest how to write the correct code?
Best Regards,
Leon Lai
If "TYPE'" = "GRPO" THEN
SBO_Application.ActivateMenuItem("1288")
'in place of 1288 u need to provide grpo menuid
oForm = SBO_Application.Forms.GetForm("940", 1)
'in place of 940 u need to provide grop fom uid
oform.mode= fine mode
'then form mode will changes to find mode
' then u need to pass doceentry of which required one
oform.itmes.item("docentyr").specific.value= "docentry"
'then above one u passed docentry now u need to click button 1 (find mode button bcz document status is changed to find mode)
oForm.Items.Item("uid_of_your_item").Click()
else
If "TYPE'" = "GReturn" THEN
SBO_Application.ActivateMenuItem("1288")
'in place of 1288 u need to provide grreturn menuid
oForm = SBO_Application.Forms.GetForm("940", 1)
'in place of 940 u need to provide grretunr form uid
oform.mode= fine mode
Hi Leon,
As a matter of fact, that is one of the correct ways to write the code.
It is just a matter of where you put this code.
I suggest you to put this code on before matrix link pressed event.
Get the type of document of the pressed row (pVal.Row) and set the type to the Link Button.
Regards
Edy
Hi,
Step 1:In item event -> Link pressed event..write the code
Step 2:Check the TYPE
If "TYPE'" = "GRPO" THEN
else
Endif
Step 3:Open GRPO /Greturn form based on the TYPE by using ActivateMenuItem
(i.e. SBO_Application.ActivateMenuItem("MenuID"))
Step 4 :Open the Form in find mode and the send the Doccumnt number(i.e. DocNum)
Step 5 :Click on find button by code
Regards,
Prasad
Hi Edy,
I have tried your suggestion.
Please look at my code and tell me if it is correct because it works well, but causes another click event to misbehave (I'll post another thread on this).
========================================
Private Sub CreateForm()
.....
.....
''// LINKED BUTTON
Dim oCol As SAPbouiCOM.EditTextColumn
oCol = oGrid.Columns.Item("DocEntry")
oCol.LinkedObjectType = "20"
========================================
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
.....
.....
If FormUID = "HandOver" _
And pVal.BeforeAction = True _
And pVal.EventType = SAPbouiCOM.BoEventTypes.et_MATRIX_LINK_PRESSED Then _
If oGrid.DataTable.GetValue("TYPE", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "GRPO" Then
Dim oCol As SAPbouiCOM.EditTextColumn
oCol = oGrid.Columns.Item("DocEntry")
oCol.LinkedObjectType = "20"
ElseIf
oGrid.DataTable.GetValue("TYPE",oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "GReturn" Then
Dim oCol As SAPbouiCOM.EditTextColumn
oCol = oGrid.Columns.Item("DocEntry")
oCol.LinkedObjectType = "21"
End If
End If
=========================================
I have a few questions:
But if I write And pVal.BeforeAction = False _ , it does NOT open the correct document on the first time the linked button is clicked. But if the button is clicked a 2nd time, then the correct document is opened. Why?
Best Regards,
Leon Lai
Hi Leon,
This all is the matter of BeforeAction. It is clearly stated in SDK help center:
pVal contains your event Information.
Yes you need to use only et_MATRIX_LINK_PRESSED for the Grid too. So you are on the right track using the right event.
Hope it helps.
Thanks & Regards
Ankit Chauhan
Hi Ankit
Thanks for your reply.
So, I was correct in writing:
And pVal.BeforeAction = True ?
So, when I click on the linked arrow, it means what?
It means "The event sent a before notification (was not processed yet)"
Sorry, I am a bit lost here! I never understood that phrase.
Could you give more detail, say by referring to my example.
In my example, when I click on the linked button on the row where DocEntry = 125, it opens the OPDN (or ORPD) whose DocEntry = 125.
So, could you explain exactly what pVal.BeforeAction = True actually does, and how it does differently from pVal.BeforeAction = False?
Best Regards,
Leon Lai
Hi Leon,
pVal.BeforeAction specifying whether or not event handling occurs before or after SAP Business One processes the event.
It means if you write your logic on BeforeAction == true then your logic will be executed first after that SAP will process its event.
So on BeforeAction == true, you set the objectType. So it means when the SAP will process its event then it will catch the DcoEntry that you have already set in BeforeAction = true.
Hope it helps you.
Thanks & Regards
Ankit Chauhan
Hi Leon,
I am using it as follows and that is working perfectly for me.
Use it on BeforeAction == true
case BoEventTypes.et_MATRIX_LINK_PRESSED:
{
if (pVal.ItemUID == "Grid" && pVal.ColUID == "DocEntry")
{
SAPbouiCOM.Grid oGrid = (SAPbouiCOM.Grid)m_SBO_Form.Items.Item("Grid").Specific;
int Row = pVal.Row;
string DocumentDescription = Convert.ToString(oGrid.DataTable.GetValue("Document Description", Row));
if (DocumentDescription == "Journal Entry")
{
SAPbouiCOM.EditTextColumn oEditColumn;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("DocEntry")));
oEditColumn.LinkedObjectType = "30";
}
else if (DocumentDescription == "Outgoing Payment")
{
SAPbouiCOM.EditTextColumn oEditColumn;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("DocEntry")));
oEditColumn.LinkedObjectType = "46";
}
else if (DocumentDescription == "A/P Invoice")
{
SAPbouiCOM.EditTextColumn oEditColumn;
oEditColumn = ((SAPbouiCOM.EditTextColumn)(oGrid.Columns.Item("DocEntry")));
oEditColumn.LinkedObjectType = "18";
}
}
} break;
Although I have used it for Grid, you can use it for matrix.
Hope it helps.
Thanks & Regards
Ankit Chauhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi.
i don't have any Idea but i would suggest one thing..
At the time of pressing the linked button.
you can open the document...
If objecttype = 13 Then 'objecttype should be the column value which holds the object
B1Connections.theAppl.OpenForm(BoFormObjectEnum.fo_Invoice)
Else
B1Connections.theAppl.OpenForm(BoFormObjectEnum.fo_PurchaseInvoice)
End If
---
sbo_application-activemenuitem...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.