-
Jan 31st, 2020, 06:34 AM
#1
Thread Starter
New Member
[RESOLVED] [Excel] - Run-time error '1001': Sap Remote Function Call
Hello Guru's
I have an excel small application created by me that connects to SAP sytem to execute a function.
Until yesterday, it was working amazingly, but today I get that error in the thread title. I wonder if anyone can help me here.
My VBA References are as follows:
The error triggers at the line:
Code:
vResult = Myfunc.Call
My code is as follows:
Code:
Private Sub cmdVerificarStatus_Click()
Dim arrayGrid() As TSelItemInfo
Dim arrayRequests() As String
Dim connR3, Myfunc, App As Object
Dim Result As Boolean
Dim iSizeArray As Integer
'Obter Array com localização das linhas seleccionadas
arrayGrid = gridRequests.SelItems.GetArray
iSizeArray = UBound(arrayGrid)
ReDim arrayRequests(iSizeArray)
'Percorrer as linhas seleccionadas e preencher array com nr das ordens a validar status
For i = 1 To UBound(arrayGrid)
arrayRequests(i) = gridRequests.CellValue(arrayGrid(i).row, 1)
Next
'*****************************************************
'Definir Ligação a R3
'*****************************************************
Set connR3 = CreateObject("SAP.Functions")
If connR3.Connection.logon(0, False) <> True Then
Exit Sub
End If
Set Myfunc = connR3.add("ZZS_CHECK_REQUESTS_STATUS")
'*****************************************************
'Declarar Variaveis
'*****************************************************
Dim oTableInput As Object 'Tabela de entrada na Função
Dim oTableOutput As Object 'Tabela de saida da Função
Set oTableInput = Myfunc.Tables("REQUESTS")
Set oTableOutput = Myfunc.Tables("REQUESTS_STATUS")
'*****************************************************
'Preencher tabela de input da função (REQUESTS)
'*****************************************************
For i = 1 To UBound(arrayGrid)
oTableInput.Rows.add
oTableInput.value(i, 1) = arrayRequests(i)
Next
'*****************************************************
'Chamda do módulo de função
'*****************************************************
Result = Myfunc.Call
'*****************************************************
'Valida resultado e preenche grelha com informação
'*****************************************************
If Result = True Then
For i = 1 To UBound(arrayGrid) 'Percorrer Células seleccionadas da grelha
For a = 1 To oTableOutput.RowCount 'Percorrer tabela de output da função
If gridRequests.CellValue(arrayGrid(i).row, "strOrdem") = oTableOutput(a, "TRKORR") Then
Select Case oTableOutput(a, "TARSYSTEM")
Case Is = "PRD"
gridRequests.CellValue(arrayGrid(i).row, "strPRD") = "Sim"
gridRequests.CellValue(arrayGrid(i).row, "strDtImportPRD") = oTableOutput(a, "TRDATE")
gridRequests.CellValue(arrayGrid(i).row, "strHrImportPRD") = oTableOutput(a, "TRTIME")
Case Is = "TST"
gridRequests.CellValue(arrayGrid(i).row, "strTST") = "Sim"
gridRequests.CellValue(arrayGrid(i).row, "strDtImportTST") = oTableOutput(a, "TRDATE")
gridRequests.CellValue(arrayGrid(i).row, "strHrImportTST") = oTableOutput(a, "TRTIME")
End Select
End If
Next
Next
Else
'ERRO
End If
'*******************************************
'Logoff de SAP
'*******************************************
connR3.Connection.Logoff
-
Jan 31st, 2020, 07:51 AM
#2
Re: [Excel] - Run-time error '1001': Sap Remote Function Call
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Jan 31st, 2020, 08:38 AM
#3
Thread Starter
New Member
Re: [Excel] - Run-time error '1001': Sap Remote Function Call
Originally Posted by Zvoni
Hi Zvoni,
as I can see, in that problem the function module doesn't exist in SAP system. In my case, the function exists, it was created by me
-
Jan 31st, 2020, 11:41 AM
#4
Thread Starter
New Member
Re: [Excel] - Run-time error '1001': Sap Remote Function Call
It is working...I did nothing to the code
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|