Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Call RFC that return structure using VB 6

Former Member
0 Likes
1,885

Hi, anyone has a sample code to call a custom RFC that returns table structure?

The RFC expect parameters to pinpoint the record and return it in a structure.

*----


*Local Interface:

'FUNCTION zfori_web_pgto_parceiros.

'*"----------------------------------------------------------------------

'*"*"Interface local:

'*"  IMPORTING

'*"     VALUE(I_LIFNR) TYPE  LIFNR

'*"     VALUE(I_DATAINICIO) TYPE  DATE OPTIONAL

'*"     VALUE(I_DATAFIM) TYPE  DATE OPTIONAL

'*"  TABLES

'*"      T_PAGTO_PARCEIRO STRUCTURE  ZSTORI_PAGTO_PARCEIRO_WEB

...

...

etc

-- final function

  t_pagto_parceiro[] = t_saida[].

ENDFUNCTION.

in se37  run work fine

Here's my vb code, but it return zero entries (I'm sure it should return records).

-


***Login Process Here***

    Set objFunc = objSAPLogon.Add("zfori_web_pgto_parceiros")

    Set objtblparceiro = objFunc.Tables("T_PAGTO_PARCEIRO")

    With objFunc

        .Exports("I_LIFNR") = "1064425"

    End With

    If Not objFunc.Call Then

        Debug.Print objFunc.Exception

        Exit Sub

    End If

    Debug.Print objtblparceiro.RowCount ==> 0

.

1 ACCEPTED SOLUTION
Read only

naresh_bammidi
Contributor
0 Likes
1,264

HI,

Pass LIFNR with leading zeros.That is the reason for empty records.

Thanks

Naresh

7 REPLIES 7
Read only

Former Member
0 Likes
1,264

I'm not going to ask why you're using VB6 instead of VB.NET, since I'm sure you have your reasons.  I see two possibilities.  Capitalize the function module (just in case), and set the objtblparceiro AFTER the function is called, not before.  Let me know if that works.

Read only

Former Member
0 Likes
1,264

Marcelo,

I tried my application using lower case for the Function Module name and it is working OK.

Did you remember to set your Function Module to be Remote Enabled?

Maybe the FM is not being called because of authority restrictions. Are you sure you have proper authority to call remote functions? We just recently starting using vb to get remote functions and we needed to update the authority roles. You will need object S_RFC with: Activity = 16, Name of RFC = Function Group (from your Function Module), Type of RFC = FUGR

Hope this helps.

Read only

Former Member
0 Likes
1,264

Hope this helps.

‘ Log into SAP
If sapConnection.logon(0, False) <> True Then
MsgBox “No connection to R/3!”
Exit Sub ‘End program
End If

‘ Call the Read RFC
Set theFunc = functionCtrl.Add(”YMAINT_TABLE”)

‘ Exporting table name
theFunc.exports(”TABLENAME”) = table_name

‘ Prepare Data sheet for data load
returnFunc = theFunc.Call
exception = theFunc.exception

‘ Map the data to cells
If returnFunc = True Then
Dim objtable As Object
Set objtable = theFunc.tables.Item(”DATA”)
End If

http://wiki.sdn.sap.com/wiki/display/ABAP/Table+Maintenance+Using+Excel+Visual+Basic+for+Application...

Read only

madhu_vadlamani
Active Contributor
0 Likes
1,264

Hi,

Check if there is any leading zeros.I faced the same problem a long back.

Regards,

Madhu.

Read only

0 Likes
1,264

Thank you all

    But the tip of Naresh work fine ,

Read only

naresh_bammidi
Contributor
0 Likes
1,265

HI,

Pass LIFNR with leading zeros.That is the reason for empty records.

Thanks

Naresh

Read only

naresh_bammidi
Contributor
0 Likes
1,264

please look into the thread..http://scn.sap.com/thread/50275