cancel
Showing results for 
Search instead for 
Did you mean: 

AddOn and DI Api

Former Member
0 Kudos

Hello everybody,

I have the following issue in DI API:

I am developing an addon, and it requires complicated query like this:

SELECT OITM.ITEMCODE, ITEMNAME, A.ONHAND AS QTY_SQFT_INSTOCK,

U_NPCS AS QTY_PCS_INSTOCK ,

(SELECT SUM(QUANTITY) AS QUANTITY FROM QUT1 WHERE ITEMCODE = A.ITEMCODE AND WHSCODE= A.WHSCODE ) AS QTY_SQFT_HOLD,

(SELECT SUM(U_TSQ) AS U_TSQ FROM QUT1 WHERE ITEMCODE = A.ITEMCODE AND WHSCODE= A.WHSCODE) AS QTY_PCS_HOLD,

(SELECT PRICE FROM ITM1 WHERE PRICELIST = 9 AND ITEMCODE = A.ITEMCODE ) AS WSP,

(SELECT PRICE FROM ITM1 WHERE PRICELIST = 8 AND ITEMCODE = A.ITEMCODE AND WHSCODE= A.WHSCODE) AS RSP,

'DEFINE FIELD' AS DSP

FROM OITW A, OITM

WHERE A.ITEMCODE = OITM.ITEMCODE

AND WHSCODE = '01'

AND OITM.ITEMCODE >= 'A00001'

AND OITM.ITEMCODE <= 'A00007'

ORDER BY OITM.ITEMCODE, ITEMNAME

and I need to link the query result to a user matrix, I think that I have to use DI Api to get this query.

I get the server name, company name, user name from SBO_Application.company, but I can not get the password connect to SAPbobsCOM.Company, any body can tell me how to do this??

Thanks in advance.

Hector

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hector,

You can use single sign on to connect to UI and DI at the same time with only connecting "once" and using the user details of the UI to connect to the DI at the same time. Here's an example.

Dim oGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
Dim sCookie As String
Dim iRet As Long
oCompany = New SAPbobsCOM.Company
oGuiApi = New SAPbouiCOM.SboGuiApi
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
oGuiApi.Connect(sConnectionString)
oApplication = oGuiApi.GetApplication()
sCookie = oCompany.GetContextCookie
sConnectionString = oApplication.Company.GetConnectionContext(sCookie)
If oCompany.Connected = True Then
  oCompany.Disconnect()
End If
iRet = oCompany.SetSboLoginContext(sConnectionString)
If Not iRet = 0 Then
  oApplication.MessageBox("Error: Cannot set connection information for DI API")
End If
iRet = oCompany.Connect()
If Not iRet = 0 Then
  oApplication.MessageBox("Error: Cannot connect to DI API")
End If

and DI and UI connections are declared globally

Public Shared oCompany As SAPbobsCOM.Company
Public WithEvents oApplication As SAPbouiCOM.Application

Hope it helps and that this is what you were looking for

Adele

Former Member
0 Kudos

Hi Adele,

this is that I was looking for. It is working correctly.

Thanks very much

Hector

Answers (1)

Answers (1)

Former Member
0 Kudos

Hector,

I'm impressed by the complexity of your query. Are you sure SBO can handle it? If SBO can't handle it, then you can try to create a stored procedure.

Juha

Former Member
0 Kudos

Hi Juha,

Yes, the query is complex. It works. But I will create a Store Procedure, to improve the performance.

Thanks

Hector