2006 Jan 25 10:53 PM
This question seems to come up again and again, but I did not find a solution that worked in previous threads. I am calling an SAP RFC from a VBA macro and receiving the error "Structure member not found" when I pass the RFC its only parameter. Below is the code:
<u><b>VBA Code</b></u>
Sub CreateRecallCancel()
Dim Functions As Object
Dim RemoteFunction As Object
Dim FunctionParameter1 As Object
'create components of the recall/cancel RFC
Dim sRecallCancel As String
Dim sMSGIND As String * 3
Dim sCLAIMNUM As String * 24
Dim sROC As String * 2
Dim sCHECKNO As String * 9
Dim sPOSNR As String * 12
'log in to SAP and send the user a message if logon was unsuccessful
Set Functions = CreateObject("SAP.Functions")
If Functions.Connection.Logon(0, False) <> True Then
MsgBox ("System could not log you on. Please check user name and password and try again.")
Exit Sub
End If
'set remote function equal to the recall function
Set RemoteFunction = Functions.Add("ZIS_CCS_RECALL")
Set FunctionParameter1 = RemoteFunction.exports("I_RECALL")
sMSGIND = "1"
sCLAIMNUM = "28X1445144"
sROC = "16"
sCHECKNO = ""
sPOSNR = "400000206500"
sRecallCancel = sMSGIND + sCLAIMNUM + sROC + sCHECKNO + sPOSNR
FunctionParameter1.Value = sMSGIND + sCLAIMNUM + sROC + sCHECKNO + sPOSNR
'log off SAP
Functions.Connection.Logoff
End Sub
<b><u>RFC Definition</u></b>
The only parameter taken in by ZIS_CCS_RECALL is I_RECALL, whose structure is as follows:
Field (Length)
MSGIND (3)
CLAIMNUM (24)
ROC (2)
CHECKNO (9)
POSNR (12)
The definition of I_RECALL is a LIKE to another structure, so the previous solution of TYPE vs. LIKE does not apply to this error. Please help. Thanks.
This question seems to come up again and again, but I did not find a solution that worked in previous threads. I am calling an SAP RFC from a VBA macro and receiving the error "Structure member not found" when I pass the RFC its only parameter. Below is the code:
<u><b>VBA Code</b></u>
Sub CreateRecallCancel()
Dim Functions As Object
Dim RemoteFunction As Object
Dim FunctionParameter1 As Object
'create components of the recall/cancel RFC
Dim sRecallCancel As String
Dim sMSGIND As String * 3
Dim sCLAIMNUM As String * 24
Dim sROC As String * 2
Dim sCHECKNO As String * 9
Dim sPOSNR As String * 12
'log in to SAP and send the user a message if logon was unsuccessful
Set Functions = CreateObject("SAP.Functions")
If Functions.Connection.Logon(0, False) <> True Then
MsgBox ("System could not log you on. Please check user name and password and try again.")
Exit Sub
End If
'set remote function equal to the recall function
Set RemoteFunction = Functions.Add("ZIS_CCS_RECALL")
Set FunctionParameter1 = RemoteFunction.exports("I_RECALL")
sMSGIND = "1"
sCLAIMNUM = "28X1445144"
sROC = "16"
sCHECKNO = ""
sPOSNR = "400000206500"
sRecallCancel = sMSGIND + sCLAIMNUM + sROC + sCHECKNO + sPOSNR
FunctionParameter1.Value = sMSGIND + sCLAIMNUM + sROC + sCHECKNO + sPOSNR
'log off SAP
Functions.Connection.Logoff
End Sub
<b><u>RFC Definition</u></b>
The only parameter taken in by ZIS_CCS_RECALL is I_RECALL, whose structure is as follows:
Field (Length)
MSGIND (3)
CLAIMNUM (24)
ROC (2)
CHECKNO (9)
POSNR (12)
The definition of I_RECALL is a LIKE to another structure, so the previous solution of TYPE vs. LIKE does not apply to this error. Please help. Thanks.
2006 Jan 26 1:50 AM
Please reference this link for how to call BAPI in VB:
http://help.sap.com/saphelp_nw04/helpdata/en/a4/ba89c5462e11d2952500a0c94260a5/frameset.htm
BAPI is a kind of RFC, so I think the method is similiar.
Hope it will be helpful
2006 Jan 26 3:36 PM
I have gone through the whole process of navigating through DCOM setup to create component DLLs for my RFCs, but in the DCOM list of available RFCs for my SAP environment, it only shows SAP-standard BAPIs and other RFCs, but the custom RFCs that I have developed do not show up as available choices.
2006 Jan 27 12:10 AM
With regard to Zhenglin's link to DCOM information:
I tried to create a component DLL for the custom RFCs I want to call, but when I click on "Build Component DLL" in the DCOM Object Builder, I get errors. The most recent is <b>"CCP2Upload2.mak(6) : fatal error U1052: file 'mkenv.inc' not found Stop."</b>
I have Visual C++ 6.0 installed. Any ideas?
2006 Jan 26 3:41 PM
Hi,
Custom Function module should be RFC enabled and
released so that external system can access your
custtom Fm.
Regards
Amole
2006 Jan 26 3:58 PM
The FMs are remote-enabled and are currently used by a .NET application, so I know they work. They are just not showing up as available choices in the DCOM list, even though they are truly available.
Message was edited by: Jon Gilman
2006 Jan 26 4:21 PM
Nevermind, I have found them, I will send update upon completion.
2006 Jul 25 12:59 AM
Hi man, i trying call Z td code from VBA, any idea ?
Public Sub rfc_call_transaction()
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object
' Create the Function control (that is, the high-level Functions collection):
Set Functions = CreateObject("SAP.Functions")
' Set the rest of Connection object values:
Functions.Connection.System = ""
Functions.Connection.client = "100"
Functions.Connection.user = ""
Functions.Connection.password = ""
Functions.Connection.language = "EN"
If Functions.Connection.Logon(0, False) <> True Then
Exit Sub
End If
' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
' Set the export parameters (here, get all customers whose names start with J):
RfcCallTransaction.exports("TRANCODE") = "ZDHWLOAD"
RfcCallTransaction.exports("UPDMODE") = "S"
If RfcCallTransaction.Call = True Then
Set Messages = RfcCallTransaction.imports("MESSG")
MsgBox Messages.Value("MSGTX")
Else
MsgBox " Call Failed! error: " + GetCustomers.Exception
Functions.Connection.Logoff
End If
Functions.Connection.Logoff
End Sub
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |