cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Return values from RFC function call with visual basic

Former Member
0 Kudos

Hi,

I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.

SAP Function name ==> "ZFMTP_RFC_GET_RESULT"

Export parameters (to SAP):

- Student Name [char 10] ==> "STUNAME"

- Student ID [char 20] ==> "STUID"

Return values (From SAP):

- Results [char 10] ==> "RESULT"

- Remarks [char 200] ==> "REMARKS"

i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?

Here's my vb code to accessing the function



        Dim R3 As Object
        Dim FBFunc As Object
        Dim returnFunc As Boolean
        Dim connected As Boolean
    

        R3 = CreateObject("SAP.Functions")
        R3.Connection.Client = "000"
        R3.Connection.User = "BCUSER"
        R3.Connection.Password = "minisap"
        R3.Connection.Language = "DE"
        R3.Connection.System = "dtsystem"
        R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx"  
        connected = R3.Connection.Logon(0, True)

        If connected <> True Then
            MsgBox("Unable to connect to SAP")
        End If

        FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
        FBFunc.exports("STUNAME") = "Jonny"
        FBFunc.exports("STUID") = "12345"

        returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?


thanks alot.

Edited by: Eugene Tan on Mar 4, 2008 7:17 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

athavanraja
Active Contributor
0 Kudos

check this thread

Former Member
0 Kudos

hi Durairaj Athavan Raja,

thanks for the link...but i am kinda lost looking at your solution to the thread.i believe i just 1 line of code to get 1 return value from the SAP. is it set varObj = Fbfunc.imports("returnValueName") ?

gregorw
Active Contributor
0 Kudos

Hello Eugene,

I think [Mass change your SAP passwords|http://martinceronio.net/?p=31] provides also a good example.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..

Below is the code snippet.


 Set impReturn = CHPASS_FN.Imports("RETURN")  <<=== is RETURN the standard keyword to get a                                                                                return object?
  expPassword.Value = currpass
  expNewPass.Value = newpass
  expFillRet.Value = "1"

''' Call change password function
  If CHPASS_FN.Call = True Then
    outFile.Write (", Called Function")
    Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return                                                               value variable names?
    outFile.WriteLine " : " & Message
  Else
    outFile.Write (", Call to function failed")
  End If


thanks alot...all your help is very appreciated.

Former Member
0 Kudos

Hi,

by the way is any place i can have alist of the activeX object methods for SAP functions?

thanks

gregorw
Active Contributor
0 Kudos

Hello Eugene,

Set impReturn = CHPASS_FN.Imports("RETURN")

Defines the Structure RETURN as an Import Parameter from the Function Module. If you have a look into your SAP System and start transaction SE37 to display the Function SUSR_USER_CHANGE_PASSWORD_RFC you will see this Parameter which is there an Export.

essage = impReturn("MESSAGE")

Reads the Element MESSAGE of the RETURN structure.

Regards

Gregor

Former Member
0 Kudos

Hi Gregor,

thanks the explanation. I will go try it out. ..